| 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" | |
| 16 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 15 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | |
| 18 #include "components/web_cache/browser/web_cache_manager.h" | 16 #include "components/web_cache/browser/web_cache_manager.h" |
| 19 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
| 21 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/browser/runtime_data.h" | 20 #include "extensions/browser/runtime_data.h" |
| 23 #include "extensions/browser/warning_set.h" | 21 #include "extensions/browser/warning_set.h" |
| 24 #include "net/base/net_log.h" | 22 #include "net/base/net_log.h" |
| 25 #include "net/cookies/cookie_util.h" | 23 #include "net/cookies/cookie_util.h" |
| 26 #include "net/cookies/parsed_cookie.h" | 24 #include "net/cookies/parsed_cookie.h" |
| 27 #include "net/http/http_util.h" | 25 #include "net/http/http_util.h" |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 void ClearCacheOnNavigation() { | 1147 void ClearCacheOnNavigation() { |
| 1150 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | 1148 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 1151 ClearCacheOnNavigationOnUI(); | 1149 ClearCacheOnNavigationOnUI(); |
| 1152 } else { | 1150 } else { |
| 1153 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 1151 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 1154 base::Bind(&ClearCacheOnNavigationOnUI)); | 1152 base::Bind(&ClearCacheOnNavigationOnUI)); |
| 1155 } | 1153 } |
| 1156 } | 1154 } |
| 1157 | 1155 |
| 1158 void NotifyWebRequestAPIUsed( | 1156 void NotifyWebRequestAPIUsed( |
| 1159 void* profile_id, | 1157 void* browser_context_id, |
| 1160 scoped_refptr<const extensions::Extension> extension) { | 1158 scoped_refptr<const extensions::Extension> extension) { |
| 1161 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 1159 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 1162 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 1160 content::BrowserContext* browser_context = |
| 1163 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 1161 reinterpret_cast<content::BrowserContext*>(browser_context_id); |
| 1162 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext( |
| 1163 browser_context)) |
| 1164 return; | 1164 return; |
| 1165 | 1165 |
| 1166 extensions::RuntimeData* runtime_data = | 1166 extensions::RuntimeData* runtime_data = |
| 1167 extensions::ExtensionSystem::Get(profile)->runtime_data(); | 1167 extensions::ExtensionSystem::Get(browser_context)->runtime_data(); |
| 1168 if (runtime_data->HasUsedWebRequest(extension.get())) | 1168 if (runtime_data->HasUsedWebRequest(extension.get())) |
| 1169 return; | 1169 return; |
| 1170 runtime_data->SetHasUsedWebRequest(extension.get(), true); | 1170 runtime_data->SetHasUsedWebRequest(extension.get(), true); |
| 1171 | 1171 |
| 1172 content::BrowserContext* browser_context = profile; | |
| 1173 for (content::RenderProcessHost::iterator it = | 1172 for (content::RenderProcessHost::iterator it = |
| 1174 content::RenderProcessHost::AllHostsIterator(); | 1173 content::RenderProcessHost::AllHostsIterator(); |
| 1175 !it.IsAtEnd(); it.Advance()) { | 1174 !it.IsAtEnd(); it.Advance()) { |
| 1176 content::RenderProcessHost* host = it.GetCurrentValue(); | 1175 content::RenderProcessHost* host = it.GetCurrentValue(); |
| 1177 if (host->GetBrowserContext() == browser_context) | 1176 if (host->GetBrowserContext() == browser_context) |
| 1178 SendExtensionWebRequestStatusToHost(host); | 1177 SendExtensionWebRequestStatusToHost(host); |
| 1179 } | 1178 } |
| 1180 } | 1179 } |
| 1181 | 1180 |
| 1182 } // namespace extension_web_request_api_helpers | 1181 } // namespace extension_web_request_api_helpers |
| OLD | NEW |