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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); |
294 !it.IsAtEnd(); it.Advance()) { | 294 !it.IsAtEnd(); it.Advance()) { |
295 RenderProcessHost* host = it.GetCurrentValue(); | 295 RenderProcessHost* host = it.GetCurrentValue(); |
296 if (host->browser_context() == browser_context) | 296 if (host->GetBrowserContext() == browser_context) |
297 SendExtensionWebRequestStatusToHost(host); | 297 SendExtensionWebRequestStatusToHost(host); |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
301 void ClearCacheOnNavigationOnUI() { | 301 void ClearCacheOnNavigationOnUI() { |
302 WebCacheManager::GetInstance()->ClearCacheOnNavigation(); | 302 WebCacheManager::GetInstance()->ClearCacheOnNavigation(); |
303 } | 303 } |
304 | 304 |
305 } // namespace | 305 } // namespace |
306 | 306 |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 base::Bind(&ExtensionWarningSet::NotifyWarningsOnUI, | 1623 base::Bind(&ExtensionWarningSet::NotifyWarningsOnUI, |
1624 profile_id(), | 1624 profile_id(), |
1625 extension_ids, | 1625 extension_ids, |
1626 ExtensionWarningSet::kRepeatedCacheFlushes)); | 1626 ExtensionWarningSet::kRepeatedCacheFlushes)); |
1627 | 1627 |
1628 // Continue gracefully. | 1628 // Continue gracefully. |
1629 Run(); | 1629 Run(); |
1630 } | 1630 } |
1631 | 1631 |
1632 void SendExtensionWebRequestStatusToHost(RenderProcessHost* host) { | 1632 void SendExtensionWebRequestStatusToHost(RenderProcessHost* host) { |
1633 Profile* profile = Profile::FromBrowserContext(host->browser_context()); | 1633 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
1634 if (!profile || !profile->GetExtensionService()) | 1634 if (!profile || !profile->GetExtensionService()) |
1635 return; | 1635 return; |
1636 | 1636 |
1637 bool adblock = false; | 1637 bool adblock = false; |
1638 bool adblock_plus = false; | 1638 bool adblock_plus = false; |
1639 bool other = false; | 1639 bool other = false; |
1640 const ExtensionList* extensions = | 1640 const ExtensionList* extensions = |
1641 profile->GetExtensionService()->extensions(); | 1641 profile->GetExtensionService()->extensions(); |
1642 for (ExtensionList::const_iterator it = extensions->begin(); | 1642 for (ExtensionList::const_iterator it = extensions->begin(); |
1643 it != extensions->end(); ++it) { | 1643 it != extensions->end(); ++it) { |
1644 if (profile->GetExtensionService()->HasUsedWebRequest(*it)) { | 1644 if (profile->GetExtensionService()->HasUsedWebRequest(*it)) { |
1645 if ((*it)->name().find("Adblock Plus") != std::string::npos) { | 1645 if ((*it)->name().find("Adblock Plus") != std::string::npos) { |
1646 adblock_plus = true; | 1646 adblock_plus = true; |
1647 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 1647 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
1648 adblock = true; | 1648 adblock = true; |
1649 } else { | 1649 } else { |
1650 other = true; | 1650 other = true; |
1651 } | 1651 } |
1652 } | 1652 } |
1653 } | 1653 } |
1654 | 1654 |
1655 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 1655 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
1656 } | 1656 } |
OLD | NEW |