summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/automation_provider.cc4
-rw-r--r--chrome/browser/extensions/browser_action_apitest.cc3
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.cc23
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.h11
-rw-r--r--chrome/browser/extensions/extension_service.cc5
-rw-r--r--chrome/browser/extensions/extension_service.h7
-rw-r--r--chrome/browser/extensions/page_action_apitest.cc9
-rw-r--r--chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm3
-rw-r--r--chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm3
-rw-r--r--chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc10
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc5
-rw-r--r--chrome/browser/ui/views/browser_actions_container.cc3
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.cc3
13 files changed, 56 insertions, 33 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index b1f54a3..49bee1d 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -947,11 +947,11 @@ void AutomationProvider::ExecuteExtensionActionInActiveTabAsync(
if (extension && service && message_service && browser) {
int tab_id = ExtensionTabUtil::GetTabId(browser->GetSelectedTabContents());
if (extension->page_action()) {
- ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
+ service->browser_event_router()->PageActionExecuted(
browser->profile(), extension->id(), "action", tab_id, "", 1);
success = true;
} else if (extension->browser_action()) {
- ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
+ service->browser_event_router()->BrowserActionExecuted(
browser->profile(), extension->id(), browser);
success = true;
}
diff --git a/chrome/browser/extensions/browser_action_apitest.cc b/chrome/browser/extensions/browser_action_apitest.cc
index cf7d045..915e7af 100644
--- a/chrome/browser/extensions/browser_action_apitest.cc
+++ b/chrome/browser/extensions/browser_action_apitest.cc
@@ -69,7 +69,8 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, Basic) {
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL("files/extensions/test_file.txt"));
- ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ service->browser_event_router()->BrowserActionExecuted(
browser()->profile(), action->extension_id(), browser());
// Verify the command worked.
diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc
index 7993949..54e54ee 100644
--- a/chrome/browser/extensions/extension_browser_event_router.cc
+++ b/chrome/browser/extensions/extension_browser_event_router.cc
@@ -61,10 +61,6 @@ DictionaryValue* ExtensionBrowserEventRouter::TabEntry::DidNavigate(
return changed_properties;
}
-ExtensionBrowserEventRouter* ExtensionBrowserEventRouter::GetInstance() {
- return Singleton<ExtensionBrowserEventRouter>::get();
-}
-
static void DispatchEvent(Profile* profile,
const char* event_name,
const std::string& json_args) {
@@ -111,11 +107,9 @@ static void DispatchSimpleBrowserEvent(Profile* profile,
DispatchEvent(profile, event_name, json_args);
}
-void ExtensionBrowserEventRouter::Init(Profile* profile) {
+void ExtensionBrowserEventRouter::Init() {
if (initialized_)
return;
- DCHECK(!profile->IsOffTheRecord());
- profile_ = profile;
BrowserList::AddObserver(this);
#if defined(TOOLKIT_VIEWS)
views::FocusManager::GetWidgetFocusManager()->AddFocusChangeListener(this);
@@ -148,12 +142,21 @@ void ExtensionBrowserEventRouter::Init(Profile* profile) {
initialized_ = true;
}
-ExtensionBrowserEventRouter::ExtensionBrowserEventRouter()
+ExtensionBrowserEventRouter::ExtensionBrowserEventRouter(Profile* profile)
: initialized_(false),
focused_window_id_(extension_misc::kUnknownWindowId),
- profile_(NULL) { }
+ profile_(profile) {
+ DCHECK(!profile->IsOffTheRecord());
+}
-ExtensionBrowserEventRouter::~ExtensionBrowserEventRouter() {}
+ExtensionBrowserEventRouter::~ExtensionBrowserEventRouter() {
+ BrowserList::RemoveObserver(this);
+#if defined(TOOLKIT_VIEWS)
+ views::FocusManager::GetWidgetFocusManager()->RemoveFocusChangeListener(this);
+#elif defined(TOOLKIT_GTK)
+ ActiveWindowWatcherX::RemoveObserver(this);
+#endif
+}
void ExtensionBrowserEventRouter::OnBrowserAdded(const Browser* browser) {
RegisterForBrowserNotifications(browser);
diff --git a/chrome/browser/extensions/extension_browser_event_router.h b/chrome/browser/extensions/extension_browser_event_router.h
index e42f831..a78dea8 100644
--- a/chrome/browser/extensions/extension_browser_event_router.h
+++ b/chrome/browser/extensions/extension_browser_event_router.h
@@ -10,7 +10,6 @@
#include <string>
#include "base/basictypes.h"
-#include "base/singleton.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/tabs/tab_strip_model_observer.h"
@@ -36,11 +35,11 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver,
public BrowserList::Observer,
public NotificationObserver {
public:
- // Get Browser-Global instance.
- static ExtensionBrowserEventRouter* GetInstance();
+ explicit ExtensionBrowserEventRouter(Profile* profile);
+ ~ExtensionBrowserEventRouter();
// Must be called once. Subsequent calls have no effect.
- void Init(Profile* profile);
+ void Init();
// BrowserList::Observer
virtual void OnBrowserAdded(const Browser* browser);
@@ -130,10 +129,6 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver,
// Removes notifications added in RegisterForTabNotifications.
void UnregisterForTabNotifications(TabContents* contents);
- ExtensionBrowserEventRouter();
- ~ExtensionBrowserEventRouter();
- friend struct DefaultSingletonTraits<ExtensionBrowserEventRouter>;
-
NotificationRegistrar registrar_;
bool initialized_;
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index f71cae0..06290c7 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include <algorithm>
+#include <set>
#include "base/basictypes.h"
#include "base/command_line.h"
@@ -501,7 +502,8 @@ void ExtensionService::InitEventRouters() {
ExtensionHistoryEventRouter::GetInstance()->ObserveProfile(profile_);
ExtensionAccessibilityEventRouter::GetInstance()->ObserveProfile(profile_);
- ExtensionBrowserEventRouter::GetInstance()->Init(profile_);
+ browser_event_router_.reset(new ExtensionBrowserEventRouter(profile_));
+ browser_event_router_->Init();
ExtensionBookmarkEventRouter::GetInstance()->Observe(
profile_->GetBookmarkModel());
ExtensionCookiesEventRouter::GetInstance()->Init();
@@ -1246,6 +1248,7 @@ void ExtensionService::UpdateExtensionBlacklist(
}
void ExtensionService::DestroyingProfile() {
+ browser_event_router_.reset();
pref_change_registrar_.RemoveAll();
profile_ = NULL;
toolbar_model_.DestroyingProfile();
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 7849762..caa8f6a 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -34,6 +34,7 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/property_bag.h"
+class ExtensionBrowserEventRouter;
class ExtensionServiceBackend;
class ExtensionToolbarModel;
class ExtensionUpdater;
@@ -395,6 +396,10 @@ class ExtensionService
ExtensionMenuManager* menu_manager() { return &menu_manager_; }
+ ExtensionBrowserEventRouter* browser_event_router() {
+ return browser_event_router_.get();
+ }
+
const std::map<GURL, int>& protected_storage_map() const {
return protected_storage_map_;
}
@@ -608,6 +613,8 @@ class ExtensionService
// Flag to make sure event routers are only initialized once.
bool event_routers_initialized_;
+ scoped_ptr<ExtensionBrowserEventRouter> browser_event_router_;
+
// A collection of external extension providers. Each provider reads
// a source of external extension information. Examples include the
// windows registry and external_extensions.json.
diff --git a/chrome/browser/extensions/page_action_apitest.cc b/chrome/browser/extensions/page_action_apitest.cc
index 504f909..e4b80e5 100644
--- a/chrome/browser/extensions/page_action_apitest.cc
+++ b/chrome/browser/extensions/page_action_apitest.cc
@@ -40,7 +40,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) {
ResultCatcher catcher;
int tab_id =
ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents());
- ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ service->browser_event_router()->PageActionExecuted(
browser()->profile(), extension->id(), "", tab_id, "", 0);
EXPECT_TRUE(catcher.GetNextResult());
}
@@ -77,7 +78,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) {
// install a page action popup.
{
ResultCatcher catcher;
- ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ service->browser_event_router()->PageActionExecuted(
browser()->profile(), extension->id(), "action", tab_id, "", 1);
ASSERT_TRUE(catcher.GetNextResult());
}
@@ -152,7 +154,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OldPageActions) {
ResultCatcher catcher;
int tab_id =
ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents());
- ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ service->browser_event_router()->PageActionExecuted(
browser()->profile(), extension->id(), "action", tab_id, "", 1);
EXPECT_TRUE(catcher.GetNextResult());
}
diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
index 0e68252..3cf2433 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
@@ -741,7 +741,8 @@ class ExtensionServiceObserverBridge : public NotificationObserver,
arrowLocation:info_bubble::kTopRight
devMode:NO];
} else {
- ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
+ ExtensionService* service = profile_->GetExtensionService();
+ service->browser_event_router()->BrowserActionExecuted(
profile_, action->extension_id(), browser_);
}
}
diff --git a/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm b/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm
index 5ab186b..221c7f8 100644
--- a/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm
@@ -97,7 +97,8 @@ bool PageActionDecoration::OnMousePressed(NSRect frame) {
arrowLocation:info_bubble::kTopRight
devMode:NO];
} else {
- ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
+ ExtensionService* service = profile_->GetExtensionService();
+ service->browser_event_router()->PageActionExecuted(
profile_, page_action_->extension_id(), page_action_->id(),
current_tab_id_, current_url_.spec(),
1);
diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
index c8abc9b..dc5e53f 100644
--- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/gtk/browser_actions_toolbar_gtk.h"
+#include <algorithm>
#include <vector>
#include "base/i18n/rtl.h"
@@ -277,7 +278,9 @@ class BrowserActionButton : public NotificationObserver,
if (action->ShowPopup(false))
return;
- ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
+ ExtensionService* service =
+ action->toolbar_->browser()->profile()->GetExtensionService();
+ service->browser_event_router()->BrowserActionExecuted(
action->toolbar_->browser()->profile(), action->extension_->id(),
action->toolbar_->browser());
}
@@ -368,7 +371,7 @@ BrowserActionsToolbarGtk::BrowserActionsToolbarGtk(Browser* browser)
if (!extension_service)
return;
- overflow_button_.reset(new CustomDrawButton(
+ overflow_button_.reset(new CustomDrawButton(
theme_provider_,
IDR_BROWSER_ACTIONS_OVERFLOW,
IDR_BROWSER_ACTIONS_OVERFLOW_P,
@@ -680,7 +683,8 @@ void BrowserActionsToolbarGtk::ExecuteCommand(int command_id) {
chevron(),
false);
} else {
- ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ service->browser_event_router()->BrowserActionExecuted(
browser()->profile(), extension->id(), browser());
}
}
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 982af73..97f0c23 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -4,7 +4,9 @@
#include "chrome/browser/gtk/location_bar_view_gtk.h"
+#include <algorithm>
#include <string>
+#include <vector>
#include "app/gtk_dnd_util.h"
#include "app/l10n_util.h"
@@ -1514,7 +1516,8 @@ gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed(
GdkEvent* event) {
if (event->button.button != 3) {
if (!ShowPopup(false)) {
- ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
+ ExtensionService* service = profile_->GetExtensionService();
+ service->browser_event_router()->PageActionExecuted(
profile_,
page_action_->extension_id(),
page_action_->id(),
diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc
index 3ac3bcf..0e3f14c 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -483,7 +483,8 @@ void BrowserActionsContainer::OnBrowserActionExecuted(
// Popups just display. No notification to the extension.
// TODO(erikkay): should there be?
if (!button->IsPopup()) {
- ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
+ ExtensionService* service = profile_->GetExtensionService();
+ service->browser_event_router()->BrowserActionExecuted(
profile_, browser_action->extension_id(), browser_);
return;
}
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
index 1612cf9..20a0953 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
@@ -98,7 +98,8 @@ void PageActionImageView::ExecuteAction(int button,
ExtensionPopup::BUBBLE_CHROME,
this); // ExtensionPopup::Observer
} else {
- ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
+ ExtensionService* service = profile_->GetExtensionService();
+ service->browser_event_router()->PageActionExecuted(
profile_, page_action_->extension_id(), page_action_->id(),
current_tab_id_, current_url_.spec(), button);
}