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

Side by Side Diff: chrome/browser/extensions/extension_webrequest_api.cc

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_webrequest_api.h" 5 #include "chrome/browser/extensions/extension_webrequest_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 void NotifyWebRequestAPIUsed(void* profile_id, const Extension* extension) { 283 void NotifyWebRequestAPIUsed(void* profile_id, const Extension* extension) {
284 Profile* profile = reinterpret_cast<Profile*>(profile_id); 284 Profile* profile = reinterpret_cast<Profile*>(profile_id);
285 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) 285 if (!g_browser_process->profile_manager()->IsValidProfile(profile))
286 return; 286 return;
287 287
288 if (profile->GetExtensionService()->HasUsedWebRequest(extension)) 288 if (profile->GetExtensionService()->HasUsedWebRequest(extension))
289 return; 289 return;
290 profile->GetExtensionService()->SetHasUsedWebRequest(extension, true); 290 profile->GetExtensionService()->SetHasUsedWebRequest(extension, true);
291 291
292 content::BrowserContext* browser_context = profile; 292 content::BrowserContext* browser_context = profile;
293 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); 293 for (content::RenderProcessHost::iterator it =
294 content::RenderProcessHost::AllHostsIterator();
294 !it.IsAtEnd(); it.Advance()) { 295 !it.IsAtEnd(); it.Advance()) {
295 RenderProcessHost* host = it.GetCurrentValue(); 296 content::RenderProcessHost* host = it.GetCurrentValue();
296 if (host->browser_context() == browser_context) 297 if (host->GetBrowserContext() == browser_context)
297 SendExtensionWebRequestStatusToHost(host); 298 SendExtensionWebRequestStatusToHost(host);
298 } 299 }
299 } 300 }
300 301
301 void ClearCacheOnNavigationOnUI() { 302 void ClearCacheOnNavigationOnUI() {
302 WebCacheManager::GetInstance()->ClearCacheOnNavigation(); 303 WebCacheManager::GetInstance()->ClearCacheOnNavigation();
303 } 304 }
304 305
305 } // namespace 306 } // namespace
306 307
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 FROM_HERE, 1623 FROM_HERE,
1623 base::Bind(&ExtensionWarningSet::NotifyWarningsOnUI, 1624 base::Bind(&ExtensionWarningSet::NotifyWarningsOnUI,
1624 profile_id(), 1625 profile_id(),
1625 extension_ids, 1626 extension_ids,
1626 ExtensionWarningSet::kRepeatedCacheFlushes)); 1627 ExtensionWarningSet::kRepeatedCacheFlushes));
1627 1628
1628 // Continue gracefully. 1629 // Continue gracefully.
1629 Run(); 1630 Run();
1630 } 1631 }
1631 1632
1632 void SendExtensionWebRequestStatusToHost(RenderProcessHost* host) { 1633 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host) {
1633 Profile* profile = Profile::FromBrowserContext(host->browser_context()); 1634 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
1634 if (!profile || !profile->GetExtensionService()) 1635 if (!profile || !profile->GetExtensionService())
1635 return; 1636 return;
1636 1637
1637 bool adblock = false; 1638 bool adblock = false;
1638 bool adblock_plus = false; 1639 bool adblock_plus = false;
1639 bool other = false; 1640 bool other = false;
1640 const ExtensionList* extensions = 1641 const ExtensionList* extensions =
1641 profile->GetExtensionService()->extensions(); 1642 profile->GetExtensionService()->extensions();
1642 for (ExtensionList::const_iterator it = extensions->begin(); 1643 for (ExtensionList::const_iterator it = extensions->begin();
1643 it != extensions->end(); ++it) { 1644 it != extensions->end(); ++it) {
1644 if (profile->GetExtensionService()->HasUsedWebRequest(*it)) { 1645 if (profile->GetExtensionService()->HasUsedWebRequest(*it)) {
1645 if ((*it)->name().find("Adblock Plus") != std::string::npos) { 1646 if ((*it)->name().find("Adblock Plus") != std::string::npos) {
1646 adblock_plus = true; 1647 adblock_plus = true;
1647 } else if ((*it)->name().find("AdBlock") != std::string::npos) { 1648 } else if ((*it)->name().find("AdBlock") != std::string::npos) {
1648 adblock = true; 1649 adblock = true;
1649 } else { 1650 } else {
1650 other = true; 1651 other = true;
1651 } 1652 }
1652 } 1653 }
1653 } 1654 }
1654 1655
1655 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); 1656 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other));
1656 } 1657 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_webrequest_api.h ('k') | chrome/browser/extensions/isolated_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698