summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-15 15:09:24 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-15 15:09:24 +0000
commit13a63d917b852736ded2ba758900725642048819 (patch)
tree7a95c019d823643cffa238fd56a716a842e19b1e /chrome/renderer
parentc9b486039c7d35d8dfcef52f36e1de2a11fbbe46 (diff)
downloadchromium_src-13a63d917b852736ded2ba758900725642048819.zip
chromium_src-13a63d917b852736ded2ba758900725642048819.tar.gz
chromium_src-13a63d917b852736ded2ba758900725642048819.tar.bz2
Merge 44632 - Check for file/ftp directory listings before applying settings.
BUG=40765 TEST=go to ftp://ibiblio.org/pub/Linux/distributions/damnsmall/current/ Review URL: http://codereview.chromium.org/1594029 TBR=jochen@chromium.org Review URL: http://codereview.chromium.org/1525036 git-svn-id: svn://svn.chromium.org/chrome/branches/375/src@44654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_view.cc63
1 files changed, 37 insertions, 26 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 39e6ec6..6e70995 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -297,6 +297,29 @@ static double CalculateBoringScore(SkBitmap* bitmap) {
return static_cast<double>(color_count) / pixel_count;
}
+// True if |frame| contains content that is white-listed for content settings.
+static bool IsWhitelistedForContentSettings(WebFrame* frame) {
+ WebSecurityOrigin origin = frame->securityOrigin();
+ if (origin.isEmpty())
+ return false; // Uninitialized document?
+
+ if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme))
+ return true; // Browser 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 frame_url = frame->url();
+ const char* kDirProtocols[] = { "ftp", "file" };
+ for (size_t i = 0; i < arraysize(kDirProtocols); ++i) {
+ if (EqualsASCII(origin.protocol(), kDirProtocols[i])) {
+ return frame_url.SchemeIs(kDirProtocols[i]) &&
+ frame_url.ExtractFileName().empty();
+ }
+ }
+
+ return false;
+}
+
///////////////////////////////////////////////////////////////////////////////
int32 RenderView::next_page_id_ = 1;
@@ -2176,13 +2199,15 @@ bool RenderView::allowPlugins(WebFrame* frame, bool enabled_per_settings) {
}
bool RenderView::allowImages(WebFrame* frame, bool enabled_per_settings) {
- if (!enabled_per_settings)
- return false;
- if (!AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) {
- DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES);
- return false;
- }
- return true;
+ if (enabled_per_settings &&
+ AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES))
+ return true;
+
+ if (IsWhitelistedForContentSettings(frame))
+ return true;
+
+ DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES);
+ return false; // Other protocols fall through here.
}
void RenderView::loadURLExternally(
@@ -2914,26 +2939,12 @@ void RenderView::didRunInsecureContent(
}
bool RenderView::allowScript(WebFrame* frame, bool enabled_per_settings) {
- if (enabled_per_settings)
- return AllowContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT);
+ if (enabled_per_settings &&
+ AllowContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT))
+ return true;
- WebSecurityOrigin origin = frame->securityOrigin();
- if (origin.isEmpty())
- return false; // Uninitialized document?
-
- if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme))
- return true; // Browser 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 frame_url = frame->url();
- const char* kDirProtocols[] = { "ftp", "file" };
- for (size_t i = 0; i < arraysize(kDirProtocols); ++i) {
- if (EqualsASCII(origin.protocol(), kDirProtocols[i])) {
- return frame_url.SchemeIs(kDirProtocols[i]) &&
- frame_url.ExtractFileName().empty();
- }
- }
+ if (IsWhitelistedForContentSettings(frame))
+ return true;
return false; // Other protocols fall through here.
}