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

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 Comments 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 9e4b961fab575f9c315e6383da1c0533ac49a027..a4a8addcad115ca222f78bb0536ac7814de3c58f 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";
@@ -355,14 +356,8 @@ void BrowserPlugin::GuestCrashed() {
}
}
-void BrowserPlugin::DidNavigate(
- const BrowserPluginMsg_DidNavigate_Params& params) {
Fady Samuel 2012/10/15 19:59:20 We still want these parameters for CanGoBack/CanGo
irobert 2012/10/16 01:26:39 Done.
- src_ = params.url.spec();
- process_id_ = params.process_id;
- current_nav_entry_index_ = params.current_entry_index;
- nav_entry_count_ = params.entry_count;
-
- if (!HasListeners(kNavigationEventName))
+void BrowserPlugin::LoadStart(const GURL& url, bool is_top_level) {
+ if (!HasListeners(kLoadStartEventName))
return;
WebKit::WebElement plugin = container()->element();
@@ -370,30 +365,32 @@ void BrowserPlugin::DidNavigate(
v8::Context::Scope context_scope(
plugin.document().frame()->mainWorldScriptContext());
- // Construct the navigation event object.
+ // 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(src_.data(), src_.size()));
+ v8::String::New(url.spec().data(), url.spec().size()));
event->Set(v8::String::New(kIsTopLevel, sizeof(kIsTopLevel) - 1),
- v8::Boolean::New(params.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_[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, &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::LoadCommit(
+ const GURL& url,
+ int process_id,
+ bool is_top_level) {
+ process_id_ = process_id;
+ if (!HasListeners(kLoadCommitEventName))
return;
WebKit::WebElement plugin = container()->element();
@@ -401,18 +398,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();
@@ -421,6 +418,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) {

Powered by Google App Engine
This is Rietveld 408576698