Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api_helpers.cc

Issue 568583002: Introduce WebRequestEventRouterDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hide tab_id and window_id from extensions. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/api/web_request/web_request_api.h" 15 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
16 #include "components/web_cache/browser/web_cache_manager.h" 16 #include "components/web_cache/browser/web_cache_manager.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "extensions/browser/api/web_request/web_request_api_constants.h"
19 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
20 #include "extensions/browser/runtime_data.h" 21 #include "extensions/browser/runtime_data.h"
21 #include "extensions/browser/warning_set.h" 22 #include "extensions/browser/warning_set.h"
22 #include "net/base/net_log.h" 23 #include "net/base/net_log.h"
23 #include "net/cookies/cookie_util.h" 24 #include "net/cookies/cookie_util.h"
24 #include "net/cookies/parsed_cookie.h" 25 #include "net/cookies/parsed_cookie.h"
25 #include "net/http/http_util.h" 26 #include "net/http/http_util.h"
26 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
27 #include "url/url_constants.h" 28 #include "url/url_constants.h"
28 29
29 // TODO(battre): move all static functions into an anonymous namespace at the 30 // TODO(battre): move all static functions into an anonymous namespace at the
30 // top of this file. 31 // top of this file.
31 32
32 using base::Time; 33 using base::Time;
33 using net::cookie_util::ParsedRequestCookie; 34 using net::cookie_util::ParsedRequestCookie;
34 using net::cookie_util::ParsedRequestCookies; 35 using net::cookie_util::ParsedRequestCookies;
35 36
37 namespace keys = extension_web_request_api_constants;
38
36 namespace extension_web_request_api_helpers { 39 namespace extension_web_request_api_helpers {
37 40
38 namespace { 41 namespace {
39 42
40 typedef std::vector<linked_ptr<net::ParsedCookie> > ParsedResponseCookies; 43 typedef std::vector<linked_ptr<net::ParsedCookie> > ParsedResponseCookies;
41 44
42 void ClearCacheOnNavigationOnUI() { 45 void ClearCacheOnNavigationOnUI() {
43 web_cache::WebCacheManager::GetInstance()->ClearCacheOnNavigation(); 46 web_cache::WebCacheManager::GetInstance()->ClearCacheOnNavigation();
44 } 47 }
45 48
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 1174
1172 for (content::RenderProcessHost::iterator it = 1175 for (content::RenderProcessHost::iterator it =
1173 content::RenderProcessHost::AllHostsIterator(); 1176 content::RenderProcessHost::AllHostsIterator();
1174 !it.IsAtEnd(); it.Advance()) { 1177 !it.IsAtEnd(); it.Advance()) {
1175 content::RenderProcessHost* host = it.GetCurrentValue(); 1178 content::RenderProcessHost* host = it.GetCurrentValue();
1176 if (host->GetBrowserContext() == browser_context) 1179 if (host->GetBrowserContext() == browser_context)
1177 SendExtensionWebRequestStatusToHost(host); 1180 SendExtensionWebRequestStatusToHost(host);
1178 } 1181 }
1179 } 1182 }
1180 1183
1184 // Converts the |name|, |value| pair of a http header to a HttpHeaders
1185 // dictionary. Ownership is passed to the caller.
1186 base::DictionaryValue* ToHeaderDictionary(const std::string& name,
1187 const std::string& value) {
1188 base::DictionaryValue* header = new base::DictionaryValue();
1189 header->SetString(keys::kHeaderNameKey, name);
1190 if (base::IsStringUTF8(value)) {
1191 header->SetString(keys::kHeaderValueKey, value);
1192 } else {
1193 header->Set(keys::kHeaderBinaryValueKey,
1194 StringToCharList(value));
1195 }
1196 return header;
1197 }
1198
1181 } // namespace extension_web_request_api_helpers 1199 } // namespace extension_web_request_api_helpers
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698