| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |