summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 21:47:31 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 21:47:31 +0000
commit7f2d7d344939597f337cd08d0584058fd5482128 (patch)
tree0a40572e18019861d9c2ccfe1ba2f0bb150f33ae
parent9caf09bc04a54dd2be5836e882148ef759a9131d (diff)
downloadchromium_src-7f2d7d344939597f337cd08d0584058fd5482128.zip
chromium_src-7f2d7d344939597f337cd08d0584058fd5482128.tar.gz
chromium_src-7f2d7d344939597f337cd08d0584058fd5482128.tar.bz2
Followup to my previous change r143991 to switch watching for Browser destruction using notification service instead of BrowserList. That way there's no BrowserList dependency at all in that class, which seems like a good thing.
Review URL: https://chromiumcodereview.appspot.com/10666035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144024 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_uninstall_dialog.cc18
-rw-r--r--chrome/browser/extensions/extension_uninstall_dialog.h14
2 files changed, 23 insertions, 9 deletions
diff --git a/chrome/browser/extensions/extension_uninstall_dialog.cc b/chrome/browser/extensions/extension_uninstall_dialog.cc
index 1425f57e..1a36abc 100644
--- a/chrome/browser/extensions/extension_uninstall_dialog.cc
+++ b/chrome/browser/extensions/extension_uninstall_dialog.cc
@@ -6,9 +6,12 @@
#include "base/logging.h"
#include "base/message_loop.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_resource.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_source.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources_standard.h"
#include "ui/base/resource/resource_bundle.h"
@@ -25,11 +28,14 @@ ExtensionUninstallDialog::ExtensionUninstallDialog(
extension_(NULL),
ui_loop_(MessageLoop::current()) {
tracker_.reset(new ImageLoadingTracker(this));
- BrowserList::AddObserver(this);
+ if (browser) {
+ registrar_.Add(this,
+ chrome::NOTIFICATION_BROWSER_CLOSING,
+ content::Source<Browser>(browser));
+ }
}
ExtensionUninstallDialog::~ExtensionUninstallDialog() {
- BrowserList::RemoveObserver(this);
}
void ExtensionUninstallDialog::ConfirmUninstall(
@@ -72,9 +78,11 @@ void ExtensionUninstallDialog::OnImageLoaded(const gfx::Image& image,
Show();
}
-void ExtensionUninstallDialog::OnBrowserRemoved(Browser* browser) {
- if (browser_ != browser)
- return;
+void ExtensionUninstallDialog::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING);
browser_ = NULL;
if (tracker_.get()) {
diff --git a/chrome/browser/extensions/extension_uninstall_dialog.h b/chrome/browser/extensions/extension_uninstall_dialog.h
index 625557b..e1fd1dd 100644
--- a/chrome/browser/extensions/extension_uninstall_dialog.h
+++ b/chrome/browser/extensions/extension_uninstall_dialog.h
@@ -11,9 +11,11 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/extensions/image_loading_tracker.h"
-#include "chrome/browser/ui/browser_list.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
#include "ui/gfx/image/image_skia.h"
+class Browser;
class MessageLoop;
namespace extensions {
@@ -22,7 +24,7 @@ class Extension;
class ExtensionUninstallDialog
: public ImageLoadingTracker::Observer,
- public BrowserList::Observer,
+ public content::NotificationObserver,
public base::SupportsWeakPtr<ExtensionUninstallDialog> {
public:
class Delegate {
@@ -75,8 +77,10 @@ class ExtensionUninstallDialog
const std::string& extension_id,
int index) OVERRIDE;
- // BrowserList::Observer
- virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
+ // content::NotificationObserver implementation.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
// Displays the prompt. This should only be called after loading the icon.
// The implementations of this method are platform-specific.
@@ -88,6 +92,8 @@ class ExtensionUninstallDialog
// purpose of showing the dialog.
scoped_ptr<ImageLoadingTracker> tracker_;
+ content::NotificationRegistrar registrar_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog);
};