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 "chrome/browser/extensions/chrome_url_request_util.h" | 5 #include "chrome/browser/extensions/chrome_url_request_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/profiler/scoped_profile.h" | 12 #include "base/profiler/scoped_tracker.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/task_runner_util.h" | 16 #include "base/task_runner_util.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" | 18 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/resource_request_info.h" | 20 #include "content/public/browser/resource_request_info.h" |
21 #include "extensions/browser/component_extension_resource_manager.h" | 21 #include "extensions/browser/component_extension_resource_manager.h" |
22 #include "extensions/browser/extension_protocols.h" | 22 #include "extensions/browser/extension_protocols.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Leave cache headers out of resource bundle requests. | 56 // Leave cache headers out of resource bundle requests. |
57 response_info_.headers = extensions::BuildHttpHeaders( | 57 response_info_.headers = extensions::BuildHttpHeaders( |
58 content_security_policy, send_cors_header, base::Time()); | 58 content_security_policy, send_cors_header, base::Time()); |
59 } | 59 } |
60 | 60 |
61 // Overridden from URLRequestSimpleJob: | 61 // Overridden from URLRequestSimpleJob: |
62 int GetData(std::string* mime_type, | 62 int GetData(std::string* mime_type, |
63 std::string* charset, | 63 std::string* charset, |
64 std::string* data, | 64 std::string* data, |
65 const net::CompletionCallback& callback) const override { | 65 const net::CompletionCallback& callback) const override { |
66 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422489 is fixed. | 66 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. |
67 tracked_objects::ScopedProfile tracking_profile( | 67 tracked_objects::ScopedTracker tracking_profile( |
68 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 68 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
69 "422489 URLRequestResourceBundleJob::GetData")); | 69 "422489 URLRequestResourceBundleJob::GetData")); |
70 | 70 |
71 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 71 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
72 *data = rb.GetRawDataResource(resource_id_).as_string(); | 72 *data = rb.GetRawDataResource(resource_id_).as_string(); |
73 | 73 |
74 // Add the Content-Length header now that we know the resource length. | 74 // Add the Content-Length header now that we know the resource length. |
75 response_info_.headers->AddHeader( | 75 response_info_.headers->AddHeader( |
76 base::StringPrintf("%s: %s", | 76 base::StringPrintf("%s: %s", |
77 net::HttpRequestHeaders::kContentLength, | 77 net::HttpRequestHeaders::kContentLength, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 resource_id, | 189 resource_id, |
190 content_security_policy, | 190 content_security_policy, |
191 send_cors_header); | 191 send_cors_header); |
192 } | 192 } |
193 } | 193 } |
194 return NULL; | 194 return NULL; |
195 } | 195 } |
196 | 196 |
197 } // namespace chrome_url_request_util | 197 } // namespace chrome_url_request_util |
198 } // namespace extensions | 198 } // namespace extensions |
OLD | NEW |