OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |