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

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

Issue 3389012: Revert 59641 - Add the onBeforeNavigate and onErrorOccured events to the webN... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 3 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: chrome/browser/extensions/extension_webnavigation_api.cc
===================================================================
--- chrome/browser/extensions/extension_webnavigation_api.cc (revision 59641)
+++ chrome/browser/extensions/extension_webnavigation_api.cc (working copy)
@@ -13,11 +13,9 @@
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/extension_webnavigation_api_constants.h"
#include "chrome/browser/profile.h"
-#include "chrome/browser/tab_contents/navigation_controller.h"
-#include "chrome/browser/tab_contents/provisional_load_details.h"
+#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/notification_service.h"
-#include "net/base/net_errors.h"
namespace keys = extension_webnavigation_api_constants;
@@ -30,14 +28,8 @@
void ExtensionWebNavigationEventRouter::Init() {
if (registrar_.IsEmpty()) {
registrar_.Add(this,
- NotificationType::FRAME_PROVISIONAL_LOAD_START,
+ NotificationType::NAV_ENTRY_COMMITTED,
NotificationService::AllSources());
- registrar_.Add(this,
- NotificationType::FRAME_PROVISIONAL_LOAD_COMMITTED,
- NotificationService::AllSources());
- registrar_.Add(this,
- NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR,
- NotificationService::AllSources());
}
}
@@ -46,64 +38,35 @@
const NotificationSource& source,
const NotificationDetails& details) {
switch (type.value) {
- case NotificationType::FRAME_PROVISIONAL_LOAD_START:
- FrameProvisionalLoadStart(
+ case NotificationType::NAV_ENTRY_COMMITTED:
+ NavEntryCommitted(
Source<NavigationController>(source).ptr(),
- Details<ProvisionalLoadDetails>(details).ptr());
+ Details<NavigationController::LoadCommittedDetails>(details).ptr());
break;
- case NotificationType::FRAME_PROVISIONAL_LOAD_COMMITTED:
- FrameProvisionalLoadCommitted(
- Source<NavigationController>(source).ptr(),
- Details<ProvisionalLoadDetails>(details).ptr());
- break;
- case NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR:
- FailProvisionalLoadWithError(
- Source<NavigationController>(source).ptr(),
- Details<ProvisionalLoadDetails>(details).ptr());
- break;
default:
NOTREACHED();
}
}
-void ExtensionWebNavigationEventRouter::FrameProvisionalLoadStart(
- NavigationController* controller,
- ProvisionalLoadDetails* details) {
- ListValue args;
- DictionaryValue* dict = new DictionaryValue();
- dict->SetInteger(keys::kTabIdKey,
- ExtensionTabUtil::GetTabId(controller->tab_contents()));
- dict->SetString(keys::kUrlKey,
- details->url().spec());
- dict->SetInteger(keys::kFrameIdKey, 0);
- dict->SetInteger(keys::kRequestIdKey, 0);
- dict->SetReal(keys::kTimeStampKey,
- (base::Time::Now() - base::Time::UnixEpoch()).InMilliseconds());
- args.Append(dict);
- std::string json_args;
- base::JSONWriter::Write(&args, false, &json_args);
- DispatchEvent(controller->profile(), keys::kOnBeforeNavigate, json_args);
-}
-
-void ExtensionWebNavigationEventRouter::FrameProvisionalLoadCommitted(
+void ExtensionWebNavigationEventRouter::NavEntryCommitted(
NavigationController* controller,
- ProvisionalLoadDetails* details) {
+ NavigationController::LoadCommittedDetails* details) {
ListValue args;
DictionaryValue* dict = new DictionaryValue();
dict->SetInteger(keys::kTabIdKey,
ExtensionTabUtil::GetTabId(controller->tab_contents()));
dict->SetString(keys::kUrlKey,
- details->url().spec());
- dict->SetInteger(keys::kFrameIdKey, 0);
+ details->entry->url().spec());
+ dict->SetInteger(keys::kFrameIdKey,
+ details->is_main_frame ? 0 : details->entry->page_id());
dict->SetString(keys::kTransitionTypeKey,
PageTransition::CoreTransitionString(
- details->transition_type()));
+ details->entry->transition_type()));
dict->SetString(keys::kTransitionQualifiersKey,
PageTransition::QualifierString(
- details->transition_type()));
- dict->SetReal(keys::kTimeStampKey,
- (base::Time::Now() - base::Time::UnixEpoch()).InMilliseconds());
+ details->entry->transition_type()));
+ dict->SetReal(keys::kTimeStampKey, base::Time::Now().ToDoubleT());
args.Append(dict);
std::string json_args;
@@ -111,27 +74,6 @@
DispatchEvent(controller->profile(), keys::kOnCommitted, json_args);
}
-void ExtensionWebNavigationEventRouter::FailProvisionalLoadWithError(
- NavigationController* controller,
- ProvisionalLoadDetails* details) {
- ListValue args;
- DictionaryValue* dict = new DictionaryValue();
- dict->SetInteger(keys::kTabIdKey,
- ExtensionTabUtil::GetTabId(controller->tab_contents()));
- dict->SetString(keys::kUrlKey,
- details->url().spec());
- dict->SetInteger(keys::kFrameIdKey, 0);
- dict->SetString(keys::kErrorKey,
- std::string(net::ErrorToString(details->error_code())));
- dict->SetReal(keys::kTimeStampKey,
- (base::Time::Now() - base::Time::UnixEpoch()).InMilliseconds());
- args.Append(dict);
-
- std::string json_args;
- base::JSONWriter::Write(&args, false, &json_args);
- DispatchEvent(controller->profile(), keys::kOnErrorOccurred, json_args);
-}
-
void ExtensionWebNavigationEventRouter::DispatchEvent(
Profile* profile,
const char* event_name,
« no previous file with comments | « chrome/browser/extensions/extension_webnavigation_api.h ('k') | chrome/browser/tab_contents/provisional_load_details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698