| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 12 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 13 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "content/public/browser/browser_thread.h" |
| 14 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
| 15 #include "net/cookies/parsed_cookie.h" | 17 #include "net/cookies/parsed_cookie.h" |
| 16 #include "net/http/http_util.h" | 18 #include "net/http/http_util.h" |
| 17 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
| 18 | 20 |
| 19 namespace extension_web_request_api_helpers { | 21 namespace extension_web_request_api_helpers { |
| 20 | 22 |
| 21 namespace { | 23 namespace { |
| 22 | 24 |
| 23 // A ParsedRequestCookie consists of the key and value of the cookie. | 25 // A ParsedRequestCookie consists of the key and value of the cookie. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 51 // (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949). Once we use a version | 53 // (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949). Once we use a version |
| 52 // of gcc with this bug fixed, or the array is changed so this duplicate | 54 // of gcc with this bug fixed, or the array is changed so this duplicate |
| 53 // entry is no longer required, this should be removed. | 55 // entry is no longer required, this should be removed. |
| 54 ResourceType::LAST_TYPE, | 56 ResourceType::LAST_TYPE, |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 COMPILE_ASSERT( | 59 COMPILE_ASSERT( |
| 58 arraysize(kResourceTypeStrings) == arraysize(kResourceTypeValues), | 60 arraysize(kResourceTypeStrings) == arraysize(kResourceTypeValues), |
| 59 keep_resource_types_in_sync); | 61 keep_resource_types_in_sync); |
| 60 | 62 |
| 63 void ClearCacheOnNavigationOnUI() { |
| 64 WebCacheManager::GetInstance()->ClearCacheOnNavigation(); |
| 65 } |
| 66 |
| 61 } // namespace | 67 } // namespace |
| 62 | 68 |
| 63 RequestCookie::RequestCookie() {} | 69 RequestCookie::RequestCookie() {} |
| 64 RequestCookie::~RequestCookie() {} | 70 RequestCookie::~RequestCookie() {} |
| 65 | 71 |
| 66 ResponseCookie::ResponseCookie() {} | 72 ResponseCookie::ResponseCookie() {} |
| 67 ResponseCookie::~ResponseCookie() {} | 73 ResponseCookie::~ResponseCookie() {} |
| 68 | 74 |
| 69 RequestCookieModification::RequestCookieModification() {} | 75 RequestCookieModification::RequestCookieModification() {} |
| 70 RequestCookieModification::~RequestCookieModification() {} | 76 RequestCookieModification::~RequestCookieModification() {} |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 } | 1016 } |
| 1011 | 1017 |
| 1012 bool CanExtensionAccessURL(const extensions::Extension* extension, | 1018 bool CanExtensionAccessURL(const extensions::Extension* extension, |
| 1013 const GURL& url) { | 1019 const GURL& url) { |
| 1014 // about: URLs are not covered in host permissions, but are allowed anyway. | 1020 // about: URLs are not covered in host permissions, but are allowed anyway. |
| 1015 return (url.SchemeIs(chrome::kAboutScheme) || | 1021 return (url.SchemeIs(chrome::kAboutScheme) || |
| 1016 extension->HasHostPermission(url) || | 1022 extension->HasHostPermission(url) || |
| 1017 url.GetOrigin() == extension->url()); | 1023 url.GetOrigin() == extension->url()); |
| 1018 } | 1024 } |
| 1019 | 1025 |
| 1026 void ClearCacheOnNavigation() { |
| 1027 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 1028 ClearCacheOnNavigationOnUI(); |
| 1029 } else { |
| 1030 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 1031 base::Bind(&ClearCacheOnNavigationOnUI)); |
| 1032 } |
| 1033 } |
| 1034 |
| 1020 } // namespace extension_web_request_api_helpers | 1035 } // namespace extension_web_request_api_helpers |
| OLD | NEW |