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

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: Nits. 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 extension_.get(), 132 extension_.get(),
133 Feature::BLESSED_EXTENSION_CONTEXT, 133 Feature::BLESSED_EXTENSION_CONTEXT,
134 source_url()); 134 source_url());
135 return availability.is_available(); 135 return availability.is_available();
136 } 136 }
137 137
138 bool RulesFunction::RunAsync() { 138 bool RulesFunction::RunAsync() {
139 std::string event_name; 139 std::string event_name;
140 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); 140 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name));
141 141
142 int webview_instance_id = 0; 142 int web_view_instance_id = 0;
143 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &webview_instance_id)); 143 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &web_view_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_web_view = web_view_instance_id != 0;
147 if (has_webview != IsWebViewEvent(event_name)) 147 if (has_web_view != 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_web_view) {
154 rules_registry_id = WebViewGuest::GetOrGenerateRulesRegistryID(
155 embedder_process_id, web_view_instance_id, browser_context());
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_ = RulesRegistryService::Get(browser_context())->
158 GetRulesRegistry(key, event_name); 161 GetRulesRegistry(rules_registry_id, event_name);
159 DCHECK(rules_registry_.get()); 162 DCHECK(rules_registry_.get());
160 // Raw access to this function is not available to extensions, therefore 163 // Raw access to this function is not available to extensions, therefore
161 // there should never be a request for a nonexisting rules registry. 164 // there should never be a request for a nonexisting rules registry.
162 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); 165 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get());
163 166
164 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { 167 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) {
165 bool success = RunAsyncOnCorrectThread(); 168 bool success = RunAsyncOnCorrectThread();
166 SendResponse(success); 169 SendResponse(success);
167 } else { 170 } else {
168 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = 171 scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } else { 219 } else {
217 rules_registry_->GetAllRules(extension_id(), &rules); 220 rules_registry_->GetAllRules(extension_id(), &rules);
218 } 221 }
219 222
220 results_ = GetRules::Results::Create(rules); 223 results_ = GetRules::Results::Create(rules);
221 224
222 return true; 225 return true;
223 } 226 }
224 227
225 } // namespace extensions 228 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698