summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_webnavigation_api.cc
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 10:13:57 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 10:13:57 +0000
commit429c909dcdb6ce422e4d16870a63deb34f729596 (patch)
treea91f1163a5a1f31e6bea196181d9f7a656c3818a /chrome/browser/extensions/extension_webnavigation_api.cc
parent8ddb1c2557d6a1f67375efd803a40b704d6fe12b (diff)
downloadchromium_src-429c909dcdb6ce422e4d16870a63deb34f729596.zip
chromium_src-429c909dcdb6ce422e4d16870a63deb34f729596.tar.gz
chromium_src-429c909dcdb6ce422e4d16870a63deb34f729596.tar.bz2
Revert 58802 - Implement the webNavigation.onCommitted event.
BUG=50943 TEST=ExtensionApiTest.WebNavigationEvents Review URL: http://codereview.chromium.org/3307013 TBR=jochen@chromium.org Review URL: http://codereview.chromium.org/3317013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_webnavigation_api.cc')
-rw-r--r--chrome/browser/extensions/extension_webnavigation_api.cc85
1 files changed, 0 insertions, 85 deletions
diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc
deleted file mode 100644
index 4a545fd..0000000
--- a/chrome/browser/extensions/extension_webnavigation_api.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Implements the Chrome Extensions WebNavigation API.
-
-#include "chrome/browser/extensions/extension_webnavigation_api.h"
-
-#include "base/json/json_writer.h"
-#include "base/time.h"
-#include "base/values.h"
-#include "chrome/browser/extensions/extension_message_service.h"
-#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_entry.h"
-#include "chrome/common/notification_type.h"
-#include "chrome/common/notification_service.h"
-
-namespace keys = extension_webnavigation_api_constants;
-
-// static
-ExtensionWebNavigationEventRouter*
-ExtensionWebNavigationEventRouter::GetInstance() {
- return Singleton<ExtensionWebNavigationEventRouter>::get();
-}
-
-void ExtensionWebNavigationEventRouter::Init() {
- if (registrar_.IsEmpty()) {
- registrar_.Add(this,
- NotificationType::NAV_ENTRY_COMMITTED,
- NotificationService::AllSources());
- }
-}
-
-void ExtensionWebNavigationEventRouter::Observe(
- NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- switch (type.value) {
- case NotificationType::NAV_ENTRY_COMMITTED:
- NavEntryCommitted(
- Source<NavigationController>(source).ptr(),
- Details<NavigationController::LoadCommittedDetails>(details).ptr());
- break;
-
- default:
- NOTREACHED();
- }
-}
-
-void ExtensionWebNavigationEventRouter::NavEntryCommitted(
- NavigationController* controller,
- NavigationController::LoadCommittedDetails* details) {
- ListValue args;
- DictionaryValue* dict = new DictionaryValue();
- dict->SetInteger(keys::kTabIdKey,
- ExtensionTabUtil::GetTabId(controller->tab_contents()));
- dict->SetString(keys::kUrlKey,
- details->entry->url().spec());
- dict->SetInteger(keys::kFrameIdKey,
- details->is_main_frame ? 0 : details->entry->page_id());
- dict->SetString(keys::kTransitionTypeKey,
- PageTransition::CoreTransitionString(
- details->entry->transition_type()));
- dict->SetString(keys::kTransitionQualifiersKey,
- PageTransition::QualifierString(
- details->entry->transition_type()));
- dict->SetReal(keys::kTimeStampKey, base::Time::Now().ToDoubleT());
- args.Append(dict);
-
- std::string json_args;
- base::JSONWriter::Write(&args, false, &json_args);
- DispatchEvent(controller->profile(), keys::kOnCommitted, json_args);
-}
-
-void ExtensionWebNavigationEventRouter::DispatchEvent(
- Profile* profile,
- const char* event_name,
- const std::string& json_args) {
- if (profile && profile->GetExtensionMessageService()) {
- profile->GetExtensionMessageService()->DispatchEventToRenderers(
- event_name, json_args, profile, GURL());
- }
-}