| 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 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/common/extensions/extension_file_util.h" | 24 #include "chrome/common/extensions/extension_file_util.h" |
| 25 #include "chrome/common/extensions/extension_resource.h" | 25 #include "chrome/common/extensions/extension_resource.h" |
| 26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 27 #include "content/public/browser/resource_request_info.h" | 27 #include "content/public/browser/resource_request_info.h" |
| 28 #include "googleurl/src/url_util.h" | 28 #include "googleurl/src/url_util.h" |
| 29 #include "grit/component_extension_resources_map.h" | 29 #include "grit/component_extension_resources_map.h" |
| 30 #include "net/base/mime_util.h" | 30 #include "net/base/mime_util.h" |
| 31 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 32 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
| 33 #include "net/http/http_response_info.h" | 33 #include "net/http/http_response_info.h" |
| 34 #include "net/url_request/url_request_context.h" |
| 34 #include "net/url_request/url_request_error_job.h" | 35 #include "net/url_request/url_request_error_job.h" |
| 35 #include "net/url_request/url_request_file_job.h" | 36 #include "net/url_request/url_request_file_job.h" |
| 36 #include "net/url_request/url_request_simple_job.h" | 37 #include "net/url_request/url_request_simple_job.h" |
| 37 #include "ui/base/layout.h" | 38 #include "ui/base/layout.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| 39 | 40 |
| 40 using content::ResourceRequestInfo; | 41 using content::ResourceRequestInfo; |
| 41 using extensions::Extension; | 42 using extensions::Extension; |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 *file_path = resource.GetFilePath(); | 189 *file_path = resource.GetFilePath(); |
| 189 } | 190 } |
| 190 | 191 |
| 191 class URLRequestExtensionJob : public net::URLRequestFileJob { | 192 class URLRequestExtensionJob : public net::URLRequestFileJob { |
| 192 public: | 193 public: |
| 193 URLRequestExtensionJob(net::URLRequest* request, | 194 URLRequestExtensionJob(net::URLRequest* request, |
| 194 const std::string& extension_id, | 195 const std::string& extension_id, |
| 195 const FilePath& directory_path, | 196 const FilePath& directory_path, |
| 196 const std::string& content_security_policy, | 197 const std::string& content_security_policy, |
| 197 bool send_cors_header) | 198 bool send_cors_header) |
| 198 : net::URLRequestFileJob(request, FilePath()), | 199 : net::URLRequestFileJob(request, |
| 200 FilePath(), |
| 201 request->context()->network_delegate()), |
| 199 // TODO(tc): Move all of these files into resources.pak so we don't break | 202 // TODO(tc): Move all of these files into resources.pak so we don't break |
| 200 // when updating on Linux. | 203 // when updating on Linux. |
| 201 resource_(extension_id, directory_path, | 204 resource_(extension_id, directory_path, |
| 202 extension_file_util::ExtensionURLToRelativeFilePath( | 205 extension_file_util::ExtensionURLToRelativeFilePath( |
| 203 request->url())), | 206 request->url())), |
| 204 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 207 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 205 response_info_.headers = BuildHttpHeaders(content_security_policy, | 208 response_info_.headers = BuildHttpHeaders(content_security_policy, |
| 206 send_cors_header); | 209 send_cors_header); |
| 207 } | 210 } |
| 208 | 211 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 content_security_policy, send_cors_header); | 393 content_security_policy, send_cors_header); |
| 391 } | 394 } |
| 392 | 395 |
| 393 } // namespace | 396 } // namespace |
| 394 | 397 |
| 395 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 398 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| 396 bool is_incognito, | 399 bool is_incognito, |
| 397 ExtensionInfoMap* extension_info_map) { | 400 ExtensionInfoMap* extension_info_map) { |
| 398 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 401 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
| 399 } | 402 } |
| OLD | NEW |