summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
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
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')
-rw-r--r--chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc9
-rw-r--r--chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h1
-rw-r--r--chrome/browser/extensions/api/alarms/alarm_manager.cc8
-rw-r--r--chrome/browser/extensions/api/app_runtime/app_runtime_api.cc13
-rw-r--r--chrome/browser/extensions/api/audio/audio_api.cc6
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_api.cc3
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc14
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc5
-rw-r--r--chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc7
-rw-r--r--chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_constants.cc5
-rw-r--r--chrome/browser/extensions/api/bookmarks/bookmark_api_constants.cc8
-rw-r--r--chrome/browser/extensions/api/bookmarks/bookmarks_api.cc28
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_api.cc8
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_api_constants.cc3
-rw-r--r--chrome/browser/extensions/api/debugger/debugger_api.cc4
-rw-r--r--chrome/browser/extensions/api/debugger/debugger_api_constants.cc3
-rw-r--r--chrome/browser/extensions/api/developer_private/developer_private_api.cc9
-rw-r--r--chrome/browser/extensions/api/dial/dial_api.cc9
-rw-r--r--chrome/browser/extensions/api/downloads/downloads_api.cc138
-rw-r--r--chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc237
-rw-r--r--chrome/browser/extensions/api/feedback_private/feedback_private_api.cc23
-rw-r--r--chrome/browser/extensions/api/font_settings/font_settings_api.cc16
-rw-r--r--chrome/browser/extensions/api/history/history_api.cc12
-rw-r--r--chrome/browser/extensions/api/identity/web_auth_flow.cc5
-rw-r--r--chrome/browser/extensions/api/idle/idle_api_constants.cc2
-rw-r--r--chrome/browser/extensions/api/idle/idle_api_unittest.cc6
-rw-r--r--chrome/browser/extensions/api/idle/idle_manager.cc7
-rw-r--r--chrome/browser/extensions/api/input_ime/input_ime_api.cc55
-rw-r--r--chrome/browser/extensions/api/location/location_manager.cc4
-rw-r--r--chrome/browser/extensions/api/management/management_api.cc20
-rw-r--r--chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc24
-rw-r--r--chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.cc25
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc11
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc20
-rw-r--r--chrome/browser/extensions/api/notifications/notifications_api.cc10
-rw-r--r--chrome/browser/extensions/api/omnibox/omnibox_api.cc22
-rw-r--r--chrome/browser/extensions/api/push_messaging/push_messaging_api.cc3
-rw-r--r--chrome/browser/extensions/api/recovery_private/recovery_operation_manager.cc14
-rw-r--r--chrome/browser/extensions/api/rtc_private/rtc_private_api.cc9
-rw-r--r--chrome/browser/extensions/api/runtime/runtime_api.cc24
-rw-r--r--chrome/browser/extensions/api/storage/managed_value_store_cache.cc8
-rw-r--r--chrome/browser/extensions/api/storage/settings_frontend.cc4
-rw-r--r--chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc14
-rw-r--r--chrome/browser/extensions/api/system_indicator/system_indicator_manager.cc5
-rw-r--r--chrome/browser/extensions/api/system_info/system_info_api.cc17
-rw-r--r--chrome/browser/extensions/api/system_private/system_private_api.cc17
-rw-r--r--chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc7
-rw-r--r--chrome/browser/extensions/api/tabs/tabs_windows_api.cc10
-rw-r--r--chrome/browser/extensions/api/tabs/windows_event_router.cc13
-rw-r--r--chrome/browser/extensions/api/terminal/terminal_private_api.cc4
-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
-rw-r--r--chrome/browser/extensions/api/web_request/web_request_api.cc10
-rw-r--r--chrome/browser/extensions/api/web_request/web_request_api_constants.cc2
-rw-r--r--chrome/browser/extensions/api/web_request/web_request_api_unittest.cc14
-rw-r--r--chrome/browser/extensions/browser_event_router.cc29
-rw-r--r--chrome/browser/extensions/event_names.cc74
-rw-r--r--chrome/browser/extensions/event_names.h89
-rw-r--r--chrome/browser/extensions/menu_manager.cc5
-rw-r--r--chrome/browser/extensions/menu_manager_unittest.cc5
-rw-r--r--chrome/browser/extensions/permissions_updater.cc11
62 files changed, 537 insertions, 698 deletions
diff --git a/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc b/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc
index d9e03fb..f2e18eb 100644
--- a/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc
+++ b/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc
@@ -18,11 +18,12 @@
namespace extensions {
+namespace activity_log_private = api::activity_log_private;
+
using api::activity_log_private::ExtensionActivity;
const char kActivityLogExtensionId[] = "acldcpdepobcjbdanifkmfndkjoilgba";
const char kActivityLogTestExtensionId[] = "ajabfgledjhbabeoojlabelaifmakodf";
-const char kNewActivityEventName[] = "activityLogPrivate.onExtensionActivity";
static base::LazyInstance<ProfileKeyedAPIFactory<ActivityLogAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;
@@ -48,7 +49,7 @@ ActivityLogAPI::ActivityLogAPI(Profile* profile)
activity_log_ = extensions::ActivityLog::GetInstance(profile_);
DCHECK(activity_log_);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, kNewActivityEventName);
+ this, activity_log_private::OnExtensionActivity::kEventName);
activity_log_->AddObserver(this);
initialized_ = true;
}
@@ -84,7 +85,9 @@ void ActivityLogAPI::OnExtensionActivity(scoped_refptr<Action> activity) {
scoped_ptr<ExtensionActivity> activity_arg =
activity->ConvertToExtensionActivity();
value->Append(activity_arg->ToValue().release());
- scoped_ptr<Event> event(new Event(kNewActivityEventName, value.Pass()));
+ scoped_ptr<Event> event(
+ new Event(activity_log_private::OnExtensionActivity::kEventName,
+ value.Pass()));
event->restrict_to_profile = profile_;
ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(event.Pass());
}
diff --git a/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h b/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h
index ea74c1f..cab0ccf 100644
--- a/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h
+++ b/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h
@@ -24,7 +24,6 @@ class ActivityLog;
// The ID of the trusted/whitelisted ActivityLog extension.
extern const char kActivityLogExtensionId[];
extern const char kActivityLogTestExtensionId[];
-extern const char kNewActivityEventName[];
// Handles interactions between the Activity Log API and implementation.
class ActivityLogAPI : public ProfileKeyedAPI,
diff --git a/chrome/browser/extensions/api/alarms/alarm_manager.cc b/chrome/browser/extensions/api/alarms/alarm_manager.cc
index aa483ee..188fa3b 100644
--- a/chrome/browser/extensions/api/alarms/alarm_manager.cc
+++ b/chrome/browser/extensions/api/alarms/alarm_manager.cc
@@ -19,13 +19,14 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/state_store.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/alarms.h"
#include "content/public/browser/notification_service.h"
namespace extensions {
-namespace {
+namespace alarms = api::alarms;
-const char kOnAlarmEvent[] = "alarms.onAlarm";
+namespace {
// A list of alarms that this extension has set.
const char kRegisteredAlarms[] = "alarms";
@@ -43,7 +44,8 @@ class DefaultAlarmDelegate : public AlarmManager::Delegate {
const Alarm& alarm) OVERRIDE {
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(alarm.js_alarm->ToValue().release());
- scoped_ptr<Event> event(new Event(kOnAlarmEvent, args.Pass()));
+ scoped_ptr<Event> event(new Event(alarms::OnAlarm::kEventName,
+ args.Pass()));
ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension(
extension_id, event.Pass());
}
diff --git a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc b/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc
index 5b7bd40..b976dc7 100644
--- a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc
+++ b/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc
@@ -10,27 +10,27 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/app_runtime.h"
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/web_contents.h"
#include "url/gurl.h"
namespace extensions {
-namespace {
+namespace app_runtime = api::app_runtime;
-using event_names::kOnLaunched;
-using event_names::kOnRestarted;
+namespace {
void DispatchOnLaunchedEventImpl(const std::string& extension_id,
scoped_ptr<base::ListValue> args,
Profile* profile) {
extensions::ExtensionSystem* system =
extensions::ExtensionSystem::Get(profile);
- scoped_ptr<Event> event(new Event(kOnLaunched, args.Pass()));
+ scoped_ptr<Event> event(new Event(app_runtime::OnLaunched::kEventName,
+ args.Pass()));
event->restrict_to_profile = profile;
system->event_router()->DispatchEventWithLazyListener(extension_id,
event.Pass());
@@ -49,7 +49,8 @@ void AppEventRouter::DispatchOnLaunchedEvent(
void AppEventRouter::DispatchOnRestartedEvent(Profile* profile,
const Extension* extension) {
scoped_ptr<base::ListValue> arguments(new base::ListValue());
- scoped_ptr<Event> event(new Event(kOnRestarted, arguments.Pass()));
+ scoped_ptr<Event> event(new Event(app_runtime::OnRestarted::kEventName,
+ arguments.Pass()));
event->restrict_to_profile = profile;
extensions::ExtensionSystem::Get(profile)->event_router()->
DispatchEventToExtension(extension->id(), event.Pass());
diff --git a/chrome/browser/extensions/api/audio/audio_api.cc b/chrome/browser/extensions/api/audio/audio_api.cc
index b6c37fb..359b48d 100644
--- a/chrome/browser/extensions/api/audio/audio_api.cc
+++ b/chrome/browser/extensions/api/audio/audio_api.cc
@@ -6,12 +6,14 @@
#include "base/lazy_instance.h"
#include "base/values.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/common/extensions/api/audio.h"
namespace extensions {
+namespace audio = api::audio;
+
static base::LazyInstance<ProfileKeyedAPIFactory<AudioAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;
@@ -39,7 +41,7 @@ AudioService* AudioAPI::GetService() const {
void AudioAPI::OnDeviceChanged() {
if (profile_ && ExtensionSystem::Get(profile_)->event_router()) {
scoped_ptr<Event> event(new Event(
- event_names::kOnAudioDeviceChanged,
+ audio::OnDeviceChanged::kEventName,
scoped_ptr<base::ListValue>(new base::ListValue())));
ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(
event.Pass());
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
index 1d71950..9532f61 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
@@ -65,6 +65,7 @@ const char kStopDiscoveryFailed[] = "Failed to stop discovery";
} // namespace
namespace AddProfile = extensions::api::bluetooth::AddProfile;
+namespace bluetooth = extensions::api::bluetooth;
namespace Connect = extensions::api::bluetooth::Connect;
namespace Disconnect = extensions::api::bluetooth::Disconnect;
namespace GetDevices = extensions::api::bluetooth::GetDevices;
@@ -85,7 +86,7 @@ BluetoothAPI* BluetoothAPI::Get(Profile* profile) {
BluetoothAPI::BluetoothAPI(Profile* profile) : profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, extensions::event_names::kBluetoothOnAdapterStateChanged);
+ this, bluetooth::OnAdapterStateChanged::kEventName);
}
BluetoothAPI::~BluetoothAPI() {
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc
index 5147a7b..5162892 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc
@@ -26,6 +26,8 @@
namespace extensions {
+namespace bluetooth = api::bluetooth;
+
ExtensionBluetoothEventRouter::ExtensionBluetoothEventRouter(Profile* profile)
: send_discovery_events_(false),
responsible_for_discovery_(false),
@@ -161,7 +163,7 @@ void ExtensionBluetoothEventRouter::SetSendDiscoveryEvents(bool should_send) {
}
void ExtensionBluetoothEventRouter::DispatchDeviceEvent(
- const char* event_name, const extensions::api::bluetooth::Device& device) {
+ const char* event_name, const bluetooth::Device& device) {
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(device.ToValue().release());
scoped_ptr<Event> event(new Event(event_name, args.Pass()));
@@ -185,7 +187,7 @@ void ExtensionBluetoothEventRouter::DispatchConnectionEvent(
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(result_socket.ToValue().release());
scoped_ptr<Event> event(new Event(
- extensions::event_names::kBluetoothOnConnection, args.Pass()));
+ bluetooth::OnConnection::kEventName, args.Pass()));
ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension(
extension_id, event.Pass());
}
@@ -232,9 +234,9 @@ void ExtensionBluetoothEventRouter::DeviceAdded(
return;
}
- extensions::api::bluetooth::Device* extension_device =
- new extensions::api::bluetooth::Device();
- extensions::api::bluetooth::BluetoothDeviceToApiDevice(
+ bluetooth::Device* extension_device =
+ new bluetooth::Device();
+ bluetooth::BluetoothDeviceToApiDevice(
*device, extension_device);
discovered_devices_.push_back(extension_device);
@@ -274,7 +276,7 @@ void ExtensionBluetoothEventRouter::DispatchAdapterStateEvent() {
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(state.ToValue().release());
scoped_ptr<Event> event(new Event(
- extensions::event_names::kBluetoothOnAdapterStateChanged,
+ bluetooth::OnAdapterStateChanged::kEventName,
args.Pass()));
ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(event.Pass());
}
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc
index 60b830a..39d3908 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router_unittest.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/test_extension_system.h"
+#include "chrome/common/extensions/api/bluetooth.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread.h"
#include "device/bluetooth/test/mock_bluetooth_adapter.h"
@@ -79,6 +80,8 @@ BrowserContextKeyedService* BuildFakeExtensionSystem(
namespace extensions {
+namespace bluetooth = api::bluetooth;
+
class ExtensionBluetoothEventRouterTest : public testing::Test {
public:
ExtensionBluetoothEventRouterTest()
@@ -166,7 +169,7 @@ TEST_F(ExtensionBluetoothEventRouterTest, DispatchConnectionEvent) {
static_cast<FakeEventRouter*>(fake_extension_system->event_router());
EXPECT_STREQ(test_extension_id, fake_event_router->extension_id().c_str());
- EXPECT_STREQ(event_names::kBluetoothOnConnection,
+ EXPECT_STREQ(bluetooth::OnConnection::kEventName,
fake_event_router->event()->event_name.c_str());
base::ListValue* event_args = fake_event_router->event()->event_args.get();
diff --git a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc
index 9d25e6c..62ca111 100644
--- a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc
+++ b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc
@@ -42,6 +42,7 @@
namespace extensions {
namespace bookmark_keys = bookmark_api_constants;
+namespace bookmark_manager_private = api::bookmark_manager_private;
namespace CanPaste = api::bookmark_manager_private::CanPaste;
namespace Copy = api::bookmark_manager_private::Copy;
namespace Cut = api::bookmark_manager_private::Cut;
@@ -198,7 +199,7 @@ void BookmarkManagerPrivateEventRouter::DispatchDragEvent(
void BookmarkManagerPrivateEventRouter::OnDragEnter(
const BookmarkNodeData& data) {
- DispatchDragEvent(data, manager_keys::kOnBookmarkDragEnter);
+ DispatchDragEvent(data, bookmark_manager_private::OnDragEnter::kEventName);
}
void BookmarkManagerPrivateEventRouter::OnDragOver(
@@ -209,11 +210,11 @@ void BookmarkManagerPrivateEventRouter::OnDragOver(
void BookmarkManagerPrivateEventRouter::OnDragLeave(
const BookmarkNodeData& data) {
- DispatchDragEvent(data, manager_keys::kOnBookmarkDragLeave);
+ DispatchDragEvent(data, bookmark_manager_private::OnDragLeave::kEventName);
}
void BookmarkManagerPrivateEventRouter::OnDrop(const BookmarkNodeData& data) {
- DispatchDragEvent(data, manager_keys::kOnBookmarkDrop);
+ DispatchDragEvent(data, bookmark_manager_private::OnDrop::kEventName);
// Make a copy that is owned by this instance.
ClearBookmarkNodeData();
diff --git a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_constants.cc b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_constants.cc
index d7f7b4e..7818494 100644
--- a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_constants.cc
+++ b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_constants.cc
@@ -11,10 +11,5 @@ namespace bookmark_manager_api_constants {
const char kSameProfileKey[] = "sameProfile";
const char kElementsKey[] = "elements";
-// Events.
-const char kOnBookmarkDragEnter[] = "bookmarkManagerPrivate.onDragEnter";
-const char kOnBookmarkDragLeave[] = "bookmarkManagerPrivate.onDragLeave";
-const char kOnBookmarkDrop[] = "bookmarkManagerPrivate.onDrop";
-
} // namespace bookmark_manager_api_constants
} // namespace extensions
diff --git a/chrome/browser/extensions/api/bookmarks/bookmark_api_constants.cc b/chrome/browser/extensions/api/bookmarks/bookmark_api_constants.cc
index 32a03f2..b2bc4ad 100644
--- a/chrome/browser/extensions/api/bookmarks/bookmark_api_constants.cc
+++ b/chrome/browser/extensions/api/bookmarks/bookmark_api_constants.cc
@@ -30,13 +30,5 @@ const char kInvalidUrlError[] = "Invalid URL.";
const char kModifySpecialError[] = "Can't modify the root bookmark folders.";
const char kEditBookmarksDisabled[] = "Bookmark editing is disabled.";
-const char kOnBookmarkCreated[] = "bookmarks.onCreated";
-const char kOnBookmarkRemoved[] = "bookmarks.onRemoved";
-const char kOnBookmarkChanged[] = "bookmarks.onChanged";
-const char kOnBookmarkMoved[] = "bookmarks.onMoved";
-const char kOnBookmarkChildrenReordered[] = "bookmarks.onChildrenReordered";
-const char kOnBookmarkImportBegan[] = "bookmarks.onImportBegan";
-const char kOnBookmarkImportEnded[] = "bookmarks.onImportEnded";
-
} // namespace bookmark_api_constants
} // namespace extensions
diff --git a/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc b/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc
index a6a2d2a..f64299c 100644
--- a/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc
+++ b/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc
@@ -189,7 +189,7 @@ void BookmarkEventRouter::BookmarkNodeMoved(BookmarkModel* model,
object_args->SetInteger(keys::kOldIndexKey, old_index);
args->Append(object_args);
- DispatchEvent(keys::kOnBookmarkMoved, args.Pass());
+ DispatchEvent(bookmarks::OnMoved::kEventName, args.Pass());
}
void BookmarkEventRouter::BookmarkNodeAdded(BookmarkModel* model,
@@ -202,7 +202,7 @@ void BookmarkEventRouter::BookmarkNodeAdded(BookmarkModel* model,
bookmark_api_helpers::GetBookmarkTreeNode(node, false, false));
args->Append(tree_node->ToValue().release());
- DispatchEvent(keys::kOnBookmarkCreated, args.Pass());
+ DispatchEvent(bookmarks::OnCreated::kEventName, args.Pass());
}
void BookmarkEventRouter::BookmarkNodeRemoved(BookmarkModel* model,
@@ -217,7 +217,7 @@ void BookmarkEventRouter::BookmarkNodeRemoved(BookmarkModel* model,
object_args->SetInteger(keys::kIndexKey, index);
args->Append(object_args);
- DispatchEvent(keys::kOnBookmarkRemoved, args.Pass());
+ DispatchEvent(bookmarks::OnRemoved::kEventName, args.Pass());
}
void BookmarkEventRouter::BookmarkAllNodesRemoved(BookmarkModel* model) {
@@ -243,7 +243,7 @@ void BookmarkEventRouter::BookmarkNodeChanged(BookmarkModel* model,
object_args->SetString(keys::kUrlKey, node->url().spec());
args->Append(object_args);
- DispatchEvent(keys::kOnBookmarkChanged, args.Pass());
+ DispatchEvent(bookmarks::OnChanged::kEventName, args.Pass());
}
void BookmarkEventRouter::BookmarkNodeFaviconChanged(BookmarkModel* model,
@@ -268,35 +268,35 @@ void BookmarkEventRouter::BookmarkNodeChildrenReordered(
reorder_info->Set(keys::kChildIdsKey, children);
args->Append(reorder_info);
- DispatchEvent(keys::kOnBookmarkChildrenReordered, args.Pass());
+ DispatchEvent(bookmarks::OnChildrenReordered::kEventName, args.Pass());
}
void BookmarkEventRouter::ExtensiveBookmarkChangesBeginning(
BookmarkModel* model) {
scoped_ptr<base::ListValue> args(new base::ListValue());
- DispatchEvent(keys::kOnBookmarkImportBegan, args.Pass());
+ DispatchEvent(bookmarks::OnImportBegan::kEventName, args.Pass());
}
void BookmarkEventRouter::ExtensiveBookmarkChangesEnded(BookmarkModel* model) {
scoped_ptr<base::ListValue> args(new base::ListValue());
- DispatchEvent(keys::kOnBookmarkImportEnded, args.Pass());
+ DispatchEvent(bookmarks::OnImportEnded::kEventName, args.Pass());
}
BookmarksAPI::BookmarksAPI(Profile* profile) : profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnBookmarkCreated);
+ this, bookmarks::OnCreated::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnBookmarkRemoved);
+ this, bookmarks::OnRemoved::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnBookmarkChanged);
+ this, bookmarks::OnChanged::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnBookmarkMoved);
+ this, bookmarks::OnMoved::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnBookmarkChildrenReordered);
+ this, bookmarks::OnChildrenReordered::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnBookmarkImportBegan);
+ this, bookmarks::OnImportBegan::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnBookmarkImportEnded);
+ this, bookmarks::OnImportEnded::kEventName);
}
BookmarksAPI::~BookmarksAPI() {
diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc
index afeaf8e..079be55 100644
--- a/chrome/browser/extensions/api/cookies/cookies_api.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_api.cc
@@ -46,6 +46,7 @@ namespace Remove = extensions::api::cookies::Remove;
namespace Set = extensions::api::cookies::Set;
namespace extensions {
+namespace cookies = api::cookies;
namespace keys = cookies_api_constants;
CookiesEventRouter::CookiesEventRouter(Profile* profile)
@@ -123,7 +124,10 @@ void CookiesEventRouter::CookieChanged(
GURL cookie_domain =
cookies_helpers::GetURLFromCanonicalCookie(*details->cookie);
- DispatchEvent(profile, keys::kOnChanged, args.Pass(), cookie_domain);
+ DispatchEvent(profile,
+ cookies::OnChanged::kEventName,
+ args.Pass(),
+ cookie_domain);
}
void CookiesEventRouter::DispatchEvent(
@@ -557,7 +561,7 @@ void CookiesGetAllCookieStoresFunction::Run() {
CookiesAPI::CookiesAPI(Profile* profile)
: profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, keys::kOnChanged);
+ this, cookies::OnChanged::kEventName);
}
CookiesAPI::~CookiesAPI() {
diff --git a/chrome/browser/extensions/api/cookies/cookies_api_constants.cc b/chrome/browser/extensions/api/cookies/cookies_api_constants.cc
index ebbde77..58876b8 100644
--- a/chrome/browser/extensions/api/cookies/cookies_api_constants.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_api_constants.cc
@@ -22,9 +22,6 @@ extern const char kExpiredOverwriteChangeCause[] = "expired_overwrite";
extern const char kExplicitChangeCause[] = "explicit";
extern const char kOverwriteChangeCause[] = "overwrite";
-// Events
-const char kOnChanged[] = "cookies.onChanged";
-
// Errors
const char kCookieSetFailedError[] =
"Failed to parse or set cookie named \"*\".";
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc
index fd06dda..b2ca4c1 100644
--- a/chrome/browser/extensions/api/debugger/debugger_api.cc
+++ b/chrome/browser/extensions/api/debugger/debugger_api.cc
@@ -398,7 +398,7 @@ void ExtensionDevToolsClientHost::SendDetachedEvent() {
scoped_ptr<base::ListValue> args(OnDetach::Create(debuggee_,
detach_reason_));
scoped_ptr<extensions::Event> event(new extensions::Event(
- keys::kOnDetach, args.Pass()));
+ OnDetach::kEventName, args.Pass()));
event->restrict_to_profile = profile_;
extensions::ExtensionSystem::Get(profile_)->event_router()->
DispatchEventToExtension(extension_id_, event.Pass());
@@ -448,7 +448,7 @@ void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend(
scoped_ptr<ListValue> args(OnEvent::Create(debuggee_, method_name, params));
scoped_ptr<extensions::Event> event(new extensions::Event(
- keys::kOnEvent, args.Pass()));
+ OnEvent::kEventName, args.Pass()));
event->restrict_to_profile = profile_;
extensions::ExtensionSystem::Get(profile_)->event_router()->
DispatchEventToExtension(extension_id_, event.Pass());
diff --git a/chrome/browser/extensions/api/debugger/debugger_api_constants.cc b/chrome/browser/extensions/api/debugger/debugger_api_constants.cc
index a9f5c6e..70da45b 100644
--- a/chrome/browser/extensions/api/debugger/debugger_api_constants.cc
+++ b/chrome/browser/extensions/api/debugger/debugger_api_constants.cc
@@ -6,9 +6,6 @@
namespace debugger_api_constants {
-const char kOnEvent[] = "debugger.onEvent";
-const char kOnDetach[] = "debugger.onDetach";
-
const char kAlreadyAttachedError[] =
"Another debugger is already attached to the * with id: *.";
const char kAttachToWebUIError[] =
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index 6c144fb..b5fa594 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/extensions/api/developer_private/developer_private_api_factory.h"
#include "chrome/browser/extensions/api/developer_private/entry_picker.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/extension_disabled_ui.h"
#include "chrome/browser/extensions/extension_error_reporter.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -72,7 +71,7 @@ using content::RenderViewHost;
namespace extensions {
-namespace events = event_names;
+namespace developer_private = api::developer_private;
namespace {
@@ -212,7 +211,7 @@ void DeveloperPrivateEventRouter::Observe(
scoped_ptr<ListValue> args(new ListValue());
args->Append(event_data.ToValue().release());
- event_name = events::kDeveloperPrivateOnItemStateChanged;
+ event_name = developer_private::OnItemStateChanged::kEventName;
scoped_ptr<Event> event(new Event(event_name, args.Pass()));
ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass());
}
@@ -223,7 +222,7 @@ void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) {
void DeveloperPrivateAPI::RegisterNotifications() {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, events::kDeveloperPrivateOnItemStateChanged);
+ this, developer_private::OnItemStateChanged::kEventName);
}
DeveloperPrivateAPI::~DeveloperPrivateAPI() {}
@@ -240,7 +239,7 @@ void DeveloperPrivateAPI::OnListenerAdded(
void DeveloperPrivateAPI::OnListenerRemoved(
const EventListenerInfo& details) {
if (!ExtensionSystem::Get(profile_)->event_router()->HasEventListener(
- event_names::kDeveloperPrivateOnItemStateChanged))
+ developer_private::OnItemStateChanged::kEventName))
developer_private_event_router_.reset(NULL);
}
diff --git a/chrome/browser/extensions/api/dial/dial_api.cc b/chrome/browser/extensions/api/dial/dial_api.cc
index 02f6d82..062fc6f 100644
--- a/chrome/browser/extensions/api/dial/dial_api.cc
+++ b/chrome/browser/extensions/api/dial/dial_api.cc
@@ -8,7 +8,6 @@
#include "base/time/time.h"
#include "chrome/browser/extensions/api/dial/dial_api_factory.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
@@ -35,11 +34,13 @@ const size_t kDialMaxDevices = 256;
namespace extensions {
+namespace dial = api::dial;
+
DialAPI::DialAPI(Profile* profile)
: RefcountedBrowserContextKeyedService(BrowserThread::IO),
profile_(profile) {
ExtensionSystem::Get(profile)->event_router()->RegisterObserver(
- this, extensions::event_names::kOnDialDeviceList);
+ this, dial::OnDeviceList::kEventName);
}
DialAPI::~DialAPI() {}
@@ -106,7 +107,7 @@ void DialAPI::SendEventOnUIThread(const DialRegistry::DeviceList& devices) {
}
scoped_ptr<base::ListValue> results = api::dial::OnDeviceList::Create(args);
scoped_ptr<Event> event(
- new Event(event_names::kOnDialDeviceList, results.Pass()));
+ new Event(dial::OnDeviceList::kEventName, results.Pass()));
extensions::ExtensionSystem::Get(profile_)->event_router()->
BroadcastEvent(event.Pass());
}
@@ -137,7 +138,7 @@ void DialAPI::SendErrorOnUIThread(const DialRegistry::DialErrorCode code) {
}
scoped_ptr<base::ListValue> results = api::dial::OnError::Create(dial_error);
- scoped_ptr<Event> event(new Event(event_names::kOnDialError, results.Pass()));
+ scoped_ptr<Event> event(new Event(dial::OnError::kEventName, results.Pass()));
extensions::ExtensionSystem::Get(profile_)->event_router()->
BroadcastEvent(event.Pass());
}
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc
index 7cc8a48..aeeac02 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -38,7 +38,6 @@
#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/download/download_stats.h"
#include "chrome/browser/download/download_util.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/extensions/extension_info_map.h"
@@ -79,8 +78,6 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/webui/web_ui_util.h"
-namespace events = extensions::event_names;
-
using content::BrowserContext;
using content::BrowserThread;
using content::DownloadItem;
@@ -121,6 +118,8 @@ namespace errors = download_extension_errors;
namespace {
+namespace downloads = extensions::api::downloads;
+
// Default icon size for getFileIcon() in pixels.
const int kDefaultIconSize = 32;
@@ -476,7 +475,7 @@ void CompileDownloadQueryOrderBy(
}
void RunDownloadQuery(
- const extensions::api::downloads::DownloadQuery& query_in,
+ const downloads::DownloadQuery& query_in,
DownloadManager* manager,
DownloadManager* incognito_manager,
std::string* error,
@@ -503,7 +502,7 @@ void RunDownloadQuery(
}
std::string state_string =
- extensions::api::downloads::ToString(query_in.state);
+ downloads::ToString(query_in.state);
if (!state_string.empty()) {
DownloadItem::DownloadState state = StateEnumFromString(state_string);
if (state == DownloadItem::MAX_DOWNLOAD_STATE) {
@@ -513,7 +512,7 @@ void RunDownloadQuery(
query_out.AddFilter(state);
}
std::string danger_string =
- extensions::api::downloads::ToString(query_in.danger);
+ downloads::ToString(query_in.danger);
if (!danger_string.empty()) {
content::DownloadDangerType danger_type = DangerEnumFromString(
danger_string);
@@ -559,14 +558,14 @@ void RunDownloadQuery(
}
DownloadPathReservationTracker::FilenameConflictAction ConvertConflictAction(
- extensions::api::downloads::FilenameConflictAction action) {
+ downloads::FilenameConflictAction action) {
switch (action) {
- case extensions::api::downloads::FILENAME_CONFLICT_ACTION_NONE:
- case extensions::api::downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY:
+ case downloads::FILENAME_CONFLICT_ACTION_NONE:
+ case downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY:
return DownloadPathReservationTracker::UNIQUIFY;
- case extensions::api::downloads::FILENAME_CONFLICT_ACTION_OVERWRITE:
+ case downloads::FILENAME_CONFLICT_ACTION_OVERWRITE:
return DownloadPathReservationTracker::OVERWRITE;
- case extensions::api::downloads::FILENAME_CONFLICT_ACTION_PROMPT:
+ case downloads::FILENAME_CONFLICT_ACTION_PROMPT:
return DownloadPathReservationTracker::PROMPT;
}
NOTREACHED();
@@ -592,9 +591,9 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
changed_fired_(0),
json_(json_item.Pass()),
creator_conflict_action_(
- extensions::api::downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY),
+ downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY),
determined_conflict_action_(
- extensions::api::downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY) {
+ downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
download_item->SetUserData(kKey, this);
}
@@ -630,7 +629,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
determined_filename_.clear();
determined_conflict_action_ =
- extensions::api::downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY;
+ downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY;
determiner_ = DeterminerInfo();
filename_no_change_ = base::Closure();
filename_change_ = ExtensionDownloadsEventRouter::FilenameChangedCallback();
@@ -677,7 +676,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
void CreatorSuggestedFilename(
const base::FilePath& filename,
- extensions::api::downloads::FilenameConflictAction conflict_action) {
+ downloads::FilenameConflictAction conflict_action) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
creator_suggested_filename_ = filename;
creator_conflict_action_ = conflict_action;
@@ -687,7 +686,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
return creator_suggested_filename_;
}
- extensions::api::downloads::FilenameConflictAction
+ downloads::FilenameConflictAction
creator_conflict_action() const {
return creator_conflict_action_;
}
@@ -696,7 +695,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
creator_suggested_filename_.clear();
creator_conflict_action_ =
- extensions::api::downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY;
+ downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY;
}
// Returns false if this |extension_id| was not expected or if this
@@ -706,7 +705,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
Profile* profile,
const std::string& extension_id,
const base::FilePath& filename,
- extensions::api::downloads::FilenameConflictAction conflict_action) {
+ downloads::FilenameConflictAction conflict_action) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
bool found_info = false;
for (size_t index = 0; index < determiners_.size(); ++index) {
@@ -803,10 +802,10 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
DeterminerInfoVector determiners_;
base::FilePath creator_suggested_filename_;
- extensions::api::downloads::FilenameConflictAction
+ downloads::FilenameConflictAction
creator_conflict_action_;
base::FilePath determined_filename_;
- extensions::api::downloads::FilenameConflictAction
+ downloads::FilenameConflictAction
determined_conflict_action_;
DeterminerInfo determiner_;
@@ -957,10 +956,10 @@ DownloadsDownloadFunction::DownloadsDownloadFunction() {}
DownloadsDownloadFunction::~DownloadsDownloadFunction() {}
bool DownloadsDownloadFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::Download::Params> params(
- extensions::api::downloads::Download::Params::Create(*args_));
+ scoped_ptr<downloads::Download::Params> params(
+ downloads::Download::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- const extensions::api::downloads::DownloadOptions& options = params->options;
+ const downloads::DownloadOptions& options = params->options;
GURL download_url(options.url);
if (Fault(!download_url.is_valid(), errors::kInvalidURL, &error_))
return false;
@@ -1000,7 +999,7 @@ bool DownloadsDownloadFunction::RunImpl() {
download_params->set_prompt(*options.save_as.get());
if (options.headers.get()) {
- typedef extensions::api::downloads::HeaderNameValuePair HeaderNameValuePair;
+ typedef downloads::HeaderNameValuePair HeaderNameValuePair;
for (std::vector<linked_ptr<HeaderNameValuePair> >::const_iterator iter =
options.headers->begin();
iter != options.headers->end();
@@ -1015,7 +1014,7 @@ bool DownloadsDownloadFunction::RunImpl() {
}
std::string method_string =
- extensions::api::downloads::ToString(options.method);
+ downloads::ToString(options.method);
if (!method_string.empty())
download_params->set_method(method_string);
if (options.body.get())
@@ -1036,7 +1035,7 @@ bool DownloadsDownloadFunction::RunImpl() {
void DownloadsDownloadFunction::OnStarted(
const base::FilePath& creator_suggested_filename,
- extensions::api::downloads::FilenameConflictAction creator_conflict_action,
+ downloads::FilenameConflictAction creator_conflict_action,
DownloadItem* item,
net::Error error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -1070,8 +1069,8 @@ DownloadsSearchFunction::DownloadsSearchFunction() {}
DownloadsSearchFunction::~DownloadsSearchFunction() {}
bool DownloadsSearchFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::Search::Params> params(
- extensions::api::downloads::Search::Params::Create(*args_));
+ scoped_ptr<downloads::Search::Params> params(
+ downloads::Search::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadManager* manager = NULL;
DownloadManager* incognito_manager = NULL;
@@ -1109,8 +1108,8 @@ DownloadsPauseFunction::DownloadsPauseFunction() {}
DownloadsPauseFunction::~DownloadsPauseFunction() {}
bool DownloadsPauseFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::Pause::Params> params(
- extensions::api::downloads::Pause::Params::Create(*args_));
+ scoped_ptr<downloads::Pause::Params> params(
+ downloads::Pause::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item = GetDownload(
profile(), include_incognito(), params->download_id);
@@ -1130,8 +1129,8 @@ DownloadsResumeFunction::DownloadsResumeFunction() {}
DownloadsResumeFunction::~DownloadsResumeFunction() {}
bool DownloadsResumeFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::Resume::Params> params(
- extensions::api::downloads::Resume::Params::Create(*args_));
+ scoped_ptr<downloads::Resume::Params> params(
+ downloads::Resume::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item = GetDownload(
profile(), include_incognito(), params->download_id);
@@ -1151,8 +1150,8 @@ DownloadsCancelFunction::DownloadsCancelFunction() {}
DownloadsCancelFunction::~DownloadsCancelFunction() {}
bool DownloadsCancelFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::Resume::Params> params(
- extensions::api::downloads::Resume::Params::Create(*args_));
+ scoped_ptr<downloads::Resume::Params> params(
+ downloads::Resume::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item = GetDownload(
profile(), include_incognito(), params->download_id);
@@ -1170,8 +1169,8 @@ DownloadsEraseFunction::DownloadsEraseFunction() {}
DownloadsEraseFunction::~DownloadsEraseFunction() {}
bool DownloadsEraseFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::Erase::Params> params(
- extensions::api::downloads::Erase::Params::Create(*args_));
+ scoped_ptr<downloads::Erase::Params> params(
+ downloads::Erase::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadManager* manager = NULL;
DownloadManager* incognito_manager = NULL;
@@ -1206,8 +1205,8 @@ DownloadsRemoveFileFunction::~DownloadsRemoveFileFunction() {
}
bool DownloadsRemoveFileFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::RemoveFile::Params> params(
- extensions::api::downloads::RemoveFile::Params::Create(*args_));
+ scoped_ptr<downloads::RemoveFile::Params> params(
+ downloads::RemoveFile::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item = GetDownload(
profile(), include_incognito(), params->download_id);
@@ -1247,8 +1246,8 @@ DownloadsAcceptDangerFunction::DownloadsAcceptDangerFunction() {}
DownloadsAcceptDangerFunction::~DownloadsAcceptDangerFunction() {}
bool DownloadsAcceptDangerFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::AcceptDanger::Params> params(
- extensions::api::downloads::AcceptDanger::Params::Create(*args_));
+ scoped_ptr<downloads::AcceptDanger::Params> params(
+ downloads::AcceptDanger::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item = GetDownload(
profile(), include_incognito(), params->download_id);
@@ -1300,8 +1299,8 @@ DownloadsShowFunction::DownloadsShowFunction() {}
DownloadsShowFunction::~DownloadsShowFunction() {}
bool DownloadsShowFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::Show::Params> params(
- extensions::api::downloads::Show::Params::Create(*args_));
+ scoped_ptr<downloads::Show::Params> params(
+ downloads::Show::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item = GetDownload(
profile(), include_incognito(), params->download_id);
@@ -1331,8 +1330,8 @@ DownloadsOpenFunction::DownloadsOpenFunction() {}
DownloadsOpenFunction::~DownloadsOpenFunction() {}
bool DownloadsOpenFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::Open::Params> params(
- extensions::api::downloads::Open::Params::Create(*args_));
+ scoped_ptr<downloads::Open::Params> params(
+ downloads::Open::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item = GetDownload(
profile(), include_incognito(), params->download_id);
@@ -1353,8 +1352,8 @@ DownloadsDragFunction::DownloadsDragFunction() {}
DownloadsDragFunction::~DownloadsDragFunction() {}
bool DownloadsDragFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::Drag::Params> params(
- extensions::api::downloads::Drag::Params::Create(*args_));
+ scoped_ptr<downloads::Drag::Params> params(
+ downloads::Drag::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item = GetDownload(
profile(), include_incognito(), params->download_id);
@@ -1381,8 +1380,8 @@ DownloadsSetShelfEnabledFunction::DownloadsSetShelfEnabledFunction() {}
DownloadsSetShelfEnabledFunction::~DownloadsSetShelfEnabledFunction() {}
bool DownloadsSetShelfEnabledFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::SetShelfEnabled::Params> params(
- extensions::api::downloads::SetShelfEnabled::Params::Create(*args_));
+ scoped_ptr<downloads::SetShelfEnabled::Params> params(
+ downloads::SetShelfEnabled::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
if (!GetExtension()->HasAPIPermission(
extensions::APIPermission::kDownloadsShelf)) {
@@ -1447,10 +1446,10 @@ void DownloadsGetFileIconFunction::SetIconExtractorForTesting(
}
bool DownloadsGetFileIconFunction::RunImpl() {
- scoped_ptr<extensions::api::downloads::GetFileIcon::Params> params(
- extensions::api::downloads::GetFileIcon::Params::Create(*args_));
+ scoped_ptr<downloads::GetFileIcon::Params> params(
+ downloads::GetFileIcon::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- const extensions::api::downloads::GetFileIconOptions* options =
+ const downloads::GetFileIconOptions* options =
params->options.get();
int icon_size = kDefaultIconSize;
if (options && options->size.get())
@@ -1496,7 +1495,8 @@ ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter(
extensions::EventRouter* router = extensions::ExtensionSystem::Get(profile_)->
event_router();
if (router)
- router->RegisterObserver(this, events::kOnDownloadDeterminingFilename);
+ router->RegisterObserver(this,
+ downloads::OnDeterminingFilename::kEventName);
}
ExtensionDownloadsEventRouter::~ExtensionDownloadsEventRouter() {
@@ -1566,7 +1566,7 @@ void ExtensionDownloadsEventRouter::OnDeterminingFilename(
base::DictionaryValue* json = DownloadItemToJSON(
item, profile_).release();
json->SetString(kFilenameKey, suggested_path.LossyDisplayName());
- DispatchEvent(events::kOnDownloadDeterminingFilename,
+ DispatchEvent(downloads::OnDeterminingFilename::kEventName,
false,
base::Bind(&OnDeterminingFilenameWillDispatchCallback,
&any_determiners,
@@ -1587,14 +1587,14 @@ void ExtensionDownloadsEventRouter::OnDeterminingFilename(
void ExtensionDownloadsEventRouter::DetermineFilenameInternal(
const base::FilePath& filename,
- extensions::api::downloads::FilenameConflictAction conflict_action,
+ downloads::FilenameConflictAction conflict_action,
const std::string& suggesting_extension_id,
const base::Time& suggesting_install_time,
const std::string& incumbent_extension_id,
const base::Time& incumbent_install_time,
std::string* winner_extension_id,
base::FilePath* determined_filename,
- extensions::api::downloads::FilenameConflictAction*
+ downloads::FilenameConflictAction*
determined_conflict_action,
extensions::ExtensionWarningSet* warnings) {
DCHECK(!filename.empty());
@@ -1635,7 +1635,7 @@ bool ExtensionDownloadsEventRouter::DetermineFilename(
const std::string& ext_id,
int download_id,
const base::FilePath& const_filename,
- extensions::api::downloads::FilenameConflictAction conflict_action,
+ downloads::FilenameConflictAction conflict_action,
std::string* error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DownloadItem* item = GetDownload(profile, include_incognito, download_id);
@@ -1678,12 +1678,12 @@ void ExtensionDownloadsEventRouter::OnListenerRemoved(
if (!manager)
return;
bool determiner_removed = (
- details.event_name == events::kOnDownloadDeterminingFilename);
+ details.event_name == downloads::OnDeterminingFilename::kEventName);
extensions::EventRouter* router = extensions::ExtensionSystem::Get(profile_)->
event_router();
bool any_listeners =
- router->HasEventListener(events::kOnDownloadChanged) ||
- router->HasEventListener(events::kOnDownloadDeterminingFilename);
+ router->HasEventListener(downloads::OnChanged::kEventName) ||
+ router->HasEventListener(downloads::OnDeterminingFilename::kEventName);
if (!determiner_removed && any_listeners)
return;
DownloadManager::DownloadVector items;
@@ -1724,20 +1724,22 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated(
// Avoid allocating a bunch of memory in DownloadItemToJSON if it isn't going
// to be used.
if (!router ||
- (!router->HasEventListener(events::kOnDownloadCreated) &&
- !router->HasEventListener(events::kOnDownloadChanged) &&
- !router->HasEventListener(events::kOnDownloadDeterminingFilename))) {
+ (!router->HasEventListener(downloads::OnCreated::kEventName) &&
+ !router->HasEventListener(downloads::OnChanged::kEventName) &&
+ !router->HasEventListener(
+ downloads::OnDeterminingFilename::kEventName))) {
return;
}
scoped_ptr<base::DictionaryValue> json_item(
DownloadItemToJSON(download_item, profile_));
- DispatchEvent(events::kOnDownloadCreated,
+ DispatchEvent(downloads::OnCreated::kEventName,
true,
extensions::Event::WillDispatchCallback(),
json_item->DeepCopy());
if (!ExtensionDownloadsEventRouterData::Get(download_item) &&
- (router->HasEventListener(events::kOnDownloadChanged) ||
- router->HasEventListener(events::kOnDownloadDeterminingFilename))) {
+ (router->HasEventListener(downloads::OnChanged::kEventName) ||
+ router->HasEventListener(
+ downloads::OnDeterminingFilename::kEventName))) {
new ExtensionDownloadsEventRouterData(download_item, json_item.Pass());
}
}
@@ -1750,7 +1752,7 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(
ExtensionDownloadsEventRouterData* data =
ExtensionDownloadsEventRouterData::Get(download_item);
if (download_item->IsTemporary() ||
- !router->HasEventListener(events::kOnDownloadChanged)) {
+ !router->HasEventListener(downloads::OnChanged::kEventName)) {
return;
}
if (!data) {
@@ -1803,7 +1805,7 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(
// changed. Replace the stored json with the new json.
data->OnItemUpdated();
if (changed) {
- DispatchEvent(events::kOnDownloadChanged,
+ DispatchEvent(downloads::OnChanged::kEventName,
true,
extensions::Event::WillDispatchCallback(),
delta.release());
@@ -1817,7 +1819,7 @@ void ExtensionDownloadsEventRouter::OnDownloadRemoved(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (download_item->IsTemporary())
return;
- DispatchEvent(events::kOnDownloadErased,
+ DispatchEvent(downloads::OnErased::kEventName,
true,
extensions::Event::WillDispatchCallback(),
new base::FundamentalValue(
diff --git a/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc b/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
index e5962af..98c5f48 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_test_file_activity_observer.h"
#include "chrome/browser/extensions/api/downloads/downloads_api.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -58,8 +57,6 @@ using content::DownloadItem;
using content::DownloadManager;
using content::URLRequestSlowDownloadJob;
-namespace events = extensions::event_names;
-
namespace errors = download_extension_errors;
namespace api = extensions::api::downloads;
@@ -116,9 +113,9 @@ class DownloadsEventsListener : public content::NotificationObserver {
if ((profile_ != other.profile_) ||
(event_name_ != other.event_name_))
return false;
- if (((event_name_ == events::kOnDownloadDeterminingFilename) ||
- (event_name_ == events::kOnDownloadCreated) ||
- (event_name_ == events::kOnDownloadChanged)) &&
+ if (((event_name_ == api::OnDeterminingFilename::kEventName) ||
+ (event_name_ == api::OnCreated::kEventName) ||
+ (event_name_ == api::OnChanged::kEventName)) &&
args_.get() &&
other.args_.get()) {
base::ListValue* left_list = NULL;
@@ -140,7 +137,7 @@ class DownloadsEventsListener : public content::NotificationObserver {
}
}
return true;
- } else if ((event_name_ == events::kOnDownloadErased) &&
+ } else if ((event_name_ == api::OnErased::kEventName) &&
args_.get() &&
other.args_.get()) {
int my_id = -1, other_id = -1;
@@ -277,17 +274,17 @@ class DownloadExtensionTest : public ExtensionApiTest {
content::PAGE_TRANSITION_LINK);
extensions::ExtensionSystem::Get(current_browser()->profile())->
event_router()->AddEventListener(
- extensions::event_names::kOnDownloadCreated,
+ api::OnCreated::kEventName,
tab->GetRenderProcessHost(),
GetExtensionId());
extensions::ExtensionSystem::Get(current_browser()->profile())->
event_router()->AddEventListener(
- extensions::event_names::kOnDownloadChanged,
+ api::OnChanged::kEventName,
tab->GetRenderProcessHost(),
GetExtensionId());
extensions::ExtensionSystem::Get(current_browser()->profile())->
event_router()->AddEventListener(
- extensions::event_names::kOnDownloadErased,
+ api::OnErased::kEventName,
tab->GetRenderProcessHost(),
GetExtensionId());
}
@@ -299,7 +296,7 @@ class DownloadExtensionTest : public ExtensionApiTest {
content::PAGE_TRANSITION_LINK);
extensions::ExtensionSystem::Get(current_browser()->profile())->
event_router()->AddEventListener(
- extensions::event_names::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
tab->GetRenderProcessHost(),
GetExtensionId());
return tab->GetRenderProcessHost();
@@ -308,7 +305,7 @@ class DownloadExtensionTest : public ExtensionApiTest {
void RemoveFilenameDeterminer(content::RenderProcessHost* host) {
extensions::ExtensionSystem::Get(current_browser()->profile())->
event_router()->RemoveEventListener(
- extensions::event_names::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
host,
GetExtensionId());
}
@@ -355,10 +352,10 @@ class DownloadExtensionTest : public ExtensionApiTest {
DownloadItem* item,
content::DownloadInterruptReason expected_error,
const std::string& on_created_event) {
- if (!WaitFor(events::kOnDownloadCreated, on_created_event))
+ if (!WaitFor(api::OnCreated::kEventName, on_created_event))
return false;
// Now, onCreated is always fired before interruption.
- return WaitFor(events::kOnDownloadChanged,
+ return WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"error\": {\"current\": \"%s\"},"
" \"state\": {"
@@ -814,7 +811,7 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ASSERT_TRUE(download_item);
EXPECT_FALSE(download_item->GetOpened());
EXPECT_FALSE(download_item->GetOpenWhenComplete());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"application/octet-stream\","
@@ -1445,21 +1442,21 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"text/plain\","
" \"paused\": false,"
" \"url\": \"%s\"}]",
download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -1489,21 +1486,21 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": true,"
" \"mime\": \"text/plain\","
" \"paused\": false,"
" \"url\": \"%s\"}]",
download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\":%d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\":%d,"
" \"state\": {"
" \"current\": \"complete\","
@@ -1600,21 +1597,21 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"text/plain\","
" \"paused\": false,"
" \"url\": \"%s\"}]",
download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("sub/dir/ect/ory.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -1697,21 +1694,21 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"text/plain\","
" \"paused\": false,"
" \"url\": \"%s\"}]",
download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -1738,21 +1735,21 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"text/plain\","
" \"paused\": false,"
" \"url\": \"%s\"}]",
download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("data.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -1790,21 +1787,21 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"text/html\","
" \"paused\": false,"
" \"url\": \"%s\"}]",
download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("file.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -1874,21 +1871,21 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"application/octet-stream\","
" \"paused\": false,"
" \"url\": \"%s\"}]",
download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("headers-succeed.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -1962,13 +1959,13 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"text/html\","
" \"paused\": false,"
" \"url\": \"%s\"}]", download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2001,20 +1998,20 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"application/octet-stream\","
" \"paused\": false,"
" \"url\": \"%s\"}]", download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("post-succeed.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2128,7 +2125,7 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"application/octet-stream\","
@@ -2138,7 +2135,7 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
result_id,
download_url.c_str())));
item->Cancel(true);
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"error\": {\"current\":\"USER_CANCELED\"},"
" \"state\": {"
@@ -2178,21 +2175,21 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"mime\": \"text/plain\","
" \"paused\": false,"
" \"url\": \"%s\"}]",
download_url.c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("on_record.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2226,7 +2223,7 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
// Wait for the onCreated and onDeterminingFilename events.
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2236,7 +2233,7 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2256,14 +2253,14 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
EXPECT_EQ("", error);
// The download should complete successfully.
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2293,7 +2290,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2303,7 +2300,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2322,7 +2319,7 @@ IN_PROC_BROWSER_TEST_F(
&error));
EXPECT_EQ("", error);
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"danger\": {"
" \"previous\":\"safe\","
@@ -2330,13 +2327,13 @@ IN_PROC_BROWSER_TEST_F(
result_id)));
item->ValidateDangerousDownload();
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"danger\": {"
" \"previous\":\"file\","
" \"current\":\"accepted\"}}]",
result_id)));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2368,7 +2365,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2378,7 +2375,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2396,14 +2393,14 @@ IN_PROC_BROWSER_TEST_F(
api::FILENAME_CONFLICT_ACTION_UNIQUIFY,
&error));
EXPECT_STREQ(errors::kInvalidFilename, error.c_str());
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2433,7 +2430,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2443,7 +2440,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2461,14 +2458,14 @@ IN_PROC_BROWSER_TEST_F(
api::FILENAME_CONFLICT_ACTION_UNIQUIFY,
&error));
EXPECT_STREQ(errors::kInvalidFilename, error.c_str());
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, base::StringPrintf(
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName, base::StringPrintf(
"[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, base::StringPrintf(
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName, base::StringPrintf(
"[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2498,7 +2495,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2508,7 +2505,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2527,14 +2524,14 @@ IN_PROC_BROWSER_TEST_F(
api::FILENAME_CONFLICT_ACTION_UNIQUIFY,
&error));
EXPECT_STREQ(errors::kInvalidFilename, error.c_str());
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, base::StringPrintf(
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName, base::StringPrintf(
"[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, base::StringPrintf(
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName, base::StringPrintf(
"[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2564,7 +2561,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2574,7 +2571,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2592,14 +2589,14 @@ IN_PROC_BROWSER_TEST_F(
api::FILENAME_CONFLICT_ACTION_UNIQUIFY,
&error));
EXPECT_STREQ(errors::kInvalidFilename, error.c_str());
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, base::StringPrintf(
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName, base::StringPrintf(
"[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, base::StringPrintf(
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName, base::StringPrintf(
"[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2629,7 +2626,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2639,7 +2636,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2657,14 +2654,14 @@ IN_PROC_BROWSER_TEST_F(
api::FILENAME_CONFLICT_ACTION_UNIQUIFY,
&error));
EXPECT_STREQ(errors::kInvalidFilename, error.c_str());
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2694,7 +2691,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2704,7 +2701,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2722,14 +2719,14 @@ IN_PROC_BROWSER_TEST_F(
api::FILENAME_CONFLICT_ACTION_UNIQUIFY,
&error));
EXPECT_STREQ(errors::kInvalidFilename, error.c_str());
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2759,7 +2756,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2769,7 +2766,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2788,14 +2785,14 @@ IN_PROC_BROWSER_TEST_F(
&error));
EXPECT_STREQ(errors::kInvalidFilename, error.c_str());
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2825,7 +2822,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2835,7 +2832,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2854,14 +2851,14 @@ IN_PROC_BROWSER_TEST_F(
&error));
EXPECT_STREQ(errors::kInvalidFilename, error.c_str());
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2890,7 +2887,7 @@ IN_PROC_BROWSER_TEST_F(
ASSERT_TRUE(item);
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2900,7 +2897,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2919,14 +2916,14 @@ IN_PROC_BROWSER_TEST_F(
&error));
EXPECT_EQ("", error);
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("slow.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -2945,7 +2942,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller2(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -2955,7 +2952,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -2977,14 +2974,14 @@ IN_PROC_BROWSER_TEST_F(
&error));
EXPECT_EQ("", error);
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("foo").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -3016,7 +3013,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -3026,7 +3023,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\":\"slow.txt\"}]",
result_id)));
@@ -3036,7 +3033,7 @@ IN_PROC_BROWSER_TEST_F(
// Remove a determiner while waiting for it.
RemoveFilenameDeterminer(host);
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -3072,7 +3069,7 @@ IN_PROC_BROWSER_TEST_F(
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
// Wait for the onCreated and onDeterminingFilename events.
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -3082,7 +3079,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"incognito\": false,"
" \"filename\":\"slow.txt\"}]",
@@ -3103,14 +3100,14 @@ IN_PROC_BROWSER_TEST_F(
EXPECT_EQ("", error);
// The download should complete successfully.
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("42.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -3130,7 +3127,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller2(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": true,"
" \"id\": %d,"
@@ -3141,7 +3138,7 @@ IN_PROC_BROWSER_TEST_F(
download_url.c_str())));
// On-Record renderers should not see events for off-record items.
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"incognito\": true,"
" \"filename\":\"slow.txt\"}]",
@@ -3162,14 +3159,14 @@ IN_PROC_BROWSER_TEST_F(
EXPECT_EQ("", error);
// The download should complete successfully.
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("5.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -3206,7 +3203,7 @@ IN_PROC_BROWSER_TEST_F(
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
// Wait for the onCreated and onDeterminingFilename events.
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -3216,7 +3213,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"incognito\": false,"
" \"filename\":\"slow.txt\"}]",
@@ -3237,14 +3234,14 @@ IN_PROC_BROWSER_TEST_F(
EXPECT_EQ("", error);
// The download should complete successfully.
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("42.txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -3264,7 +3261,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller2(item);
ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": true,"
" \"id\": %d,"
@@ -3274,7 +3271,7 @@ IN_PROC_BROWSER_TEST_F(
result_id,
download_url.c_str())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"incognito\": true,"
" \"filename\":\"slow.txt\"}]",
@@ -3295,14 +3292,14 @@ IN_PROC_BROWSER_TEST_F(
EXPECT_EQ("", error);
// The download should complete successfully.
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
" \"current\": \"%s\"}}]",
result_id,
GetFilename("42 (1).txt").c_str())));
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
@@ -3364,7 +3361,7 @@ IN_PROC_BROWSER_TEST_F(
ScopedCancellingItem canceller(item);
// Wait for the onCreated and onDeterminingFilename event.
- ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
+ ASSERT_TRUE(WaitFor(api::OnCreated::kEventName,
base::StringPrintf("[{\"danger\": \"safe\","
" \"incognito\": false,"
" \"id\": %d,"
@@ -3372,7 +3369,7 @@ IN_PROC_BROWSER_TEST_F(
" \"paused\": false}]",
item->GetId())));
ASSERT_TRUE(WaitFor(
- events::kOnDownloadDeterminingFilename,
+ api::OnDeterminingFilename::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"incognito\": false,"
" \"filename\":\"download-unknown-size\"}]",
@@ -3399,7 +3396,7 @@ IN_PROC_BROWSER_TEST_F(
api::FILENAME_CONFLICT_ACTION_UNIQUIFY,
&error)) << error;
EXPECT_EQ("", error);
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"filename\": {"
" \"previous\": \"\","
@@ -3410,7 +3407,7 @@ IN_PROC_BROWSER_TEST_F(
content::DownloadUpdatedObserver interrupted(item, base::Bind(
ItemIsInterrupted));
ASSERT_TRUE(interrupted.WaitForEvent());
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"error\":{\"current\":\"NETWORK_FAILED\"},"
" \"state\":{"
@@ -3429,7 +3426,7 @@ IN_PROC_BROWSER_TEST_F(
// does not need to be re-done. So, there will not be a second
// onDeterminingFilename event.
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"error\":{\"previous\":\"NETWORK_FAILED\"},"
" \"state\":{"
@@ -3441,7 +3438,7 @@ IN_PROC_BROWSER_TEST_F(
FinishPendingSlowDownloads();
// The download should complete successfully.
- ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
+ ASSERT_TRUE(WaitFor(api::OnChanged::kEventName,
base::StringPrintf("[{\"id\": %d,"
" \"state\": {"
" \"previous\": \"in_progress\","
diff --git a/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc b/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc
index b47bc53..fafcbd5 100644
--- a/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc
+++ b/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc
@@ -10,7 +10,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/feedback_private/feedback_service.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
#include "grit/generated_resources.h"
@@ -20,8 +19,10 @@
namespace extensions {
-using api::feedback_private::SystemInformation;
-using api::feedback_private::FeedbackInfo;
+namespace feedback_private = api::feedback_private;
+
+using feedback_private::SystemInformation;
+using feedback_private::FeedbackInfo;
static base::LazyInstance<ProfileKeyedAPIFactory<FeedbackPrivateAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;
@@ -68,8 +69,8 @@ void FeedbackPrivateAPI::RequestFeedback(
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(info.ToValue().release());
- scoped_ptr<Event> event(
- new Event(event_names::kOnFeedbackRequested, args.Pass()));
+ scoped_ptr<Event> event(new Event(
+ feedback_private::OnFeedbackRequested::kEventName, args.Pass()));
ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(
event.Pass());
}
@@ -122,14 +123,14 @@ bool FeedbackPrivateGetSystemInformationFunction::RunImpl() {
void FeedbackPrivateGetSystemInformationFunction::OnCompleted(
const SystemInformationList& sys_info) {
- results_ = api::feedback_private::GetSystemInformation::Results::Create(
+ results_ = feedback_private::GetSystemInformation::Results::Create(
sys_info);
SendResponse(true);
}
bool FeedbackPrivateSendFeedbackFunction::RunImpl() {
- scoped_ptr<api::feedback_private::SendFeedback::Params> params(
- api::feedback_private::SendFeedback::Params::Create(*args_));
+ scoped_ptr<feedback_private::SendFeedback::Params> params(
+ feedback_private::SendFeedback::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
const FeedbackInfo &feedback_info = params->feedback;
@@ -186,9 +187,9 @@ bool FeedbackPrivateSendFeedbackFunction::RunImpl() {
void FeedbackPrivateSendFeedbackFunction::OnCompleted(
bool success) {
- results_ = api::feedback_private::SendFeedback::Results::Create(
- success ? api::feedback_private::STATUS_SUCCESS :
- api::feedback_private::STATUS_DELAYED);
+ results_ = feedback_private::SendFeedback::Results::Create(
+ success ? feedback_private::STATUS_SUCCESS :
+ feedback_private::STATUS_DELAYED);
SendResponse(true);
}
diff --git a/chrome/browser/extensions/api/font_settings/font_settings_api.cc b/chrome/browser/extensions/api/font_settings/font_settings_api.cc
index 476adcb..2152270 100644
--- a/chrome/browser/extensions/api/font_settings/font_settings_api.cc
+++ b/chrome/browser/extensions/api/font_settings/font_settings_api.cc
@@ -49,14 +49,6 @@ const char kScriptKey[] = "script";
const char kSetFromIncognitoError[] =
"Can't modify regular settings from an incognito context.";
-const char kOnDefaultFixedFontSizeChanged[] =
- "fontSettings.onDefaultFixedFontSizeChanged";
-const char kOnDefaultFontSizeChanged[] =
- "fontSettings.onDefaultFontSizeChanged";
-const char kOnFontChanged[] = "fontSettings.onFontChanged";
-const char kOnMinimumFontSizeChanged[] =
- "fontSettings.onMinimumFontSizeChanged";
-
// Format for font name preference paths.
const char kWebKitFontPrefFormat[] = "webkit.webprefs.fonts.%s.%s";
@@ -106,13 +98,13 @@ FontSettingsEventRouter::FontSettingsEventRouter(
registrar_.Init(profile_->GetPrefs());
AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize,
- kOnDefaultFixedFontSizeChanged,
+ fonts::OnDefaultFixedFontSizeChanged::kEventName,
kPixelSizeKey);
AddPrefToObserve(prefs::kWebKitDefaultFontSize,
- kOnDefaultFontSizeChanged,
+ fonts::OnDefaultFontSizeChanged::kEventName,
kPixelSizeKey);
AddPrefToObserve(prefs::kWebKitMinimumFontSize,
- kOnMinimumFontSizeChanged,
+ fonts::OnMinimumFontSizeChanged::kEventName,
kPixelSizeKey);
PrefChangeRegistrar::NamedChangeCallback callback =
@@ -183,7 +175,7 @@ void FontSettingsEventRouter::OnFontNamePrefChanged(
extensions::preference_helpers::DispatchEventToExtensions(
profile_,
- kOnFontChanged,
+ fonts::OnFontChanged::kEventName,
&args,
APIPermission::kFontSettings,
false,
diff --git a/chrome/browser/extensions/api/history/history_api.cc b/chrome/browser/extensions/api/history/history_api.cc
index 0543a27..e387b4f 100644
--- a/chrome/browser/extensions/api/history/history_api.cc
+++ b/chrome/browser/extensions/api/history/history_api.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/cancelable_task_tracker.h"
#include "chrome/common/extensions/api/experimental_history.h"
+#include "chrome/common/extensions/api/history.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
@@ -52,9 +53,6 @@ namespace Search = api::history::Search;
namespace {
-const char kOnVisited[] = "history.onVisited";
-const char kOnVisitRemoved[] = "history.onVisitRemoved";
-
const char kInvalidIdError[] = "History item id is invalid.";
const char kInvalidUrlError[] = "Url is invalid.";
const char kDeleteProhibitedError[] = "Browsing history is not allowed to be "
@@ -170,7 +168,7 @@ void HistoryEventRouter::HistoryUrlVisited(
scoped_ptr<HistoryItem> history_item = GetHistoryItem(details->row);
scoped_ptr<base::ListValue> args = OnVisited::Create(*history_item);
- DispatchEvent(profile, kOnVisited, args.Pass());
+ DispatchEvent(profile, api::history::OnVisited::kEventName, args.Pass());
}
void HistoryEventRouter::HistoryUrlsRemoved(
@@ -187,7 +185,7 @@ void HistoryEventRouter::HistoryUrlsRemoved(
removed.urls.reset(urls);
scoped_ptr<base::ListValue> args = OnVisitRemoved::Create(removed);
- DispatchEvent(profile, kOnVisitRemoved, args.Pass());
+ DispatchEvent(profile, api::history::OnVisitRemoved::kEventName, args.Pass());
}
void HistoryEventRouter::DispatchEvent(
@@ -205,9 +203,9 @@ void HistoryEventRouter::DispatchEvent(
HistoryAPI::HistoryAPI(Profile* profile) : profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, kOnVisited);
+ this, api::history::OnVisited::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, kOnVisitRemoved);
+ this, api::history::OnVisitRemoved::kEventName);
}
HistoryAPI::~HistoryAPI() {
diff --git a/chrome/browser/extensions/api/identity/web_auth_flow.cc b/chrome/browser/extensions/api/identity/web_auth_flow.cc
index 977f1f1..2c50724 100644
--- a/chrome/browser/extensions/api/identity/web_auth_flow.cc
+++ b/chrome/browser/extensions/api/identity/web_auth_flow.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/identity_private.h"
#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
@@ -38,6 +39,8 @@ using content::WebContentsObserver;
namespace extensions {
+namespace identity_private = api::identity_private;
+
WebAuthFlow::WebAuthFlow(
Delegate* delegate,
Profile* profile,
@@ -86,7 +89,7 @@ void WebAuthFlow::Start() {
args->AppendString("silent");
scoped_ptr<Event> event(
- new Event("identityPrivate.onWebFlowRequest", args.Pass()));
+ new Event(identity_private::OnWebFlowRequest::kEventName, args.Pass()));
event->restrict_to_profile = profile_;
ExtensionSystem* system = ExtensionSystem::Get(profile_);
diff --git a/chrome/browser/extensions/api/idle/idle_api_constants.cc b/chrome/browser/extensions/api/idle/idle_api_constants.cc
index 15d6325..84d42e0 100644
--- a/chrome/browser/extensions/api/idle/idle_api_constants.cc
+++ b/chrome/browser/extensions/api/idle/idle_api_constants.cc
@@ -8,8 +8,6 @@ namespace extensions {
namespace idle_api_constants {
-const char kOnStateChanged[] = "idle.onStateChanged";
-
const char kStateActive[] = "active";
const char kStateIdle[] = "idle";
const char kStateLocked[] = "locked";
diff --git a/chrome/browser/extensions/api/idle/idle_api_unittest.cc b/chrome/browser/extensions/api/idle/idle_api_unittest.cc
index bbffd00..cf6ee66 100644
--- a/chrome/browser/extensions/api/idle/idle_api_unittest.cc
+++ b/chrome/browser/extensions/api/idle/idle_api_unittest.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/extensions/api/idle/idle_manager_factory.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
+#include "chrome/common/extensions/api/idle.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/test/base/browser_with_test_window_test.h"
@@ -25,6 +26,7 @@
using ::testing::_;
namespace utils = extension_function_test_utils;
+namespace idle = extensions::api::idle;
namespace extensions {
@@ -107,13 +109,13 @@ ScopedListen::ScopedListen(IdleManager* idle_manager,
const std::string& extension_id)
: idle_manager_(idle_manager),
extension_id_(extension_id) {
- const EventListenerInfo details(idle_api_constants::kOnStateChanged,
+ const EventListenerInfo details(idle::OnStateChanged::kEventName,
extension_id_);
idle_manager_->OnListenerAdded(details);
}
ScopedListen::~ScopedListen() {
- const EventListenerInfo details(idle_api_constants::kOnStateChanged,
+ const EventListenerInfo details(idle::OnStateChanged::kEventName,
extension_id_);
idle_manager_->OnListenerRemoved(details);
}
diff --git a/chrome/browser/extensions/api/idle/idle_manager.cc b/chrome/browser/extensions/api/idle/idle_manager.cc
index 8b66e86..48785c7 100644
--- a/chrome/browser/extensions/api/idle/idle_manager.cc
+++ b/chrome/browser/extensions/api/idle/idle_manager.cc
@@ -12,12 +12,14 @@
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/idle.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
namespace keys = extensions::idle_api_constants;
+namespace idle = extensions::api::idle;
namespace extensions {
@@ -51,7 +53,8 @@ void DefaultEventDelegate::OnStateChanged(const std::string& extension_id,
IdleState new_state) {
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(IdleManager::CreateIdleValue(new_state));
- scoped_ptr<Event> event(new Event(keys::kOnStateChanged, args.Pass()));
+ scoped_ptr<Event> event(new Event(idle::OnStateChanged::kEventName,
+ args.Pass()));
event->restrict_to_profile = profile_;
ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension(
extension_id, event.Pass());
@@ -60,7 +63,7 @@ void DefaultEventDelegate::OnStateChanged(const std::string& extension_id,
void DefaultEventDelegate::RegisterObserver(
EventRouter::Observer* observer) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- observer, idle_api_constants::kOnStateChanged);
+ observer, idle::OnStateChanged::kEventName);
}
void DefaultEventDelegate::UnregisterObserver(EventRouter::Observer* observer) {
diff --git a/chrome/browser/extensions/api/input_ime/input_ime_api.cc b/chrome/browser/extensions/api/input_ime/input_ime_api.cc
index 20d89e6..15baf4b 100644
--- a/chrome/browser/extensions/api/input_ime/input_ime_api.cc
+++ b/chrome/browser/extensions/api/input_ime/input_ime_api.cc
@@ -79,21 +79,6 @@ static void DispatchEventToExtension(Profile* profile,
} // namespace
-namespace events {
-
-const char kOnActivate[] = "input.ime.onActivate";
-const char kOnDeactivated[] = "input.ime.onDeactivated";
-const char kOnFocus[] = "input.ime.onFocus";
-const char kOnBlur[] = "input.ime.onBlur";
-const char kOnInputContextUpdate[] = "input.ime.onInputContextUpdate";
-const char kOnKeyEvent[] = "input.ime.onKeyEvent";
-const char kOnCandidateClicked[] = "input.ime.onCandidateClicked";
-const char kOnMenuItemActivated[] = "input.ime.onMenuItemActivated";
-const char kOnSurroundingTextChanged[] = "input.ime.onSurroundingTextChanged";
-const char kOnReset[] = "input.ime.onReset";
-
-} // namespace events
-
namespace chromeos {
class ImeObserver : public chromeos::InputMethodEngine::Observer {
public:
@@ -114,7 +99,7 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
args->Append(new base::StringValue(engine_id));
DispatchEventToExtension(profile_, extension_id_,
- events::kOnActivate, args.Pass());
+ input_ime::OnActivate::kEventName, args.Pass());
}
virtual void OnDeactivated(const std::string& engine_id) OVERRIDE {
@@ -125,7 +110,7 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
args->Append(new base::StringValue(engine_id));
DispatchEventToExtension(profile_, extension_id_,
- events::kOnDeactivated, args.Pass());
+ input_ime::OnDeactivated::kEventName, args.Pass());
}
virtual void OnFocus(
@@ -141,7 +126,7 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
args->Append(dict);
DispatchEventToExtension(profile_, extension_id_,
- events::kOnFocus, args.Pass());
+ input_ime::OnFocus::kEventName, args.Pass());
}
virtual void OnBlur(int context_id) OVERRIDE {
@@ -152,7 +137,7 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
args->Append(new base::FundamentalValue(context_id));
DispatchEventToExtension(profile_, extension_id_,
- events::kOnBlur, args.Pass());
+ input_ime::OnBlur::kEventName, args.Pass());
}
virtual void OnInputContextUpdate(
@@ -167,8 +152,10 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(dict);
- DispatchEventToExtension(profile_, extension_id_,
- events::kOnInputContextUpdate, args.Pass());
+ DispatchEventToExtension(profile_,
+ extension_id_,
+ input_ime::OnInputContextUpdate::kEventName,
+ args.Pass());
}
virtual void OnKeyEvent(
@@ -197,7 +184,7 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
args->Append(dict);
DispatchEventToExtension(profile_, extension_id_,
- events::kOnKeyEvent, args.Pass());
+ input_ime::OnKeyEvent::kEventName, args.Pass());
}
virtual void OnCandidateClicked(
@@ -226,8 +213,10 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
break;
}
- DispatchEventToExtension(profile_, extension_id_,
- events::kOnCandidateClicked, args.Pass());
+ DispatchEventToExtension(profile_,
+ extension_id_,
+ input_ime::OnCandidateClicked::kEventName,
+ args.Pass());
}
virtual void OnMenuItemActivated(const std::string& engine_id,
@@ -239,8 +228,10 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
args->Append(new base::StringValue(engine_id));
args->Append(new base::StringValue(menu_id));
- DispatchEventToExtension(profile_, extension_id_,
- events::kOnMenuItemActivated, args.Pass());
+ DispatchEventToExtension(profile_,
+ extension_id_,
+ input_ime::OnMenuItemActivated::kEventName,
+ args.Pass());
}
virtual void OnSurroundingTextChanged(const std::string& engine_id,
@@ -258,8 +249,10 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
args->Append(new base::StringValue(engine_id));
args->Append(dict);
- DispatchEventToExtension(profile_, extension_id_,
- events::kOnSurroundingTextChanged, args.Pass());
+ DispatchEventToExtension(profile_,
+ extension_id_,
+ input_ime::OnSurroundingTextChanged::kEventName,
+ args.Pass());
}
virtual void OnReset(const std::string& engine_id) OVERRIDE {
@@ -268,8 +261,10 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer {
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(new base::StringValue(engine_id));
- DispatchEventToExtension(profile_, extension_id_,
- events::kOnReset, args.Pass());
+ DispatchEventToExtension(profile_,
+ extension_id_,
+ input_ime::OnReset::kEventName,
+ args.Pass());
}
private:
diff --git a/chrome/browser/extensions/api/location/location_manager.cc b/chrome/browser/extensions/api/location/location_manager.cc
index 5611a43..95579a3 100644
--- a/chrome/browser/extensions/api/location/location_manager.cc
+++ b/chrome/browser/extensions/api/location/location_manager.cc
@@ -382,12 +382,12 @@ void LocationManager::SendLocationUpdate(
location.timestamp = position.timestamp.ToJsTime();
args->Append(location.ToValue().release());
- event_name = "location.onLocationUpdate";
+ event_name = location::OnLocationUpdate::kEventName;
} else {
// Set data for onLocationError event.
// TODO(vadimt): Set name.
args->AppendString(position.error_message);
- event_name = "location.onLocationError";
+ event_name = location::OnLocationError::kEventName;
}
scoped_ptr<Event> event(new Event(event_name, args.Pass()));
diff --git a/chrome/browser/extensions/api/management/management_api.cc b/chrome/browser/extensions/api/management/management_api.cc
index 1debb52..eb776d1 100644
--- a/chrome/browser/extensions/api/management/management_api.cc
+++ b/chrome/browser/extensions/api/management/management_api.cc
@@ -20,7 +20,6 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/management/management_api_constants.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -60,7 +59,6 @@ namespace keys = extension_management_api_constants;
namespace extensions {
-namespace events = event_names;
namespace management = api::management;
namespace {
@@ -652,20 +650,20 @@ void ManagementEventRouter::Observe(
switch (type) {
case chrome::NOTIFICATION_EXTENSION_INSTALLED:
- event_name = events::kOnExtensionInstalled;
+ event_name = management::OnInstalled::kEventName;
extension =
content::Details<const InstalledExtensionInfo>(details)->extension;
break;
case chrome::NOTIFICATION_EXTENSION_UNINSTALLED:
- event_name = events::kOnExtensionUninstalled;
+ event_name = management::OnUninstalled::kEventName;
extension = content::Details<const Extension>(details).ptr();
break;
case chrome::NOTIFICATION_EXTENSION_LOADED:
- event_name = events::kOnExtensionEnabled;
+ event_name = management::OnEnabled::kEventName;
extension = content::Details<const Extension>(details).ptr();
break;
case chrome::NOTIFICATION_EXTENSION_UNLOADED:
- event_name = events::kOnExtensionDisabled;
+ event_name = management::OnDisabled::kEventName;
extension =
content::Details<const UnloadedExtensionInfo>(details)->extension;
break;
@@ -680,7 +678,7 @@ void ManagementEventRouter::Observe(
return; // Don't dispatch events for built-in extensions.
scoped_ptr<base::ListValue> args(new base::ListValue());
- if (event_name == events::kOnExtensionUninstalled) {
+ if (event_name == management::OnUninstalled::kEventName) {
args->Append(new base::StringValue(extension->id()));
} else {
scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo(
@@ -695,13 +693,13 @@ void ManagementEventRouter::Observe(
ManagementAPI::ManagementAPI(Profile* profile)
: profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, events::kOnExtensionInstalled);
+ this, management::OnInstalled::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, events::kOnExtensionUninstalled);
+ this, management::OnUninstalled::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, events::kOnExtensionEnabled);
+ this, management::OnEnabled::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, events::kOnExtensionDisabled);
+ this, management::OnDisabled::kEventName);
}
ManagementAPI::~ManagementAPI() {
diff --git a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc
index 7e8436cc..4111d0c 100644
--- a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc
+++ b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.cc
@@ -40,6 +40,8 @@ namespace GetAllGalleryWatch =
extensions::api::media_galleries_private::GetAllGalleryWatch;
namespace EjectDevice =
extensions::api::media_galleries_private::EjectDevice;
+namespace media_galleries_private =
+ api::media_galleries_private;
namespace {
@@ -87,11 +89,11 @@ MediaGalleriesPrivateAPI::MediaGalleriesPrivateAPI(Profile* profile)
weak_ptr_factory_(this) {
DCHECK(profile_);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, event_names::kOnAttachEventName);
+ this, media_galleries_private::OnDeviceAttached::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, event_names::kOnDetachEventName);
+ this, media_galleries_private::OnDeviceDetached::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, event_names::kOnGalleryChangedEventName);
+ this, media_galleries_private::OnGalleryChanged::kEventName);
}
MediaGalleriesPrivateAPI::~MediaGalleriesPrivateAPI() {
@@ -217,7 +219,7 @@ void MediaGalleriesPrivateAddGalleryWatchFunction::HandleResponse(
chrome::MediaGalleryPrefId gallery_id,
bool success) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- extensions::api::media_galleries_private::AddGalleryWatchResult result;
+ media_galleries_private::AddGalleryWatchResult result;
result.gallery_id = base::Uint64ToString(gallery_id);
result.success = success;
SetResult(result.ToValue().release());
@@ -396,15 +398,11 @@ void MediaGalleriesPrivateEjectDeviceFunction::OnStorageMonitorInit(
void MediaGalleriesPrivateEjectDeviceFunction::HandleResponse(
chrome::StorageMonitor::EjectStatus status) {
- using extensions::api::media_galleries_private::
- EJECT_DEVICE_RESULT_CODE_FAILURE;
- using extensions::api::media_galleries_private::
- EJECT_DEVICE_RESULT_CODE_IN_USE;
- using extensions::api::media_galleries_private::
- EJECT_DEVICE_RESULT_CODE_NO_SUCH_DEVICE;
- using extensions::api::media_galleries_private::
- EJECT_DEVICE_RESULT_CODE_SUCCESS;
- using extensions::api::media_galleries_private::EjectDeviceResultCode;
+ using media_galleries_private::EJECT_DEVICE_RESULT_CODE_FAILURE;
+ using media_galleries_private::EJECT_DEVICE_RESULT_CODE_IN_USE;
+ using media_galleries_private::EJECT_DEVICE_RESULT_CODE_NO_SUCH_DEVICE;
+ using media_galleries_private::EJECT_DEVICE_RESULT_CODE_SUCCESS;
+ using media_galleries_private::EjectDeviceResultCode;
EjectDeviceResultCode result = EJECT_DEVICE_RESULT_CODE_FAILURE;
if (status == chrome::StorageMonitor::EJECT_OK)
diff --git a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.cc b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.cc
index 2522239..8f0baf3 100644
--- a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.cc
+++ b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.cc
@@ -18,6 +18,8 @@
#include "chrome/common/extensions/api/media_galleries_private.h"
#include "content/public/browser/browser_thread.h"
+namespace media_galleries_private = extensions::api::media_galleries_private;
+
namespace extensions {
namespace {
@@ -29,9 +31,9 @@ std::string GetTransientIdForDeviceId(const std::string& device_id) {
} // namespace
-using extensions::api::media_galleries_private::DeviceAttachmentDetails;
-using extensions::api::media_galleries_private::DeviceDetachmentDetails;
-using extensions::api::media_galleries_private::GalleryChangeDetails;
+using media_galleries_private::DeviceAttachmentDetails;
+using media_galleries_private::DeviceDetachmentDetails;
+using media_galleries_private::GalleryChangeDetails;
MediaGalleriesPrivateEventRouter::MediaGalleriesPrivateEventRouter(
Profile* profile)
@@ -55,7 +57,8 @@ void MediaGalleriesPrivateEventRouter::OnGalleryChanged(
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
EventRouter* router =
extensions::ExtensionSystem::Get(profile_)->event_router();
- if (!router->HasEventListener(event_names::kOnGalleryChangedEventName))
+ if (!router->HasEventListener(
+ media_galleries_private::OnGalleryChanged::kEventName))
return;
for (std::set<std::string>::const_iterator it = extension_ids.begin();
@@ -65,7 +68,7 @@ void MediaGalleriesPrivateEventRouter::OnGalleryChanged(
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(details.ToValue().release());
scoped_ptr<extensions::Event> event(new extensions::Event(
- event_names::kOnGalleryChangedEventName,
+ media_galleries_private::OnGalleryChanged::kEventName,
args.Pass()));
// Use DispatchEventToExtension() instead of BroadcastEvent().
// BroadcastEvent() sends the gallery changed events to all the extensions
@@ -83,7 +86,8 @@ void MediaGalleriesPrivateEventRouter::OnRemovableStorageAttached(
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
EventRouter* router =
extensions::ExtensionSystem::Get(profile_)->event_router();
- if (!router->HasEventListener(event_names::kOnAttachEventName))
+ if (!router->HasEventListener(
+ media_galleries_private::OnDeviceAttached::kEventName))
return;
chrome::MediaGalleryPrefInfo pref_info;
@@ -102,7 +106,8 @@ void MediaGalleriesPrivateEventRouter::OnRemovableStorageAttached(
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(details.ToValue().release());
- DispatchEvent(event_names::kOnAttachEventName, args.Pass());
+ DispatchEvent(
+ media_galleries_private::OnDeviceAttached::kEventName, args.Pass());
}
void MediaGalleriesPrivateEventRouter::OnRemovableStorageDetached(
@@ -110,7 +115,8 @@ void MediaGalleriesPrivateEventRouter::OnRemovableStorageDetached(
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
EventRouter* router =
extensions::ExtensionSystem::Get(profile_)->event_router();
- if (!router->HasEventListener(event_names::kOnDetachEventName))
+ if (!router->HasEventListener(
+ media_galleries_private::OnDeviceDetached::kEventName))
return;
DeviceDetachmentDetails details;
@@ -118,7 +124,8 @@ void MediaGalleriesPrivateEventRouter::OnRemovableStorageDetached(
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(details.ToValue().release());
- DispatchEvent(event_names::kOnDetachEventName, args.Pass());
+ DispatchEvent(
+ media_galleries_private::OnDeviceDetached::kEventName, args.Pass());
}
void MediaGalleriesPrivateEventRouter::DispatchEvent(
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc b/chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc
index 65ddc026..15adc7a 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc
@@ -10,7 +10,6 @@
#include "base/command_line.h"
#include "base/json/json_reader.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_function_registry.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -18,8 +17,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/networking_private.h"
-using extensions::event_names::kOnNetworkListChanged;
-using extensions::event_names::kOnNetworksChanged;
using extensions::EventRouter;
using extensions::ExtensionSystem;
namespace api = extensions::api::networking_private;
@@ -289,7 +286,7 @@ bool NetworkingPrivateRequestNetworkScanFunction::RunImpl() {
EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router();
scoped_ptr<base::ListValue> args(api::OnNetworkListChanged::Create(changes));
scoped_ptr<extensions::Event> extension_event(new extensions::Event(
- kOnNetworkListChanged, args.Pass()));
+ api::OnNetworkListChanged::kEventName, args.Pass()));
event_router->BroadcastEvent(extension_event.Pass());
return true;
@@ -333,7 +330,7 @@ bool NetworkingPrivateStartConnectFunction::RunImpl() {
scoped_ptr<base::ListValue> args(api::OnNetworksChanged::Create(
std::vector<std::string>(1, params->network_guid)));
scoped_ptr<extensions::Event> netchanged_event(
- new extensions::Event(kOnNetworksChanged, args.Pass()));
+ new extensions::Event(api::OnNetworksChanged::kEventName, args.Pass()));
event_router->BroadcastEvent(netchanged_event.Pass());
// Generate NetworkListChanged event.
@@ -346,7 +343,7 @@ bool NetworkingPrivateStartConnectFunction::RunImpl() {
scoped_ptr<base::ListValue> arg2(api::OnNetworkListChanged::Create(list));
scoped_ptr<extensions::Event> netlist_event(new extensions::Event(
- kOnNetworkListChanged, arg2.Pass()));
+ api::OnNetworkListChanged::kEventName, arg2.Pass()));
event_router->BroadcastEvent(netlist_event.Pass());
}
return true;
@@ -374,7 +371,7 @@ bool NetworkingPrivateStartDisconnectFunction::RunImpl() {
scoped_ptr<base::ListValue> args(api::OnNetworksChanged::Create(
std::vector<std::string>(1, params->network_guid)));
scoped_ptr<extensions::Event> extension_event(
- new extensions::Event(kOnNetworksChanged, args.Pass()));
+ new extensions::Event(api::OnNetworksChanged::kEventName, args.Pass()));
event_router->BroadcastEvent(extension_event.Pass());
}
return true;
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc b/chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc
index 44d70eb..c431c7f 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc
@@ -7,7 +7,6 @@
#include "base/json/json_writer.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/networking_private/networking_private_api.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_system_factory.h"
@@ -22,8 +21,6 @@
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
-using extensions::event_names::kOnNetworkListChanged;
-using extensions::event_names::kOnNetworksChanged;
using extensions::EventRouter;
using extensions::ExtensionSystem;
namespace api = extensions::api::networking_private;
@@ -39,9 +36,9 @@ NetworkingPrivateEventRouter::NetworkingPrivateEventRouter(Profile* profile)
EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router();
if (event_router) {
event_router->RegisterObserver(
- this, extensions::event_names::kOnNetworksChanged);
+ this, api::OnNetworksChanged::kEventName);
event_router->RegisterObserver(
- this, extensions::event_names::kOnNetworkListChanged);
+ this, api::OnNetworkListChanged::kEventName);
StartOrStopListeningForNetworkChanges();
}
}
@@ -80,8 +77,9 @@ void NetworkingPrivateEventRouter::OnListenerRemoved(
void NetworkingPrivateEventRouter::StartOrStopListeningForNetworkChanges() {
EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router();
- bool should_listen = event_router->HasEventListener(kOnNetworksChanged) ||
- event_router->HasEventListener(kOnNetworkListChanged);
+ bool should_listen =
+ event_router->HasEventListener(api::OnNetworksChanged::kEventName) ||
+ event_router->HasEventListener(api::OnNetworkListChanged::kEventName);
if (should_listen && !listening_) {
NetworkHandler::Get()->network_state_handler()->AddObserver(
@@ -97,7 +95,7 @@ void NetworkingPrivateEventRouter::NetworkListChanged() {
EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router();
NetworkStateHandler::NetworkStateList networks;
NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks);
- if (!event_router->HasEventListener(kOnNetworkListChanged)) {
+ if (!event_router->HasEventListener(api::OnNetworkListChanged::kEventName)) {
// TODO(stevenjb): Remove logging once crbug.com/256881 is fixed
// (or at least reduce to LOG_DEBUG). Same with NET_LOG events below.
NET_LOG_EVENT("NetworkingPrivate.NetworkListChanged: No Listeners", "");
@@ -117,14 +115,14 @@ void NetworkingPrivateEventRouter::NetworkListChanged() {
scoped_ptr<base::ListValue> args(api::OnNetworkListChanged::Create(changes));
scoped_ptr<extensions::Event> extension_event(new extensions::Event(
- kOnNetworkListChanged, args.Pass()));
+ api::OnNetworkListChanged::kEventName, args.Pass()));
event_router->BroadcastEvent(extension_event.Pass());
}
void NetworkingPrivateEventRouter::NetworkPropertiesUpdated(
const NetworkState* network) {
EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router();
- if (!event_router->HasEventListener(kOnNetworksChanged)) {
+ if (!event_router->HasEventListener(api::OnNetworksChanged::kEventName)) {
NET_LOG_EVENT("NetworkingPrivate.NetworkPropertiesUpdated: No Listeners",
network->path());
return;
@@ -134,7 +132,7 @@ void NetworkingPrivateEventRouter::NetworkPropertiesUpdated(
scoped_ptr<base::ListValue> args(api::OnNetworksChanged::Create(
std::vector<std::string>(1, network->path())));
scoped_ptr<extensions::Event> extension_event(
- new extensions::Event(kOnNetworksChanged, args.Pass()));
+ new extensions::Event(api::OnNetworksChanged::kEventName, args.Pass()));
event_router->BroadcastEvent(extension_event.Pass());
}
diff --git a/chrome/browser/extensions/api/notifications/notifications_api.cc b/chrome/browser/extensions/api/notifications/notifications_api.cc
index 962e162..c69f4cb 100644
--- a/chrome/browser/extensions/api/notifications/notifications_api.cc
+++ b/chrome/browser/extensions/api/notifications/notifications_api.cc
@@ -32,6 +32,8 @@
namespace extensions {
+namespace notifications = api::notifications;
+
namespace {
const char kResultKey[] = "result";
@@ -150,23 +152,23 @@ class NotificationsApiDelegate : public NotificationDelegate {
virtual void Close(bool by_user) OVERRIDE {
scoped_ptr<base::ListValue> args(CreateBaseEventArgs());
args->Append(new base::FundamentalValue(by_user));
- SendEvent(event_names::kOnNotificationClosed, args.Pass());
+ SendEvent(notifications::OnClosed::kEventName, args.Pass());
}
virtual void Click() OVERRIDE {
scoped_ptr<base::ListValue> args(CreateBaseEventArgs());
- SendEvent(event_names::kOnNotificationClicked, args.Pass());
+ SendEvent(notifications::OnClicked::kEventName, args.Pass());
}
virtual bool HasClickedListener() OVERRIDE {
return ExtensionSystem::Get(profile_)->event_router()->HasEventListener(
- event_names::kOnNotificationClicked);
+ notifications::OnClicked::kEventName);
}
virtual void ButtonClick(int index) OVERRIDE {
scoped_ptr<base::ListValue> args(CreateBaseEventArgs());
args->Append(new base::FundamentalValue(index));
- SendEvent(event_names::kOnNotificationButtonClicked, args.Pass());
+ SendEvent(notifications::OnButtonClicked::kEventName, args.Pass());
}
virtual std::string id() const OVERRIDE {
diff --git a/chrome/browser/extensions/api/omnibox/omnibox_api.cc b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
index 18250ad..585b39e 100644
--- a/chrome/browser/extensions/api/omnibox/omnibox_api.cc
+++ b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
@@ -27,13 +27,6 @@
#include "content/public/browser/notification_service.h"
#include "ui/gfx/image/image.h"
-namespace events {
-const char kOnInputStarted[] = "omnibox.onInputStarted";
-const char kOnInputChanged[] = "omnibox.onInputChanged";
-const char kOnInputEntered[] = "omnibox.onInputEntered";
-const char kOnInputCancelled[] = "omnibox.onInputCancelled";
-} // namespace events
-
namespace extensions {
namespace omnibox = api::omnibox;
@@ -112,7 +105,8 @@ bool SetOmniboxDefaultSuggestion(
void ExtensionOmniboxEventRouter::OnInputStarted(
Profile* profile, const std::string& extension_id) {
scoped_ptr<Event> event(new Event(
- events::kOnInputStarted, make_scoped_ptr(new base::ListValue())));
+ omnibox::OnInputStarted::kEventName,
+ make_scoped_ptr(new base::ListValue())));
event->restrict_to_profile = profile;
ExtensionSystem::Get(profile)->event_router()->
DispatchEventToExtension(extension_id, event.Pass());
@@ -123,14 +117,16 @@ bool ExtensionOmniboxEventRouter::OnInputChanged(
Profile* profile, const std::string& extension_id,
const std::string& input, int suggest_id) {
if (!extensions::ExtensionSystem::Get(profile)->event_router()->
- ExtensionHasEventListener(extension_id, events::kOnInputChanged))
+ ExtensionHasEventListener(extension_id,
+ omnibox::OnInputChanged::kEventName))
return false;
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Set(0, new base::StringValue(input));
args->Set(1, new base::FundamentalValue(suggest_id));
- scoped_ptr<Event> event(new Event(events::kOnInputChanged, args.Pass()));
+ scoped_ptr<Event> event(new Event(omnibox::OnInputChanged::kEventName,
+ args.Pass()));
event->restrict_to_profile = profile;
ExtensionSystem::Get(profile)->event_router()->
DispatchEventToExtension(extension_id, event.Pass());
@@ -162,7 +158,8 @@ void ExtensionOmniboxEventRouter::OnInputEntered(
else
args->Set(1, new base::StringValue(kCurrentTabDisposition));
- scoped_ptr<Event> event(new Event(events::kOnInputEntered, args.Pass()));
+ scoped_ptr<Event> event(new Event(omnibox::OnInputEntered::kEventName,
+ args.Pass()));
event->restrict_to_profile = profile;
ExtensionSystem::Get(profile)->event_router()->
DispatchEventToExtension(extension_id, event.Pass());
@@ -177,7 +174,8 @@ void ExtensionOmniboxEventRouter::OnInputEntered(
void ExtensionOmniboxEventRouter::OnInputCancelled(
Profile* profile, const std::string& extension_id) {
scoped_ptr<Event> event(new Event(
- events::kOnInputCancelled, make_scoped_ptr(new base::ListValue())));
+ omnibox::OnInputCancelled::kEventName,
+ make_scoped_ptr(new base::ListValue())));
event->restrict_to_profile = profile;
ExtensionSystem::Get(profile)->event_router()->
DispatchEventToExtension(extension_id, event.Pass());
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
index 5cc854f..d9fdf77 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
@@ -13,7 +13,6 @@
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -78,7 +77,7 @@ void PushMessagingEventRouter::OnMessage(const std::string& extension_id,
scoped_ptr<base::ListValue> args(glue::OnMessage::Create(message));
scoped_ptr<extensions::Event> event(new extensions::Event(
- event_names::kOnPushMessage, args.Pass()));
+ glue::OnMessage::kEventName, args.Pass()));
event->restrict_to_profile = profile_;
ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension(
extension_id, event.Pass());
diff --git a/chrome/browser/extensions/api/recovery_private/recovery_operation_manager.cc b/chrome/browser/extensions/api/recovery_private/recovery_operation_manager.cc
index 3c80583..3bf999e 100644
--- a/chrome/browser/extensions/api/recovery_private/recovery_operation_manager.cc
+++ b/chrome/browser/extensions/api/recovery_private/recovery_operation_manager.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/extensions/api/recovery_private/recovery_operation_manager.h"
#include "chrome/browser/extensions/api/recovery_private/write_from_file_operation.h"
#include "chrome/browser/extensions/api/recovery_private/write_from_url_operation.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -17,6 +16,9 @@
#include "content/public/browser/notification_service.h"
namespace extensions {
+
+namespace recovery_private = extensions::api::recovery_private;
+
namespace recovery {
namespace {
@@ -112,8 +114,8 @@ void RecoveryOperationManager::OnProgress(const ExtensionId& extension_id,
info.percent_complete = progress;
scoped_ptr<base::ListValue> args(recovery_api::OnWriteProgress::Create(info));
- scoped_ptr<Event> event(new Event(event_names::kRecoveryOnWriteProgress,
- args.Pass()));
+ scoped_ptr<Event> event(new Event(
+ recovery_private::OnWriteProgress::kEventName, args.Pass()));
ExtensionSystem::Get(profile_)->event_router()->
DispatchEventToExtension(extension_id, event.Pass());
@@ -122,8 +124,8 @@ void RecoveryOperationManager::OnProgress(const ExtensionId& extension_id,
void RecoveryOperationManager::OnComplete(const ExtensionId& extension_id) {
scoped_ptr<base::ListValue> args(recovery_api::OnWriteComplete::Create());
- scoped_ptr<Event> event(new Event(event_names::kRecoveryOnWriteComplete,
- args.Pass()));
+ scoped_ptr<Event> event(new Event(
+ recovery_private::OnWriteComplete::kEventName, args.Pass()));
ExtensionSystem::Get(profile_)->event_router()->
DispatchEventToExtension(extension_id, event.Pass());
@@ -140,7 +142,7 @@ void RecoveryOperationManager::OnError(const ExtensionId& extension_id,
info.percent_complete = progress;
scoped_ptr<base::ListValue> args(recovery_api::OnWriteError::Create(info));
- scoped_ptr<Event> event(new Event(event_names::kRecoveryOnWriteError,
+ scoped_ptr<Event> event(new Event(recovery_private::OnWriteError::kEventName,
args.Pass()));
ExtensionSystem::Get(profile_)->event_router()->
diff --git a/chrome/browser/extensions/api/rtc_private/rtc_private_api.cc b/chrome/browser/extensions/api/rtc_private/rtc_private_api.cc
index ac1fe83..2fe759d 100644
--- a/chrome/browser/extensions/api/rtc_private/rtc_private_api.cc
+++ b/chrome/browser/extensions/api/rtc_private/rtc_private_api.cc
@@ -30,10 +30,10 @@ using contacts::Contact_PhoneNumber;
namespace extensions {
+namespace rtc_private = api::rtc_private;
+
namespace {
-// Launch event name.
-const char kOnLaunchEvent[] = "rtcPrivate.onLaunch";
// Web intent data payload mimetype.
const char kMimeTypeJson[] = "application/vnd.chromium.contact";
// Web intent data structure fields.
@@ -92,7 +92,7 @@ void RtcPrivateEventRouter::DispatchLaunchEvent(
Profile* profile, LaunchAction action, const Contact* contact) {
if (action == RtcPrivateEventRouter::LAUNCH_ACTIVATE) {
scoped_ptr<Event> event(new Event(
- kOnLaunchEvent, make_scoped_ptr(new ListValue())));
+ rtc_private::OnLaunch::kEventName, make_scoped_ptr(new ListValue())));
event->restrict_to_profile = profile;
ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass());
} else {
@@ -103,7 +103,8 @@ void RtcPrivateEventRouter::DispatchLaunchEvent(
&launch_data.intent.data.additional_properties);
launch_data.intent.type = kMimeTypeJson;
scoped_ptr<Event> event(new Event(
- kOnLaunchEvent, api::rtc_private::OnLaunch::Create(launch_data)));
+ rtc_private::OnLaunch::kEventName,
+ api::rtc_private::OnLaunch::Create(launch_data)));
event->restrict_to_profile = profile;
ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass());
}
diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc
index e54664e..5966e8a 100644
--- a/chrome/browser/extensions/api/runtime/runtime_api.cc
+++ b/chrome/browser/extensions/api/runtime/runtime_api.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/common/extensions/api/runtime.h"
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/omaha_query_params/omaha_query_params.h"
@@ -38,14 +39,10 @@ namespace GetPlatformInfo = extensions::api::runtime::GetPlatformInfo;
namespace extensions {
+namespace runtime = api::runtime;
+
namespace {
-const char kOnStartupEvent[] = "runtime.onStartup";
-const char kOnInstalledEvent[] = "runtime.onInstalled";
-const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable";
-const char kOnBrowserUpdateAvailableEvent[] =
- "runtime.onBrowserUpdateAvailable";
-const char kOnRestartRequiredEvent[] = "runtime.onRestartRequired";
const char kNoBackgroundPageError[] = "You do not have a background page.";
const char kPageLoadError[] = "Background page failed to load.";
const char kInstallReason[] = "reason";
@@ -105,7 +102,8 @@ static void DispatchOnStartupEventImpl(
}
scoped_ptr<base::ListValue> event_args(new base::ListValue());
- scoped_ptr<Event> event(new Event(kOnStartupEvent, event_args.Pass()));
+ scoped_ptr<Event> event(new Event(runtime::OnStartup::kEventName,
+ event_args.Pass()));
system->event_router()->DispatchEventToExtension(extension_id, event.Pass());
}
@@ -154,7 +152,8 @@ void RuntimeEventRouter::DispatchOnInstalledEvent(
info->SetString(kInstallReason, kInstallReasonInstall);
}
DCHECK(system->event_router());
- scoped_ptr<Event> event(new Event(kOnInstalledEvent, event_args.Pass()));
+ scoped_ptr<Event> event(new Event(runtime::OnInstalled::kEventName,
+ event_args.Pass()));
system->event_router()->DispatchEventWithLazyListener(extension_id,
event.Pass());
}
@@ -171,7 +170,8 @@ void RuntimeEventRouter::DispatchOnUpdateAvailableEvent(
scoped_ptr<base::ListValue> args(new base::ListValue);
args->Append(manifest->DeepCopy());
DCHECK(system->event_router());
- scoped_ptr<Event> event(new Event(kOnUpdateAvailableEvent, args.Pass()));
+ scoped_ptr<Event> event(new Event(runtime::OnUpdateAvailable::kEventName,
+ args.Pass()));
system->event_router()->DispatchEventToExtension(extension_id, event.Pass());
}
@@ -184,8 +184,8 @@ void RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(
scoped_ptr<base::ListValue> args(new base::ListValue);
DCHECK(system->event_router());
- scoped_ptr<Event> event(new Event(kOnBrowserUpdateAvailableEvent,
- args.Pass()));
+ scoped_ptr<Event> event(new Event(
+ runtime::OnBrowserUpdateAvailable::kEventName, args.Pass()));
system->event_router()->BroadcastEvent(event.Pass());
}
@@ -199,7 +199,7 @@ void RuntimeEventRouter::DispatchOnRestartRequiredEvent(
return;
scoped_ptr<Event> event(
- new Event(kOnRestartRequiredEvent,
+ new Event(runtime::OnRestartRequired::kEventName,
api::runtime::OnRestartRequired::Create(reason)));
DCHECK(system->event_router());
diff --git a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc
index 4d2453a..8e98df2 100644
--- a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc
+++ b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/storage/policy_value_store.h"
#include "chrome/browser/extensions/api/storage/settings_storage_factory.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -23,6 +22,7 @@
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/value_store/value_store_change.h"
+#include "chrome/common/extensions/api/storage.h"
#include "chrome/common/extensions/api/storage/storage_schema_manifest_handler.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
@@ -39,6 +39,8 @@ using content::BrowserThread;
namespace extensions {
+namespace storage = api::storage;
+
namespace {
const char kLoadSchemasBackgroundTaskTokenName[] =
@@ -180,7 +182,7 @@ ManagedValueStoreCache::ManagedValueStoreCache(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// |event_router_| can be NULL on unit_tests.
if (event_router_)
- event_router_->RegisterObserver(this, event_names::kOnSettingsChanged);
+ event_router_->RegisterObserver(this, storage::OnChanged::kEventName);
GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_EXTENSIONS, this);
@@ -278,7 +280,7 @@ void ManagedValueStoreCache::UpdatePolicyOnFILE(
void ManagedValueStoreCache::OnListenerAdded(
const EventListenerInfo& details) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK_EQ(std::string(event_names::kOnSettingsChanged), details.event_name);
+ DCHECK_EQ(std::string(storage::OnChanged::kEventName), details.event_name);
// This is invoked on several occasions:
//
// 1. when an extension first registers to observe storage.onChanged; in this
diff --git a/chrome/browser/extensions/api/storage/settings_frontend.cc b/chrome/browser/extensions/api/storage/settings_frontend.cc
index 05dc82d..86f4262 100644
--- a/chrome/browser/extensions/api/storage/settings_frontend.cc
+++ b/chrome/browser/extensions/api/storage/settings_frontend.cc
@@ -29,6 +29,8 @@ using content::BrowserThread;
namespace extensions {
+namespace storage = api::storage;
+
namespace {
// Settings change Observer which forwards changes on to the extension
@@ -49,7 +51,7 @@ class DefaultObserver : public SettingsObserver {
args->Append(new base::StringValue(settings_namespace::ToString(
settings_namespace)));
scoped_ptr<Event> event(new Event(
- event_names::kOnSettingsChanged, args.Pass()));
+ storage::OnChanged::kEventName, args.Pass()));
ExtensionSystem::Get(profile_)->event_router()->
DispatchEventToExtension(extension_id, event.Pass());
}
diff --git a/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc b/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc
index f5a8ae7..3b93044 100644
--- a/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc
+++ b/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc
@@ -65,9 +65,10 @@ void ExtensionSyncEventObserver::OnSyncStateUpdated(
scoped_ptr<base::ListValue> params(
api::sync_file_system::OnServiceStatusChanged::Create(service_info));
- BroadcastOrDispatchEvent(app_origin,
- event_names::kOnServiceStatusChanged,
- params.Pass());
+ BroadcastOrDispatchEvent(
+ app_origin,
+ api::sync_file_system::OnServiceStatusChanged::kEventName,
+ params.Pass());
}
void ExtensionSyncEventObserver::OnFileSynced(
@@ -92,9 +93,10 @@ void ExtensionSyncEventObserver::OnFileSynced(
params->AppendString(api::sync_file_system::ToString(action_enum));
params->AppendString(api::sync_file_system::ToString(direction_enum));
- BroadcastOrDispatchEvent(url.origin(),
- event_names::kOnFileStatusChanged,
- params.Pass());
+ BroadcastOrDispatchEvent(
+ url.origin(),
+ api::sync_file_system::OnFileStatusChanged::kEventName,
+ params.Pass());
}
void ExtensionSyncEventObserver::BroadcastOrDispatchEvent(
diff --git a/chrome/browser/extensions/api/system_indicator/system_indicator_manager.cc b/chrome/browser/extensions/api/system_indicator/system_indicator_manager.cc
index a7601f0..a8b344d 100644
--- a/chrome/browser/extensions/api/system_indicator/system_indicator_manager.cc
+++ b/chrome/browser/extensions/api/system_indicator/system_indicator_manager.cc
@@ -7,7 +7,6 @@
#include "base/memory/linked_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -24,6 +23,8 @@
namespace extensions {
+namespace system_indicator = api::system_indicator;
+
// Observes clicks on a given status icon and forwards the event to the
// appropriate extension. Handles icon updates, and responsible for creating
// and removing the icon from the notification area during construction and
@@ -86,7 +87,7 @@ void ExtensionIndicatorIcon::OnStatusIconClicked() {
EventRouter* event_router =
ExtensionSystem::Get(profile_)->event_router();
scoped_ptr<Event> event(new Event(
- event_names::kOnSystemIndicatorClicked,
+ system_indicator::OnClicked::kEventName,
params.Pass(),
profile_));
event_router->DispatchEventToExtension(
diff --git a/chrome/browser/extensions/api/system_info/system_info_api.cc b/chrome/browser/extensions/api/system_info/system_info_api.cc
index 546c878..20842a9 100644
--- a/chrome/browser/extensions/api/system_info/system_info_api.cc
+++ b/chrome/browser/extensions/api/system_info/system_info_api.cc
@@ -14,11 +14,11 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/system_storage/storage_info_provider.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/storage_monitor/removable_storage_observer.h"
#include "chrome/browser/storage_monitor/storage_info.h"
#include "chrome/browser/storage_monitor/storage_monitor.h"
+#include "chrome/common/extensions/api/system_display.h"
#include "chrome/common/extensions/api/system_storage.h"
#include "ui/gfx/display_observer.h"
@@ -32,10 +32,13 @@ namespace extensions {
using api::system_storage::StorageUnitInfo;
using content::BrowserThread;
+namespace system_display = api::system_display;
+namespace system_storage = api::system_storage;
+
namespace {
bool IsDisplayChangedEvent(const std::string& event_name) {
- return event_name == event_names::kOnDisplayChanged;
+ return event_name == system_display::OnDisplayChanged::kEventName;
}
// Event router for systemInfo API. It is a singleton instance shared by
@@ -136,7 +139,7 @@ void SystemInfoEventRouter::OnRemovableStorageAttached(
systeminfo::BuildStorageUnitInfo(info, &unit);
scoped_ptr<base::ListValue> args(new base::ListValue);
args->Append(unit.ToValue().release());
- DispatchEvent(event_names::kOnStorageAttached, args.Pass());
+ DispatchEvent(system_storage::OnAttached::kEventName, args.Pass());
}
void SystemInfoEventRouter::OnRemovableStorageDetached(
@@ -145,7 +148,7 @@ void SystemInfoEventRouter::OnRemovableStorageDetached(
args->Append(new base::StringValue(chrome::StorageMonitor::GetInstance()->
GetTransientIdForDeviceId(info.device_id())));
- DispatchEvent(event_names::kOnStorageDetached, args.Pass());
+ DispatchEvent(system_storage::OnDetached::kEventName, args.Pass());
}
void SystemInfoEventRouter::OnDisplayBoundsChanged(
@@ -163,7 +166,7 @@ void SystemInfoEventRouter::OnDisplayRemoved(const gfx::Display& old_display) {
void SystemInfoEventRouter::OnDisplayChanged() {
scoped_ptr<base::ListValue> args(new base::ListValue());
- DispatchEvent(event_names::kOnDisplayChanged, args.Pass());
+ DispatchEvent(system_display::OnDisplayChanged::kEventName, args.Pass());
}
void SystemInfoEventRouter::DispatchEvent(const std::string& event_name,
@@ -184,9 +187,9 @@ ProfileKeyedAPIFactory<SystemInfoAPI>* SystemInfoAPI::GetFactoryInstance() {
SystemInfoAPI::SystemInfoAPI(Profile* profile) : profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, event_names::kOnStorageAttached);
+ this, system_storage::OnAttached::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, event_names::kOnStorageDetached);
+ this, system_storage::OnDetached::kEventName);
}
SystemInfoAPI::~SystemInfoAPI() {
diff --git a/chrome/browser/extensions/api/system_private/system_private_api.cc b/chrome/browser/extensions/api/system_private/system_private_api.cc
index 758f6b7..ec42006 100644
--- a/chrome/browser/extensions/api/system_private/system_private_api.cc
+++ b/chrome/browser/extensions/api/system_private/system_private_api.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/system_private.h"
#include "chrome/common/pref_names.h"
#if defined(OS_CHROMEOS)
@@ -41,12 +42,6 @@ const char kNotAvailableState[] = "NotAvailable";
const char kUpdatingState[] = "Updating";
const char kNeedRestartState[] = "NeedRestart";
-// Event names.
-const char kOnBrightnessChanged[] = "systemPrivate.onBrightnessChanged";
-const char kOnVolumeChanged[] = "systemPrivate.onVolumeChanged";
-const char kOnScreenUnlocked[] = "systemPrivate.onScreenUnlocked";
-const char kOnWokeUp[] = "systemPrivate.onWokeUp";
-
// Dispatches an extension event with |argument|
void DispatchEvent(const std::string& event_name, base::Value* argument) {
scoped_ptr<base::ListValue> list_args(new base::ListValue());
@@ -61,6 +56,8 @@ void DispatchEvent(const std::string& event_name, base::Value* argument) {
namespace extensions {
+namespace system_private = api::system_private;
+
bool SystemPrivateGetIncognitoModeAvailabilityFunction::RunImpl() {
PrefService* prefs = profile_->GetPrefs();
int value = prefs->GetInteger(prefs::kIncognitoModeAvailability);
@@ -136,22 +133,22 @@ void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) {
base::DictionaryValue* dict = new base::DictionaryValue();
dict->SetDouble(kVolumeKey, volume);
dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted);
- DispatchEvent(kOnVolumeChanged, dict);
+ DispatchEvent(system_private::OnVolumeChanged::kEventName, dict);
}
void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) {
base::DictionaryValue* dict = new base::DictionaryValue();
dict->SetInteger(kBrightnessKey, brightness);
dict->SetBoolean(kUserInitiatedKey, user_initiated);
- DispatchEvent(kOnBrightnessChanged, dict);
+ DispatchEvent(system_private::OnBrightnessChanged::kEventName, dict);
}
void DispatchScreenUnlockedEvent() {
- DispatchEvent(kOnScreenUnlocked, NULL);
+ DispatchEvent(system_private::OnScreenUnlocked::kEventName, NULL);
}
void DispatchWokeUpEvent() {
- DispatchEvent(kOnWokeUp, NULL);
+ DispatchEvent(system_private::OnWokeUp::kEventName, NULL);
}
} // namespace extensions
diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc
index 757db57..1fa0080 100644
--- a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc
+++ b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc
@@ -7,7 +7,6 @@
#include <utility>
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
@@ -28,6 +27,8 @@ using extensions::tab_capture::TabCaptureState;
namespace extensions {
+namespace tab_capture = api::tab_capture;
+
class FullscreenObserver : public content::WebContentsObserver {
public:
FullscreenObserver(TabCaptureRequest* request,
@@ -314,8 +315,8 @@ void TabCaptureRegistry::DispatchStatusChangeEvent(
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(info->ToValue().release());
- scoped_ptr<Event> event(new Event(
- extensions::event_names::kOnTabCaptureStatusChanged, args.Pass()));
+ scoped_ptr<Event> event(new Event(tab_capture::OnStatusChanged::kEventName,
+ args.Pass()));
event->restrict_to_profile = profile_;
router->DispatchEventToExtension(request->extension_id, event.Pass());
diff --git a/chrome/browser/extensions/api/tabs/tabs_windows_api.cc b/chrome/browser/extensions/api/tabs/tabs_windows_api.cc
index 24cb81d..5f40de2 100644
--- a/chrome/browser/extensions/api/tabs/tabs_windows_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_windows_api.cc
@@ -6,20 +6,22 @@
#include "base/lazy_instance.h"
#include "chrome/browser/extensions/api/tabs/windows_event_router.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/common/extensions/api/windows.h"
namespace extensions {
+namespace windows = api::windows;
+
TabsWindowsAPI::TabsWindowsAPI(Profile* profile)
: profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, event_names::kOnWindowCreated);
+ this, windows::OnCreated::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, event_names::kOnWindowRemoved);
+ this, windows::OnRemoved::kEventName);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
- this, event_names::kOnWindowFocusedChanged);
+ this, windows::OnFocusChanged::kEventName);
}
TabsWindowsAPI::~TabsWindowsAPI() {
diff --git a/chrome/browser/extensions/api/tabs/windows_event_router.cc b/chrome/browser/extensions/api/tabs/windows_event_router.cc
index e6a8a57..efdac24 100644
--- a/chrome/browser/extensions/api/tabs/windows_event_router.cc
+++ b/chrome/browser/extensions/api/tabs/windows_event_router.cc
@@ -6,13 +6,13 @@
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/extensions/window_controller_list.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/windows.h"
#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/notification_service.h"
@@ -20,10 +20,10 @@
#include "ui/base/x/active_window_watcher_x.h"
#endif
-namespace event_names = extensions::event_names;
-
namespace extensions {
+namespace windows = extensions::api::windows;
+
WindowsEventRouter::WindowsEventRouter(Profile* profile)
: profile_(profile),
focused_profile_(NULL),
@@ -61,7 +61,7 @@ void WindowsEventRouter::OnWindowControllerAdded(
base::DictionaryValue* window_dictionary =
window_controller->CreateWindowValue();
args->Append(window_dictionary);
- DispatchEvent(event_names::kOnWindowCreated, window_controller->profile(),
+ DispatchEvent(windows::OnCreated::kEventName, window_controller->profile(),
args.Pass());
}
@@ -73,7 +73,8 @@ void WindowsEventRouter::OnWindowControllerRemoved(
int window_id = window_controller->GetWindowId();
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(new base::FundamentalValue(window_id));
- DispatchEvent(event_names::kOnWindowRemoved, window_controller->profile(),
+ DispatchEvent(windows::OnRemoved::kEventName,
+ window_controller->profile(),
args.Pass());
}
@@ -143,7 +144,7 @@ void WindowsEventRouter::OnActiveWindowChanged(
focused_profile_ = window_profile;
focused_window_id_ = window_id;
- scoped_ptr<Event> event(new Event(event_names::kOnWindowFocusedChanged,
+ scoped_ptr<Event> event(new Event(windows::OnFocusChanged::kEventName,
make_scoped_ptr(new base::ListValue())));
event->will_dispatch_callback =
base::Bind(&WillDispatchWindowFocusedEvent, window_profile, window_id);
diff --git a/chrome/browser/extensions/api/terminal/terminal_private_api.cc b/chrome/browser/extensions/api/terminal/terminal_private_api.cc
index fb5ef8a..a7cfdcb 100644
--- a/chrome/browser/extensions/api/terminal/terminal_private_api.cc
+++ b/chrome/browser/extensions/api/terminal/terminal_private_api.cc
@@ -9,7 +9,6 @@
#include "base/json/json_writer.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -18,6 +17,7 @@
#include "chromeos/process_proxy/process_proxy_registry.h"
#include "content/public/browser/browser_thread.h"
+namespace terminal_private = extensions::api::terminal_private;
namespace OnTerminalResize =
extensions::api::terminal_private::OnTerminalResize;
namespace OpenTerminalProcess =
@@ -65,7 +65,7 @@ void NotifyProcessOutput(Profile* profile,
if (profile &&
extensions::ExtensionSystem::Get(profile)->event_router()) {
scoped_ptr<extensions::Event> event(new extensions::Event(
- extensions::event_names::kOnTerminalProcessOutput, args.Pass()));
+ terminal_private::OnProcessOutput::kEventName, args.Pass()));
extensions::ExtensionSystem::Get(profile)->event_router()->
DispatchEventToExtension(extension_id, event.Pass());
}
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
diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc
index 478c990..acccfcf 100644
--- a/chrome/browser/extensions/api/web_request/web_request_api.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_api.cc
@@ -93,10 +93,10 @@ const char kWebView[] = "webview";
// List of all the webRequest events.
const char* const kWebRequestEvents[] = {
keys::kOnBeforeRedirectEvent,
- keys::kOnBeforeRequestEvent,
+ web_request::OnBeforeRequest::kEventName,
keys::kOnBeforeSendHeadersEvent,
keys::kOnCompletedEvent,
- keys::kOnErrorOccurredEvent,
+ web_request::OnErrorOccurred::kEventName,
keys::kOnSendHeadersEvent,
keys::kOnAuthRequiredEvent,
keys::kOnResponseStartedEvent,
@@ -631,13 +631,13 @@ int ExtensionWebRequestEventRouter::OnBeforeRequest(
initialize_blocked_requests |=
ProcessDeclarativeRules(profile, extension_info_map,
- keys::kOnBeforeRequestEvent, request,
+ web_request::OnBeforeRequest::kEventName, request,
extensions::ON_BEFORE_REQUEST, NULL);
int extra_info_spec = 0;
std::vector<const EventListener*> listeners =
GetMatchingListeners(profile, extension_info_map,
- keys::kOnBeforeRequestEvent, request,
+ web_request::OnBeforeRequest::kEventName, request,
&extra_info_spec);
if (!listeners.empty() &&
!GetAndSetSignaled(request->identifier(), kOnBeforeRequest)) {
@@ -1057,7 +1057,7 @@ void ExtensionWebRequestEventRouter::OnErrorOccurred(
int extra_info_spec = 0;
std::vector<const EventListener*> listeners =
GetMatchingListeners(profile, extension_info_map,
- keys::kOnErrorOccurredEvent, request,
+ web_request::OnErrorOccurred::kEventName, request,
&extra_info_spec);
if (listeners.empty())
return;
diff --git a/chrome/browser/extensions/api/web_request/web_request_api_constants.cc b/chrome/browser/extensions/api/web_request/web_request_api_constants.cc
index ffcd8dd..493a903d 100644
--- a/chrome/browser/extensions/api/web_request/web_request_api_constants.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_api_constants.cc
@@ -44,10 +44,8 @@ const char kUsernameKey[] = "username";
const char kPasswordKey[] = "password";
const char kOnBeforeRedirectEvent[] = "webRequest.onBeforeRedirect";
-const char kOnBeforeRequestEvent[] = "webRequest.onBeforeRequest";
const char kOnBeforeSendHeadersEvent[] = "webRequest.onBeforeSendHeaders";
const char kOnCompletedEvent[] = "webRequest.onCompleted";
-const char kOnErrorOccurredEvent[] = "webRequest.onErrorOccurred";
const char kOnHeadersReceivedEvent[] = "webRequest.onHeadersReceived";
const char kOnResponseStartedEvent[] = "webRequest.onResponseStarted";
const char kOnSendHeadersEvent[] = "webRequest.onSendHeaders";
diff --git a/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc b/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc
index 1a71294..ac8fb70 100644
--- a/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/extensions/extension_warning_set.h"
#include "chrome/browser/net/about_protocol_handler.h"
#include "chrome/browser/net/chrome_network_delegate.h"
+#include "chrome/common/extensions/api/web_request.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/features/feature.h"
#include "chrome/common/pref_names.h"
@@ -52,6 +53,7 @@
namespace helpers = extension_web_request_api_helpers;
namespace keys = extension_web_request_api_constants;
+namespace web_request = extensions::api::web_request;
using base::BinaryValue;
using base::DictionaryValue;
@@ -218,7 +220,7 @@ TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) {
std::string extension1_id("1");
std::string extension2_id("2");
ExtensionWebRequestEventRouter::RequestFilter filter;
- const std::string kEventName(keys::kOnBeforeRequestEvent);
+ const std::string kEventName(web_request::OnBeforeRequest::kEventName);
base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
&profile_, extension1_id, extension1_id, kEventName, kEventName + "/1",
@@ -353,7 +355,7 @@ TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceCancel) {
std::string extension1_id("1");
std::string extension2_id("2");
ExtensionWebRequestEventRouter::RequestFilter filter;
- const std::string kEventName(keys::kOnBeforeRequestEvent);
+ const std::string kEventName(web_request::OnBeforeRequest::kEventName);
base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
&profile_, extension1_id, extension1_id, kEventName, kEventName + "/1",
@@ -420,8 +422,8 @@ TEST_F(ExtensionWebRequestTest, SimulateChancelWhileBlocked) {
ExtensionWebRequestEventRouter::RequestFilter filter;
// Subscribe to OnBeforeRequest and OnErrorOccurred.
- const std::string kEventName(keys::kOnBeforeRequestEvent);
- const std::string kEventName2(keys::kOnErrorOccurredEvent);
+ const std::string kEventName(web_request::OnBeforeRequest::kEventName);
+ const std::string kEventName2(web_request::OnErrorOccurred::kEventName);
base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
&profile_, extension_id, extension_id, kEventName, kEventName + "/1",
@@ -604,7 +606,7 @@ TEST_F(ExtensionWebRequestTest, AccessRequestBodyData) {
#undef kBoundary
// Set up a dummy extension name.
- const std::string kEventName(keys::kOnBeforeRequestEvent);
+ const std::string kEventName(web_request::OnBeforeRequest::kEventName);
ExtensionWebRequestEventRouter::RequestFilter filter;
std::string extension_id("1");
const std::string string_spec_post("blocking,requestBody");
@@ -695,7 +697,7 @@ TEST_F(ExtensionWebRequestTest, NoAccessRequestBodyData) {
const char* kMethods[] = { "POST", "PUT", "GET" };
// Set up a dummy extension name.
- const std::string kEventName(keys::kOnBeforeRequestEvent);
+ const std::string kEventName(web_request::OnBeforeRequest::kEventName);
ExtensionWebRequestEventRouter::RequestFilter filter;
const std::string extension_id("1");
int extra_info_spec = 0;
diff --git a/chrome/browser/extensions/browser_event_router.cc b/chrome/browser/extensions/browser_event_router.cc
index 635781a..baa4171 100644
--- a/chrome/browser/extensions/browser_event_router.cc
+++ b/chrome/browser/extensions/browser_event_router.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/api/tabs/tabs_windows_api.h"
#include "chrome/browser/extensions/api/tabs/windows_event_router.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -31,7 +30,6 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
-namespace events = extensions::event_names;
namespace tab_keys = extensions::tabs_constants;
namespace page_actions_keys = extension_page_actions_api_constants;
@@ -40,6 +38,8 @@ using content::WebContents;
namespace extensions {
+namespace tabs = api::tabs;
+
BrowserEventRouter::TabEntry::TabEntry()
: complete_waiting_on_load_(false),
url_() {
@@ -178,7 +178,7 @@ void BrowserEventRouter::TabCreatedAt(WebContents* contents,
bool active) {
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
scoped_ptr<base::ListValue> args(new base::ListValue());
- scoped_ptr<Event> event(new Event(events::kOnTabCreated, args.Pass()));
+ scoped_ptr<Event> event(new Event(tabs::OnCreated::kEventName, args.Pass()));
event->restrict_to_profile = profile;
event->user_gesture = EventRouter::USER_GESTURE_NOT_ENABLED;
event->will_dispatch_callback =
@@ -211,7 +211,7 @@ void BrowserEventRouter::TabInsertedAt(WebContents* contents,
args->Append(object_args);
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
- DispatchEvent(profile, events::kOnTabAttached, args.Pass(),
+ DispatchEvent(profile, tabs::OnAttached::kEventName, args.Pass(),
EventRouter::USER_GESTURE_UNKNOWN);
}
@@ -233,7 +233,7 @@ void BrowserEventRouter::TabDetachedAt(WebContents* contents, int index) {
args->Append(object_args);
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
- DispatchEvent(profile, events::kOnTabDetached, args.Pass(),
+ DispatchEvent(profile, tabs::OnDetached::kEventName, args.Pass(),
EventRouter::USER_GESTURE_UNKNOWN);
}
@@ -253,7 +253,7 @@ void BrowserEventRouter::TabClosingAt(TabStripModel* tab_strip_model,
args->Append(object_args);
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
- DispatchEvent(profile, events::kOnTabRemoved, args.Pass(),
+ DispatchEvent(profile, tabs::OnRemoved::kEventName, args.Pass(),
EventRouter::USER_GESTURE_UNKNOWN);
int removed_count = tab_entries_.erase(tab_id);
@@ -283,15 +283,15 @@ void BrowserEventRouter::ActiveTabChanged(WebContents* old_contents,
reason & CHANGE_REASON_USER_GESTURE
? EventRouter::USER_GESTURE_ENABLED
: EventRouter::USER_GESTURE_NOT_ENABLED;
- DispatchEvent(profile, events::kOnTabSelectionChanged,
+ DispatchEvent(profile, tabs::OnSelectionChanged::kEventName,
scoped_ptr<base::ListValue>(args->DeepCopy()), gesture);
- DispatchEvent(profile, events::kOnTabActiveChanged,
+ DispatchEvent(profile, tabs::OnActiveChanged::kEventName,
scoped_ptr<base::ListValue>(args->DeepCopy()), gesture);
// The onActivated event takes one argument: {windowId, tabId}.
args->Remove(0, NULL);
object_args->Set(tab_keys::kTabIdKey, new base::FundamentalValue(tab_id));
- DispatchEvent(profile, events::kOnTabActivated, args.Pass(), gesture);
+ DispatchEvent(profile, tabs::OnActivated::kEventName, args.Pass(), gesture);
}
void BrowserEventRouter::TabSelectionChanged(
@@ -321,10 +321,10 @@ void BrowserEventRouter::TabSelectionChanged(
// The onHighlighted event replaced onHighlightChanged.
Profile* profile = tab_strip_model->profile();
- DispatchEvent(profile, events::kOnTabHighlightChanged,
+ DispatchEvent(profile, tabs::OnHighlightChanged::kEventName,
scoped_ptr<base::ListValue>(args->DeepCopy()),
EventRouter::USER_GESTURE_UNKNOWN);
- DispatchEvent(profile, events::kOnTabHighlighted, args.Pass(),
+ DispatchEvent(profile, tabs::OnHighlighted::kEventName, args.Pass(),
EventRouter::USER_GESTURE_UNKNOWN);
}
@@ -345,7 +345,7 @@ void BrowserEventRouter::TabMoved(WebContents* contents,
args->Append(object_args);
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
- DispatchEvent(profile, events::kOnTabMoved, args.Pass(),
+ DispatchEvent(profile, tabs::OnMoved::kEventName, args.Pass(),
EventRouter::USER_GESTURE_UNKNOWN);
}
@@ -462,7 +462,8 @@ void BrowserEventRouter::DispatchTabUpdatedEvent(
// WillDispatchTabUpdatedEvent.
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
- scoped_ptr<Event> event(new Event(events::kOnTabUpdated, args_base.Pass()));
+ scoped_ptr<Event> event(new Event(tabs::OnUpdated::kEventName,
+ args_base.Pass()));
event->restrict_to_profile = profile;
event->user_gesture = EventRouter::USER_GESTURE_NOT_ENABLED;
event->will_dispatch_callback =
@@ -524,7 +525,7 @@ void BrowserEventRouter::TabReplacedAt(TabStripModel* tab_strip_model,
args->Append(new base::FundamentalValue(old_tab_id));
DispatchEvent(Profile::FromBrowserContext(new_contents->GetBrowserContext()),
- events::kOnTabReplaced,
+ tabs::OnReplaced::kEventName,
args.Pass(),
EventRouter::USER_GESTURE_UNKNOWN);
diff --git a/chrome/browser/extensions/event_names.cc b/chrome/browser/extensions/event_names.cc
index 2fb55be..5c59a39 100644
--- a/chrome/browser/extensions/event_names.cc
+++ b/chrome/browser/extensions/event_names.cc
@@ -8,28 +8,6 @@ namespace extensions {
namespace event_names {
-const char kOnTabActivated[] = "tabs.onActivated";
-const char kOnTabActiveChanged[] = "tabs.onActiveChanged";
-const char kOnTabAttached[] = "tabs.onAttached";
-const char kOnTabCreated[] = "tabs.onCreated";
-const char kOnTabDetached[] = "tabs.onDetached";
-const char kOnTabHighlightChanged[] = "tabs.onHighlightChanged";
-const char kOnTabHighlighted[] = "tabs.onHighlighted";
-const char kOnTabMoved[] = "tabs.onMoved";
-const char kOnTabRemoved[] = "tabs.onRemoved";
-const char kOnTabReplaced[] = "tabs.onReplaced";
-const char kOnTabSelectionChanged[] = "tabs.onSelectionChanged";
-const char kOnTabUpdated[] = "tabs.onUpdated";
-
-const char kOnWindowCreated[] = "windows.onCreated";
-const char kOnWindowFocusedChanged[] = "windows.onFocusChanged";
-const char kOnWindowRemoved[] = "windows.onRemoved";
-
-const char kOnExtensionInstalled[] = "management.onInstalled";
-const char kOnExtensionUninstalled[] = "management.onUninstalled";
-const char kOnExtensionEnabled[] = "management.onEnabled";
-const char kOnExtensionDisabled[] = "management.onDisabled";
-
const char kOnDirectoryChanged[] = "fileBrowserPrivate.onDirectoryChanged";
const char kOnFileBrowserMountCompleted[] =
"fileBrowserPrivate.onMountCompleted";
@@ -43,72 +21,20 @@ const char kOnFileBrowserDriveConnectionStatusChanged[] =
const char kOnInputMethodChanged[] = "inputMethodPrivate.onChanged";
const char kOnContextMenus[] = "contextMenus";
-const char kOnContextMenuClicked[] = "contextMenus.onClicked";
-
-const char kOnDialDeviceList[] = "dial.onDeviceList";
-const char kOnDialError[] = "dial.onError";
-
-const char kOnDownloadCreated[] = "downloads.onCreated";
-const char kOnDownloadChanged[] = "downloads.onChanged";
-const char kOnDownloadErased[] = "downloads.onErased";
-const char kOnDownloadDeterminingFilename[] = "downloads.onDeterminingFilename";
-
-const char kOnSettingsChanged[] = "storage.onChanged";
-
-const char kOnTerminalProcessOutput[] = "terminalPrivate.onProcessOutput";
const char kOnOffscreenTabUpdated[] = "experimental.offscreenTabs.onUpdated";
-const char kOnTabCaptureStatusChanged[] = "tabCapture.onStatusChanged";
-
-const char kBluetoothOnAdapterStateChanged[] =
- "bluetooth.onAdapterStateChanged";
-const char kBluetoothOnConnection[] = "bluetooth.onConnection";
const char kBluetoothOnDeviceDiscovered[] = "bluetooth.onDeviceDiscovered";
const char kBluetoothOnDeviceSearchFinished[] =
"bluetooth.onDeviceSearchFinished";
const char kBluetoothOnDeviceSearchResult[] = "bluetooth.onDeviceSearchResult";
-const char kOnPushMessage[] = "pushMessaging.onMessage";
-
const char kOnDisplayChanged[] = "system.display.onDisplayChanged";
const char kOnStorageAvailableCapacityChanged[] =
"system.storage.onAvailableCapacityChanged";
-const char kOnStorageAttached[] = "system.storage.onAttached";
-const char kOnStorageDetached[] = "system.storage.onDetached";
-
-const char kOnSystemIndicatorClicked[] = "systemIndicator.onClicked";
-
-const char kOnServiceStatusChanged[] = "syncFileSystem.onServiceStatusChanged";
-const char kOnFileStatusChanged[] = "syncFileSystem.onFileStatusChanged";
-
-const char kOnAttachEventName[] = "mediaGalleriesPrivate.onDeviceAttached";
-const char kOnDetachEventName[] = "mediaGalleriesPrivate.onDeviceDetached";
-const char kOnGalleryChangedEventName[] =
- "mediaGalleriesPrivate.onGalleryChanged";
const char kOnNotificationDisplayed[] = "notifications.onDisplayed";
const char kOnNotificationError[] = "notifications.onError";
-const char kOnNotificationClosed[] = "notifications.onClosed";
-const char kOnNotificationClicked[] = "notifications.onClicked";
-const char kOnNotificationButtonClicked[] = "notifications.onButtonClicked";
-
-const char kOnNetworksChanged[] = "networkingPrivate.onNetworksChanged";
-const char kOnNetworkListChanged[] = "networkingPrivate.onNetworkListChanged";
-
-const char kOnAudioDeviceChanged[] = "audio.onDeviceChanged";
-
-const char kOnLaunched[] = "app.runtime.onLaunched";
-const char kOnRestarted[] = "app.runtime.onRestarted";
-
-const char kOnFeedbackRequested[] = "feedbackPrivate.onFeedbackRequested";
-
-const char kDeveloperPrivateOnItemStateChanged[] =
- "developerPrivate.onItemStateChanged";
-
-const char kRecoveryOnWriteProgress[] = "recoveryPrivate.onWriteProgress";
-const char kRecoveryOnWriteComplete[] = "recoveryPrivate.onWriteComplete";
-const char kRecoveryOnWriteError[] = "recoveryPrivate.onWriteError";
} // namespace event_names
diff --git a/chrome/browser/extensions/event_names.h b/chrome/browser/extensions/event_names.h
index 9e005e2..0a1ebd6d 100644
--- a/chrome/browser/extensions/event_names.h
+++ b/chrome/browser/extensions/event_names.h
@@ -11,31 +11,6 @@ namespace extensions {
namespace event_names {
-// Tabs.
-extern const char kOnTabActivated[];
-extern const char kOnTabActiveChanged[];
-extern const char kOnTabAttached[];
-extern const char kOnTabCreated[];
-extern const char kOnTabDetached[];
-extern const char kOnTabHighlightChanged[];
-extern const char kOnTabHighlighted[];
-extern const char kOnTabMoved[];
-extern const char kOnTabRemoved[];
-extern const char kOnTabReplaced[];
-extern const char kOnTabSelectionChanged[];
-extern const char kOnTabUpdated[];
-
-// Windows.
-extern const char kOnWindowCreated[];
-extern const char kOnWindowFocusedChanged[];
-extern const char kOnWindowRemoved[];
-
-// Management.
-extern const char kOnExtensionInstalled[];
-extern const char kOnExtensionUninstalled[];
-extern const char kOnExtensionEnabled[];
-extern const char kOnExtensionDisabled[];
-
// FileBrowser.
extern const char kOnDirectoryChanged[];
extern const char kOnFileBrowserMountCompleted[];
@@ -49,86 +24,22 @@ extern const char kOnInputMethodChanged[];
// Context menus.
extern const char kOnContextMenus[];
-extern const char kOnContextMenuClicked[];
-
-// DIAL.
-extern const char kOnDialDeviceList[];
-extern const char kOnDialError[];
-
-// Downloads.
-extern const char kOnDownloadCreated[];
-extern const char kOnDownloadChanged[];
-extern const char kOnDownloadErased[];
-extern const char kOnDownloadDeterminingFilename[];
-
-// Settings.
-extern const char kOnSettingsChanged[];
-
-// TerminalPrivate.
-extern const char kOnTerminalProcessOutput[];
// OffscreenTabs.
extern const char kOnOffscreenTabUpdated[];
-// Tab content capture.
-extern const char kOnTabCaptureStatusChanged[];
-
// Bluetooth.
-extern const char kBluetoothOnAdapterStateChanged[];
-extern const char kBluetoothOnConnection[];
extern const char kBluetoothOnDeviceDiscovered[];
extern const char kBluetoothOnDeviceSearchFinished[];
extern const char kBluetoothOnDeviceSearchResult[];
-// Push messaging.
-extern const char kOnPushMessage[];
-
// systemInfo event names.
extern const char kOnDisplayChanged[];
extern const char kOnStorageAvailableCapacityChanged[];
-extern const char kOnStorageAttached[];
-extern const char kOnStorageDetached[];
-
-// System Indicator icon.
-extern const char kOnSystemIndicatorClicked[];
-
-// SyncFileSystem.
-extern const char kOnServiceStatusChanged[];
-extern const char kOnFileStatusChanged[];
-
-// MediaGalleriesPrivate.
-extern const char kOnAttachEventName[];
-extern const char kOnDetachEventName[];
-extern const char kOnGalleryChangedEventName[];
// Notifications.
extern const char kOnNotificationDisplayed[];
extern const char kOnNotificationError[];
-extern const char kOnNotificationClosed[];
-extern const char kOnNotificationClicked[];
-extern const char kOnNotificationButtonClicked[];
-
-// NetworkingPrivate
-extern const char kOnNetworksChanged[];
-extern const char kOnNetworkListChanged[];
-
-// Audio
-extern const char kOnAudioDeviceChanged[];
-
-// Runtime.
-extern const char kOnLaunched[];
-extern const char kOnRestarted[];
-
-// FeedbackPrivate
-extern const char kOnFeedbackRequested[];
-
-// DeveloperPrivate.
-extern const char kDeveloperPrivateOnItemStateChanged[];
-
-// ImageWriter
-extern const char kRecoveryOnWriteProgress[];
-extern const char kRecoveryOnWriteComplete[];
-extern const char kRecoveryOnWriteError[];
} // namespace event_names
diff --git a/chrome/browser/extensions/menu_manager.cc b/chrome/browser/extensions/menu_manager.cc
index 2091db8..6b0303d 100644
--- a/chrome/browser/extensions/menu_manager.cc
+++ b/chrome/browser/extensions/menu_manager.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/extensions/state_store.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/context_menus.h"
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/notification_details.h"
@@ -35,6 +36,8 @@ using extensions::ExtensionSystem;
namespace extensions {
+namespace context_menus = api::context_menus;
+
namespace {
// Keys for serialization to and from Value to store in the preferences.
@@ -681,7 +684,7 @@ void MenuManager::ExecuteCommand(Profile* profile,
event_router->DispatchEventToExtension(item->extension_id(), event.Pass());
}
{
- scoped_ptr<Event> event(new Event(event_names::kOnContextMenuClicked,
+ scoped_ptr<Event> event(new Event(context_menus::OnClicked::kEventName,
args.Pass()));
event->restrict_to_profile = profile;
event->user_gesture = EventRouter::USER_GESTURE_ENABLED;
diff --git a/chrome/browser/extensions/menu_manager_unittest.cc b/chrome/browser/extensions/menu_manager_unittest.cc
index 5b402be..80e7c60 100644
--- a/chrome/browser/extensions/menu_manager_unittest.cc
+++ b/chrome/browser/extensions/menu_manager_unittest.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/extensions/api/context_menus.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/test/base/testing_profile.h"
@@ -40,6 +41,8 @@ using testing::SaveArg;
namespace extensions {
+namespace context_menus = api::context_menus;
+
// Base class for tests.
class MenuManagerTest : public testing::Test {
public:
@@ -588,7 +591,7 @@ TEST_F(MenuManagerTest, ExecuteCommand) {
EXPECT_CALL(*mock_event_router,
DispatchEventToExtensionMock(
item->extension_id(),
- extensions::event_names::kOnContextMenuClicked,
+ context_menus::OnClicked::kEventName,
_,
&profile,
GURL(),
diff --git a/chrome/browser/extensions/permissions_updater.cc b/chrome/browser/extensions/permissions_updater.cc
index e52af60..5ca9f53 100644
--- a/chrome/browser/extensions/permissions_updater.cc
+++ b/chrome/browser/extensions/permissions_updater.cc
@@ -27,12 +27,7 @@ using extensions::permissions_api_helpers::PackPermissionSet;
namespace extensions {
-namespace {
-
-const char kOnAdded[] = "permissions.onAdded";
-const char kOnRemoved[] = "permissions.onRemoved";
-
-} // namespace
+namespace permissions = api::permissions;
PermissionsUpdater::PermissionsUpdater(Profile* profile)
: profile_(profile) {}
@@ -123,11 +118,11 @@ void PermissionsUpdater::NotifyPermissionsUpdated(
if (event_type == REMOVED) {
reason = UpdatedExtensionPermissionsInfo::REMOVED;
- event_name = kOnRemoved;
+ event_name = permissions::OnRemoved::kEventName;
} else {
CHECK_EQ(ADDED, event_type);
reason = UpdatedExtensionPermissionsInfo::ADDED;
- event_name = kOnAdded;
+ event_name = permissions::OnAdded::kEventName;
}
// Notify other APIs or interested parties.