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

Side by Side Diff: extensions/browser/api/declarative/declarative_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/declarative/declarative_api.h" 5 #include "extensions/browser/api/declarative/declarative_api.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 int webview_instance_id = 0; 142 int webview_instance_id = 0;
143 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &webview_instance_id)); 143 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &webview_instance_id));
144 int embedder_process_id = render_view_host()->GetProcess()->GetID(); 144 int embedder_process_id = render_view_host()->GetProcess()->GetID();
145 145
146 bool has_webview = webview_instance_id != 0; 146 bool has_webview = webview_instance_id != 0;
147 if (has_webview != IsWebViewEvent(event_name)) 147 if (has_webview != IsWebViewEvent(event_name))
148 EXTENSION_FUNCTION_ERROR(kWebViewExpectedError); 148 EXTENSION_FUNCTION_ERROR(kWebViewExpectedError);
149 event_name = GetWebRequestEventName(event_name); 149 event_name = GetWebRequestEventName(event_name);
150 150
151 // If we are not operating on a particular <webview>, then the key is (0, 0). 151 // If we are not operating on a particular <webview>, then the key is 0.
152 RulesRegistry::WebViewKey key( 152 int rules_registry_id = RulesRegistryService::kDefultRulesRegistryID;
153 webview_instance_id ? embedder_process_id : 0, webview_instance_id); 153 if (has_webview) {
154 WebViewGuest::GenerateRulesRegistryID(
155 embedder_process_id, webview_instance_id,
156 RulesRegistryService::Get(browser_context()), &rules_registry_id);
157 }
154 158
155 // The following call will return a NULL pointer for apps_shell, but should 159 // The following call will return a NULL pointer for apps_shell, but should
156 // never be called there anyways. 160 // never be called there anyways.
157 rules_registry_ = RulesRegistryService::Get(browser_context())-> 161 rules_registry_ =
158 GetRulesRegistry(key, event_name); 162 RulesRegistryService::Get(browser_context())
163 ->GetRulesRegistry(rules_registry_id, has_webview, event_name);
159 DCHECK(rules_registry_.get()); 164 DCHECK(rules_registry_.get());
160 // Raw access to this function is not available to extensions, therefore 165 // Raw access to this function is not available to extensions, therefore
161 // there should never be a request for a nonexisting rules registry. 166 // there should never be a request for a nonexisting rules registry.
162 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); 167 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get());
163 168
164 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { 169 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) {
165 bool success = RunAsyncOnCorrectThread(); 170 bool success = RunAsyncOnCorrectThread();
166 SendResponse(success); 171 SendResponse(success);
167 } else { 172 } else {
168 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = 173 scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } else { 221 } else {
217 rules_registry_->GetAllRules(extension_id(), &rules); 222 rules_registry_->GetAllRules(extension_id(), &rules);
218 } 223 }
219 224
220 results_ = GetRules::Results::Create(rules); 225 results_ = GetRules::Results::Create(rules);
221 226
222 return true; 227 return true;
223 } 228 }
224 229
225 } // namespace extensions 230 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698