| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_protocols.h" | 5 #include "extensions/browser/extension_protocols.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 21 #include "base/metrics/sparse_histogram.h" | 21 #include "base/metrics/sparse_histogram.h" |
| 22 #include "base/profiler/scoped_tracker.h" | |
| 23 #include "base/sha1.h" | 22 #include "base/sha1.h" |
| 24 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 25 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 26 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/threading/sequenced_worker_pool.h" | 27 #include "base/threading/sequenced_worker_pool.h" |
| 29 #include "base/threading/thread_restrictions.h" | 28 #include "base/threading/thread_restrictions.h" |
| 30 #include "base/timer/elapsed_timer.h" | 29 #include "base/timer/elapsed_timer.h" |
| 31 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 32 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 response_info_.headers = BuildHttpHeaders(content_security_policy, | 79 response_info_.headers = BuildHttpHeaders(content_security_policy, |
| 81 send_cors_headers, | 80 send_cors_headers, |
| 82 base::Time()); | 81 base::Time()); |
| 83 } | 82 } |
| 84 | 83 |
| 85 // Overridden from URLRequestSimpleJob: | 84 // Overridden from URLRequestSimpleJob: |
| 86 int GetData(std::string* mime_type, | 85 int GetData(std::string* mime_type, |
| 87 std::string* charset, | 86 std::string* charset, |
| 88 std::string* data, | 87 std::string* data, |
| 89 const net::CompletionCallback& callback) const override { | 88 const net::CompletionCallback& callback) const override { |
| 90 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. | |
| 91 tracked_objects::ScopedTracker tracking_profile( | |
| 92 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 93 "422489 GeneratedBackgroundPageJob::GetData")); | |
| 94 | |
| 95 *mime_type = "text/html"; | 89 *mime_type = "text/html"; |
| 96 *charset = "utf-8"; | 90 *charset = "utf-8"; |
| 97 | 91 |
| 98 *data = "<!DOCTYPE html>\n<body>\n"; | 92 *data = "<!DOCTYPE html>\n<body>\n"; |
| 99 const std::vector<std::string>& background_scripts = | 93 const std::vector<std::string>& background_scripts = |
| 100 extensions::BackgroundInfo::GetBackgroundScripts(extension_.get()); | 94 extensions::BackgroundInfo::GetBackgroundScripts(extension_.get()); |
| 101 for (size_t i = 0; i < background_scripts.size(); ++i) { | 95 for (size_t i = 0; i < background_scripts.size(); ++i) { |
| 102 *data += "<script src=\""; | 96 *data += "<script src=\""; |
| 103 *data += background_scripts[i]; | 97 *data += background_scripts[i]; |
| 104 *data += "\"></script>\n"; | 98 *data += "\"></script>\n"; |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 return new net::HttpResponseHeaders(raw_headers); | 553 return new net::HttpResponseHeaders(raw_headers); |
| 560 } | 554 } |
| 561 | 555 |
| 562 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 556 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| 563 bool is_incognito, | 557 bool is_incognito, |
| 564 extensions::InfoMap* extension_info_map) { | 558 extensions::InfoMap* extension_info_map) { |
| 565 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 559 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
| 566 } | 560 } |
| 567 | 561 |
| 568 } // namespace extensions | 562 } // namespace extensions |
| OLD | NEW |