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

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

Issue 2442213003: Remove dead extensions tracking code. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 "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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 1225
1226 void ClearCacheOnNavigation() { 1226 void ClearCacheOnNavigation() {
1227 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { 1227 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
1228 ClearCacheOnNavigationOnUI(); 1228 ClearCacheOnNavigationOnUI();
1229 } else { 1229 } else {
1230 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 1230 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
1231 base::Bind(&ClearCacheOnNavigationOnUI)); 1231 base::Bind(&ClearCacheOnNavigationOnUI));
1232 } 1232 }
1233 } 1233 }
1234 1234
1235 void NotifyWebRequestAPIUsed(void* browser_context_id,
1236 const std::string& extension_id) {
1237 DCHECK(!extension_id.empty());
1238 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
1239 content::BrowserContext* browser_context =
1240 reinterpret_cast<content::BrowserContext*>(browser_context_id);
1241 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(
1242 browser_context))
1243 return;
1244
1245 extensions::RuntimeData* runtime_data =
1246 extensions::ExtensionSystem::Get(browser_context)->runtime_data();
1247 if (runtime_data->HasUsedWebRequest(extension_id))
1248 return;
1249 runtime_data->SetHasUsedWebRequest(extension_id, true);
1250
1251 for (content::RenderProcessHost::iterator it =
1252 content::RenderProcessHost::AllHostsIterator();
1253 !it.IsAtEnd(); it.Advance()) {
1254 content::RenderProcessHost* host = it.GetCurrentValue();
1255 if (host->GetBrowserContext() == browser_context)
1256 SendExtensionWebRequestStatusToHost(host);
1257 }
1258 }
1259
1260 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host) {
1261 content::BrowserContext* browser_context = host->GetBrowserContext();
1262 if (!browser_context)
1263 return;
1264
1265 bool webrequest_used = false;
1266 const extensions::ExtensionSet& extensions =
1267 extensions::ExtensionRegistry::Get(browser_context)->enabled_extensions();
1268 extensions::RuntimeData* runtime_data =
1269 extensions::ExtensionSystem::Get(browser_context)->runtime_data();
1270 for (extensions::ExtensionSet::const_iterator it = extensions.begin();
1271 !webrequest_used && it != extensions.end();
1272 ++it) {
1273 webrequest_used |= runtime_data->HasUsedWebRequest((*it)->id());
1274 }
1275
1276 host->Send(new ExtensionMsg_UsingWebRequestAPI(webrequest_used));
1277 }
1278
1279 // Converts the |name|, |value| pair of a http header to a HttpHeaders 1235 // Converts the |name|, |value| pair of a http header to a HttpHeaders
1280 // dictionary. 1236 // dictionary.
1281 std::unique_ptr<base::DictionaryValue> CreateHeaderDictionary( 1237 std::unique_ptr<base::DictionaryValue> CreateHeaderDictionary(
1282 const std::string& name, 1238 const std::string& name,
1283 const std::string& value) { 1239 const std::string& value) {
1284 std::unique_ptr<base::DictionaryValue> header(new base::DictionaryValue()); 1240 std::unique_ptr<base::DictionaryValue> header(new base::DictionaryValue());
1285 header->SetString(keys::kHeaderNameKey, name); 1241 header->SetString(keys::kHeaderNameKey, name);
1286 if (base::IsStringUTF8(value)) { 1242 if (base::IsStringUTF8(value)) {
1287 header->SetString(keys::kHeaderValueKey, value); 1243 header->SetString(keys::kHeaderValueKey, value);
1288 } else { 1244 } else {
(...skipping 28 matching lines...) Expand all
1317 for (size_t i = 0; i < kResourceTypeStringsLength; ++i) { 1273 for (size_t i = 0; i < kResourceTypeStringsLength; ++i) {
1318 if (type_str == kResourceTypeStrings[i]) { 1274 if (type_str == kResourceTypeStrings[i]) {
1319 found = true; 1275 found = true;
1320 types->push_back(kResourceTypeValues[i]); 1276 types->push_back(kResourceTypeValues[i]);
1321 } 1277 }
1322 } 1278 }
1323 return found; 1279 return found;
1324 } 1280 }
1325 1281
1326 } // namespace extension_web_request_api_helpers 1282 } // namespace extension_web_request_api_helpers
OLDNEW
« no previous file with comments | « extensions/browser/api/web_request/web_request_api_helpers.h ('k') | extensions/browser/runtime_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698