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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api.cc

Issue 11826048: Revert 176015 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 months 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) 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.h" 5 #include "chrome/browser/extensions/api/web_request/web_request_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/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 } 1699 }
1700 1700
1701 void ExtensionWebRequestEventRouter::ClearSignaled(uint64 request_id, 1701 void ExtensionWebRequestEventRouter::ClearSignaled(uint64 request_id,
1702 EventTypes event_type) { 1702 EventTypes event_type) {
1703 SignaledRequestMap::iterator iter = signaled_requests_.find(request_id); 1703 SignaledRequestMap::iterator iter = signaled_requests_.find(request_id);
1704 if (iter == signaled_requests_.end()) 1704 if (iter == signaled_requests_.end())
1705 return; 1705 return;
1706 iter->second &= ~event_type; 1706 iter->second &= ~event_type;
1707 } 1707 }
1708 1708
1709 // Special QuotaLimitHeuristic for WebRequestHandlerBehaviorChangedFunction. 1709 // Special QuotaLimitHeuristic for WebRequestHandlerBehaviorChanged.
1710 // 1710 //
1711 // Each call of webRequest.handlerBehaviorChanged() clears the in-memory cache 1711 // Each call of webRequest.handlerBehaviorChanged() clears the in-memory cache
1712 // of WebKit at the time of the next page load (top level navigation event). 1712 // of WebKit at the time of the next page load (top level navigation event).
1713 // This quota heuristic is intended to limit the number of times the cache is 1713 // This quota heuristic is intended to limit the number of times the cache is
1714 // cleared by an extension. 1714 // cleared by an extension.
1715 // 1715 //
1716 // As we want to account for the number of times the cache is really cleared 1716 // As we want to account for the number of times the cache is really cleared
1717 // (opposed to the number of times webRequest.handlerBehaviorChanged() is 1717 // (opposed to the number of times webRequest.handlerBehaviorChanged() is
1718 // called), we cannot decide whether a call of 1718 // called), we cannot decide whether a call of
1719 // webRequest.handlerBehaviorChanged() should trigger a quota violation at the 1719 // webRequest.handlerBehaviorChanged() should trigger a quota violation at the
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 } 1948 }
1949 } 1949 }
1950 1950
1951 ExtensionWebRequestEventRouter::GetInstance()->OnEventHandled( 1951 ExtensionWebRequestEventRouter::GetInstance()->OnEventHandled(
1952 profile_id(), extension_id(), event_name, sub_event_name, request_id, 1952 profile_id(), extension_id(), event_name, sub_event_name, request_id,
1953 response.release()); 1953 response.release());
1954 1954
1955 return true; 1955 return true;
1956 } 1956 }
1957 1957
1958 void WebRequestHandlerBehaviorChangedFunction::GetQuotaLimitHeuristics( 1958 void WebRequestHandlerBehaviorChanged::GetQuotaLimitHeuristics(
1959 QuotaLimitHeuristics* heuristics) const { 1959 QuotaLimitHeuristics* heuristics) const {
1960 QuotaLimitHeuristic::Config config = { 1960 QuotaLimitHeuristic::Config config = {
1961 // See web_request.json for current value. 1961 // See web_request.json for current value.
1962 web_request::MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES, 1962 web_request::MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES,
1963 base::TimeDelta::FromMinutes(10) 1963 base::TimeDelta::FromMinutes(10)
1964 }; 1964 };
1965 QuotaLimitHeuristic::BucketMapper* bucket_mapper = 1965 QuotaLimitHeuristic::BucketMapper* bucket_mapper =
1966 new QuotaLimitHeuristic::SingletonBucketMapper(); 1966 new QuotaLimitHeuristic::SingletonBucketMapper();
1967 ClearCacheQuotaHeuristic* heuristic = 1967 ClearCacheQuotaHeuristic* heuristic =
1968 new ClearCacheQuotaHeuristic(config, bucket_mapper); 1968 new ClearCacheQuotaHeuristic(config, bucket_mapper);
1969 heuristics->push_back(heuristic); 1969 heuristics->push_back(heuristic);
1970 } 1970 }
1971 1971
1972 void WebRequestHandlerBehaviorChangedFunction::OnQuotaExceeded( 1972 void WebRequestHandlerBehaviorChanged::OnQuotaExceeded(
1973 const std::string& violation_error) { 1973 const std::string& violation_error) {
1974 // Post warning message. 1974 // Post warning message.
1975 ExtensionWarningSet warnings; 1975 ExtensionWarningSet warnings;
1976 warnings.insert( 1976 warnings.insert(
1977 ExtensionWarning::CreateRepeatedCacheFlushesWarning(extension_id())); 1977 ExtensionWarning::CreateRepeatedCacheFlushesWarning(extension_id()));
1978 BrowserThread::PostTask( 1978 BrowserThread::PostTask(
1979 BrowserThread::UI, 1979 BrowserThread::UI,
1980 FROM_HERE, 1980 FROM_HERE,
1981 base::Bind(&ExtensionWarningService::NotifyWarningsOnUI, 1981 base::Bind(&ExtensionWarningService::NotifyWarningsOnUI,
1982 profile_id(), warnings)); 1982 profile_id(), warnings));
1983 1983
1984 // Continue gracefully. 1984 // Continue gracefully.
1985 Run(); 1985 Run();
1986 } 1986 }
1987 1987
1988 bool WebRequestHandlerBehaviorChangedFunction::RunImpl() { 1988 bool WebRequestHandlerBehaviorChanged::RunImpl() {
1989 helpers::ClearCacheOnNavigation(); 1989 helpers::ClearCacheOnNavigation();
1990 return true; 1990 return true;
1991 } 1991 }
1992 1992
1993 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host) { 1993 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host) {
1994 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); 1994 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
1995 if (!profile || !profile->GetExtensionService()) 1995 if (!profile || !profile->GetExtensionService())
1996 return; 1996 return;
1997 1997
1998 bool adblock = false; 1998 bool adblock = false;
1999 bool adblock_plus = false; 1999 bool adblock_plus = false;
2000 bool other = false; 2000 bool other = false;
2001 const ExtensionSet* extensions = 2001 const ExtensionSet* extensions =
2002 profile->GetExtensionService()->extensions(); 2002 profile->GetExtensionService()->extensions();
2003 for (ExtensionSet::const_iterator it = extensions->begin(); 2003 for (ExtensionSet::const_iterator it = extensions->begin();
2004 it != extensions->end(); ++it) { 2004 it != extensions->end(); ++it) {
2005 if (profile->GetExtensionService()->HasUsedWebRequest(*it)) { 2005 if (profile->GetExtensionService()->HasUsedWebRequest(*it)) {
2006 if ((*it)->name().find("Adblock Plus") != std::string::npos) { 2006 if ((*it)->name().find("Adblock Plus") != std::string::npos) {
2007 adblock_plus = true; 2007 adblock_plus = true;
2008 } else if ((*it)->name().find("AdBlock") != std::string::npos) { 2008 } else if ((*it)->name().find("AdBlock") != std::string::npos) {
2009 adblock = true; 2009 adblock = true;
2010 } else { 2010 } else {
2011 other = true; 2011 other = true;
2012 } 2012 }
2013 } 2013 }
2014 } 2014 }
2015 2015
2016 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); 2016 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other));
2017 } 2017 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_api.h ('k') | chrome/browser/extensions/browser_event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698