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

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

Issue 764643002: Remove WebViewKey in rules registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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.h" 5 #include "extensions/browser/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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 web_request_event_router_delegate_.reset( 654 web_request_event_router_delegate_.reset(
655 extensions::ExtensionsAPIClient::Get()-> 655 extensions::ExtensionsAPIClient::Get()->
656 CreateWebRequestEventRouterDelegate()); 656 CreateWebRequestEventRouterDelegate());
657 } 657 }
658 658
659 ExtensionWebRequestEventRouter::~ExtensionWebRequestEventRouter() { 659 ExtensionWebRequestEventRouter::~ExtensionWebRequestEventRouter() {
660 } 660 }
661 661
662 void ExtensionWebRequestEventRouter::RegisterRulesRegistry( 662 void ExtensionWebRequestEventRouter::RegisterRulesRegistry(
663 void* browser_context, 663 void* browser_context,
664 const extensions::RulesRegistry::WebViewKey& webview_key, 664 int rules_registry_id,
665 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry) { 665 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry) {
666 RulesRegistryKey key(browser_context, webview_key); 666 RulesRegistryKey key(browser_context, rules_registry_id);
667 if (rules_registry.get()) 667 if (rules_registry.get())
668 rules_registries_[key] = rules_registry; 668 rules_registries_[key] = rules_registry;
669 else 669 else
670 rules_registries_.erase(key); 670 rules_registries_.erase(key);
671 } 671 }
672 672
673 void ExtensionWebRequestEventRouter::ExtractRequestInfo( 673 void ExtensionWebRequestEventRouter::ExtractRequestInfo(
674 net::URLRequest* request, base::DictionaryValue* out) { 674 net::URLRequest* request, base::DictionaryValue* out) {
675 bool is_main_frame = false; 675 bool is_main_frame = false;
676 int frame_id = -1; 676 int frame_id = -1;
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 1959
1960 bool ExtensionWebRequestEventRouter::ProcessDeclarativeRules( 1960 bool ExtensionWebRequestEventRouter::ProcessDeclarativeRules(
1961 void* browser_context, 1961 void* browser_context,
1962 InfoMap* extension_info_map, 1962 InfoMap* extension_info_map,
1963 const std::string& event_name, 1963 const std::string& event_name,
1964 net::URLRequest* request, 1964 net::URLRequest* request,
1965 extensions::RequestStage request_stage, 1965 extensions::RequestStage request_stage,
1966 const net::HttpResponseHeaders* original_response_headers) { 1966 const net::HttpResponseHeaders* original_response_headers) {
1967 extensions::WebViewRendererState::WebViewInfo web_view_info; 1967 extensions::WebViewRendererState::WebViewInfo web_view_info;
1968 bool is_web_view_guest = GetWebViewInfo(request, &web_view_info); 1968 bool is_web_view_guest = GetWebViewInfo(request, &web_view_info);
1969 int rules_registry_id =
1970 is_web_view_guest ? web_view_info.rules_registry_id : 0;
Fady Samuel 2014/11/26 23:39:41 Use the default value here.
Xi Han 2014/11/27 23:25:25 Done.
1969 1971
1970 extensions::RulesRegistry::WebViewKey webview_key( 1972 RulesRegistryKey rules_key(browser_context, rules_registry_id);
1971 is_web_view_guest ? web_view_info.embedder_process_id : 0,
1972 is_web_view_guest ? web_view_info.instance_id : 0);
1973 RulesRegistryKey rules_key(browser_context, webview_key);
1974 // If this check fails, check that the active stages are up-to-date in 1973 // If this check fails, check that the active stages are up-to-date in
1975 // extensions/browser/api/declarative_webrequest/request_stage.h . 1974 // extensions/browser/api/declarative_webrequest/request_stage.h .
1976 DCHECK(request_stage & extensions::kActiveStages); 1975 DCHECK(request_stage & extensions::kActiveStages);
1977 1976
1978 // Rules of the current |browser_context| may apply but we need to check also 1977 // Rules of the current |browser_context| may apply but we need to check also
1979 // whether there are applicable rules from extensions whose background page 1978 // whether there are applicable rules from extensions whose background page
1980 // spans from regular to incognito mode. 1979 // spans from regular to incognito mode.
1981 1980
1982 // First parameter identifies the registry, the second indicates whether the 1981 // First parameter identifies the registry, the second indicates whether the
1983 // registry belongs to the cross browser_context. 1982 // registry belongs to the cross browser_context.
1984 typedef std::pair<extensions::WebRequestRulesRegistry*, bool> 1983 typedef std::pair<extensions::WebRequestRulesRegistry*, bool>
1985 RelevantRegistry; 1984 RelevantRegistry;
1986 typedef std::vector<RelevantRegistry> RelevantRegistries; 1985 typedef std::vector<RelevantRegistry> RelevantRegistries;
1987 RelevantRegistries relevant_registries; 1986 RelevantRegistries relevant_registries;
1988 1987
1989 if (rules_registries_.find(rules_key) != rules_registries_.end()) { 1988 if (rules_registries_.find(rules_key) != rules_registries_.end()) {
1990 relevant_registries.push_back( 1989 relevant_registries.push_back(
1991 std::make_pair(rules_registries_[rules_key].get(), false)); 1990 std::make_pair(rules_registries_[rules_key].get(), false));
1992 } 1991 }
1993 1992
1994 void* cross_browser_context = GetCrossBrowserContext(browser_context); 1993 void* cross_browser_context = GetCrossBrowserContext(browser_context);
1995 RulesRegistryKey cross_browser_context_rules_key( 1994 RulesRegistryKey cross_browser_context_rules_key(cross_browser_context,
1996 cross_browser_context, webview_key); 1995 rules_registry_id);
1997 if (cross_browser_context && 1996 if (cross_browser_context &&
1998 rules_registries_.find(cross_browser_context_rules_key) != 1997 rules_registries_.find(cross_browser_context_rules_key) !=
1999 rules_registries_.end()) { 1998 rules_registries_.end()) {
2000 relevant_registries.push_back( 1999 relevant_registries.push_back(
2001 std::make_pair( 2000 std::make_pair(
2002 rules_registries_[cross_browser_context_rules_key].get(), true)); 2001 rules_registries_[cross_browser_context_rules_key].get(), true));
2003 } 2002 }
2004 2003
2005 // The following block is experimentally enabled and its impact on load time 2004 // The following block is experimentally enabled and its impact on load time
2006 // logged with UMA Extensions.NetworkDelayRegistryLoad. crbug.com/175961 2005 // logged with UMA Extensions.NetworkDelayRegistryLoad. crbug.com/175961
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 base::Bind(&WarningService::NotifyWarningsOnUI, profile_id(), warnings)); 2452 base::Bind(&WarningService::NotifyWarningsOnUI, profile_id(), warnings));
2454 2453
2455 // Continue gracefully. 2454 // Continue gracefully.
2456 RunSync(); 2455 RunSync();
2457 } 2456 }
2458 2457
2459 bool WebRequestHandlerBehaviorChangedFunction::RunSync() { 2458 bool WebRequestHandlerBehaviorChangedFunction::RunSync() {
2460 helpers::ClearCacheOnNavigation(); 2459 helpers::ClearCacheOnNavigation();
2461 return true; 2460 return true;
2462 } 2461 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698