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 "extensions/browser/api/web_request/web_request_api_helpers.h" | 5 #include "extensions/browser/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 "components/web_cache/browser/web_cache_manager.h" | 15 #include "components/web_cache/browser/web_cache_manager.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
18 #include "extensions/browser/api/web_request/web_request_api_constants.h" | |
18 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
19 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
20 #include "extensions/browser/extensions_browser_client.h" | 21 #include "extensions/browser/extensions_browser_client.h" |
21 #include "extensions/browser/runtime_data.h" | 22 #include "extensions/browser/runtime_data.h" |
22 #include "extensions/browser/warning_set.h" | 23 #include "extensions/browser/warning_set.h" |
23 #include "extensions/common/extension_messages.h" | 24 #include "extensions/common/extension_messages.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 web_cache::WebCacheManager::GetInstance()->ClearCacheOnNavigation(); | 48 web_cache::WebCacheManager::GetInstance()->ClearCacheOnNavigation(); |
46 } | 49 } |
47 | 50 |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1192 extensions::ExtensionSystem::Get(browser_context)->runtime_data(); | 1195 extensions::ExtensionSystem::Get(browser_context)->runtime_data(); |
1193 for (extensions::ExtensionSet::const_iterator it = extensions.begin(); | 1196 for (extensions::ExtensionSet::const_iterator it = extensions.begin(); |
1194 !webrequest_used && it != extensions.end(); | 1197 !webrequest_used && it != extensions.end(); |
1195 ++it) { | 1198 ++it) { |
1196 webrequest_used |= runtime_data->HasUsedWebRequest(it->get()); | 1199 webrequest_used |= runtime_data->HasUsedWebRequest(it->get()); |
1197 } | 1200 } |
1198 | 1201 |
1199 host->Send(new ExtensionMsg_UsingWebRequestAPI(webrequest_used)); | 1202 host->Send(new ExtensionMsg_UsingWebRequestAPI(webrequest_used)); |
1200 } | 1203 } |
1201 | 1204 |
1205 // Converts the |name|, |value| pair of a http header to a HttpHeaders | |
1206 // dictionary. Ownership is passed to the caller. | |
1207 base::DictionaryValue* ToHeaderDictionary(const std::string& name, | |
Ken Rockot(use gerrit already)
2014/09/19 20:52:27
How about CreateHeaderDictionary or MakeHeaderDict
Xi Han
2014/09/19 22:05:55
Change to CreateHeaderDictionary.
| |
1208 const std::string& value) { | |
1209 base::DictionaryValue* header = new base::DictionaryValue(); | |
1210 header->SetString(keys::kHeaderNameKey, name); | |
1211 if (base::IsStringUTF8(value)) { | |
1212 header->SetString(keys::kHeaderValueKey, value); | |
1213 } else { | |
1214 header->Set(keys::kHeaderBinaryValueKey, | |
1215 StringToCharList(value)); | |
1216 } | |
1217 return header; | |
1218 } | |
1219 | |
1202 } // namespace extension_web_request_api_helpers | 1220 } // namespace extension_web_request_api_helpers |
OLD | NEW |