| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/extension_protocols.h" | 5 #include "chrome/browser/extensions/extension_protocols.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 | 137 |
| 138 return true; | 138 return true; |
| 139 } | 139 } |
| 140 | 140 |
| 141 virtual void GetResponseInfo(net::HttpResponseInfo* info) { | 141 virtual void GetResponseInfo(net::HttpResponseInfo* info) { |
| 142 *info = response_info_; | 142 *info = response_info_; |
| 143 } | 143 } |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 virtual ~GeneratedBackgroundPageJob() {} |
| 147 |
| 146 scoped_refptr<const Extension> extension_; | 148 scoped_refptr<const Extension> extension_; |
| 147 net::HttpResponseInfo response_info_; | 149 net::HttpResponseInfo response_info_; |
| 148 }; | 150 }; |
| 149 | 151 |
| 150 class URLRequestExtensionJob : public net::URLRequestFileJob { | 152 class URLRequestExtensionJob : public net::URLRequestFileJob { |
| 151 public: | 153 public: |
| 152 URLRequestExtensionJob(net::URLRequest* request, | 154 URLRequestExtensionJob(net::URLRequest* request, |
| 153 const FilePath& filename, | 155 const FilePath& filename, |
| 154 const std::string& content_security_policy, | 156 const std::string& content_security_policy, |
| 155 bool send_cors_header) | 157 bool send_cors_header) |
| 156 : net::URLRequestFileJob(request, filename) { | 158 : net::URLRequestFileJob(request, filename) { |
| 157 response_info_.headers = BuildHttpHeaders(content_security_policy, | 159 response_info_.headers = BuildHttpHeaders(content_security_policy, |
| 158 send_cors_header); | 160 send_cors_header); |
| 159 } | 161 } |
| 160 | 162 |
| 161 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE { | 163 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE { |
| 162 *info = response_info_; | 164 *info = response_info_; |
| 163 } | 165 } |
| 164 | 166 |
| 167 private: |
| 168 virtual ~URLRequestExtensionJob() {} |
| 169 |
| 165 net::HttpResponseInfo response_info_; | 170 net::HttpResponseInfo response_info_; |
| 166 }; | 171 }; |
| 167 | 172 |
| 168 bool ExtensionCanLoadInIncognito(const ResourceRequestInfo* info, | 173 bool ExtensionCanLoadInIncognito(const ResourceRequestInfo* info, |
| 169 const std::string& extension_id, | 174 const std::string& extension_id, |
| 170 ExtensionInfoMap* extension_info_map) { | 175 ExtensionInfoMap* extension_info_map) { |
| 171 if (!extension_info_map->IsIncognitoEnabled(extension_id)) | 176 if (!extension_info_map->IsIncognitoEnabled(extension_id)) |
| 172 return false; | 177 return false; |
| 173 | 178 |
| 174 // Only allow incognito toplevel navigations to extension resources in | 179 // Only allow incognito toplevel navigations to extension resources in |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 content_security_policy, send_cors_header); | 327 content_security_policy, send_cors_header); |
| 323 } | 328 } |
| 324 | 329 |
| 325 } // namespace | 330 } // namespace |
| 326 | 331 |
| 327 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 332 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| 328 bool is_incognito, | 333 bool is_incognito, |
| 329 ExtensionInfoMap* extension_info_map) { | 334 ExtensionInfoMap* extension_info_map) { |
| 330 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 335 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
| 331 } | 336 } |
| OLD | NEW |