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/extension_warning_set.h" | 17 #include "chrome/browser/extensions/extension_warning_set.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/browser/renderer_host/web_cache_manager.h" | 19 #include "chrome/browser/renderer_host/web_cache_manager.h" |
20 #include "chrome/common/url_constants.h" | |
21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
23 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
24 #include "extensions/browser/runtime_data.h" | 23 #include "extensions/browser/runtime_data.h" |
25 #include "net/base/net_log.h" | 24 #include "net/base/net_log.h" |
26 #include "net/cookies/cookie_util.h" | 25 #include "net/cookies/cookie_util.h" |
27 #include "net/cookies/parsed_cookie.h" | 26 #include "net/cookies/parsed_cookie.h" |
28 #include "net/http/http_util.h" | 27 #include "net/http/http_util.h" |
29 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
| 29 #include "url/url_constants.h" |
30 | 30 |
31 // TODO(battre): move all static functions into an anonymous namespace at the | 31 // TODO(battre): move all static functions into an anonymous namespace at the |
32 // top of this file. | 32 // top of this file. |
33 | 33 |
34 using base::Time; | 34 using base::Time; |
35 using extensions::ExtensionWarning; | 35 using extensions::ExtensionWarning; |
36 | 36 |
37 namespace extension_web_request_api_helpers { | 37 namespace extension_web_request_api_helpers { |
38 | 38 |
39 namespace { | 39 namespace { |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 bool consider_only_cancel_scheme_urls) { | 420 bool consider_only_cancel_scheme_urls) { |
421 bool redirected = false; | 421 bool redirected = false; |
422 | 422 |
423 // Extension that determines the |new_url|. | 423 // Extension that determines the |new_url|. |
424 std::string winning_extension_id; | 424 std::string winning_extension_id; |
425 EventResponseDeltas::const_iterator delta; | 425 EventResponseDeltas::const_iterator delta; |
426 for (delta = deltas.begin(); delta != deltas.end(); ++delta) { | 426 for (delta = deltas.begin(); delta != deltas.end(); ++delta) { |
427 if ((*delta)->new_url.is_empty()) | 427 if ((*delta)->new_url.is_empty()) |
428 continue; | 428 continue; |
429 if (consider_only_cancel_scheme_urls && | 429 if (consider_only_cancel_scheme_urls && |
430 !(*delta)->new_url.SchemeIs(content::kDataScheme) && | 430 !(*delta)->new_url.SchemeIs(url::kDataScheme) && |
431 (*delta)->new_url.spec() != "about:blank") { | 431 (*delta)->new_url.spec() != "about:blank") { |
432 continue; | 432 continue; |
433 } | 433 } |
434 | 434 |
435 if (!redirected || *new_url == (*delta)->new_url) { | 435 if (!redirected || *new_url == (*delta)->new_url) { |
436 *new_url = (*delta)->new_url; | 436 *new_url = (*delta)->new_url; |
437 winning_extension_id = (*delta)->extension_id; | 437 winning_extension_id = (*delta)->extension_id; |
438 redirected = true; | 438 redirected = true; |
439 net_log->AddEvent( | 439 net_log->AddEvent( |
440 net::NetLog::TYPE_CHROME_EXTENSION_REDIRECTED_REQUEST, | 440 net::NetLog::TYPE_CHROME_EXTENSION_REDIRECTED_REQUEST, |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 return net::HttpUtil::IsToken(name); | 1314 return net::HttpUtil::IsToken(name); |
1315 } | 1315 } |
1316 | 1316 |
1317 bool IsValidHeaderValue(const std::string& value) { | 1317 bool IsValidHeaderValue(const std::string& value) { |
1318 // Just a sanity check: disallow NUL and CRLF. | 1318 // Just a sanity check: disallow NUL and CRLF. |
1319 return value.find('\0') == std::string::npos && | 1319 return value.find('\0') == std::string::npos && |
1320 value.find("\r\n") == std::string::npos; | 1320 value.find("\r\n") == std::string::npos; |
1321 } | 1321 } |
1322 | 1322 |
1323 } // namespace extension_web_request_api_helpers | 1323 } // namespace extension_web_request_api_helpers |
OLD | NEW |