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

Unified Diff: chrome/browser/ui/webui/chrome_url_data_manager_backend.cc

Issue 8124010: Replace <meta> tag with header for content-security-policy on chrome:// pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | « chrome/browser/resources/workers/index.html ('k') | chrome/test/functional/special_tabs.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chrome_url_data_manager_backend.cc
===================================================================
--- chrome/browser/ui/webui/chrome_url_data_manager_backend.cc (revision 103729)
+++ chrome/browser/ui/webui/chrome_url_data_manager_backend.cc (working copy)
@@ -4,10 +4,13 @@
#include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
+#include <set>
+
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
+#include "base/lazy_instance.h"
#include "base/memory/ref_counted_memory.h"
#include "base/message_loop.h"
#include "base/path_service.h"
@@ -34,6 +37,57 @@
namespace {
+// X-WebKit-CSP is our development name for Content-Security-Policy.
+// TODO(tsepez) rename when Content-security-policy is done.
+// TODO(tsepez) remove unsafe-eval when bidichecker_packaged.js fixed.
+// TODO(tsepez) chrome-extension: permits the ChromeVox screen reader
+// extension to function on these pages. Remove it when the extension
+// is updated to stop injecting script into the pages.
+const char kChromeURLContentSecurityPolicyHeader[] =
+ "X-WebKit-CSP: object-src 'self'; script-src chrome://resources "
+ "chrome-extension://mndnfokpggljbaajbnioimlmbfngpief "
+ "'self' 'unsafe-eval'";
+
+class ChromeURLContentSecurityPolicyExceptionSet
+ : public std::set<std::string> {
+ public:
+ ChromeURLContentSecurityPolicyExceptionSet() : std::set<std::string>() {
+ insert(chrome::kChromeUICloudPrintResourcesHost);
+ insert(chrome::kChromeUICloudPrintSetupHost);
+ insert(chrome::kChromeUICreditsHost);
+ insert(chrome::kChromeUIDevToolsHost);
+ insert(chrome::kChromeUIDialogHost);
+ insert(chrome::kChromeUINewTabHost);
+ insert(chrome::kChromeUITextfieldsHost);
+#if defined(OS_CHROMEOS)
+ insert(chrome::kChromeUIActiveDownloadsHost);
+ insert(chrome::kChromeUIChooseMobileNetworkHost);
+ insert(chrome::kChromeUIEnterpriseEnrollmentHost);
+ insert(chrome::kChromeUIImageBurnerHost);
+ insert(chrome::kChromeUIKeyboardOverlayHost);
+ insert(chrome::kChromeUIOobeHost);
+ insert(chrome::kChromeUIMobileSetupHost);
+ insert(chrome::kChromeUIProxySettingsHost);
+ insert(chrome::kChromeUIRegisterPageHost);
+ insert(chrome::kChromeUISimUnlockHost);
+ insert(chrome::kChromeUISystemInfoHost);
+#else
+ insert(chrome::kChromeUISyncPromoHost);
+#endif
+#if defined(TOUCH_UI)
+ insert(chrome::kChromeUIKeyboardHost);
+#endif
+#if defined(OS_CHROMEOS) || defined(TOUCH_UI)
+ insert(chrome::kChromeUICollectedCookiesHost);
+ insert(chrome::kChromeUIHttpAuthHost);
+ insert(chrome::kChromeUIRepostFormWarningHost);
+#endif
+ }
+};
+
+base::LazyInstance<ChromeURLContentSecurityPolicyExceptionSet>
+ g_ChromeURLContentSecurityPolicyExceptions(base::LINKER_INITIALIZED);
Evan Stade 2011/10/04 02:28:55 wrong var name style (should be c style)
+
// Parse a URL into the components used to resolve its request. |source_name|
// is the hostname and |path| is the remaining portion of the URL.
void URLToRequest(const GURL& url, std::string* source_name,
@@ -155,6 +209,10 @@
// status code of 200. Without this they return a 0, which makes the status
// indistiguishable from other error types. Instant relies on getting a 200.
info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK");
+ ChromeURLContentSecurityPolicyExceptionSet* exceptions =
+ g_ChromeURLContentSecurityPolicyExceptions.Pointer();
+ if (exceptions->find(request_->url().host()) == exceptions->end())
+ info->headers->AddHeader(kChromeURLContentSecurityPolicyHeader);
}
void URLRequestChromeJob::DataAvailable(RefCountedMemory* bytes) {
« no previous file with comments | « chrome/browser/resources/workers/index.html ('k') | chrome/test/functional/special_tabs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698