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

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: Renaming move "remove rules registry for webview" part to WebViewGuest. 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::kDefaultRulesRegistryID;
153 webview_instance_id ? embedder_process_id : 0, webview_instance_id); 153 if (has_webview) {
154 rules_registry_id = WebViewGuest::GetOrGenerateRulesRegistryID(
155 embedder_process_id, webview_instance_id, browser_context());
Fady Samuel 2014/11/28 11:35:51 make it web_view_instance_id to be consistent with
Xi Han 2014/11/28 16:12:56 Done.
156 }
154 157
155 // The following call will return a NULL pointer for apps_shell, but should 158 // The following call will return a NULL pointer for apps_shell, but should
156 // never be called there anyways. 159 // never be called there anyways.
157 rules_registry_ = RulesRegistryService::Get(browser_context())-> 160 rules_registry_ =
158 GetRulesRegistry(key, event_name); 161 RulesRegistryService::Get(browser_context())
162 ->GetRulesRegistry(rules_registry_id, has_webview, event_name);
Fady Samuel 2014/11/28 11:35:51 I don't think we need to pass in has_webview anymo
Xi Han 2014/11/28 16:12:56 Removed.
159 DCHECK(rules_registry_.get()); 163 DCHECK(rules_registry_.get());
160 // Raw access to this function is not available to extensions, therefore 164 // Raw access to this function is not available to extensions, therefore
161 // there should never be a request for a nonexisting rules registry. 165 // there should never be a request for a nonexisting rules registry.
162 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); 166 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get());
163 167
164 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { 168 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) {
165 bool success = RunAsyncOnCorrectThread(); 169 bool success = RunAsyncOnCorrectThread();
166 SendResponse(success); 170 SendResponse(success);
167 } else { 171 } else {
168 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = 172 scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } else { 220 } else {
217 rules_registry_->GetAllRules(extension_id(), &rules); 221 rules_registry_->GetAllRules(extension_id(), &rules);
218 } 222 }
219 223
220 results_ = GetRules::Results::Create(rules); 224 results_ = GetRules::Results::Create(rules);
221 225
222 return true; 226 return true;
223 } 227 }
224 228
225 } // namespace extensions 229 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698