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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
18 #include "base/threading/worker_pool.h" | 18 #include "base/threading/worker_pool.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "chrome/browser/extensions/extension_info_map.h" | 20 #include "chrome/browser/extensions/extension_info_map.h" |
21 #include "chrome/browser/extensions/image_loader.h" | 21 #include "chrome/browser/extensions/image_loader.h" |
22 #include "chrome/browser/net/chrome_url_request_context.h" | 22 #include "chrome/browser/net/chrome_url_request_context.h" |
23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 24 #include "chrome/common/extensions/background_info.h" |
24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
25 #include "chrome/common/extensions/extension_file_util.h" | 26 #include "chrome/common/extensions/extension_file_util.h" |
26 #include "chrome/common/extensions/extension_resource.h" | 27 #include "chrome/common/extensions/extension_resource.h" |
27 #include "chrome/common/extensions/web_accessible_resources_handler.h" | 28 #include "chrome/common/extensions/web_accessible_resources_handler.h" |
28 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
29 #include "content/public/browser/resource_request_info.h" | 30 #include "content/public/browser/resource_request_info.h" |
30 #include "extensions/common/constants.h" | 31 #include "extensions/common/constants.h" |
31 #include "googleurl/src/url_util.h" | 32 #include "googleurl/src/url_util.h" |
32 #include "grit/component_extension_resources_map.h" | 33 #include "grit/component_extension_resources_map.h" |
33 #include "net/base/mime_util.h" | 34 #include "net/base/mime_util.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 162 |
162 // Overridden from URLRequestSimpleJob: | 163 // Overridden from URLRequestSimpleJob: |
163 virtual int GetData(std::string* mime_type, | 164 virtual int GetData(std::string* mime_type, |
164 std::string* charset, | 165 std::string* charset, |
165 std::string* data, | 166 std::string* data, |
166 const net::CompletionCallback& callback) const OVERRIDE { | 167 const net::CompletionCallback& callback) const OVERRIDE { |
167 *mime_type = "text/html"; | 168 *mime_type = "text/html"; |
168 *charset = "utf-8"; | 169 *charset = "utf-8"; |
169 | 170 |
170 *data = "<!DOCTYPE html>\n<body>\n"; | 171 *data = "<!DOCTYPE html>\n<body>\n"; |
171 for (size_t i = 0; i < extension_->background_scripts().size(); ++i) { | 172 const std::vector<std::string>& background_scripts = |
| 173 extensions::BackgroundInfo::GetBackgroundScripts(extension_); |
| 174 for (size_t i = 0; i < background_scripts.size(); ++i) { |
172 *data += "<script src=\""; | 175 *data += "<script src=\""; |
173 *data += extension_->background_scripts()[i]; | 176 *data += background_scripts[i]; |
174 *data += "\"></script>\n"; | 177 *data += "\"></script>\n"; |
175 } | 178 } |
176 | 179 |
177 return net::OK; | 180 return net::OK; |
178 } | 181 } |
179 | 182 |
180 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE { | 183 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE { |
181 *info = response_info_; | 184 *info = response_info_; |
182 } | 185 } |
183 | 186 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 send_cors_header); | 406 send_cors_header); |
404 } | 407 } |
405 | 408 |
406 } // namespace | 409 } // namespace |
407 | 410 |
408 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 411 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
409 bool is_incognito, | 412 bool is_incognito, |
410 ExtensionInfoMap* extension_info_map) { | 413 ExtensionInfoMap* extension_info_map) { |
411 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 414 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
412 } | 415 } |
OLD | NEW |