diff options
author | garykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 22:36:43 +0000 |
---|---|---|
committer | garykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 22:36:43 +0000 |
commit | 1cd5f75fcb5c382330778bffffc4f950aff488de (patch) | |
tree | bc127b6fe1e5b4e5fb9c1cfc7d84c3c1ab1ae7ec | |
parent | 08ffddf1c2dfed2fe307b295e3325fcb3b3f70c9 (diff) | |
download | chromium_src-1cd5f75fcb5c382330778bffffc4f950aff488de.zip chromium_src-1cd5f75fcb5c382330778bffffc4f950aff488de.tar.gz chromium_src-1cd5f75fcb5c382330778bffffc4f950aff488de.tar.bz2 |
Add RemotingUI class to handle chrome://remoting URLs.
These URLs are handled by a plugin that is registered to the
chrome-internal-plugin/remoting MIME type.
BUG=none
TEST=verify plugin is loaded when navigating to chrome://remoting
Review URL: http://codereview.chromium.org/2812017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50655 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/dom_ui/dom_ui_factory.cc | 16 | ||||
-rw-r--r-- | chrome/browser/dom_ui/remoting_ui.cc | 85 | ||||
-rw-r--r-- | chrome/browser/dom_ui/remoting_ui.h | 24 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 29 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 5 |
6 files changed, 142 insertions, 19 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc index 9222044..9780d33 100644 --- a/chrome/browser/dom_ui/dom_ui_factory.cc +++ b/chrome/browser/dom_ui/dom_ui_factory.cc @@ -14,8 +14,9 @@ #include "chrome/browser/dom_ui/html_dialog_ui.h" #include "chrome/browser/dom_ui/net_internals_ui.h" #include "chrome/browser/dom_ui/new_tab_ui.h" -#include "chrome/browser/dom_ui/plugins_ui.h" #include "chrome/browser/dom_ui/options_ui.h" +#include "chrome/browser/dom_ui/remoting_ui.h" +#include "chrome/browser/dom_ui/plugins_ui.h" #include "chrome/browser/dom_ui/slideshow_ui.h" #include "chrome/browser/extensions/extension_dom_ui.h" #include "chrome/browser/extensions/extensions_service.h" @@ -112,6 +113,10 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(const GURL& url) { return &NewDOMUI<NetInternalsUI>; if (url.host() == chrome::kChromeUIPluginsHost) return &NewDOMUI<PluginsUI>; +#if defined(ENABLE_REMOTING) + if (url.host() == chrome::kChromeUIRemotingHost) + return &NewDOMUI<RemotingUI>; +#endif #if defined(OS_CHROMEOS) if (url.host() == chrome::kChromeUIFileBrowseHost) @@ -185,11 +190,16 @@ RefCountedMemory* DOMUIFactory::GetFaviconResourceBytes(Profile* profile, if (page_url.host() == chrome::kChromeUIHistory2Host) return HistoryUI2::GetFaviconResourceBytes(); + if (page_url.host() == chrome::kChromeUIOptionsHost) + return OptionsUI::GetFaviconResourceBytes(); + if (page_url.host() == chrome::kChromeUIPluginsHost) return PluginsUI::GetFaviconResourceBytes(); - if (page_url.host() == chrome::kChromeUIOptionsHost) - return OptionsUI::GetFaviconResourceBytes(); +#if defined(ENABLE_REMOTING) + if (page_url.host() == chrome::kChromeUIRemotingHost) + return RemotingUI::GetFaviconResourceBytes(); +#endif return NULL; } diff --git a/chrome/browser/dom_ui/remoting_ui.cc b/chrome/browser/dom_ui/remoting_ui.cc new file mode 100644 index 0000000..15dd1b0 --- /dev/null +++ b/chrome/browser/dom_ui/remoting_ui.cc @@ -0,0 +1,85 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/dom_ui/remoting_ui.h" + +#include "app/resource_bundle.h" +#include "base/singleton.h" +#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/dom_ui/chrome_url_data_manager.h" +#include "chrome/common/url_constants.h" +#include "grit/theme_resources.h" + +namespace { + +/////////////////////////////////////////////////////////////////////////////// +// +// RemotingHTMLSource +// +/////////////////////////////////////////////////////////////////////////////// + +class RemotingUIHTMLSource : public ChromeURLDataManager::DataSource { + public: + RemotingUIHTMLSource() + : DataSource(chrome::kChromeUIRemotingHost, MessageLoop::current()) {} + + // Called when the network layer has requested a resource underneath + // the path we registered. + virtual void StartDataRequest(const std::string& path, + bool is_off_the_record, + int request_id); + virtual std::string GetMimeType(const std::string&) const { + return "pepper-application/x-chromoting"; + } + + private: + ~RemotingUIHTMLSource() {} + + DISALLOW_COPY_AND_ASSIGN(RemotingUIHTMLSource); +}; + +void RemotingUIHTMLSource::StartDataRequest(const std::string& path, + bool is_off_the_record, + int request_id) { + // Dummy data. Not used, but we need to send something back in the response. + std::string full_html = "remoting"; + + scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes()); + html_bytes->data.resize(full_html.size()); + std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); + + SendResponse(request_id, html_bytes); +} + +} // namespace + +/////////////////////////////////////////////////////////////////////////////// +// +// RemotingUI +// +/////////////////////////////////////////////////////////////////////////////// + +RemotingUI::RemotingUI(TabContents* contents) : DOMUI(contents) { + RemotingUIHTMLSource* html_source = new RemotingUIHTMLSource(); + + // Set up the chrome://remoting source. + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, + NewRunnableMethod(Singleton<ChromeURLDataManager>::get(), + &ChromeURLDataManager::AddDataSource, + make_scoped_refptr(html_source))); +} + + +// static +RefCountedMemory* RemotingUI::GetFaviconResourceBytes() { + return ResourceBundle::GetSharedInstance(). + // TODO(garykac): Have custom remoting icon created. + LoadDataResourceBytes(IDR_PLUGIN); +} + +// static +void RemotingUI::RegisterUserPrefs(PrefService* prefs) { + // TODO(garykac): Add remoting prefs (if needed). +} diff --git a/chrome/browser/dom_ui/remoting_ui.h b/chrome/browser/dom_ui/remoting_ui.h new file mode 100644 index 0000000..1d98b98 --- /dev/null +++ b/chrome/browser/dom_ui/remoting_ui.h @@ -0,0 +1,24 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_DOM_UI_REMOTING_UI_H_ +#define CHROME_BROWSER_DOM_UI_REMOTING_UI_H_ + +#include "chrome/browser/dom_ui/dom_ui.h" + +class PrefService; +class RefCountedMemory; + +class RemotingUI : public DOMUI { + public: + explicit RemotingUI(TabContents* contents); + + static RefCountedMemory* GetFaviconResourceBytes(); + static void RegisterUserPrefs(PrefService* prefs); + + private: + DISALLOW_COPY_AND_ASSIGN(RemotingUI); +}; + +#endif // CHROME_BROWSER_DOM_UI_REMOTING_UI_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 9c88786..b13864a 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1029,6 +1029,8 @@ 'browser/dom_ui/options_ui.h', 'browser/dom_ui/plugins_ui.cc', 'browser/dom_ui/plugins_ui.h', + 'browser/dom_ui/remoting_ui.cc', + 'browser/dom_ui/remoting_ui.h', 'browser/dom_ui/shown_sections_handler.cc', 'browser/dom_ui/shown_sections_handler.h', 'browser/dom_ui/slideshow_ui.cc', diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 238dd07..58a7a69 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -61,18 +61,18 @@ const char kChromeUIBookmarksURL[] = "chrome://bookmarks/"; const char kChromeUIDevToolsURL[] = "chrome://devtools/"; const char kChromeUIDownloadsURL[] = "chrome://downloads/"; const char kChromeUIExtensionsURL[] = "chrome://extensions/"; -const char kChromeUIHistoryURL[] = "chrome://history/"; -const char kChromeUIHistory2URL[] = "chrome://history2/"; -const char kChromeUIPluginsURL[] = "chrome://plugins/"; -const char kChromeUIPrintURL[] = "chrome://print/"; const char kChromeUIFavIconURL[] = "chrome://favicon/"; const char kChromeUIFileBrowseURL[] = "chrome://filebrowse/"; -const char kChromeUIMediaplayerURL[] = "chrome://mediaplayer/"; -const char kChromeUISlideshowURL[] = "chrome://slideshow/"; -const char kChromeUIOptionsURL[] = "chrome://options/"; +const char kChromeUIHistoryURL[] = "chrome://history/"; +const char kChromeUIHistory2URL[] = "chrome://history2/"; const char kChromeUIIPCURL[] = "chrome://about/ipc"; +const char kChromeUIMediaplayerURL[] = "chrome://mediaplayer/"; const char kChromeUINetworkURL[] = "chrome://about/network"; const char kChromeUINewTabURL[] = "chrome://newtab"; +const char kChromeUIOptionsURL[] = "chrome://options/"; +const char kChromeUIPluginsURL[] = "chrome://plugins/"; +const char kChromeUIPrintURL[] = "chrome://print/"; +const char kChromeUISlideshowURL[] = "chrome://slideshow/"; const char kChromeUIBookmarksHost[] = "bookmarks"; const char kChromeUIDevToolsHost[] = "devtools"; @@ -80,20 +80,21 @@ const char kChromeUIDialogHost[] = "dialog"; const char kChromeUIDownloadsHost[] = "downloads"; const char kChromeUIExtensionsHost[] = "extensions"; const char kChromeUIFavIconHost[] = "favicon"; +const char kChromeUIFileBrowseHost[] = "filebrowse"; const char kChromeUIHistoryHost[] = "history"; const char kChromeUIHistory2Host[] = "history2"; +const char kChromeUIInspectorHost[] = "inspector"; +const char kChromeUIMediaplayerHost[] = "mediaplayer"; +const char kChromeUINetInternalsHost[] = "net-internals"; +const char kChromeUINewTabHost[] = "newtab"; +const char kChromeUIOptionsHost[] = "options"; const char kChromeUIPluginsHost[] = "plugins"; const char kChromeUIPrintHost[] = "print"; +const char kChromeUIRemotingHost[] = "remoting"; const char kChromeUIResourcesHost[] = "resources"; -const char kChromeUIFileBrowseHost[] = "filebrowse"; -const char kChromeUIMediaplayerHost[] = "mediaplayer"; const char kChromeUISlideshowHost[] = "slideshow"; -const char kChromeUIOptionsHost[] = "options"; -const char kChromeUIInspectorHost[] = "inspector"; -const char kChromeUINetInternalsHost[] = "net-internals"; -const char kChromeUINewTabHost[] = "newtab"; -const char kChromeUIThumbnailPath[] = "thumb"; const char kChromeUIThemePath[] = "theme"; +const char kChromeUIThumbnailPath[] = "thumb"; const char kSyncResourcesHost[] = "syncresources"; const char kSyncGaiaLoginPath[] = "gaialogin"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 1a668960..d878e10 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -85,6 +85,7 @@ extern const char kChromeUINewTabHost[]; extern const char kChromeUIOptionsHost[]; extern const char kChromeUIPluginsHost[]; extern const char kChromeUIPrintHost[]; +extern const char kChromeUIRemotingHost[]; extern const char kChromeUIResourcesHost[]; extern const char kChromeUISlideshowHost[]; extern const char kChromeUIThumbnailPath[]; @@ -94,9 +95,9 @@ extern const char kChromeUIThemePath[]; extern const char kSyncResourcesHost[]; extern const char kSyncGaiaLoginPath[]; extern const char kSyncMergeAndSyncPath[]; -extern const char kSyncThrobberPath[]; -extern const char kSyncSetupFlowPath[]; extern const char kSyncSetupDonePath[]; +extern const char kSyncSetupFlowPath[]; +extern const char kSyncThrobberPath[]; // AppCache related URL. extern const char kAppCacheViewInternalsURL[]; |