summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/shell/browser/shell_extensions_browser_client.cc6
-rw-r--r--apps/shell/browser/shell_extensions_browser_client.h2
-rw-r--r--chrome/browser/extensions/activity_log/activity_database.h2
-rw-r--r--chrome/browser/extensions/activity_log/activity_log.cc32
-rw-r--r--chrome/browser/extensions/activity_log/activity_log.h22
-rw-r--r--chrome/browser/extensions/activity_log/counting_policy_unittest.cc4
-rw-r--r--chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc2
-rw-r--r--chrome/browser/extensions/chrome_extensions_browser_client.cc7
-rw-r--r--chrome/browser/extensions/chrome_extensions_browser_client.h2
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc50
-rw-r--r--extensions/browser/api_activity_monitor.h39
-rw-r--r--extensions/browser/event_router.cc83
-rw-r--r--extensions/browser/event_router.h30
-rw-r--r--extensions/browser/extensions_browser_client.h6
-rw-r--r--extensions/extensions.gyp1
15 files changed, 165 insertions, 123 deletions
diff --git a/apps/shell/browser/shell_extensions_browser_client.cc b/apps/shell/browser/shell_extensions_browser_client.cc
index 0ed1f1b..079e5a0 100644
--- a/apps/shell/browser/shell_extensions_browser_client.cc
+++ b/apps/shell/browser/shell_extensions_browser_client.cc
@@ -122,6 +122,12 @@ ShellExtensionsBrowserClient::GetJavaScriptDialogManager() {
return NULL;
}
+ApiActivityMonitor* ShellExtensionsBrowserClient::GetApiActivityMonitor(
+ BrowserContext* context) {
+ // app_shell doesn't monitor API function calls or events.
+ return NULL;
+}
+
std::vector<BrowserContextKeyedServiceFactory*>
ShellExtensionsBrowserClient::GetExtensionSystemDependencies() {
return ShellExtensionSystem::GetDependencies();
diff --git a/apps/shell/browser/shell_extensions_browser_client.h b/apps/shell/browser/shell_extensions_browser_client.h
index 106ccc7..61f9bcb 100644
--- a/apps/shell/browser/shell_extensions_browser_client.h
+++ b/apps/shell/browser/shell_extensions_browser_client.h
@@ -46,6 +46,8 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {
virtual bool IsRunningInForcedAppMode() OVERRIDE;
virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager()
OVERRIDE;
+ virtual ApiActivityMonitor* GetApiActivityMonitor(
+ content::BrowserContext* context) OVERRIDE;
virtual std::vector<BrowserContextKeyedServiceFactory*>
GetExtensionSystemDependencies() OVERRIDE;
virtual ExtensionSystem* CreateExtensionSystem(
diff --git a/chrome/browser/extensions/activity_log/activity_database.h b/chrome/browser/extensions/activity_log/activity_database.h
index a71dd1c..8435709 100644
--- a/chrome/browser/extensions/activity_log/activity_database.h
+++ b/chrome/browser/extensions/activity_log/activity_database.h
@@ -15,7 +15,6 @@
#include "base/synchronization/lock.h"
#include "base/timer/timer.h"
#include "chrome/browser/extensions/activity_log/activity_actions.h"
-#include "content/public/browser/browser_thread.h"
#include "extensions/common/extension.h"
#include "sql/connection.h"
#include "sql/init_status.h"
@@ -202,4 +201,5 @@ class ActivityDatabase {
};
} // namespace extensions
+
#endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_DATABASE_H_
diff --git a/chrome/browser/extensions/activity_log/activity_log.cc b/chrome/browser/extensions/activity_log/activity_log.cc
index 50a007d..b0cd4c2 100644
--- a/chrome/browser/extensions/activity_log/activity_log.cc
+++ b/chrome/browser/extensions/activity_log/activity_log.cc
@@ -20,18 +20,22 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/extension_tab_util.h"
+#include "chrome/browser/extensions/install_tracker.h"
#include "chrome/browser/extensions/install_tracker_factory.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/prerender/prerender_manager_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/extension.h"
#include "third_party/re2/re2/re2.h"
#include "url/gurl.h"
@@ -46,6 +50,7 @@ namespace {
using extensions::Action;
using constants::kArgUrlPlaceholder;
+using content::BrowserThread;
// If DOM API methods start with this string, we flag them as being of type
// DomActionType::XHR.
@@ -393,10 +398,6 @@ ActivityLog::ActivityLog(Profile* profile)
FROM_HERE,
base::Bind(&ActivityLog::InitInstallTracker, base::Unretained(this)));
- EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router();
- if (event_router)
- event_router->SetEventDispatchObserver(this);
-
// None of this should run on Android since the AL is behind ENABLE_EXTENSION
// checks. However, UmaPolicy can't even compile on Android because it uses
// BrowserList and related classes that aren't compiled for Android.
@@ -617,12 +618,27 @@ void ActivityLog::OnScriptsExecuted(
}
}
-void ActivityLog::OnWillDispatchEvent(scoped_ptr<EventDispatchInfo> details) {
- scoped_refptr<Action> action = new Action(details->extension_id,
+void ActivityLog::OnApiEventDispatched(const std::string& extension_id,
+ const std::string& event_name,
+ scoped_ptr<base::ListValue> event_args) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ scoped_refptr<Action> action = new Action(extension_id,
base::Time::Now(),
Action::ACTION_API_EVENT,
- details->event_name);
- action->set_args(details->event_args.Pass());
+ event_name);
+ action->set_args(event_args.Pass());
+ LogAction(action);
+}
+
+void ActivityLog::OnApiFunctionCalled(const std::string& extension_id,
+ const std::string& api_name,
+ scoped_ptr<base::ListValue> args) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ scoped_refptr<Action> action = new Action(extension_id,
+ base::Time::Now(),
+ Action::ACTION_API_CALL,
+ api_name);
+ action->set_args(args.Pass());
LogAction(action);
}
diff --git a/chrome/browser/extensions/activity_log/activity_log.h b/chrome/browser/extensions/activity_log/activity_log.h
index e827ad1..b913ee3 100644
--- a/chrome/browser/extensions/activity_log/activity_log.h
+++ b/chrome/browser/extensions/activity_log/activity_log.h
@@ -15,19 +15,15 @@
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
#include "chrome/browser/extensions/activity_log/activity_actions.h"
-#include "chrome/browser/extensions/activity_log/activity_database.h"
#include "chrome/browser/extensions/activity_log/activity_log_policy.h"
#include "chrome/browser/extensions/install_observer.h"
-#include "chrome/browser/extensions/install_tracker.h"
#include "chrome/browser/extensions/tab_helper.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/dom_action_types.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
-#include "extensions/browser/event_router.h"
+#include "extensions/browser/api_activity_monitor.h"
class Profile;
-using content::BrowserThread;
namespace content {
class BrowserContext;
@@ -39,12 +35,12 @@ class PrefRegistrySyncable;
namespace extensions {
class Extension;
-class ActivityLogPolicy;
+class InstallTracker;
// A utility for tracing interesting activity for each extension.
// It writes to an ActivityDatabase on a separate thread to record the activity.
class ActivityLog : public BrowserContextKeyedService,
- public EventRouter::EventDispatchObserver,
+ public ApiActivityMonitor,
public TabHelper::ScriptExecutionObserver,
public InstallObserver {
public:
@@ -101,9 +97,15 @@ class ActivityLog : public BrowserContextKeyedService,
const std::string& extension_id) OVERRIDE {}
virtual void OnShutdown() OVERRIDE {}
- // EventRouter::EventDispatchObserver
- virtual void OnWillDispatchEvent(scoped_ptr<EventDispatchInfo> details)
- OVERRIDE;
+ // ApiActivityMonitor
+ virtual void OnApiEventDispatched(
+ const std::string& extension_id,
+ const std::string& event_name,
+ scoped_ptr<base::ListValue> event_args) OVERRIDE;
+ virtual void OnApiFunctionCalled(
+ const std::string& extension_id,
+ const std::string& api_name,
+ scoped_ptr<base::ListValue> event_args) OVERRIDE;
// BrowserContextKeyedService
virtual void Shutdown() OVERRIDE;
diff --git a/chrome/browser/extensions/activity_log/counting_policy_unittest.cc b/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
index 354d0e6..7f66a16 100644
--- a/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
+++ b/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
@@ -30,6 +30,8 @@
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#endif
+using content::BrowserThread;
+
namespace extensions {
class CountingPolicyTest : public testing::Test {
@@ -62,7 +64,7 @@ class CountingPolicyTest : public testing::Test {
}
// Wait for the task queue for the specified thread to empty.
- void WaitOnThread(const content::BrowserThread::ID& thread) {
+ void WaitOnThread(const BrowserThread::ID& thread) {
BrowserThread::PostTaskAndReply(
thread,
FROM_HERE,
diff --git a/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc b/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc
index ee63755..fe5e971 100644
--- a/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc
+++ b/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc
@@ -29,6 +29,8 @@
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#endif
+using content::BrowserThread;
+
namespace extensions {
class FullStreamUIPolicyTest : public testing::Test {
diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.cc b/chrome/browser/extensions/chrome_extensions_browser_client.cc
index e132a02..77727ce 100644
--- a/chrome/browser/extensions/chrome_extensions_browser_client.cc
+++ b/chrome/browser/extensions/chrome_extensions_browser_client.cc
@@ -8,6 +8,7 @@
#include "base/version.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/activity_log/activity_log.h"
#include "chrome/browser/extensions/chrome_app_sorting.h"
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -168,6 +169,12 @@ ChromeExtensionsBrowserClient::GetJavaScriptDialogManager() {
return GetJavaScriptDialogManagerInstance();
}
+ApiActivityMonitor* ChromeExtensionsBrowserClient::GetApiActivityMonitor(
+ content::BrowserContext* context) {
+ // The ActivityLog monitors and records function calls and events.
+ return ActivityLog::GetInstance(context);
+}
+
std::vector<BrowserContextKeyedServiceFactory*>
ChromeExtensionsBrowserClient::GetExtensionSystemDependencies() {
std::vector<BrowserContextKeyedServiceFactory*> dependencies;
diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.h b/chrome/browser/extensions/chrome_extensions_browser_client.h
index 4552699..3e5a9de 100644
--- a/chrome/browser/extensions/chrome_extensions_browser_client.h
+++ b/chrome/browser/extensions/chrome_extensions_browser_client.h
@@ -57,6 +57,8 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient {
virtual bool IsRunningInForcedAppMode() OVERRIDE;
virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager()
OVERRIDE;
+ virtual ApiActivityMonitor* GetApiActivityMonitor(
+ content::BrowserContext* context) OVERRIDE;
virtual std::vector<BrowserContextKeyedServiceFactory*>
GetExtensionSystemDependencies() OVERRIDE;
virtual ExtensionSystem* CreateExtensionSystem(
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 1de6920..77ba907 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -12,9 +12,6 @@
#include "base/process/process.h"
#include "base/values.h"
#include "build/build_config.h"
-#include "chrome/browser/extensions/activity_log/activity_action_constants.h"
-#include "chrome/browser/extensions/activity_log/activity_log.h"
-#include "chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h"
#include "chrome/browser/extensions/extension_function_registry.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/extension_web_ui.h"
@@ -30,8 +27,10 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/result_codes.h"
+#include "extensions/browser/api_activity_monitor.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_map.h"
#include "extensions/browser/quota_service.h"
@@ -45,35 +44,34 @@ using extensions::Extension;
using extensions::ExtensionAPI;
using extensions::ExtensionSystem;
using extensions::Feature;
+using content::BrowserThread;
using content::RenderViewHost;
namespace {
-void LogSuccess(const std::string& extension_id,
- const std::string& api_name,
- scoped_ptr<base::ListValue> args,
- content::BrowserContext* browser_context) {
- // The ActivityLog can only be accessed from the main (UI) thread. If we're
- // running on the wrong thread, re-dispatch from the main thread.
+// Notifies the ApiActivityMonitor that an extension API function has been
+// called. May be called from any thread.
+void NotifyApiFunctionCalled(const std::string& extension_id,
+ const std::string& api_name,
+ scoped_ptr<base::ListValue> args,
+ content::BrowserContext* browser_context) {
+ // The ApiActivityLogger can only be accessed from the main (UI) thread. If
+ // we're running on the wrong thread, re-dispatch from the main thread.
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
- base::Bind(&LogSuccess,
+ base::Bind(&NotifyApiFunctionCalled,
extension_id,
api_name,
base::Passed(&args),
browser_context));
- } else {
- extensions::ActivityLog* activity_log =
- extensions::ActivityLog::GetInstance(browser_context);
- scoped_refptr<extensions::Action> action =
- new extensions::Action(extension_id,
- base::Time::Now(),
- extensions::Action::ACTION_API_CALL,
- api_name);
- action->set_args(args.Pass());
- activity_log->LogAction(action);
+ return;
}
+ extensions::ApiActivityMonitor* monitor =
+ extensions::ExtensionsBrowserClient::Get()->GetApiActivityMonitor(
+ browser_context);
+ if (monitor)
+ monitor->OnApiFunctionCalled(extension_id, api_name, args.Pass());
}
// Separate copy of ExtensionAPI used for IO thread extension functions. We need
@@ -278,10 +276,11 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread(
base::TimeTicks::Now());
if (violation_error.empty()) {
scoped_ptr<base::ListValue> args(params.arguments.DeepCopy());
- LogSuccess(extension->id(),
- params.name,
- args.Pass(),
- static_cast<content::BrowserContext*>(browser_context));
+ NotifyApiFunctionCalled(
+ extension->id(),
+ params.name,
+ args.Pass(),
+ static_cast<content::BrowserContext*>(browser_context));
function->Run();
} else {
function->OnQuotaExceeded(violation_error);
@@ -389,7 +388,8 @@ void ExtensionFunctionDispatcher::DispatchWithCallbackInternal(
// See crbug.com/39178.
ExternalProtocolHandler::PermitLaunchUrl();
- LogSuccess(extension->id(), params.name, args.Pass(), browser_context_);
+ NotifyApiFunctionCalled(
+ extension->id(), params.name, args.Pass(), browser_context_);
function->Run();
} else {
function->OnQuotaExceeded(violation_error);
diff --git a/extensions/browser/api_activity_monitor.h b/extensions/browser/api_activity_monitor.h
new file mode 100644
index 0000000..b8f0cc3
--- /dev/null
+++ b/extensions/browser/api_activity_monitor.h
@@ -0,0 +1,39 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_
+#define EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_
+
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+
+namespace base {
+class ListValue;
+}
+
+namespace extensions {
+
+// ApiActivityMonitor is used to monitor extension API event dispatch and API
+// function calls. An embedder can use this interface to log low-level extension
+// activity.
+class ApiActivityMonitor {
+ public:
+ // Called when an API event is dispatched to an extension.
+ virtual void OnApiEventDispatched(const std::string& extension_id,
+ const std::string& event_name,
+ scoped_ptr<base::ListValue> event_args) = 0;
+
+ // Called when an extension calls an API function.
+ virtual void OnApiFunctionCalled(const std::string& extension_id,
+ const std::string& api_name,
+ scoped_ptr<base::ListValue> args) = 0;
+
+ protected:
+ virtual ~ApiActivityMonitor() {}
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_
diff --git a/extensions/browser/event_router.cc b/extensions/browser/event_router.cc
index 29661be..d145059 100644
--- a/extensions/browser/event_router.cc
+++ b/extensions/browser/event_router.cc
@@ -17,6 +17,7 @@
#include "chrome/common/extensions/extension_messages.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
+#include "extensions/browser/api_activity_monitor.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
@@ -45,6 +46,35 @@ void DoNothing(ExtensionHost* host) {}
// registered from its lazy background page.
const char kFilteredEvents[] = "filtered_events";
+// Sends a notification about an event to the API activity monitor on the
+// UI thread. Can be called from any thread.
+void NotifyApiEventDispatched(void* browser_context_id,
+ const std::string& extension_id,
+ const std::string& event_name,
+ scoped_ptr<ListValue> args) {
+ // The ApiActivityMonitor can only be accessed from the UI thread.
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&NotifyApiEventDispatched,
+ browser_context_id,
+ extension_id,
+ event_name,
+ base::Passed(&args)));
+ return;
+ }
+
+ // Notify the ApiActivityMonitor about the event dispatch.
+ BrowserContext* context = static_cast<BrowserContext*>(browser_context_id);
+ if (!ExtensionsBrowserClient::Get()->IsValidContext(context))
+ return;
+ ApiActivityMonitor* monitor =
+ ExtensionsBrowserClient::Get()->GetApiActivityMonitor(context);
+ if (monitor)
+ monitor->OnApiEventDispatched(extension_id, event_name, args.Pass());
+}
+
} // namespace
const char EventRouter::kRegisteredEvents[] = "events";
@@ -67,32 +97,6 @@ struct EventRouter::ListenerProcess {
};
// static
-void EventRouter::NotifyExtensionDispatchObserverOnUIThread(
- void* browser_context_id,
- scoped_ptr<EventDispatchInfo> details) {
- if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(&NotifyExtensionDispatchObserverOnUIThread,
- browser_context_id, base::Passed(&details)));
- } else {
- BrowserContext* context =
- reinterpret_cast<BrowserContext*>(browser_context_id);
- if (!ExtensionsBrowserClient::Get()->IsValidContext(context))
- return;
- ExtensionSystem* extension_system = ExtensionSystem::Get(context);
- EventRouter* event_router = extension_system->event_router();
- if (!event_router)
- return;
- if (event_router->event_dispatch_observer_) {
- event_router->event_dispatch_observer_->OnWillDispatchEvent(
- details.Pass());
- }
- }
-}
-
-// static
void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender,
void* browser_context_id,
const std::string& extension_id,
@@ -100,12 +104,10 @@ void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender,
ListValue* event_args,
UserGestureState user_gesture,
const EventFilteringInfo& info) {
- NotifyExtensionDispatchObserverOnUIThread(
- browser_context_id,
- make_scoped_ptr(new EventDispatchInfo(
- extension_id,
- event_name,
- make_scoped_ptr(event_args->DeepCopy()))));
+ NotifyApiEventDispatched(browser_context_id,
+ extension_id,
+ event_name,
+ make_scoped_ptr(event_args->DeepCopy()));
ListValue args;
args.Set(0, new base::StringValue(event_name));
@@ -160,8 +162,7 @@ EventRouter::EventRouter(BrowserContext* browser_context,
ExtensionPrefs* extension_prefs)
: browser_context_(browser_context),
extension_prefs_(extension_prefs),
- listeners_(this),
- event_dispatch_observer_(NULL) {
+ listeners_(this) {
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::NotificationService::AllSources());
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
@@ -209,11 +210,6 @@ void EventRouter::UnregisterObserver(Observer* observer) {
observers_.erase(iters_to_remove[i]);
}
-void EventRouter::SetEventDispatchObserver(EventDispatchObserver* observer) {
- CHECK(!event_dispatch_observer_);
- event_dispatch_observer_ = observer;
-}
-
void EventRouter::OnListenerAdded(const EventListener* listener) {
const EventListenerInfo details(
listener->event_name,
@@ -773,13 +769,4 @@ EventListenerInfo::EventListenerInfo(const std::string& event_name,
extension_id(extension_id),
browser_context(browser_context) {}
-EventDispatchInfo::EventDispatchInfo(const std::string& extension_id,
- const std::string& event_name,
- scoped_ptr<ListValue> event_args)
- : extension_id(extension_id),
- event_name(event_name),
- event_args(event_args.Pass()) {}
-
-EventDispatchInfo::~EventDispatchInfo() {}
-
} // namespace extensions
diff --git a/extensions/browser/event_router.h b/extensions/browser/event_router.h
index a42aa68..467e7f3 100644
--- a/extensions/browser/event_router.h
+++ b/extensions/browser/event_router.h
@@ -68,13 +68,6 @@ class EventRouter : public content::NotificationObserver,
virtual void OnListenerRemoved(const EventListenerInfo& details) {}
};
- // The EventDispatchObserver is notified on the UI thread whenever
- // an event is dispatched. There can be only one EventDispatchObserver.
- class EventDispatchObserver {
- public:
- virtual void OnWillDispatchEvent(scoped_ptr<EventDispatchInfo> details) = 0;
- };
-
// Converts event names like "foo.onBar/123" into "foo.onBar". Event names
// without a "/" are returned unchanged.
static std::string GetBaseEventName(const std::string& full_event_name);
@@ -117,10 +110,6 @@ class EventRouter : public content::NotificationObserver,
// Unregisters an observer from all events.
void UnregisterObserver(Observer* observer);
- // Sets the observer to be notified whenever an event is dispatched to an
- // extension.
- void SetEventDispatchObserver(EventDispatchObserver* observer);
-
// Add or remove the extension as having a lazy background page that listens
// to the event. The difference from the above methods is that these will be
// remembered even after the process goes away. We use this list to decide
@@ -192,12 +181,6 @@ class EventRouter : public content::NotificationObserver,
typedef std::pair<const content::BrowserContext*, std::string>
EventDispatchIdentifier;
- // Sends a notification about an event to the event dispatch observer on the
- // UI thread. Can be called from any thread.
- static void NotifyExtensionDispatchObserverOnUIThread(
- void* browser_context_id,
- scoped_ptr<EventDispatchInfo> details);
-
// TODO(gdk): Document this.
static void DispatchExtensionMessage(
IPC::Sender* ipc_sender,
@@ -300,8 +283,6 @@ class EventRouter : public content::NotificationObserver,
typedef base::hash_map<std::string, Observer*> ObserverMap;
ObserverMap observers_;
- EventDispatchObserver* event_dispatch_observer_;
-
DISALLOW_COPY_AND_ASSIGN(EventRouter);
};
@@ -377,17 +358,6 @@ struct EventListenerInfo {
content::BrowserContext* browser_context;
};
-struct EventDispatchInfo {
- EventDispatchInfo(const std::string& extension_id,
- const std::string& event_name,
- scoped_ptr<base::ListValue> event_args);
- ~EventDispatchInfo();
-
- const std::string extension_id;
- const std::string event_name;
- scoped_ptr<base::ListValue> event_args;
-};
-
} // namespace extensions
#endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_
diff --git a/extensions/browser/extensions_browser_client.h b/extensions/browser/extensions_browser_client.h
index ee7fde3..7cff76d 100644
--- a/extensions/browser/extensions_browser_client.h
+++ b/extensions/browser/extensions_browser_client.h
@@ -21,6 +21,7 @@ class WebContents;
namespace extensions {
+class ApiActivityMonitor;
class AppSorting;
class ExtensionSystem;
@@ -96,6 +97,11 @@ class ExtensionsBrowserClient {
// does not support JavaScript dialogs.
virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager() = 0;
+ // Returns the embedder's ApiActivityMonitor for |context|. Returns NULL if
+ // the embedder does not monitor extension API activity.
+ virtual ApiActivityMonitor* GetApiActivityMonitor(
+ content::BrowserContext* context) = 0;
+
// Returns the dependencies of ExtensionSystem. May return an empty list.
virtual std::vector<BrowserContextKeyedServiceFactory*>
GetExtensionSystemDependencies() = 0;
diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp
index 45ef054..8fa8921 100644
--- a/extensions/extensions.gyp
+++ b/extensions/extensions.gyp
@@ -167,6 +167,7 @@
'sources': [
'browser/admin_policy.cc',
'browser/admin_policy.h',
+ 'browser/api_activity_monitor.h',
'browser/app_sorting.h',
'browser/blacklist_state.h',
'browser/error_map.cc',