Chromium Code Reviews| Index: content/renderer/browser_plugin/browser_plugin.cc |
| diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc |
| index 712c41a93f060738323e498f6fa612bbd476bcd5..168542231c5250643afac5044ca1f0809b4636a2 100644 |
| --- a/content/renderer/browser_plugin/browser_plugin.cc |
| +++ b/content/renderer/browser_plugin/browser_plugin.cc |
| @@ -43,6 +43,8 @@ namespace content { |
| namespace { |
| const char kCrashEventName[] = "crash"; |
| +const char kLoadAbortEventName[] = "loadAbort"; |
| +const char kLoadStartEventName[] = "loadStart"; |
| const char kNavigationEventName[] = "navigation"; |
| const char* kPartitionAttribute = "partition"; |
| const char* kPersistPrefix = "persist:"; |
| @@ -342,6 +344,72 @@ void BrowserPlugin::DidNavigate(const GURL& url, int process_id) { |
| } |
| } |
| +void BrowserPlugin::LoadStart(const GURL& url, bool is_top_level) { |
| + if (!HasListeners(kLoadStartEventName)) |
| + return; |
| + |
| + EventListeners& listeners = event_listener_map_[kLoadStartEventName]; |
| + EventListeners::iterator it = listeners.begin(); |
| + const std::string kURL = "url"; |
| + const std::string kIsTopLevel = "isTopLevel"; |
|
Charlie Reis
2012/10/03 01:52:30
It might make sense to move these to the top, sinc
Fady Samuel
2012/10/04 00:43:38
Done.
|
| + |
| + v8::Context::Scope context_scope(v8::Context::New()); |
| + v8::HandleScope handle_scope; |
| + // Construct the loadStart event object. |
| + v8::Local<v8::Value> event = |
| + v8::Local<v8::Object>::New(v8::Object::New()); |
| + v8::Local<v8::Object>::Cast(event)->Set( |
| + v8::String::New(kURL.c_str(), kURL.size()), |
| + v8::String::New(url.spec().c_str(), url.spec().size())); |
| + v8::Local<v8::Object>::Cast(event)->Set( |
| + v8::String::New(kIsTopLevel.c_str(), kIsTopLevel.size()), |
| + v8::Boolean::New(is_top_level)); |
| + for (; it != listeners.end(); ++it) { |
| + // Fire the event listener. |
| + container()->element().document().frame()-> |
| + callFunctionEvenIfScriptDisabled(*it, |
| + v8::Object::New(), |
| + 1, |
| + &event); |
| + } |
| +} |
| + |
| +void BrowserPlugin::LoadAbort(const GURL& url, |
| + bool is_top_level, |
| + const std::string& type) { |
| + if (!HasListeners(kLoadAbortEventName)) |
| + return; |
| + |
| + EventListeners& listeners = event_listener_map_[kLoadAbortEventName]; |
| + EventListeners::iterator it = listeners.begin(); |
| + const std::string kURL = "url"; |
| + const std::string kIsTopLevel = "isTopLevel"; |
| + const std::string kType = "type"; |
|
Charlie Reis
2012/10/03 01:52:30
Ditto, even for kType.
Fady Samuel
2012/10/04 00:43:38
Done.
|
| + |
| + v8::Context::Scope context_scope(v8::Context::New()); |
| + v8::HandleScope handle_scope; |
| + // Construct the loadAbort event object. |
| + v8::Local<v8::Value> event = |
| + v8::Local<v8::Object>::New(v8::Object::New()); |
| + v8::Local<v8::Object>::Cast(event)->Set( |
| + v8::String::New(kURL.c_str(), kURL.size()), |
| + v8::String::New(url.spec().c_str(), url.spec().size())); |
| + v8::Local<v8::Object>::Cast(event)->Set( |
| + v8::String::New(kIsTopLevel.c_str(), kIsTopLevel.size()), |
| + v8::Boolean::New(is_top_level)); |
| + v8::Local<v8::Object>::Cast(event)->Set( |
| + v8::String::New(kType.c_str(), kType.size()), |
| + v8::String::New(type.c_str(), type.size())); |
| + for (; it != listeners.end(); ++it) { |
| + // Fire the event listener. |
| + container()->element().document().frame()-> |
| + callFunctionEvenIfScriptDisabled(*it, |
| + v8::Object::New(), |
| + 1, |
| + &event); |
| + } |
| +} |
| + |
| void BrowserPlugin::AdvanceFocus(bool reverse) { |
| // We do not have a RenderView when we are testing. |
| if (render_view_) |