diff options
author | podivilov@chromium.org <podivilov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-22 09:28:43 +0000 |
---|---|---|
committer | podivilov@chromium.org <podivilov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-22 09:28:43 +0000 |
commit | 27c790d4c60ac6a2f7ca445e7946884c450f1c53 (patch) | |
tree | 0620d3b15d510bb35c71fd5c3896d6c69515e7d1 | |
parent | 0192f41151d4d34576da444f1d7d1e1fded4f648 (diff) | |
download | chromium_src-27c790d4c60ac6a2f7ca445e7946884c450f1c53.zip chromium_src-27c790d4c60ac6a2f7ca445e7946884c450f1c53.tar.gz chromium_src-27c790d4c60ac6a2f7ca445e7946884c450f1c53.tar.bz2 |
Move inspector to "chrome-devtools" scheme
Pages with "chrome" scheme have very narrow permissions (e.g. no access to localStorage). We want inspector page to have the same permissions as usual page.
Review URL: http://codereview.chromium.org/3838005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63495 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_url_handler.cc | 3 | ||||
-rw-r--r-- | chrome/browser/child_process_security_policy.cc | 6 | ||||
-rw-r--r-- | chrome/browser/child_process_security_policy.h | 5 | ||||
-rw-r--r-- | chrome/browser/child_process_security_policy_unittest.cc | 14 | ||||
-rw-r--r-- | chrome/browser/dom_ui/chrome_url_data_manager.cc | 5 | ||||
-rw-r--r-- | chrome/browser/dom_ui/dom_ui_factory.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_protocols.cc | 3 | ||||
-rw-r--r-- | chrome/browser/history/history.cc | 1 | ||||
-rw-r--r-- | chrome/browser/host_content_settings_map.cc | 3 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 7 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 11 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 3 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 6 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 2 |
14 files changed, 29 insertions, 46 deletions
diff --git a/chrome/browser/browser_url_handler.cc b/chrome/browser/browser_url_handler.cc index 6707606..f4f9fd7 100644 --- a/chrome/browser/browser_url_handler.cc +++ b/chrome/browser/browser_url_handler.cc @@ -22,7 +22,8 @@ static bool HandleViewSource(GURL* url, Profile* profile) { // other kind of 'active' url scheme like 'javascript' or 'data'. static const char* const allowed_sub_schemes[] = { chrome::kHttpScheme, chrome::kHttpsScheme, chrome::kFtpScheme, - chrome::kChromeUIScheme, chrome::kFileScheme + chrome::kChromeDevToolsScheme, chrome::kChromeUIScheme, + chrome::kFileScheme }; bool is_sub_scheme_allowed = false; diff --git a/chrome/browser/child_process_security_policy.cc b/chrome/browser/child_process_security_policy.cc index 67b8a7c..0aed464 100644 --- a/chrome/browser/child_process_security_policy.cc +++ b/chrome/browser/child_process_security_policy.cc @@ -273,12 +273,6 @@ void ChildProcessSecurityPolicy::GrantScheme(int renderer_id, state->second->GrantScheme(scheme); } -void ChildProcessSecurityPolicy::GrantInspectElement(int renderer_id) { - // The inspector is served from a chrome: URL. In order to run the - // inspector, the renderer needs to be able to load chrome: URLs. - GrantScheme(renderer_id, chrome::kChromeUIScheme); -} - void ChildProcessSecurityPolicy::GrantDOMUIBindings(int renderer_id) { AutoLock lock(lock_); diff --git a/chrome/browser/child_process_security_policy.h b/chrome/browser/child_process_security_policy.h index fc8814a..b70dc25 100644 --- a/chrome/browser/child_process_security_policy.h +++ b/chrome/browser/child_process_security_policy.h @@ -84,11 +84,6 @@ class ChildProcessSecurityPolicy { // scheme. void GrantScheme(int renderer_id, const std::string& scheme); - // Whenever the browser processes commands the renderer to run web inspector, - // it should call this method to grant the renderer process the capability to - // run the inspector. - void GrantInspectElement(int renderer_id); - // Grant this renderer the ability to use DOM UI Bindings. void GrantDOMUIBindings(int renderer_id); diff --git a/chrome/browser/child_process_security_policy_unittest.cc b/chrome/browser/child_process_security_policy_unittest.cc index 40b249b..26f794f 100644 --- a/chrome/browser/child_process_security_policy_unittest.cc +++ b/chrome/browser/child_process_security_policy_unittest.cc @@ -287,20 +287,6 @@ TEST_F(ChildProcessSecurityPolicyTest, FilePermissions) { p->Remove(kRendererID); } -TEST_F(ChildProcessSecurityPolicyTest, CanServiceInspectElement) { - ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance(); - - GURL url("chrome://devtools/devtools.html"); - - p->Add(kRendererID); - - EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); - p->GrantInspectElement(kRendererID); - EXPECT_TRUE(p->CanRequestURL(kRendererID, url)); - - p->Remove(kRendererID); -} - TEST_F(ChildProcessSecurityPolicyTest, CanServiceDOMUIBindings) { ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance(); diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.cc b/chrome/browser/dom_ui/chrome_url_data_manager.cc index e415699..dfa7785 100644 --- a/chrome/browser/dom_ui/chrome_url_data_manager.cc +++ b/chrome/browser/dom_ui/chrome_url_data_manager.cc @@ -102,6 +102,8 @@ void RegisterURLRequestChromeJob() { } SharedResourcesDataSource::Register(); + URLRequest::RegisterProtocolFactory(chrome::kChromeDevToolsScheme, + &ChromeURLDataManager::Factory); URLRequest::RegisterProtocolFactory(chrome::kChromeUIScheme, &ChromeURLDataManager::Factory); } @@ -118,7 +120,8 @@ void UnregisterURLRequestChromeJob() { void ChromeURLDataManager::URLToRequest(const GURL& url, std::string* source_name, std::string* path) { - DCHECK(url.SchemeIs(chrome::kChromeUIScheme)); + DCHECK(url.SchemeIs(chrome::kChromeDevToolsScheme) || + url.SchemeIs(chrome::kChromeUIScheme)); if (!url.is_valid()) { NOTREACHED(); diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc index 8ed538f..be3546a 100644 --- a/chrome/browser/dom_ui/dom_ui_factory.cc +++ b/chrome/browser/dom_ui/dom_ui_factory.cc @@ -97,7 +97,8 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(Profile* profile, // This will get called a lot to check all URLs, so do a quick check of other // schemes (gears was handled above) to filter out most URLs. - if (!url.SchemeIs(chrome::kChromeInternalScheme) && + if (!url.SchemeIs(chrome::kChromeDevToolsScheme) && + !url.SchemeIs(chrome::kChromeInternalScheme) && !url.SchemeIs(chrome::kChromeUIScheme)) return NULL; @@ -206,7 +207,8 @@ DOMUITypeID DOMUIFactory::GetDOMUIType(Profile* profile, const GURL& url) { // static bool DOMUIFactory::HasDOMUIScheme(const GURL& url) { - return url.SchemeIs(chrome::kChromeInternalScheme) || + return url.SchemeIs(chrome::kChromeDevToolsScheme) || + url.SchemeIs(chrome::kChromeInternalScheme) || url.SchemeIs(chrome::kChromeUIScheme) || url.SchemeIs(chrome::kExtensionScheme); } diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc index ce56589..90d198c 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -84,7 +84,8 @@ bool AllowExtensionResourceLoad(URLRequest* request, // chrome:// URLs are always allowed to load chrome-extension:// resources. // The app launcher in the NTP uses this feature, as does dev tools. - if (origin_url.SchemeIs(chrome::kChromeUIScheme)) + if (origin_url.SchemeIs(chrome::kChromeDevToolsScheme) || + origin_url.SchemeIs(chrome::kChromeUIScheme)) return true; // Disallow loading of packaged resources for hosted apps. We don't allow diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index bc5db7d..91323c3 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -673,6 +673,7 @@ bool HistoryService::CanAddURL(const GURL& url) { // typed. Right now, however, these are marked as typed even when triggered // by a shortcut or menu action. if (url.SchemeIs(chrome::kJavaScriptScheme) || + url.SchemeIs(chrome::kChromeDevToolsScheme) || url.SchemeIs(chrome::kChromeUIScheme) || url.SchemeIs(chrome::kViewSourceScheme) || url.SchemeIs(chrome::kChromeInternalScheme)) diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc index 96a9bc2..e1a0bb1 100644 --- a/chrome/browser/host_content_settings_map.cc +++ b/chrome/browser/host_content_settings_map.cc @@ -93,7 +93,8 @@ const bool kRequiresResourceIdentifier[CONTENT_SETTINGS_NUM_TYPES] = { // true for various internal objects like chrome:// URLs, so UI and other // things users think of as "not webpages" don't break. static bool ShouldAllowAllContent(const GURL& url) { - return url.SchemeIs(chrome::kChromeInternalScheme) || + return url.SchemeIs(chrome::kChromeDevToolsScheme) || + url.SchemeIs(chrome::kChromeInternalScheme) || url.SchemeIs(chrome::kChromeUIScheme) || url.SchemeIs(chrome::kExtensionScheme) || url.SchemeIs(chrome::kGearsScheme) || diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index cc1fe93..e59e00e 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -358,9 +358,10 @@ ChromeURLRequestContext* FactoryForExtensions::Create() { net::CookieMonster* cookie_monster = new net::CookieMonster(cookie_db.get(), NULL); - // Enable cookies for extension URLs only. - const char* schemes[] = {chrome::kExtensionScheme}; - cookie_monster->SetCookieableSchemes(schemes, 1); + // Enable cookies for devtools and extension URLs. + const char* schemes[] = {chrome::kChromeDevToolsScheme, + chrome::kExtensionScheme}; + cookie_monster->SetCookieableSchemes(schemes, 2); context->set_cookie_store(cookie_monster); // TODO(cbentzel): How should extensions handle HTTP Authentication? context->set_http_auth_handler_factory( diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 4dc7b11..68041ec 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -64,8 +64,7 @@ const size_t RenderViewContextMenu::kMaxSelectionTextLength = 50; // static bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { - return url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUIDevToolsHost; + return url.SchemeIs(chrome::kChromeDevToolsScheme); } // static @@ -1407,8 +1406,7 @@ bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { bool debug_mode = true; #endif // Don't inspect new tab UI, etc. - if (active_entry->url().SchemeIs(chrome::kChromeUIScheme) && !debug_mode && - active_entry->url().host() != chrome::kChromeUIDevToolsHost) + if (active_entry->url().SchemeIs(chrome::kChromeUIScheme) && !debug_mode) return false; // Don't inspect about:network, about:memory, etc. @@ -1423,11 +1421,6 @@ bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { if (!profile_->GetPrefs()->GetBoolean(prefs::kWebKitJavascriptEnabled) || command_line.HasSwitch(switches::kDisableJavaScript)) return false; - // Don't enable the web inspector on web inspector if there is no process - // per tab flag set. - if (IsDevToolsURL(active_entry->url()) && - !command_line.HasSwitch(switches::kProcessPerTab)) - return false; } return true; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index eb6f1c0..c7e68ea 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -2878,7 +2878,8 @@ WebPreferences TabContents::GetWebkitPrefs() { // Force accelerated compositing and 2d canvas off for chrome: and // chrome-extension: pages. - if (GetURL().SchemeIs(chrome::kChromeUIScheme)) { + if (GetURL().SchemeIs(chrome::kChromeDevToolsScheme) || + GetURL().SchemeIs(chrome::kChromeUIScheme)) { web_prefs.accelerated_compositing_enabled = false; web_prefs.accelerated_2d_canvas_enabled = false; } diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 1c65a66..fdca702 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -1,3 +1,4 @@ + // 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. @@ -11,6 +12,7 @@ namespace chrome { const char kAboutScheme[] = "about"; const char kBlobScheme[] = "blob"; +const char kChromeDevToolsScheme[] = "chrome-devtools"; const char kChromeInternalScheme[] = "chrome-internal"; const char kChromeUIScheme[] = "chrome"; const char kDataScheme[] = "data"; @@ -38,6 +40,7 @@ const char* kSavableSchemes[] = { kFileScheme, kFtpScheme, kExtensionScheme, + kChromeDevToolsScheme, kChromeUIScheme, NULL }; @@ -72,7 +75,7 @@ const char kChromeUIAppLauncherURL[] = "chrome://newtab/#mode=app-launcher"; const char kChromeUIBookmarksURL[] = "chrome://bookmarks/"; const char kChromeUIBugReportURL[] = "chrome://bugreport/"; const char kChromeUIConstrainedHTMLTestURL[] = "chrome://constrained-test/"; -const char kChromeUIDevToolsURL[] = "chrome://devtools/"; +const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/"; const char kChromeUIDownloadsURL[] = "chrome://downloads/"; const char kChromeUIExtensionsURL[] = "chrome://extensions/"; const char kChromeUIFavIconURL[] = "chrome://favicon/"; @@ -165,6 +168,7 @@ const char kSystemOptionsSubPage[] = "system"; void RegisterChromeSchemes() { // Don't need "chrome-internal" which was used in old versions of Chrome for // the new tab page. + url_util::AddStandardScheme(kChromeDevToolsScheme); url_util::AddStandardScheme(kChromeUIScheme); url_util::AddStandardScheme(kGearsScheme); url_util::AddStandardScheme(kExtensionScheme); diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index e11e5b5..011309f 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -13,6 +13,7 @@ namespace chrome { // Canonical schemes you can use as input to GURL.SchemeIs(). extern const char kAboutScheme[]; extern const char kBlobScheme[]; +extern const char kChromeDevToolsScheme[]; extern const char kChromeInternalScheme[]; extern const char kChromeUIScheme[]; // The scheme used for DOMUIs. extern const char kCrosScheme[]; // The scheme used for ChromeOS. @@ -101,7 +102,6 @@ extern const char kChromeUIFavIconHost[]; extern const char kChromeUIFlagsHost[]; extern const char kChromeUIHistory2Host[]; extern const char kChromeUIHistoryHost[]; -extern const char kChromeUIInspectorHost[]; extern const char kChromeUIKeyboardHost[]; extern const char kChromeUINetInternalsHost[]; extern const char kChromeUINewTabHost[]; |