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

Unified Diff: chrome/browser/extensions/extension_webnavigation_api.cc

Issue 4448003: Implement onCompleted event for the webNavigation API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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: chrome/browser/extensions/extension_webnavigation_api.cc
diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc
index 3b5f0e39e837769bf49597dabca2b01278cf506d..9a3e4abd5d91f109617ea0af8c8d73158b6a1e7c 100644
--- a/chrome/browser/extensions/extension_webnavigation_api.cc
+++ b/chrome/browser/extensions/extension_webnavigation_api.cc
@@ -120,6 +120,9 @@ void ExtensionWebNavigationEventRouter::Init() {
NotificationType::FRAME_DOM_CONTENT_LOADED,
NotificationService::AllSources());
registrar_.Add(this,
+ NotificationType::FRAME_DID_FINISH_LOAD,
+ NotificationService::AllSources());
+ registrar_.Add(this,
NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR,
NotificationService::AllSources());
registrar_.Add(this,
@@ -148,6 +151,11 @@ void ExtensionWebNavigationEventRouter::Observe(
Source<NavigationController>(source).ptr(),
*Details<long long>(details).ptr());
break;
+ case NotificationType::FRAME_DID_FINISH_LOAD:
+ FrameDidFinishLoad(
+ Source<NavigationController>(source).ptr(),
+ *Details<long long>(details).ptr());
+ break;
case NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR:
FailProvisionalLoadWithError(
Source<NavigationController>(source).ptr(),
@@ -233,6 +241,25 @@ void ExtensionWebNavigationEventRouter::FrameDomContentLoaded(
DispatchEvent(controller->profile(), keys::kOnDOMContentLoaded, json_args);
}
+void ExtensionWebNavigationEventRouter::FrameDidFinishLoad(
+ NavigationController* controller, long long frame_id) {
+ if (!navigation_state_.CanSendEvents(frame_id))
+ return;
+ ListValue args;
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetInteger(keys::kTabIdKey,
+ ExtensionTabUtil::GetTabId(controller->tab_contents()));
+ dict->SetString(keys::kUrlKey, navigation_state_.GetUrl(frame_id).spec());
+ dict->SetInteger(keys::kFrameIdKey, navigation_state_.IsMainFrame(frame_id) ?
+ 0 : static_cast<int>(frame_id));
+ dict->SetReal(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
+ args.Append(dict);
+
+ std::string json_args;
+ base::JSONWriter::Write(&args, false, &json_args);
+ DispatchEvent(controller->profile(), keys::kOnCompleted, json_args);
+}
+
void ExtensionWebNavigationEventRouter::FailProvisionalLoadWithError(
NavigationController* controller,
ProvisionalLoadDetails* details) {
« no previous file with comments | « chrome/browser/extensions/extension_webnavigation_api.h ('k') | chrome/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698