| 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..49c4974251c6e011993de3485c6c1512f111e4ba 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,8 @@ void BrowserPlugin::GuestCrashed() {
|
| }
|
| }
|
|
|
| -void BrowserPlugin::DidNavigate(const GURL& url, int process_id) {
|
| - src_ = url.spec();
|
| - process_id_ = process_id;
|
| - if (!HasListeners(kNavigationEventName))
|
| +void BrowserPlugin::LoadStart(const GURL& url, bool is_top_level) {
|
| + if (!HasListeners(kLoadStartEventName))
|
| return;
|
|
|
| WebKit::WebElement plugin = container()->element();
|
| @@ -355,24 +354,32 @@ 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 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_[kNavigationEventName]);
|
| + 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, ¶m);
|
| - }
|
| + 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::LoadCommit(
|
| + const GURL& url,
|
| + int process_id,
|
| + bool is_top_level) {
|
| + process_id_ = process_id;
|
| + if (!HasListeners(kLoadCommitEventName))
|
| return;
|
|
|
| WebKit::WebElement plugin = container()->element();
|
| @@ -380,18 +387,18 @@ 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 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()));
|
| + 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::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_[kLoadCommitEventName]);
|
| EventListeners::iterator it = listeners.begin();
|
| for (; it != listeners.end(); ++it) {
|
| WebKit::WebFrame* frame = plugin.document().frame();
|
| @@ -400,6 +407,32 @@ void BrowserPlugin::LoadStart(const GURL& url, bool is_top_level) {
|
| }
|
| }
|
|
|
| +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::LoadAbort(const GURL& url,
|
| bool is_top_level,
|
| const std::string& type) {
|
|
|