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 acdea505531f3c687f84dc5f68770e90ef04c081..613ca172377efed7e2ddbeadbfe7c5e96f3026de 100644 |
--- a/content/renderer/browser_plugin/browser_plugin.cc |
+++ b/content/renderer/browser_plugin/browser_plugin.cc |
@@ -47,6 +47,8 @@ const char kIsTopLevel[] = "isTopLevel"; |
const char kLoadAbortEventName[] = "loadAbort"; |
const char kLoadRedirectEventName[] = "loadRedirect"; |
const char kLoadStartEventName[] = "loadStart"; |
+const char kLoadStopEventName[] = "loadStop"; |
+const char kLoadCommitEventName[] = "loadCommit"; |
Charlie Reis
2012/10/08 19:03:39
Please keep these alphabetized.
irobert
2012/10/10 23:55:16
Done.
|
const char kNavigationEventName[] = "navigation"; |
Charlie Reis
2012/10/08 19:03:39
We can remove this one now, right?
irobert
2012/10/10 23:55:16
Done.
|
const char kNewURL[] = "newUrl"; |
const char kOldURL[] = "oldUrl"; |
@@ -336,24 +338,56 @@ void BrowserPlugin::GuestCrashed() { |
} |
} |
-void BrowserPlugin::DidNavigate(const GURL& url, int process_id) { |
- src_ = url.spec(); |
+void BrowserPlugin::LoadStop() { |
+ if (!HasListeners(kLoadStopEventName)) |
+ return; |
+ EventListeners& listeners = event_listener_map_[kLoadStopEventName]; |
+ EventListeners::iterator it = listeners.begin(); |
+ |
+ v8::Context::Scope context_scope(v8::Context::New()); |
+ v8::HandleScope handle_scope; |
+ // Construct the loadStop event object. |
+ v8::Local<v8::Value> event = |
+ v8::Local<v8::Object>::New(v8::Object::New()); |
+ for (; it != listeners.end(); ++it) { |
+ // Fire the event listener. |
+ container()->element().document().frame()-> |
+ callFunctionEvenIfScriptDisabled(*it, |
+ v8::Object::New(), |
+ 1, |
+ &event); |
+ } |
+} |
+ |
+void BrowserPlugin::LoadCommit( |
+ const GURL& url, |
+ int process_id, |
+ bool is_top_level) { |
process_id_ = process_id; |
- if (!HasListeners(kNavigationEventName)) |
+ if (!HasListeners(kLoadCommitEventName)) |
return; |
- EventListeners& listeners = event_listener_map_[kNavigationEventName]; |
+ EventListeners& listeners = event_listener_map_[kLoadCommitEventName]; |
EventListeners::iterator it = listeners.begin(); |
+ |
+ v8::Context::Scope context_scope(v8::Context::New()); |
Charlie Reis
2012/10/08 19:03:39
Note: We've learned that this approach doesn't wor
irobert
2012/10/10 23:55:16
Done.
|
+ v8::HandleScope handle_scope; |
+ // Construct the loadCommit 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, sizeof(kURL) - 1), |
+ v8::String::New(url.spec().c_str(), url.spec().size())); |
+ v8::Local<v8::Object>::Cast(event)->Set( |
+ v8::String::New(kIsTopLevel, sizeof(kIsTopLevel) - 1), |
+ v8::Boolean::New(is_top_level)); |
for (; it != listeners.end(); ++it) { |
- v8::Context::Scope context_scope(v8::Context::New()); |
- v8::HandleScope handle_scope; |
- v8::Local<v8::Value> param = |
- v8::Local<v8::Value>::New(v8::String::New(src_.c_str())); |
+ // Fire the event listener. |
container()->element().document().frame()-> |
callFunctionEvenIfScriptDisabled(*it, |
v8::Object::New(), |
1, |
- ¶m); |
+ &event); |
} |
} |