summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/web_navigation
diff options
context:
space:
mode:
authorDHNishi@gmail.com <DHNishi@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-20 00:41:57 +0000
committerDHNishi@gmail.com <DHNishi@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-20 00:41:57 +0000
commite054ea1282bb5e221e43961202b378a8df43f496 (patch)
treec402d642648d33a21ec024fbeeec2fe4abb46151 /chrome/browser/extensions/api/web_navigation
parent9e43d6eb69814ca81f900e04d54d9eb6224fc38d (diff)
downloadchromium_src-e054ea1282bb5e221e43961202b378a8df43f496.zip
chromium_src-e054ea1282bb5e221e43961202b378a8df43f496.tar.gz
chromium_src-e054ea1282bb5e221e43961202b378a8df43f496.tar.bz2
JSON/IDL Compiler now generates event names as of r215660. Use these generated event names instead of custom constant strings.
BUG=268380 Review URL: https://chromiumcodereview.appspot.com/23013006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218378 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/web_navigation')
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_api.cc25
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_api_constants.cc13
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc29
3 files changed, 33 insertions, 34 deletions
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
index 73c80f1..7e2c8db 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
@@ -41,6 +41,7 @@ namespace extensions {
namespace helpers = web_navigation_api_helpers;
namespace keys = web_navigation_api_constants;
+namespace web_navigation = api::web_navigation;
namespace {
@@ -453,7 +454,7 @@ void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame(
if (is_reference_fragment_navigation) {
helpers::DispatchOnCommitted(
- keys::kOnReferenceFragmentUpdated,
+ web_navigation::OnReferenceFragmentUpdated::kEventName,
web_contents(),
frame_num,
is_main_frame,
@@ -461,7 +462,7 @@ void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame(
transition_type);
} else if (is_history_state_modification) {
helpers::DispatchOnCommitted(
- keys::kOnHistoryStateUpdated,
+ web_navigation::OnHistoryStateUpdated::kEventName,
web_contents(),
frame_num,
is_main_frame,
@@ -473,7 +474,7 @@ void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame(
transition_type | content::PAGE_TRANSITION_SERVER_REDIRECT);
}
helpers::DispatchOnCommitted(
- keys::kOnCommitted,
+ web_navigation::OnCommitted::kEventName,
web_contents(),
frame_num,
is_main_frame,
@@ -820,23 +821,23 @@ bool WebNavigationGetAllFramesFunction::RunImpl() {
WebNavigationAPI::WebNavigationAPI(Profile* profile)
: profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnBeforeNavigate);
+ this, web_navigation::OnBeforeNavigate::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnCommitted);
+ this, web_navigation::OnCommitted::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnCompleted);
+ this, web_navigation::OnCompleted::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnCreatedNavigationTarget);
+ this, web_navigation::OnCreatedNavigationTarget::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnDOMContentLoaded);
+ this, web_navigation::OnDOMContentLoaded::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnHistoryStateUpdated);
+ this, web_navigation::OnHistoryStateUpdated::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnErrorOccurred);
+ this, web_navigation::OnErrorOccurred::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnReferenceFragmentUpdated);
+ this, web_navigation::OnReferenceFragmentUpdated::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnTabReplaced);
+ this, web_navigation::OnTabReplaced::kEventName);
}
WebNavigationAPI::~WebNavigationAPI() {
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api_constants.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api_constants.cc
index be8ac77..785cbfa 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api_constants.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api_constants.cc
@@ -22,19 +22,6 @@ const char kTransitionTypeKey[] = "transitionType";
const char kTransitionQualifiersKey[] = "transitionQualifiers";
const char kUrlKey[] = "url";
-const char kOnBeforeNavigate[] = "webNavigation.onBeforeNavigate";
-const char kOnCommitted[] = "webNavigation.onCommitted";
-const char kOnCompleted[] = "webNavigation.onCompleted";
-const char kOnCreatedNavigationTarget[] =
- "webNavigation.onCreatedNavigationTarget";
-const char kOnDOMContentLoaded[] =
- "webNavigation.onDOMContentLoaded";
-const char kOnHistoryStateUpdated[] = "webNavigation.onHistoryStateUpdated";
-const char kOnErrorOccurred[] = "webNavigation.onErrorOccurred";
-const char kOnReferenceFragmentUpdated[] =
- "webNavigation.onReferenceFragmentUpdated";
-const char kOnTabReplaced[] = "webNavigation.onTabReplaced";
-
} // namespace web_navigation_api_constants
} // namespace extensions
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc
index b684650..4648b5f 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/web_navigation.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
@@ -24,6 +25,7 @@
namespace extensions {
namespace keys = web_navigation_api_constants;
+namespace web_navigation = api::web_navigation;
namespace web_navigation_api_helpers {
@@ -77,7 +79,7 @@ void DispatchOnBeforeNavigate(content::WebContents* web_contents,
args->Append(dict);
DispatchEvent(web_contents->GetBrowserContext(),
- keys::kOnBeforeNavigate,
+ web_navigation::OnBeforeNavigate::kEventName,
args.Pass(),
validated_url);
}
@@ -134,7 +136,7 @@ void DispatchOnDOMContentLoaded(content::WebContents* web_contents,
args->Append(dict);
DispatchEvent(web_contents->GetBrowserContext(),
- keys::kOnDOMContentLoaded,
+ web_navigation::OnDOMContentLoaded::kEventName,
args.Pass(),
url);
}
@@ -155,7 +157,8 @@ void DispatchOnCompleted(content::WebContents* web_contents,
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
args->Append(dict);
- DispatchEvent(web_contents->GetBrowserContext(), keys::kOnCompleted,
+ DispatchEvent(web_contents->GetBrowserContext(),
+ web_navigation::OnCompleted::kEventName,
args.Pass(), url);
}
@@ -188,7 +191,9 @@ void DispatchOnCreatedNavigationTarget(
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
args->Append(dict);
- DispatchEvent(browser_context, keys::kOnCreatedNavigationTarget, args.Pass(),
+ DispatchEvent(browser_context,
+ web_navigation::OnCreatedNavigationTarget::kEventName,
+ args.Pass(),
target_url);
}
@@ -206,10 +211,12 @@ void DispatchOnErrorOccurred(content::WebContents* web_contents,
dict->SetInteger(keys::kProcessIdKey, render_process_id);
dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id));
dict->SetString(keys::kErrorKey, net::ErrorToString(error_code));
- dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
+ dict->SetDouble(keys::kTimeStampKey,
+ MilliSecondsFromTime(base::Time::Now()));
args->Append(dict);
- DispatchEvent(web_contents->GetBrowserContext(), keys::kOnErrorOccurred,
+ DispatchEvent(web_contents->GetBrowserContext(),
+ web_navigation::OnErrorOccurred::kEventName,
args.Pass(), url);
}
@@ -222,12 +229,16 @@ void DispatchOnTabReplaced(
base::DictionaryValue* dict = new base::DictionaryValue();
dict->SetInteger(keys::kReplacedTabIdKey,
ExtensionTabUtil::GetTabId(old_web_contents));
- dict->SetInteger(keys::kTabIdKey,
- ExtensionTabUtil::GetTabId(new_web_contents));
+ dict->SetInteger(
+ keys::kTabIdKey,
+ ExtensionTabUtil::GetTabId(new_web_contents));
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
args->Append(dict);
- DispatchEvent(browser_context, keys::kOnTabReplaced, args.Pass(), GURL());
+ DispatchEvent(browser_context,
+ web_navigation::OnTabReplaced::kEventName,
+ args.Pass(),
+ GURL());
}
} // namespace web_navigation_api_helpers