diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-03 12:06:06 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-03 12:06:06 +0000 |
commit | 30c58691961266c918daaf10f2b867b27691dd89 (patch) | |
tree | fdd7651e9dffc79221c365a284a4d8bc40b7a1d9 | |
parent | 2a59ebeb4f6684eda0cbdf9183cb9fce7b32247c (diff) | |
download | chromium_src-30c58691961266c918daaf10f2b867b27691dd89.zip chromium_src-30c58691961266c918daaf10f2b867b27691dd89.tar.gz chromium_src-30c58691961266c918daaf10f2b867b27691dd89.tar.bz2 |
DevTools: open remote front-ends using chrome-devtools://remote/* urls.
BUG=13392008
TBR=brettw (for oneliners outside webui)
This change splits chrome-devtools:// handler into the one serving chrome-devtools://devtools (for embedded) and chrome-devtools://remote (for remote) front-ends. It also remove command line check for remote/ path.
Drive-by: move url constants from content/ to chrome/, remove legacy data source registration.
Review URL: https://codereview.chromium.org/13465007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192052 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/devtools/devtools_window.cc | 2 | ||||
-rw-r--r-- | chrome/browser/devtools/remote_debugging_server.cc | 3 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.cc | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/devtools_ui.cc | 168 | ||||
-rw-r--r-- | chrome/browser/ui/webui/devtools_ui.h | 1 | ||||
-rw-r--r-- | chrome/browser/ui/webui/inspect_ui.cc | 9 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 3 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 3 | ||||
-rw-r--r-- | content/public/common/url_constants.cc | 1 | ||||
-rw-r--r-- | content/public/common/url_constants.h | 1 |
14 files changed, 96 insertions, 107 deletions
diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc index f5738d6..0d9552c 100644 --- a/chrome/browser/devtools/devtools_window.cc +++ b/chrome/browser/devtools/devtools_window.cc @@ -240,7 +240,7 @@ DevToolsWindow* DevToolsWindow::Create( RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); content::DevToolsClientHost::SetupDevToolsFrontendClient(render_view_host); - if (url.path().find(chrome::kChromeUIDevToolsHostedPath) == 0) { + if (url.host() == chrome::kChromeUIDevToolsBundledHost) { // Only allow file scheme in embedded front-end by default. int process_id = render_view_host->GetProcess()->GetID(); content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( diff --git a/chrome/browser/devtools/remote_debugging_server.cc b/chrome/browser/devtools/remote_debugging_server.cc index d1b9fcd..e89d013 100644 --- a/chrome/browser/devtools/remote_debugging_server.cc +++ b/chrome/browser/devtools/remote_debugging_server.cc @@ -15,9 +15,6 @@ RemoteDebuggingServer::RemoteDebuggingServer( const std::string& ip, int port, const std::string& frontend_url) { - // Initialize DevTools data source. - DevToolsUI::RegisterDevToolsDataSource(profile); - devtools_http_handler_ = content::DevToolsHttpHandler::Start( new net::TCPListenSocketFactory(ip, port), frontend_url, diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 2cbc148..5026a67 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -146,8 +146,7 @@ Profile* GetProfileOnUI(ProfileManager* profile_manager, Profile* profile) { #if defined(DEBUG_DEVTOOLS) bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { if (!url.SchemeIs(chrome::kChromeDevToolsScheme) || - url.host() != chrome::kChromeUIDevToolsHost || - url.path().find(chrome::kChromeUIDevToolsHostedPath) == 1) { + url.host() != chrome::kChromeUIDevToolsBundledHost) { return false; } diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index fc5bada..6cad698 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -244,8 +244,7 @@ const size_t RenderViewContextMenu::kMaxSelectionTextLength = 50; // static bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { - return url.SchemeIs(chrome::kChromeDevToolsScheme) && - url.host() == chrome::kChromeUIDevToolsHost; + return url.SchemeIs(chrome::kChromeDevToolsScheme); } // static diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 2dfcdcb..40a1b99 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -259,7 +259,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, // Bookmarks are part of NTP on Android. if (url.host() == chrome::kChromeUIBookmarksHost) return &NewWebUI<BookmarksUI>; - if (url.host() == chrome::kChromeUIDevToolsHost) + if (url.SchemeIs(chrome::kChromeDevToolsScheme)) return &NewWebUI<DevToolsUI>; // Downloads list on Android uses the built-in download manager. if (url.host() == chrome::kChromeUIDownloadsHost) diff --git a/chrome/browser/ui/webui/devtools_ui.cc b/chrome/browser/ui/webui/devtools_ui.cc index 7229094..92dd673 100644 --- a/chrome/browser/ui/webui/devtools_ui.cc +++ b/chrome/browser/ui/webui/devtools_ui.cc @@ -6,14 +6,12 @@ #include <string> -#include "base/command_line.h" #include "base/memory/ref_counted_memory.h" #include "base/memory/scoped_ptr.h" #include "base/string_util.h" #include "base/stringprintf.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/devtools_http_handler.h" @@ -35,8 +33,8 @@ std::string PathWithoutParams(const std::string& path) { .path().substr(1); } -const char kHostedFrontendDomain[] = "chrome-devtools-frontend.appspot.com"; -const char kHostedFrontendBase[] = +const char kRemoteFrontendDomain[] = "chrome-devtools-frontend.appspot.com"; +const char kRemoteFrontendBase[] = "https://chrome-devtools-frontend.appspot.com/"; const char kHttpNotFound[] = "HTTP/1.1 404 Not Found\n\n"; @@ -46,10 +44,7 @@ class FetchRequest : public net::URLFetcherDelegate { const GURL& url, const content::URLDataSource::GotDataCallback& callback) : callback_(callback) { - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - bool hosted_frontend = - command_line.HasSwitch(switches::kEnableHostedDevToolsFrontend); - if (!hosted_frontend || !url.is_valid()) { + if (!url.is_valid()) { OnURLFetchComplete(NULL); return; } @@ -77,105 +72,111 @@ class FetchRequest : public net::URLFetcherDelegate { content::URLDataSource::GotDataCallback callback_; }; -} // namespace +std::string GetMimeTypeForPath(const std::string& path) { + std::string filename = PathWithoutParams(path); + if (EndsWith(filename, ".html", false)) { + return "text/html"; + } else if (EndsWith(filename, ".css", false)) { + return "text/css"; + } else if (EndsWith(filename, ".js", false)) { + return "application/javascript"; + } else if (EndsWith(filename, ".png", false)) { + return "image/png"; + } else if (EndsWith(filename, ".gif", false)) { + return "image/gif"; + } else if (EndsWith(filename, ".manifest", false)) { + return "text/cache-manifest"; + } + NOTREACHED(); + return "text/plain"; +} -class DevToolsDataSource : public content::URLDataSource { +class BundledDataSource : public content::URLDataSource { public: - explicit DevToolsDataSource(net::URLRequestContextGetter* request_context); + explicit BundledDataSource() { + } // content::URLDataSource implementation. - virtual std::string GetSource() OVERRIDE; + virtual std::string GetSource() OVERRIDE { + return chrome::kChromeUIDevToolsBundledHost; + } + virtual void StartDataRequest( const std::string& path, bool is_incognito, - const content::URLDataSource::GotDataCallback& callback) OVERRIDE; - virtual std::string GetMimeType(const std::string& path) const OVERRIDE; - virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE; + const content::URLDataSource::GotDataCallback& callback) OVERRIDE { + std::string filename = PathWithoutParams(path); + + int resource_id = + content::DevToolsHttpHandler::GetFrontendResourceId(filename); + + DLOG_IF(WARNING, -1 == resource_id) << "Unable to find dev tool resource: " + << filename << ". If you compiled with debug_devtools=1, try running" + " with --debug-devtools."; + const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + scoped_refptr<base::RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes( + resource_id)); + callback.Run(bytes); + } + + virtual std::string GetMimeType(const std::string& path) const OVERRIDE { + return GetMimeTypeForPath(path); + } + + virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE { + return false; + } private: - virtual ~DevToolsDataSource() {} - scoped_refptr<net::URLRequestContextGetter> request_context_; - DISALLOW_COPY_AND_ASSIGN(DevToolsDataSource); + virtual ~BundledDataSource() {} + DISALLOW_COPY_AND_ASSIGN(BundledDataSource); }; +class RemoteDataSource : public content::URLDataSource { + public: + explicit RemoteDataSource(net::URLRequestContextGetter* + request_context) : request_context_(request_context) { + } -DevToolsDataSource::DevToolsDataSource( - net::URLRequestContextGetter* request_context) - : request_context_(request_context) { -} - -std::string DevToolsDataSource::GetSource() { - return chrome::kChromeUIDevToolsHost; -} + // content::URLDataSource implementation. + virtual std::string GetSource() OVERRIDE { + return chrome::kChromeUIDevToolsRemoteHost; + } -void DevToolsDataSource::StartDataRequest( - const std::string& path, - bool is_incognito, - const content::URLDataSource::GotDataCallback& callback) { - std::string filename = PathWithoutParams(path); + virtual void StartDataRequest( + const std::string& path, + bool is_incognito, + const content::URLDataSource::GotDataCallback& callback) OVERRIDE { - if (filename.find(chrome::kChromeUIDevToolsHostedPath) == 0) { - GURL url = GURL(kHostedFrontendBase + - filename.substr(strlen(chrome::kChromeUIDevToolsHostedPath))); - CHECK(url.host() == kHostedFrontendDomain); + GURL url = GURL(kRemoteFrontendBase + path); + CHECK_EQ(url.host(), kRemoteFrontendDomain); new FetchRequest(request_context_, url, callback); - return; } - int resource_id = - content::DevToolsHttpHandler::GetFrontendResourceId(filename); - - DLOG_IF(WARNING, -1 == resource_id) << "Unable to find dev tool resource: " - << filename << ". If you compiled with debug_devtools=1, try running" - " with --debug-devtools."; - const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - scoped_refptr<base::RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes( - resource_id)); - callback.Run(bytes); -} + virtual std::string GetMimeType(const std::string& path) const OVERRIDE { + return GetMimeTypeForPath(path); + } -std::string DevToolsDataSource::GetMimeType(const std::string& path) const { - std::string filename = PathWithoutParams(path); - if (EndsWith(filename, ".html", false)) { - return "text/html"; - } else if (EndsWith(filename, ".css", false)) { - return "text/css"; - } else if (EndsWith(filename, ".js", false)) { - return "application/javascript"; - } else if (EndsWith(filename, ".png", false)) { - return "image/png"; - } else if (EndsWith(filename, ".gif", false)) { - return "image/gif"; - } else if (EndsWith(filename, ".manifest", false)) { - return "text/cache-manifest"; + virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE { + return false; } - NOTREACHED(); - return "text/plain"; -} -bool DevToolsDataSource::ShouldAddContentSecurityPolicy() const { - return false; -} + private: + virtual ~RemoteDataSource() {} + scoped_refptr<net::URLRequestContextGetter> request_context_; -// static -void DevToolsUI::RegisterDevToolsDataSource(Profile* profile) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - static bool registered = false; - if (!registered) { - content::URLDataSource::Add(profile, new DevToolsDataSource( - profile->GetRequestContext())); - registered = true; - } -} + DISALLOW_COPY_AND_ASSIGN(RemoteDataSource); +}; + +} // namespace // static GURL DevToolsUI::GetProxyURL(const std::string& frontend_url) { GURL url(frontend_url); CHECK(url.is_valid()); - CHECK_EQ(url.host(), kHostedFrontendDomain); - return GURL(base::StringPrintf("%s://%s/%s%s", chrome::kChromeDevToolsScheme, - chrome::kChromeUIDevToolsHost, - chrome::kChromeUIDevToolsHostedPath, + CHECK_EQ(url.host(), kRemoteFrontendDomain); + return GURL(base::StringPrintf("%s://%s/%s", chrome::kChromeDevToolsScheme, + chrome::kChromeUIDevToolsRemoteHost, url.path().substr(1).c_str())); } @@ -184,5 +185,8 @@ DevToolsUI::DevToolsUI(content::WebUI* web_ui) : WebUIController(web_ui) { Profile* profile = Profile::FromWebUI(web_ui); content::URLDataSource::Add( profile, - new DevToolsDataSource(profile->GetRequestContext())); + new BundledDataSource()); + content::URLDataSource::Add( + profile, + new RemoteDataSource(profile->GetRequestContext())); } diff --git a/chrome/browser/ui/webui/devtools_ui.h b/chrome/browser/ui/webui/devtools_ui.h index 9f67050..9c4e2b6 100644 --- a/chrome/browser/ui/webui/devtools_ui.h +++ b/chrome/browser/ui/webui/devtools_ui.h @@ -12,7 +12,6 @@ class Profile; class DevToolsUI : public content::WebUIController { public: - static void RegisterDevToolsDataSource(Profile* profile); static GURL GetProxyURL(const std::string& frontend_url); explicit DevToolsUI(content::WebUI* web_ui); diff --git a/chrome/browser/ui/webui/inspect_ui.cc b/chrome/browser/ui/webui/inspect_ui.cc index 4c59921..b0b67c3 100644 --- a/chrome/browser/ui/webui/inspect_ui.cc +++ b/chrome/browser/ui/webui/inspect_ui.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/command_line.h" #include "base/json/json_writer.h" #include "base/memory/ref_counted_memory.h" #include "base/string_util.h" @@ -19,7 +18,6 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_data.h" @@ -429,11 +427,8 @@ bool InspectUI::HandleRequestCallback( const content::WebUIDataSource::GotDataCallback& callback) { if (path == kDataFile) return HandleDataRequestCallback(path, callback); - if (path.find(kAdbPages) == 0) { - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(switches::kEnableHostedDevToolsFrontend)) - return HandleAdbPagesCallback(path, callback); - } + if (path.find(kAdbPages) == 0) + return HandleAdbPagesCallback(path, callback); return false; } diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index fe58994..d3ec727 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -495,9 +495,6 @@ const char kEnableDesktopGuestMode[] = "enable-desktop-guest-mode"; // If true devtools experimental settings are enabled. const char kEnableDevToolsExperiments[] = "enable-devtools-experiments"; -// If true devtools is allowed to load hosted front-ends. -const char kEnableHostedDevToolsFrontend[] = "enable-hosted-devtools-frontend"; - // Enables an interactive autocomplete UI and a way to invoke this UI from // WebKit by enabling HTMLFormElement#requestAutocomplete (and associated // autocomplete* events and logic). diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index cb15a1b..312d380 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -154,7 +154,6 @@ extern const char kEnableExtensionActivityLogTesting[]; extern const char kEnableExtensionActivityUI[]; extern const char kEnableFileCookies[]; extern const char kEnableGoogleNowIntegration[]; -extern const char kEnableHostedDevToolsFrontend[]; extern const char kEnableInstantExtendedAPI[]; extern const char kEnableInteractiveAutocomplete[]; extern const char kEnableIPCFuzzing[]; diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index f7b9e85..aca09f2 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -144,6 +144,8 @@ const char kChromeUICrashesHost[] = "crashes"; const char kChromeUICrashHost[] = "crash"; const char kChromeUICreditsHost[] = "credits"; const char kChromeUIDefaultHost[] = "version"; +const char kChromeUIDevToolsBundledHost[] = "devtools"; +const char kChromeUIDevToolsRemoteHost[] = "remote"; const char kChromeUIDNSHost[] = "dns"; const char kChromeUIDownloadsHost[] = "downloads"; const char kChromeUIDriveInternalsHost[] = "drive-internals"; @@ -209,7 +211,6 @@ const char kChromeUIUserActionsHost[] = "user-actions"; const char kChromeUIVersionHost[] = "version"; const char kChromeUIWorkersHost[] = "workers"; -const char kChromeUIDevToolsHostedPath[] = "hosted/"; const char kChromeUIScreenshotPath[] = "screenshots"; const char kChromeUIThemePath[] = "theme"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 5e49877..dcb0c88 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -137,6 +137,8 @@ extern const char kChromeUICrashesHost[]; extern const char kChromeUICrashHost[]; extern const char kChromeUICreditsHost[]; extern const char kChromeUIDefaultHost[]; +extern const char kChromeUIDevToolsBundledHost[]; +extern const char kChromeUIDevToolsRemoteHost[]; extern const char kChromeUIDNSHost[]; extern const char kChromeUIDownloadsHost[]; extern const char kChromeUIDriveInternalsHost[]; @@ -201,7 +203,6 @@ extern const char kChromeUIUserActionsHost[]; extern const char kChromeUIVersionHost[]; extern const char kChromeUIWorkersHost[]; -extern const char kChromeUIDevToolsHostedPath[]; extern const char kChromeUIScreenshotPath[]; extern const char kChromeUIThemePath[]; diff --git a/content/public/common/url_constants.cc b/content/public/common/url_constants.cc index 40b3b03..f83ebc5 100644 --- a/content/public/common/url_constants.cc +++ b/content/public/common/url_constants.cc @@ -36,7 +36,6 @@ const char kChromeUIAppCacheInternalsHost[] = "appcache-internals"; const char kChromeUIAccessibilityHost[] = "accessibility"; const char kChromeUIBlobInternalsHost[] = "blob-internals"; const char kChromeUIBrowserCrashHost[] = "inducebrowsercrashforrealz"; -const char kChromeUIDevToolsHost[] = "devtools"; const char kChromeUIGpuHost[] = "gpu"; const char kChromeUIHistogramHost[] = "histograms"; const char kChromeUIMediaInternalsHost[] = "media-internals"; diff --git a/content/public/common/url_constants.h b/content/public/common/url_constants.h index ef45d26..aa977c6 100644 --- a/content/public/common/url_constants.h +++ b/content/public/common/url_constants.h @@ -43,7 +43,6 @@ CONTENT_EXPORT extern const char kChromeUIAccessibilityHost[]; CONTENT_EXPORT extern const char kChromeUIAppCacheInternalsHost[]; CONTENT_EXPORT extern const char kChromeUIBlobInternalsHost[]; CONTENT_EXPORT extern const char kChromeUIBrowserCrashHost[]; -CONTENT_EXPORT extern const char kChromeUIDevToolsHost[]; CONTENT_EXPORT extern const char kChromeUIHistogramHost[]; CONTENT_EXPORT extern const char kChromeUIMediaInternalsHost[]; CONTENT_EXPORT extern const char kChromeUINetworkViewCacheHost[]; |