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

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

Issue 17419004: <webview>: Add support for filtering extension events by instanceId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@filter_listener
Patch Set: Correct diff Created 7 years, 6 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 (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 "chrome/renderer/extensions/event_bindings.h" 5 #include "chrome/renderer/extensions/event_bindings.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 args.GetReturnValue().Set(array); 295 args.GetReturnValue().Set(array);
296 } 296 }
297 297
298 static EventFilteringInfo ParseFromObject(v8::Handle<v8::Object> object) { 298 static EventFilteringInfo ParseFromObject(v8::Handle<v8::Object> object) {
299 EventFilteringInfo info; 299 EventFilteringInfo info;
300 v8::Handle<v8::String> url(v8::String::New("url")); 300 v8::Handle<v8::String> url(v8::String::New("url"));
301 if (object->Has(url)) { 301 if (object->Has(url)) {
302 v8::Handle<v8::Value> url_value(object->Get(url)); 302 v8::Handle<v8::Value> url_value(object->Get(url));
303 info.SetURL(GURL(*v8::String::AsciiValue(url_value))); 303 info.SetURL(GURL(*v8::String::AsciiValue(url_value)));
304 } 304 }
305 v8::Handle<v8::String> instance_id(v8::String::New("instanceId"));
306 if (object->Has(instance_id)) {
307 v8::Handle<v8::Value> instance_id_value(object->Get(instance_id));
308 info.SetInstanceID(instance_id_value->IntegerValue());
309 }
305 return info; 310 return info;
306 } 311 }
307 312
308 private: 313 private:
309 static bool IsLazyBackgroundPage(content::RenderView* render_view, 314 static bool IsLazyBackgroundPage(content::RenderView* render_view,
310 const Extension* extension) { 315 const Extension* extension) {
311 if (!render_view) 316 if (!render_view)
312 return false; 317 return false;
313 ExtensionHelper* helper = ExtensionHelper::Get(render_view); 318 ExtensionHelper* helper = ExtensionHelper::Get(render_view);
314 return (extension && BackgroundInfo::HasLazyBackgroundPage(extension) && 319 return (extension && BackgroundInfo::HasLazyBackgroundPage(extension) &&
315 helper->view_type() == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); 320 helper->view_type() == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
316 } 321 }
317 322
318 static scoped_ptr<EventMatcher> ParseEventMatcher( 323 static scoped_ptr<EventMatcher> ParseEventMatcher(
319 base::DictionaryValue* filter_dict) { 324 base::DictionaryValue* filter_dict) {
320 return scoped_ptr<EventMatcher>(new EventMatcher( 325 return scoped_ptr<EventMatcher>(new EventMatcher(
321 scoped_ptr<base::DictionaryValue>(filter_dict->DeepCopy()))); 326 scoped_ptr<base::DictionaryValue>(filter_dict->DeepCopy())));
322 } 327 }
323 }; 328 };
324 329
325 } // namespace 330 } // namespace
326 331
327 // static 332 // static
328 ChromeV8Extension* EventBindings::Create(Dispatcher* dispatcher, 333 ChromeV8Extension* EventBindings::Create(Dispatcher* dispatcher,
329 ChromeV8Context* context) { 334 ChromeV8Context* context) {
330 return new ExtensionImpl(dispatcher, context); 335 return new ExtensionImpl(dispatcher, context);
331 } 336 }
332 337
333 } // namespace extensions 338 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/common/event_filtering_info.h » ('j') | extensions/common/event_filtering_info.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698