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

Unified Diff: chrome/renderer/content_settings_observer.cc

Issue 10440014: Correctly whitelist ftp directory listings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months 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
« no previous file with comments | « no previous file | chrome/renderer/page_load_histograms.cc » ('j') | content/renderer/render_view_impl.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/content_settings_observer.cc
diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc
index fea2747a4fa9b11a3dcdf016b77f12605a785dba..0bf74f69580cb226e05857e24fffdf804561e078 100644
--- a/chrome/renderer/content_settings_observer.cc
+++ b/chrome/renderer/content_settings_observer.cc
@@ -16,6 +16,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+#include "webkit/glue/weburlresponse_extradata_impl.h"
using WebKit::WebDataSource;
using WebKit::WebFrame;
@@ -312,6 +313,13 @@ void ContentSettingsObserver::ClearBlockedContentSettings() {
}
bool ContentSettingsObserver::IsWhitelistedForContentSettings(WebFrame* frame) {
+ // Whitelist ftp directory listings, as they requier JavaScript to function
marja 2012/05/24 13:48:40 nit: require
+ // properly.
+ webkit_glue::WebURLResponseExtraDataImpl* extra_data =
+ static_cast<webkit_glue::WebURLResponseExtraDataImpl*>(
+ frame->dataSource()->response().extraData());
+ if (extra_data && extra_data->is_ftp_directory_listing())
+ return true;
return IsWhitelistedForContentSettings(frame->document().securityOrigin(),
frame->document().url());
}
@@ -334,14 +342,11 @@ bool ContentSettingsObserver::IsWhitelistedForContentSettings(
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();
- }
+ // If the scheme is file:, an empty file name indicates a directory listing,
+ // which requires JavaScript to function properly.
+ if (EqualsASCII(origin.protocol(), chrome::kFileScheme)) {
+ return document_url.SchemeIs(chrome::kFileScheme) &&
+ document_url.ExtractFileName().empty();
}
return false;
« no previous file with comments | « no previous file | chrome/renderer/page_load_histograms.cc » ('j') | content/renderer/render_view_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698