| 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 ad90ac0ba419fde83cd4ade880a8858634f381c8..5bf93ea9e6c90876da5fe54e218587fc9f1525cc 100644
|
| --- a/content/renderer/browser_plugin/browser_plugin.cc
|
| +++ b/content/renderer/browser_plugin/browser_plugin.cc
|
| @@ -45,9 +45,10 @@ namespace {
|
| const char kCrashEventName[] = "crash";
|
| const char kIsTopLevel[] = "isTopLevel";
|
| const char kLoadAbortEventName[] = "loadAbort";
|
| +const char kLoadCommitEventName[] = "loadCommit";
|
| const char kLoadRedirectEventName[] = "loadRedirect";
|
| const char kLoadStartEventName[] = "loadStart";
|
| -const char kNavigationEventName[] = "navigation";
|
| +const char kLoadStopEventName[] = "loadStop";
|
| const char kNewURL[] = "newUrl";
|
| const char kOldURL[] = "oldUrl";
|
| const char kPartitionAttribute[] = "partition";
|
| @@ -358,8 +359,37 @@ void BrowserPlugin::GuestCrashed() {
|
| }
|
| }
|
|
|
| -void BrowserPlugin::DidNavigate(
|
| - const BrowserPluginMsg_DidNavigate_Params& params) {
|
| +void BrowserPlugin::LoadStart(const GURL& url, bool is_top_level) {
|
| + if (!HasListeners(kLoadStartEventName))
|
| + return;
|
| +
|
| + WebKit::WebElement plugin = container()->element();
|
| + v8::HandleScope handle_scope;
|
| + v8::Context::Scope context_scope(
|
| + plugin.document().frame()->mainWorldScriptContext());
|
| +
|
| + // Construct the loadStart event object.
|
| + v8::Local<v8::Object> event = v8::Object::New();
|
| + event->Set(v8::String::New(kURL, sizeof(kURL) - 1),
|
| + v8::String::New(url.spec().data(), url.spec().size()));
|
| + event->Set(v8::String::New(kIsTopLevel, sizeof(kIsTopLevel) - 1),
|
| + v8::Boolean::New(is_top_level));
|
| + v8::Local<v8::Value> val = event;
|
| +
|
| + // TODO(fsamuel): Copying the event listeners is insufficent because
|
| + // new persistent handles are not created when the copy constructor is
|
| + // called. See http://crbug.com/155044.
|
| + EventListeners listeners(event_listener_map_[kLoadStartEventName]);
|
| + EventListeners::iterator it = listeners.begin();
|
| + for (; it != listeners.end(); ++it) {
|
| + WebKit::WebFrame* frame = plugin.document().frame();
|
| + if (frame)
|
| + frame->callFunctionEvenIfScriptDisabled(*it, v8::Object::New(), 1, &val);
|
| + }
|
| +}
|
| +
|
| +void BrowserPlugin::LoadCommit(
|
| + const BrowserPluginMsg_LoadCommit_Params& params) {
|
| // If the guest has just committed a new navigation then it is no longer
|
| // crashed.
|
| guest_crashed_ = false;
|
| @@ -368,7 +398,7 @@ void BrowserPlugin::DidNavigate(
|
| current_nav_entry_index_ = params.current_entry_index;
|
| nav_entry_count_ = params.entry_count;
|
|
|
| - if (!HasListeners(kNavigationEventName))
|
| + if (!HasListeners(kLoadCommitEventName))
|
| return;
|
|
|
| WebKit::WebElement plugin = container()->element();
|
| @@ -376,7 +406,7 @@ void BrowserPlugin::DidNavigate(
|
| v8::Context::Scope context_scope(
|
| plugin.document().frame()->mainWorldScriptContext());
|
|
|
| - // Construct the navigation event object.
|
| + // Construct the loadCommit event object.
|
| v8::Local<v8::Object> event = v8::Object::New();
|
| event->Set(v8::String::New(kURL, sizeof(kURL) - 1),
|
| v8::String::New(src_.data(), src_.size()));
|
| @@ -387,19 +417,17 @@ void BrowserPlugin::DidNavigate(
|
| // TODO(fsamuel): Copying the event listeners is insufficent because
|
| // new persistent handles are not created when the copy constructor is
|
| // called. See http://crbug.com/155044.
|
| - EventListeners listeners(event_listener_map_[kNavigationEventName]);
|
| + EventListeners listeners(event_listener_map_[kLoadCommitEventName]);
|
| EventListeners::iterator it = listeners.begin();
|
| for (; it != listeners.end(); ++it) {
|
| WebKit::WebFrame* frame = plugin.document().frame();
|
| - if (frame) {
|
| - frame->callFunctionEvenIfScriptDisabled(
|
| - *it, v8::Object::New(), 1, &val);
|
| - }
|
| + if (frame)
|
| + frame->callFunctionEvenIfScriptDisabled(*it, v8::Object::New(), 1, &val);
|
| }
|
| }
|
|
|
| -void BrowserPlugin::LoadStart(const GURL& url, bool is_top_level) {
|
| - if (!HasListeners(kLoadStartEventName))
|
| +void BrowserPlugin::LoadStop() {
|
| + if (!HasListeners(kLoadStopEventName))
|
| return;
|
|
|
| WebKit::WebElement plugin = container()->element();
|
| @@ -407,18 +435,14 @@ void BrowserPlugin::LoadStart(const GURL& url, bool is_top_level) {
|
| v8::Context::Scope context_scope(
|
| plugin.document().frame()->mainWorldScriptContext());
|
|
|
| - // Construct the loadStart event object.
|
| + // Construct the loadStop event object.
|
| v8::Local<v8::Object> event = v8::Object::New();
|
| - event->Set(v8::String::New(kURL, sizeof(kURL) - 1),
|
| - v8::String::New(url.spec().data(), url.spec().size()));
|
| - event->Set(v8::String::New(kIsTopLevel, sizeof(kIsTopLevel) - 1),
|
| - v8::Boolean::New(is_top_level));
|
| v8::Local<v8::Value> val = event;
|
|
|
| // TODO(fsamuel): Copying the event listeners is insufficent because
|
| // new persistent handles are not created when the copy constructor is
|
| // called. See http://crbug.com/155044.
|
| - EventListeners listeners(event_listener_map_[kLoadStartEventName]);
|
| + EventListeners listeners(event_listener_map_[kLoadStopEventName]);
|
| EventListeners::iterator it = listeners.begin();
|
| for (; it != listeners.end(); ++it) {
|
| WebKit::WebFrame* frame = plugin.document().frame();
|
|
|