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/api/web_request/web_request_api_helpers.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 16 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 17 #include "chrome/browser/extensions/api/web_request/web_request_api_constants.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/renderer_host/web_cache_manager.h" | 19 #include "chrome/browser/renderer_host/web_cache_manager.h" |
19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
21 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
22 #include "extensions/browser/runtime_data.h" | 23 #include "extensions/browser/runtime_data.h" |
23 #include "extensions/browser/warning_set.h" | 24 #include "extensions/browser/warning_set.h" |
24 #include "net/base/net_log.h" | 25 #include "net/base/net_log.h" |
25 #include "net/cookies/cookie_util.h" | 26 #include "net/cookies/cookie_util.h" |
26 #include "net/cookies/parsed_cookie.h" | 27 #include "net/cookies/parsed_cookie.h" |
27 #include "net/http/http_util.h" | 28 #include "net/http/http_util.h" |
28 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
29 #include "url/url_constants.h" | 30 #include "url/url_constants.h" |
30 | 31 |
31 // TODO(battre): move all static functions into an anonymous namespace at the | 32 // TODO(battre): move all static functions into an anonymous namespace at the |
32 // top of this file. | 33 // top of this file. |
33 | 34 |
34 using base::Time; | 35 using base::Time; |
35 using net::cookie_util::ParsedRequestCookie; | 36 using net::cookie_util::ParsedRequestCookie; |
36 using net::cookie_util::ParsedRequestCookies; | 37 using net::cookie_util::ParsedRequestCookies; |
37 | 38 |
| 39 namespace keys = extension_web_request_api_constants; |
| 40 |
38 namespace extension_web_request_api_helpers { | 41 namespace extension_web_request_api_helpers { |
39 | 42 |
40 namespace { | 43 namespace { |
41 | 44 |
42 typedef std::vector<linked_ptr<net::ParsedCookie> > ParsedResponseCookies; | 45 typedef std::vector<linked_ptr<net::ParsedCookie> > ParsedResponseCookies; |
43 | 46 |
44 void ClearCacheOnNavigationOnUI() { | 47 void ClearCacheOnNavigationOnUI() { |
45 WebCacheManager::GetInstance()->ClearCacheOnNavigation(); | 48 WebCacheManager::GetInstance()->ClearCacheOnNavigation(); |
46 } | 49 } |
47 | 50 |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 content::BrowserContext* browser_context = profile; | 1175 content::BrowserContext* browser_context = profile; |
1173 for (content::RenderProcessHost::iterator it = | 1176 for (content::RenderProcessHost::iterator it = |
1174 content::RenderProcessHost::AllHostsIterator(); | 1177 content::RenderProcessHost::AllHostsIterator(); |
1175 !it.IsAtEnd(); it.Advance()) { | 1178 !it.IsAtEnd(); it.Advance()) { |
1176 content::RenderProcessHost* host = it.GetCurrentValue(); | 1179 content::RenderProcessHost* host = it.GetCurrentValue(); |
1177 if (host->GetBrowserContext() == browser_context) | 1180 if (host->GetBrowserContext() == browser_context) |
1178 SendExtensionWebRequestStatusToHost(host); | 1181 SendExtensionWebRequestStatusToHost(host); |
1179 } | 1182 } |
1180 } | 1183 } |
1181 | 1184 |
| 1185 // Converts the |name|, |value| pair of a http header to a HttpHeaders |
| 1186 // dictionary. Ownership is passed to the caller. |
| 1187 base::DictionaryValue* ToHeaderDictionary(const std::string& name, |
| 1188 const std::string& value) { |
| 1189 base::DictionaryValue* header = new base::DictionaryValue(); |
| 1190 header->SetString(keys::kHeaderNameKey, name); |
| 1191 if (base::IsStringUTF8(value)) { |
| 1192 header->SetString(keys::kHeaderValueKey, value); |
| 1193 } else { |
| 1194 header->Set(keys::kHeaderBinaryValueKey, |
| 1195 StringToCharList(value)); |
| 1196 } |
| 1197 return header; |
| 1198 } |
| 1199 |
1182 } // namespace extension_web_request_api_helpers | 1200 } // namespace extension_web_request_api_helpers |
OLD | NEW |