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

Side by Side Diff: extensions/renderer/event_bindings.cc

Issue 453613002: Implement support for <extensionoptions> embedding in WebUI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer/event_bindings.h" 5 #include "extensions/renderer/event_bindings.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 CHECK(args[0]->IsString()); 203 CHECK(args[0]->IsString());
204 CHECK(args[1]->IsObject()); 204 CHECK(args[1]->IsObject());
205 205
206 std::string event_name = *v8::String::Utf8Value(args[0]); 206 std::string event_name = *v8::String::Utf8Value(args[0]);
207 207
208 // This method throws an exception if it returns false. 208 // This method throws an exception if it returns false.
209 if (!dispatcher_->CheckContextAccessToExtensionAPI(event_name, context())) 209 if (!dispatcher_->CheckContextAccessToExtensionAPI(event_name, context()))
210 return; 210 return;
211 211
212 std::string extension_id = context()->GetExtensionID(); 212 std::string extension_id = context()->GetExtensionID();
213 if (extension_id.empty()) { 213 if (extension_id.empty() &&
214 context()->context_type() != Feature::Context::WEBUI_CONTEXT) {
not at google - send to devlin 2014/08/07 23:06:03 I'm surprised any of the filtered event logic work
ericzeng 2014/08/08 00:23:47 Done. Are you absolutely sure that the check isn't
not at google - send to devlin 2014/08/08 14:08:15 yes, it will get caught up on the browser.
214 args.GetReturnValue().Set(static_cast<int32_t>(-1)); 215 args.GetReturnValue().Set(static_cast<int32_t>(-1));
215 return; 216 return;
216 } 217 }
217 218
218 scoped_ptr<base::DictionaryValue> filter; 219 scoped_ptr<base::DictionaryValue> filter;
219 scoped_ptr<content::V8ValueConverter> converter( 220 scoped_ptr<content::V8ValueConverter> converter(
220 content::V8ValueConverter::create()); 221 content::V8ValueConverter::create());
221 222
222 base::DictionaryValue* filter_dict = NULL; 223 base::DictionaryValue* filter_dict = NULL;
223 base::Value* filter_value = 224 base::Value* filter_value =
(...skipping 25 matching lines...) Expand all
249 } 250 }
250 251
251 void EventBindings::DetachFilteredEvent( 252 void EventBindings::DetachFilteredEvent(
252 const v8::FunctionCallbackInfo<v8::Value>& args) { 253 const v8::FunctionCallbackInfo<v8::Value>& args) {
253 CHECK_EQ(2, args.Length()); 254 CHECK_EQ(2, args.Length());
254 CHECK(args[0]->IsInt32()); 255 CHECK(args[0]->IsInt32());
255 CHECK(args[1]->IsBoolean()); 256 CHECK(args[1]->IsBoolean());
256 bool is_manual = args[1]->BooleanValue(); 257 bool is_manual = args[1]->BooleanValue();
257 258
258 std::string extension_id = context()->GetExtensionID(); 259 std::string extension_id = context()->GetExtensionID();
259 if (extension_id.empty()) 260 if (extension_id.empty() &&
261 context()->context_type() != Feature::Context::WEBUI_CONTEXT) {
not at google - send to devlin 2014/08/07 23:06:03 likewise
ericzeng 2014/08/08 00:23:47 Done.
262 args.GetReturnValue().Set(static_cast<int32_t>(-1));
260 return; 263 return;
264 }
261 265
262 int matcher_id = args[0]->Int32Value(); 266 int matcher_id = args[0]->Int32Value();
263 EventFilter& event_filter = g_event_filter.Get(); 267 EventFilter& event_filter = g_event_filter.Get();
264 EventMatcher* event_matcher = event_filter.GetEventMatcher(matcher_id); 268 EventMatcher* event_matcher = event_filter.GetEventMatcher(matcher_id);
265 269
266 const std::string& event_name = event_filter.GetEventName(matcher_id); 270 const std::string& event_name = event_filter.GetEventName(matcher_id);
267 271
268 // Only send IPCs the last time a filter gets removed. 272 // Only send IPCs the last time a filter gets removed.
269 if (RemoveFilter(event_name, extension_id, event_matcher->value())) { 273 if (RemoveFilter(event_name, extension_id, event_matcher->value())) {
270 bool lazy = is_manual && IsLazyBackgroundPage(context()->GetRenderView(), 274 bool lazy = is_manual && IsLazyBackgroundPage(context()->GetRenderView(),
(...skipping 29 matching lines...) Expand all
300 } 304 }
301 305
302 scoped_ptr<EventMatcher> EventBindings::ParseEventMatcher( 306 scoped_ptr<EventMatcher> EventBindings::ParseEventMatcher(
303 base::DictionaryValue* filter_dict) { 307 base::DictionaryValue* filter_dict) {
304 return scoped_ptr<EventMatcher>(new EventMatcher( 308 return scoped_ptr<EventMatcher>(new EventMatcher(
305 scoped_ptr<base::DictionaryValue>(filter_dict->DeepCopy()), 309 scoped_ptr<base::DictionaryValue>(filter_dict->DeepCopy()),
306 context()->GetRenderView()->GetRoutingID())); 310 context()->GetRenderView()->GetRoutingID()));
307 } 311 }
308 312
309 } // namespace extensions 313 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698