Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2265)

Unified Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 11035067: Add loadCommit and loadStop Event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Merge Conflict Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6139b839c0b5fb59bee0e1fcb2196686c49dbba4..e817e4e7b94f2d27932f738789f91496c3660ec0 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";
@@ -345,8 +346,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;
@@ -355,7 +385,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();
@@ -363,30 +393,28 @@ 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()));
+ v8::String::New(src_.data(), src_.size()));
Charlie Reis 2012/10/17 21:27:08 nit: No need to change the indent on these two lin
irobert 2012/10/18 01:42:25 Done.
event->Set(v8::String::New(kIsTopLevel, sizeof(kIsTopLevel) - 1),
- v8::Boolean::New(params.is_top_level));
+ v8::Boolean::New(params.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, &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();
@@ -394,18 +422,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();

Powered by Google App Engine
This is Rietveld 408576698