summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-01 18:16:56 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-01 18:16:56 +0000
commitbfd04a62ce610d7bb61dbb78811dccbed23589b7 (patch)
tree70bb228c0f00ba1c12c584efd569daccf96b4026 /chrome/browser/browser.cc
parenta814d863440f0a154a7299f2d8b440f405c7700e (diff)
downloadchromium_src-bfd04a62ce610d7bb61dbb78811dccbed23589b7.zip
chromium_src-bfd04a62ce610d7bb61dbb78811dccbed23589b7.tar.gz
chromium_src-bfd04a62ce610d7bb61dbb78811dccbed23589b7.tar.bz2
Remove most header file dependencies on the notification type list. It is
really painful to add more types, since lots of headers include the notification service to derive from the notification observer. This splits that out, so much less of the project should end up including notification_types.h ---Paths modified but not in any changelist: Review URL: http://codereview.chromium.org/19744 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r--chrome/browser/browser.cc51
1 files changed, 30 insertions, 21 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 1ad5d8b..d686f1f 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/tab_contents/tab_contents_type.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/page_transition_types.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
@@ -179,7 +180,9 @@ Browser::Browser(Type type, Profile* profile)
tabstrip_model_.AddObserver(this);
NotificationService::current()->AddObserver(
- this, NOTIFY_SSL_STATE_CHANGED, NotificationService::AllSources());
+ this,
+ NotificationType::SSL_STATE_CHANGED,
+ NotificationService::AllSources());
InitCommandState();
BrowserList::AddBrowser(this);
@@ -222,7 +225,9 @@ Browser::~Browser() {
tab_restore_service->BrowserClosed(this);
NotificationService::current()->RemoveObserver(
- this, NOTIFY_SSL_STATE_CHANGED, NotificationService::AllSources());
+ this,
+ NotificationType::SSL_STATE_CHANGED,
+ NotificationService::AllSources());
if (profile_->IsOffTheRecord() &&
!BrowserList::IsOffTheRecordSessionActive()) {
@@ -1433,18 +1438,19 @@ void Browser::TabInsertedAt(TabContents* contents,
// If the tab crashes in the beforeunload or unload handler, it won't be
// able to ack. But we know we can close it.
- NotificationService::current()->
- AddObserver(this, NOTIFY_WEB_CONTENTS_DISCONNECTED,
- Source<TabContents>(contents));
+ NotificationService::current()->AddObserver(
+ this,
+ NotificationType::WEB_CONTENTS_DISCONNECTED,
+ Source<TabContents>(contents));
}
void Browser::TabClosingAt(TabContents* contents, int index) {
NavigationController* controller = contents->controller();
DCHECK(controller);
- NotificationService::current()->
- Notify(NOTIFY_TAB_CLOSING,
- Source<NavigationController>(controller),
- NotificationService::NoDetails());
+ NotificationService::current()->Notify(
+ NotificationType::TAB_CLOSING,
+ Source<NavigationController>(controller),
+ NotificationService::NoDetails());
// Sever the TabContents' connection back to us.
contents->set_delegate(NULL);
@@ -1457,9 +1463,10 @@ void Browser::TabDetachedAt(TabContents* contents, int index) {
RemoveScheduledUpdatesFor(contents);
- NotificationService::current()->
- RemoveObserver(this, NOTIFY_WEB_CONTENTS_DISCONNECTED,
- Source<TabContents>(contents));
+ NotificationService::current()->RemoveObserver(
+ this,
+ NotificationType::WEB_CONTENTS_DISCONNECTED,
+ Source<TabContents>(contents));
}
void Browser::TabSelectedAt(TabContents* old_contents,
@@ -1681,12 +1688,14 @@ void Browser::ReplaceContents(TabContents* source, TabContents* new_contents) {
// Need to remove ourselves as an observer for disconnection on the replaced
// TabContents, since we only care to fire onbeforeunload handlers on active
// Tabs. Make sure an observer is added for the replacement TabContents.
- NotificationService::current()->
- RemoveObserver(this, NOTIFY_WEB_CONTENTS_DISCONNECTED,
- Source<TabContents>(source));
- NotificationService::current()->
- AddObserver(this, NOTIFY_WEB_CONTENTS_DISCONNECTED,
- Source<TabContents>(new_contents));
+ NotificationService::current()->RemoveObserver(
+ this,
+ NotificationType::WEB_CONTENTS_DISCONNECTED,
+ Source<TabContents>(source));
+ NotificationService::current()->AddObserver(
+ this,
+ NotificationType::WEB_CONTENTS_DISCONNECTED,
+ Source<TabContents>(new_contents));
}
void Browser::AddNewContents(TabContents* source,
@@ -1910,8 +1919,8 @@ void Browser::FileSelected(const std::wstring& path, void* params) {
void Browser::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- switch (type) {
- case NOTIFY_WEB_CONTENTS_DISCONNECTED:
+ switch (type.value) {
+ case NotificationType::WEB_CONTENTS_DISCONNECTED:
if (is_attempting_to_close_browser_) {
// Need to do this asynchronously as it will close the tab, which is
// currently on the call stack above us.
@@ -1921,7 +1930,7 @@ void Browser::Observe(NotificationType type,
}
break;
- case NOTIFY_SSL_STATE_CHANGED:
+ case NotificationType::SSL_STATE_CHANGED:
// When the current tab's SSL state changes, we need to update the URL
// bar to reflect the new state. Note that it's possible for the selected
// tab contents to be NULL. This is because we listen for all sources