| 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 adde725e61b83c614b638541935b9a737c56661b..9583f15337d51b2cb06350a08a1d3632ff78109a 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";
|
| @@ -344,10 +345,38 @@ void BrowserPlugin::GuestCrashed() {
|
| }
|
| }
|
|
|
| -void BrowserPlugin::DidNavigate(const GURL& url, int process_id) {
|
| - src_ = url.spec();
|
| +void BrowserPlugin::LoadStop() {
|
| + if (!HasListeners(kLoadStopEventName))
|
| + return;
|
| +
|
| + WebKit::WebElement plugin = container()->element();
|
| + v8::HandleScope handle_scope;
|
| + v8::Context::Scope context_scope(
|
| + plugin.document().frame()->mainWorldScriptContext());
|
| +
|
| + // Construct the loadStop event object.
|
| + v8::Local<v8::Object> event = v8::Object::New();
|
| + 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_[kLoadStopEventName]);
|
| + 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 GURL& url,
|
| + int process_id,
|
| + bool is_top_level) {
|
| process_id_ = process_id;
|
| - if (!HasListeners(kNavigationEventName))
|
| + if (!HasListeners(kLoadCommitEventName))
|
| return;
|
|
|
| WebKit::WebElement plugin = container()->element();
|
| @@ -355,18 +384,23 @@ void BrowserPlugin::DidNavigate(const GURL& url, int process_id) {
|
| v8::Context::Scope context_scope(
|
| plugin.document().frame()->mainWorldScriptContext());
|
|
|
| - v8::Local<v8::Value> param = v8::String::New(src_.data(), src_.size());
|
| + // 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(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_[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, ¶m);
|
| + frame->callFunctionEvenIfScriptDisabled(*it, v8::Object::New(), 1, &val);
|
| }
|
| }
|
| }
|
|
|