summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/extension_webnavigation_api.cc85
-rw-r--r--chrome/browser/extensions/extension_webnavigation_api.h56
-rw-r--r--chrome/browser/extensions/extension_webnavigation_apitest.cc7
-rw-r--r--chrome/browser/extensions/extensions_service.cc2
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc9
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/extensions/api/extension_api.json2
-rw-r--r--chrome/common/extensions/docs/experimental.webNavigation.html6
-rw-r--r--chrome/common/page_transition_types.cc17
-rw-r--r--chrome/common/page_transition_types.h6
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/a.html3
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/b.html1
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/a.html6
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/b.html3
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/a.html1
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/b.html3
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/c.html1
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/manifest.json7
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/simpleLoad/a.html1
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/test.html113
20 files changed, 4 insertions, 327 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());
- }
-}
diff --git a/chrome/browser/extensions/extension_webnavigation_api.h b/chrome/browser/extensions/extension_webnavigation_api.h
deleted file mode 100644
index 77182e1..0000000
--- a/chrome/browser/extensions/extension_webnavigation_api.h
+++ /dev/null
@@ -1,56 +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.
-
-// Defines the Chrome Extensions WebNavigation API functions for observing and
-// intercepting navigation events, as specified in
-// chrome/common/extensions/api/extension_api.json.
-
-#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_
-#pragma once
-
-#include "base/singleton.h"
-#include "chrome/browser/extensions/extension_function.h"
-#include "chrome/browser/tab_contents/navigation_controller.h"
-#include "chrome/common/notification_registrar.h"
-#include "googleurl/src/gurl.h"
-
-// Observes navigation notifications and routes them as events to the extension
-// system.
-class ExtensionWebNavigationEventRouter : public NotificationObserver {
- public:
- // Single instance of the event router.
- static ExtensionWebNavigationEventRouter* GetInstance();
-
- void Init();
-
- private:
- friend struct DefaultSingletonTraits<ExtensionWebNavigationEventRouter>;
-
- ExtensionWebNavigationEventRouter() {}
- virtual ~ExtensionWebNavigationEventRouter() {}
-
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- // Handler for the NAV_ENTRY_COMMITTED event. The method takes the details of
- // such an event and constructs a suitable JSON formatted extension event
- // from it.
- void NavEntryCommitted(NavigationController* controller,
- NavigationController::LoadCommittedDetails* details);
-
- // This method dispatches events to the extension message service.
- void DispatchEvent(Profile* context,
- const char* event_name,
- const std::string& json_args);
-
- // Used for tracking registrations to navigation notifications.
- NotificationRegistrar registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionWebNavigationEventRouter);
-};
-
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBNAVIGATION_API_H_
diff --git a/chrome/browser/extensions/extension_webnavigation_apitest.cc b/chrome/browser/extensions/extension_webnavigation_apitest.cc
index 087a8b8a..b0ccd77 100644
--- a/chrome/browser/extensions/extension_webnavigation_apitest.cc
+++ b/chrome/browser/extensions/extension_webnavigation_apitest.cc
@@ -12,10 +12,3 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigation) {
ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
}
-
-IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExperimentalExtensionApis);
-
- ASSERT_TRUE(RunExtensionTest("webnavigation/navigation")) << message_;
-}
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 9a59114..06198387 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -34,7 +34,6 @@
#include "chrome/browser/extensions/extension_management_api.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_updater.h"
-#include "chrome/browser/extensions/extension_webnavigation_api.h"
#include "chrome/browser/extensions/external_extension_provider.h"
#include "chrome/browser/extensions/external_pref_extension_provider.h"
#include "chrome/browser/net/chrome_url_request_context.h"
@@ -252,7 +251,6 @@ void ExtensionsService::InitEventRouters() {
profile_->GetBookmarkModel());
ExtensionCookiesEventRouter::GetInstance()->Init();
ExtensionManagementEventRouter::GetInstance()->Init();
- ExtensionWebNavigationEventRouter::GetInstance()->Init();
}
void ExtensionsService::Init() {
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc
index 0aa86f2..a416bc9 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -352,9 +352,6 @@ void NavigationController::GoBack() {
DiscardNonCommittedEntries();
pending_entry_index_ = current_index - 1;
- entries_[pending_entry_index_]->set_transition_type(
- entries_[pending_entry_index_]->transition_type() |
- PageTransition::FORWARD_BACK);
NavigateToPendingEntry(NO_RELOAD);
}
@@ -385,9 +382,6 @@ void NavigationController::GoForward() {
if (!transient)
pending_entry_index_++;
- entries_[pending_entry_index_]->set_transition_type(
- entries_[pending_entry_index_]->transition_type() |
- PageTransition::FORWARD_BACK);
NavigateToPendingEntry(NO_RELOAD);
}
@@ -426,9 +420,6 @@ void NavigationController::GoToIndex(int index) {
DiscardNonCommittedEntries();
pending_entry_index_ = index;
- entries_[pending_entry_index_]->set_transition_type(
- entries_[pending_entry_index_]->transition_type() |
- PageTransition::FORWARD_BACK);
NavigateToPendingEntry(NO_RELOAD);
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index ecae835..f864796 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1464,8 +1464,6 @@
'browser/extensions/extension_updater.h',
'browser/extensions/extension_webrequest_api_constants.cc',
'browser/extensions/extension_webrequest_api_constants.h',
- 'browser/extensions/extension_webnavigation_api.cc',
- 'browser/extensions/extension_webnavigation_api.h',
'browser/extensions/extension_webnavigation_api_constants.cc',
'browser/extensions/extension_webnavigation_api_constants.h',
'browser/extensions/extension_webstore_private_api.cc',
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 4727108..0ca4808 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -3192,7 +3192,7 @@
"url": {"type": "string"},
"frameId": {"type": "integer", "description": "0 indicates the navigation happens in the tab content window; positive value indicates navigation in a subframe."},
"transitionType": {"type": "string", "enum": ["link", "typed", "auto_bookmark", "auto_subframe", "manual_subframe", "generated", "start_page", "form_submit", "reload", "keyword", "keyword_generated"], "description": "Cause of the navigation. The same transition types as defined in the history API are used."},
- "transitionQualifiers": {"type": "string", "description": "Zero or more transition qualifiers delimited by \"|\". Possible qualifiers are \"client_redirect\", \"server_redirect\", and \"forward_back\"."},
+ "transitionQualifiers": {"type": "string", "enum": ["client_redirect", "server_redirect", "forward_back"], "description": "Zero or more transition qualifiers delimited by \"|\". Possible qualifiers are \"client_redirect\", \"server_redirect\", and \"forward_backward\"."},
"timeStamp": {"type": "number", "description": "The time when the navigation was committed, in milliseconds since the epoch."}
}
}
diff --git a/chrome/common/extensions/docs/experimental.webNavigation.html b/chrome/common/extensions/docs/experimental.webNavigation.html
index b71aac33..ee897d5 100644
--- a/chrome/common/extensions/docs/experimental.webNavigation.html
+++ b/chrome/common/extensions/docs/experimental.webNavigation.html
@@ -1392,7 +1392,7 @@
<div style="display:inline">
(
<span class="optional" style="display: none; ">optional</span>
- <span class="enum" style="display: none; ">enumerated</span>
+ <span class="enum">enumerated</span>
<span id="typeTemplate">
<span style="display: none; ">
<a> Type</a>
@@ -1402,7 +1402,7 @@
array of <span><span></span></span>
</span>
<span>string</span>
- <span style="display: none; "></span>
+ <span>["client_redirect", "server_redirect", "forward_back"]</span>
</span>
</span>
)
@@ -1413,7 +1413,7 @@
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>Zero or more transition qualifiers delimited by "|". Possible qualifiers are "client_redirect", "server_redirect", and "forward_back".</dd>
+ <dd>Zero or more transition qualifiers delimited by "|". Possible qualifiers are "client_redirect", "server_redirect", and "forward_backward".</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
diff --git a/chrome/common/page_transition_types.cc b/chrome/common/page_transition_types.cc
index 1079ea0..bf686f9 100644
--- a/chrome/common/page_transition_types.cc
+++ b/chrome/common/page_transition_types.cc
@@ -34,20 +34,3 @@ const char* PageTransition::CoreTransitionString(Type type) {
}
return NULL;
}
-
-// static
-const char* PageTransition::QualifierString(Type type) {
- DCHECK_NE((int)(type & (CLIENT_REDIRECT | SERVER_REDIRECT)),
- (int)(CLIENT_REDIRECT | SERVER_REDIRECT));
-
- switch (type & (CLIENT_REDIRECT | SERVER_REDIRECT | FORWARD_BACK)) {
- case CLIENT_REDIRECT: return "client_redirect";
- case SERVER_REDIRECT: return "server_redirect";
- case FORWARD_BACK: return "forward_back";
- case (CLIENT_REDIRECT | FORWARD_BACK):
- return "client_redirect|forward_back";
- case (SERVER_REDIRECT | FORWARD_BACK):
- return "server_redirect|forward_back";
- }
- return "";
-}
diff --git a/chrome/common/page_transition_types.h b/chrome/common/page_transition_types.h
index 8ca7042..71cd386 100644
--- a/chrome/common/page_transition_types.h
+++ b/chrome/common/page_transition_types.h
@@ -102,9 +102,6 @@ class PageTransition {
// Any of the core values above can be augmented by one or more qualifiers.
// These qualifiers further define the transition.
- // User used the Forward or Back button to navigate among browsing history.
- FORWARD_BACK = 0x01000000,
-
// The beginning of a navigation chain.
CHAIN_START = 0x10000000,
@@ -160,9 +157,6 @@ class PageTransition {
// Return a string version of the core type values.
static const char* CoreTransitionString(Type type);
-
- // Return a string version of the qualifier type values.
- static const char* QualifierString(Type type);
};
#endif // CHROME_COMMON_PAGE_TRANSITION_TYPES_H__
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/a.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/a.html
deleted file mode 100644
index 3e3e11a..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/a.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<script>
- window.setTimeout('document.location = "b.html";', 500);
-</script>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/b.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/b.html
deleted file mode 100644
index 18ecdcb..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/b.html
+++ /dev/null
@@ -1 +0,0 @@
-<html></html>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/a.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/a.html
deleted file mode 100644
index 7b3462c..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/a.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<script>
- if (window.sessionStorage['redirected'] != 1) {
- window.sessionStorage['redirected'] = 1;
- window.setTimeout('document.location = "b.html";', 500);
- }
-</script>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/b.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/b.html
deleted file mode 100644
index a4270ed..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/b.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<script>
- window.setTimeout('history.back();', 500);
-</script>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/a.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/a.html
deleted file mode 100644
index c5c157d..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/a.html
+++ /dev/null
@@ -1 +0,0 @@
-<html><body><iframe src="b.html"></iframe></body></html>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/b.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/b.html
deleted file mode 100644
index d6e86d8..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/b.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<script>
- window.setTimeout('document.location = "c.html";', 500);
-</script>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/c.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/c.html
deleted file mode 100644
index 18ecdcb..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/c.html
+++ /dev/null
@@ -1 +0,0 @@
-<html></html>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/manifest.json b/chrome/test/data/extensions/api_test/webnavigation/navigation/manifest.json
deleted file mode 100644
index c5538ce..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/manifest.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "navigation",
- "version": "1.0",
- "description": "Tests the webNavigation API events.",
- "permissions": ["experimental", "tabs"],
- "background_page": "test.html"
-}
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/simpleLoad/a.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/simpleLoad/a.html
deleted file mode 100644
index 18ecdcb..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/simpleLoad/a.html
+++ /dev/null
@@ -1 +0,0 @@
-<html></html>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html
deleted file mode 100644
index 4ac358d1..0000000
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html
+++ /dev/null
@@ -1,113 +0,0 @@
-<script>
-var expectedEventData;
-var capturedEventData;
-
-function expect(data) {
- expectedEventData = data;
- capturedEventData = [];
-}
-
-function checkExpectations() {
- if (capturedEventData.length < expectedEventData.length) {
- return;
- }
- chrome.test.assertEq(JSON.stringify(expectedEventData),
- JSON.stringify(capturedEventData));
- chrome.test.succeed();
-}
-
-chrome.experimental.webNavigation.onCommitted.addListener(function(details) {
- console.log('---onCommitted: ' + details.url);
- // normalize details.
- details.timeStamp = 0;
- if (details.frameId != 0) {
- details.frameId = 1;
- }
- capturedEventData.push(details);
- checkExpectations();
-});
-
-var getURL = chrome.extension.getURL;
-chrome.tabs.getSelected(null, function(tab) {
- var tabId = tab.id;
-
- chrome.test.runTests([
- /* Navigates to an URL */
- function simpleLoad() {
- expect([
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('simpleLoad/a.html') }]);
- chrome.tabs.update(tabId, { url: getURL('simpleLoad/a.html') });
- },
-
- /* Navigates to a.html that redirects to b.html (using javascript)
- after a delay of 500ms, so the initial navigation is completed and
- the redirection is marked as client_redirect */
- function clientRedirect() {
- expect([
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('clientRedirect/a.html') },
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "client_redirect",
- transitionType: "link",
- url: getURL('clientRedirect/b.html') }]);
- chrome.tabs.update(tabId, { url: getURL('clientRedirect/a.html') });
- },
-
- /* First navigates to a.html which redirects to to b.html which uses
- history.back() to navigate back to a.html */
- function forwardBack() {
- expect([
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('forwardBack/a.html') },
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "client_redirect",
- transitionType: "link",
- url: getURL('forwardBack/b.html') },
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "forward_back",
- transitionType: "link",
- url: getURL('forwardBack/a.html') }]);
- chrome.tabs.update(tabId, { url: getURL('forwardBack/a.html') });
- },
-
- /* Navigates to a.html which includes b.html as an iframe. b.html
- redirects to c.html. Note that all navigation entries are for
- a.html. Also, b.html does not generate a navigation entry. */
- function iframe() {
- expect([
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('iframe/a.html') },
- { frameId: 1,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('iframe/a.html') }]);
- chrome.tabs.update(tabId, { url: getURL('iframe/a.html') });
- },
- ]);
-});
-</script>