Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 // with the same name that has already been registered. The default is true. | 79 // with the same name that has already been registered. The default is true. |
| 80 // | 80 // |
| 81 // WARNING: this is invoked on the IO thread. | 81 // WARNING: this is invoked on the IO thread. |
| 82 // | 82 // |
| 83 // TODO: nuke this and convert all callers to not replace. | 83 // TODO: nuke this and convert all callers to not replace. |
| 84 virtual bool ShouldReplaceExistingSource() const; | 84 virtual bool ShouldReplaceExistingSource() const; |
| 85 | 85 |
| 86 // Returns true if responses from this URLDataSource can be cached. | 86 // Returns true if responses from this URLDataSource can be cached. |
| 87 virtual bool AllowCaching() const; | 87 virtual bool AllowCaching() const; |
| 88 | 88 |
| 89 // If you are overriding this, then you have a bug. | 89 // If you are overriding the following two methods, then you have a bug. |
| 90 // It is not acceptable to disable content-security-policy on chrome:// pages | 90 // It is not acceptable to disable content-security-policy on chrome:// pages |
| 91 // to permit functionality excluded by CSP, such as inline script. | 91 // to permit functionality excluded by CSP, such as inline script. |
| 92 // Instead, you must go back and change your WebUI page so that it is | 92 // Instead, you must go back and change your WebUI page so that it is |
| 93 // compliant with the policy. This typically involves ensuring that all script | 93 // compliant with the policy. This typically involves ensuring that all script |
| 94 // is delivered through the data manager backend. Talk to tsepez for more | 94 // is delivered through the data manager backend. Do not disable CSP on your |
| 95 // info. | 95 // page without first contacting the chrome security team. |
| 96 virtual bool ShouldAddContentSecurityPolicy() const; | 96 virtual bool ShouldAddContentSecurityPolicy() const; |
| 97 // For pre-exsiting code, enabling CSP with relaxed script-src attributes | |
| 98 // may be marginally better than disabling CSP outright. | |
| 99 // Do not override this method without first contacting the chrome security | |
| 100 // team. | |
| 101 // By default, "script-src chrome://resources 'self' 'unsafe-eval';" is added | |
| 102 // to CSP. Override to change this. | |
| 103 virtual std::string GetContentSecurityPolicyScriptSrc() const; | |
| 97 | 104 |
| 98 // It is OK to override the following two methods to a custom CSP directive | 105 // It is OK to override the following two methods to a custom CSP directive |
|
Tom Sepez
2016/05/25 23:07:03
nit: four methods.
wychen
2016/05/26 17:54:24
Done.
| |
| 99 // thereby slightly reducing the protection applied to the page. | 106 // thereby slightly reducing the protection applied to the page. |
| 100 | 107 |
| 101 // By default, "object-src 'none';" is added to CSP. Override to change this. | 108 // By default, "object-src 'none';" is added to CSP. Override to change this. |
| 102 virtual std::string GetContentSecurityPolicyObjectSrc() const; | 109 virtual std::string GetContentSecurityPolicyObjectSrc() const; |
| 103 // By default, "frame-src 'none';" is added to CSP. Override to change this. | 110 // By default, "frame-src 'none';" is added to CSP. Override to change this. |
| 104 virtual std::string GetContentSecurityPolicyFrameSrc() const; | 111 virtual std::string GetContentSecurityPolicyFrameSrc() const; |
| 112 // By default empty. Override to change this. | |
| 113 virtual std::string GetContentSecurityPolicyStyleSrc() const; | |
| 114 // By default empty. Override to change this. | |
| 115 virtual std::string GetContentSecurityPolicyImgSrc() const; | |
| 105 | 116 |
| 106 // By default, the "X-Frame-Options: DENY" header is sent. To stop this from | 117 // By default, the "X-Frame-Options: DENY" header is sent. To stop this from |
| 107 // happening, return false. It is OK to return false as needed. | 118 // happening, return false. It is OK to return false as needed. |
| 108 virtual bool ShouldDenyXFrameOptions() const; | 119 virtual bool ShouldDenyXFrameOptions() const; |
| 109 | 120 |
| 110 // By default, only chrome: and chrome-devtools: requests are allowed. | 121 // By default, only chrome: and chrome-devtools: requests are allowed. |
| 111 // Override in specific WebUI data sources to enable for additional schemes or | 122 // Override in specific WebUI data sources to enable for additional schemes or |
| 112 // to implement fancier access control. Typically used in concert with | 123 // to implement fancier access control. Typically used in concert with |
| 113 // ContentBrowserClient::GetAdditionalWebUISchemes() to permit additional | 124 // ContentBrowserClient::GetAdditionalWebUISchemes() to permit additional |
| 114 // WebUI scheme support for an embedder. | 125 // WebUI scheme support for an embedder. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 134 // Gives the source an opportunity to rewrite |path| to incorporate extra | 145 // Gives the source an opportunity to rewrite |path| to incorporate extra |
| 135 // information from the URLRequest prior to serving. | 146 // information from the URLRequest prior to serving. |
| 136 virtual void WillServiceRequest( | 147 virtual void WillServiceRequest( |
| 137 const net::URLRequest* request, | 148 const net::URLRequest* request, |
| 138 std::string* path) const {} | 149 std::string* path) const {} |
| 139 }; | 150 }; |
| 140 | 151 |
| 141 } // namespace content | 152 } // namespace content |
| 142 | 153 |
| 143 #endif // CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ | 154 #endif // CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ |
| OLD | NEW |