Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7782)

Unified Diff: chrome/renderer/content_settings_observer.cc

Issue 8775005: Content settings: whitelist kExtensionScheme and kChromeInternalScheme on the renderer side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More tests Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/content_settings_observer.cc
diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc
index 1fcdc201e7ea583f66406b65566d2ae43dcc41f2..17b33ae384c9e4af426d33fdcd1daa13b4e06a43 100644
--- a/chrome/renderer/content_settings_observer.cc
+++ b/chrome/renderer/content_settings_observer.cc
@@ -29,32 +29,6 @@ using content::NavigationState;
namespace {
-// True if |frame| contains content that is white-listed for content settings.
-static bool IsWhitelistedForContentSettings(WebFrame* frame) {
- WebSecurityOrigin origin = frame->document().securityOrigin();
- if (origin.isUnique())
- return false; // Uninitialized document?
-
- if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme))
- return true; // Browser UI elements should still work.
-
- if (EqualsASCII(origin.protocol(), chrome::kChromeDevToolsScheme))
- return true; // DevTools UI elements should still work.
-
- // If the scheme is ftp: or file:, an empty file name indicates a directory
- // listing, which requires JavaScript to function properly.
- GURL document_url = frame->document().url();
- const char* kDirProtocols[] = { chrome::kFtpScheme, chrome::kFileScheme };
- for (size_t i = 0; i < arraysize(kDirProtocols); ++i) {
- if (EqualsASCII(origin.protocol(), kDirProtocols[i])) {
- return document_url.SchemeIs(kDirProtocols[i]) &&
- document_url.ExtractFileName().empty();
- }
- }
-
- return false;
-}
-
GURL GetOriginOrURL(const WebFrame* frame) {
WebString top_origin = frame->top()->document().securityOrigin().toString();
// The the |top_origin| is unique ("null") e.g., for file:// URLs. Use the
@@ -308,3 +282,39 @@ void ContentSettingsObserver::ClearBlockedContentSettings() {
cached_storage_permissions_.clear();
cached_script_permissions_.clear();
}
+
+bool ContentSettingsObserver::IsWhitelistedForContentSettings(WebFrame* frame) {
+ return IsWhitelistedForContentSettings(frame->document().securityOrigin(),
+ frame->document().url());
+}
+
+bool ContentSettingsObserver::IsWhitelistedForContentSettings(
+ const WebSecurityOrigin& origin,
+ const GURL& document_url) {
+ if (origin.isUnique())
+ return false; // Uninitialized document?
+
+ if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme))
+ return true; // Browser UI elements should still work.
+
+ if (EqualsASCII(origin.protocol(), chrome::kChromeDevToolsScheme))
+ return true; // DevTools UI elements should still work.
+
+ if (EqualsASCII(origin.protocol(), chrome::kExtensionScheme))
+ return true;
+
+ if (EqualsASCII(origin.protocol(), chrome::kChromeInternalScheme))
+ return true;
+
+ // If the scheme is ftp: or file:, an empty file name indicates a directory
+ // listing, which requires JavaScript to function properly.
+ const char* kDirProtocols[] = { chrome::kFtpScheme, chrome::kFileScheme };
+ for (size_t i = 0; i < arraysize(kDirProtocols); ++i) {
+ if (EqualsASCII(origin.protocol(), kDirProtocols[i])) {
+ return document_url.SchemeIs(kDirProtocols[i]) &&
+ document_url.ExtractFileName().empty();
+ }
+ }
+
+ return false;
+}

Powered by Google App Engine
This is Rietveld 408576698