summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
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/tab_contents
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/tab_contents')
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc19
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc18
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.cc4
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc48
-rw-r--r--chrome/browser/tab_contents/web_contents.cc103
5 files changed, 102 insertions, 90 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index 942c126..c7e7d49 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/browser/tab_contents/web_contents_view_win.h"
+#include "chrome/common/notification_service.h"
#include "chrome/views/window.h"
#include "chrome/views/window_delegate.h"
#include "net/base/escape.h"
@@ -106,7 +107,7 @@ void InterstitialPage::Show() {
// NOTIFY_TAB_CONTENTS_DESTROYED as at that point the RenderViewHost has
// already been destroyed.
notification_registrar_.Add(
- this, NOTIFY_RENDER_WIDGET_HOST_DESTROYED,
+ this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
Source<RenderWidgetHost>(tab_->render_view_host()));
// Update the tab_to_interstitial_page_ map.
@@ -134,11 +135,11 @@ void InterstitialPage::Show() {
EscapePath(GetHTMLContents());
render_view_host_->NavigateToURL(GURL(data_url));
- notification_registrar_.Add(this, NOTIFY_TAB_CONTENTS_DESTROYED,
+ notification_registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
Source<TabContents>(tab_));
- notification_registrar_.Add(this, NOTIFY_NAV_ENTRY_COMMITTED,
+ notification_registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
Source<NavigationController>(tab_->controller()));
- notification_registrar_.Add(this, NOTIFY_NAV_ENTRY_PENDING,
+ notification_registrar_.Add(this, NotificationType::NAV_ENTRY_PENDING,
Source<NavigationController>(tab_->controller()));
}
@@ -159,8 +160,8 @@ void InterstitialPage::Hide() {
void InterstitialPage::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- switch (type) {
- case NOTIFY_NAV_ENTRY_PENDING:
+ switch (type.value) {
+ case NotificationType::NAV_ENTRY_PENDING:
// We are navigating away from the interstitial (the user has typed a URL
// in the location bar or clicked a bookmark). Make sure clicking on the
// interstitial will have no effect. Also cancel any blocked requests
@@ -174,7 +175,7 @@ void InterstitialPage::Observe(NotificationType type,
DCHECK(!resource_dispatcher_host_notified_);
TakeActionOnResourceDispatcher(CANCEL);
break;
- case NOTIFY_RENDER_WIDGET_HOST_DESTROYED:
+ case NotificationType::RENDER_WIDGET_HOST_DESTROYED:
if (!action_taken_) {
// The RenderViewHost is being destroyed (as part of the tab being
// closed), make sure we clear the blocked requests.
@@ -184,8 +185,8 @@ void InterstitialPage::Observe(NotificationType type,
TakeActionOnResourceDispatcher(CANCEL);
}
break;
- case NOTIFY_TAB_CONTENTS_DESTROYED:
- case NOTIFY_NAV_ENTRY_COMMITTED:
+ case NotificationType::TAB_CONTENTS_DESTROYED:
+ case NotificationType::NAV_ENTRY_COMMITTED:
if (!action_taken_) {
// We are navigating away from the interstitial or closing a tab with an
// interstitial. Default to DontProceed(). We don't just call Hide as
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc
index 9fb1be6..af0d810 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/navigation_types.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/common/scoped_vector.h"
#include "net/base/net_util.h"
@@ -36,7 +37,7 @@ void NotifyPrunedEntries(NavigationController* nav_controller,
details.from_front = from_front;
details.count = count;
NotificationService::current()->Notify(
- NOTIFY_NAV_LIST_PRUNED,
+ NotificationType::NAV_LIST_PRUNED,
Source<NavigationController>(nav_controller),
Details<NavigationController::PrunedDetails>(&details));
}
@@ -194,9 +195,10 @@ NavigationController::~NavigationController() {
DiscardNonCommittedEntriesInternal();
- NotificationService::current()->Notify(NOTIFY_TAB_CLOSED,
- Source<NavigationController>(this),
- NotificationService::NoDetails());
+ NotificationService::current()->Notify(
+ NotificationType::TAB_CLOSED,
+ Source<NavigationController>(this),
+ NotificationService::NoDetails());
}
TabContents* NavigationController::GetTabContents(TabContentsType t) {
@@ -249,7 +251,7 @@ void NavigationController::LoadEntry(NavigationEntry* entry) {
DiscardNonCommittedEntriesInternal();
pending_entry_ = entry;
NotificationService::current()->Notify(
- NOTIFY_NAV_ENTRY_PENDING,
+ NotificationType::NAV_ENTRY_PENDING,
Source<NavigationController>(this),
NotificationService::NoDetails());
NavigateToPendingEntry(false);
@@ -984,7 +986,7 @@ void NavigationController::InsertEntry(NavigationEntry* entry) {
void NavigationController::SetWindowID(const SessionID& id) {
window_id_ = id;
- NotificationService::current()->Notify(NOTIFY_TAB_PARENTED,
+ NotificationService::current()->Notify(NotificationType::TAB_PARENTED,
Source<NavigationController>(this),
NotificationService::NoDetails());
}
@@ -1029,7 +1031,7 @@ void NavigationController::NotifyNavigationEntryCommitted(
details->entry = GetActiveEntry();
NotificationService::current()->Notify(
- NOTIFY_NAV_ENTRY_COMMITTED,
+ NotificationType::NAV_ENTRY_COMMITTED,
Source<NavigationController>(this),
Details<LoadCommittedDetails>(details));
}
@@ -1113,7 +1115,7 @@ void NavigationController::NotifyEntryChanged(const NavigationEntry* entry,
EntryChangedDetails det;
det.changed_entry = entry;
det.index = index;
- NotificationService::current()->Notify(NOTIFY_NAV_ENTRY_CHANGED,
+ NotificationService::current()->Notify(NotificationType::NAV_ENTRY_CHANGED,
Source<NavigationController>(this),
Details<EntryChangedDetails>(&det));
}
diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc
index 789bb57..92c1d04 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.cc
+++ b/chrome/browser/tab_contents/render_view_host_manager.cc
@@ -92,7 +92,7 @@ RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) {
details.new_host = render_view_host_;
details.old_host = NULL;
NotificationService::current()->Notify(
- NOTIFY_RENDER_VIEW_HOST_CHANGED,
+ NotificationType::RENDER_VIEW_HOST_CHANGED,
Source<NavigationController>(
delegate_->GetControllerForRenderManager()),
Details<RenderViewHostSwitchedDetails>(&details));
@@ -415,7 +415,7 @@ void RenderViewHostManager::SwapToRenderView(
details.new_host = render_view_host_;
details.old_host = old_render_view_host;
NotificationService::current()->Notify(
- NOTIFY_RENDER_VIEW_HOST_CHANGED,
+ NotificationType::RENDER_VIEW_HOST_CHANGED,
Source<NavigationController>(delegate_->GetControllerForRenderManager()),
Details<RenderViewHostSwitchedDetails>(&details));
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 8afcfef..6db2c86 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/common/l10n_util.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/views/native_scroll_bar.h"
@@ -98,9 +99,10 @@ void TabContents::Destroy() {
infobar_delegates_.clear();
// Notify any observer that have a reference on this tab contents.
- NotificationService::current()->Notify(NOTIFY_TAB_CONTENTS_DESTROYED,
- Source<TabContents>(this),
- NotificationService::NoDetails());
+ NotificationService::current()->Notify(
+ NotificationType::TAB_CONTENTS_DESTROYED,
+ Source<TabContents>(this),
+ NotificationService::NoDetails());
// If we still have a window handle, destroy it. GetContainerHWND can return
// NULL if this contents was part of a window that closed.
@@ -246,9 +248,10 @@ void TabContents::DidBecomeSelected() {
}
void TabContents::WasHidden() {
- NotificationService::current()->Notify(NOTIFY_TAB_CONTENTS_HIDDEN,
- Source<TabContents>(this),
- NotificationService::NoDetails());
+ NotificationService::current()->Notify(
+ NotificationType::TAB_CONTENTS_HIDDEN,
+ Source<TabContents>(this),
+ NotificationService::NoDetails());
}
void TabContents::Activate() {
@@ -413,16 +416,17 @@ void TabContents::AddInfoBar(InfoBarDelegate* delegate) {
}
infobar_delegates_.push_back(delegate);
- NotificationService::current()->Notify(NOTIFY_TAB_CONTENTS_INFOBAR_ADDED,
- Source<TabContents>(this),
- Details<InfoBarDelegate>(delegate));
+ NotificationService::current()->Notify(
+ NotificationType::TAB_CONTENTS_INFOBAR_ADDED,
+ Source<TabContents>(this),
+ Details<InfoBarDelegate>(delegate));
// Add ourselves as an observer for navigations the first time a delegate is
// added. We use this notification to expire InfoBars that need to expire on
// page transitions.
if (infobar_delegates_.size() == 1) {
DCHECK(controller());
- registrar_.Add(this, NOTIFY_NAV_ENTRY_COMMITTED,
+ registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
Source<NavigationController>(controller()));
}
}
@@ -432,14 +436,15 @@ void TabContents::RemoveInfoBar(InfoBarDelegate* delegate) {
find(infobar_delegates_.begin(), infobar_delegates_.end(), delegate);
if (it != infobar_delegates_.end()) {
InfoBarDelegate* delegate = *it;
- NotificationService::current()->Notify(NOTIFY_TAB_CONTENTS_INFOBAR_REMOVED,
- Source<TabContents>(this),
- Details<InfoBarDelegate>(delegate));
+ NotificationService::current()->Notify(
+ NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
+ Source<TabContents>(this),
+ Details<InfoBarDelegate>(delegate));
infobar_delegates_.erase(it);
// Remove ourselves as an observer if we are tracking no more InfoBars.
if (infobar_delegates_.empty()) {
- registrar_.Remove(this, NOTIFY_NAV_ENTRY_COMMITTED,
+ registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED,
Source<NavigationController>(controller()));
}
}
@@ -529,7 +534,7 @@ void TabContents::DidMoveOrResize(ConstrainedWindow* window) {
void TabContents::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(type == NOTIFY_NAV_ENTRY_COMMITTED);
+ DCHECK(type == NotificationType::NAV_ENTRY_COMMITTED);
DCHECK(controller() == Source<NavigationController>(source).ptr());
NavigationController::LoadCommittedDetails& committed_details =
@@ -560,11 +565,14 @@ void TabContents::SetIsLoading(bool is_loading,
if (delegate_)
delegate_->LoadingStateChanged(this);
- NotificationService::current()->
- Notify((is_loading ? NOTIFY_LOAD_START : NOTIFY_LOAD_STOP),
- Source<NavigationController>(this->controller()),
- details ? Details<LoadNotificationDetails>(details) :
- NotificationService::NoDetails());
+ NotificationType type = is_loading ? NotificationType::LOAD_START :
+ NotificationType::LOAD_STOP;
+ NotificationDetails det = details ?
+ Details<LoadNotificationDetails>(details) :
+ NotificationService::NoDetails();
+ NotificationService::current()->Notify(type,
+ Source<NavigationController>(this->controller()),
+ det);
}
// TODO(brettw) This should be on the WebContentsView.
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index 9d6543f..5f82bc0 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -37,6 +37,7 @@
#include "chrome/browser/views/hung_renderer_view.h" // TODO(brettw) delete me.
#include "chrome/common/chrome_switches.h"
#include "chrome/common/l10n_util.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/resource_bundle.h"
@@ -206,14 +207,14 @@ WebContents::WebContents(Profile* profile,
}
// Register for notifications about URL starredness changing on any profile.
- NotificationService::current()->
- AddObserver(this, NOTIFY_URLS_STARRED, NotificationService::AllSources());
- NotificationService::current()->
- AddObserver(this, NOTIFY_BOOKMARK_MODEL_LOADED,
- NotificationService::AllSources());
- NotificationService::current()->
- AddObserver(this, NOTIFY_RENDER_WIDGET_HOST_DESTROYED,
- NotificationService::AllSources());
+ NotificationService::current()->AddObserver(
+ this, NotificationType::URLS_STARRED, NotificationService::AllSources());
+ NotificationService::current()->AddObserver(
+ this, NotificationType::BOOKMARK_MODEL_LOADED,
+ NotificationService::AllSources());
+ NotificationService::current()->AddObserver(
+ this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
+ NotificationService::AllSources());
}
WebContents::~WebContents() {
@@ -221,9 +222,9 @@ WebContents::~WebContents() {
web_app_->RemoveObserver(this);
if (pending_install_.callback_functor)
pending_install_.callback_functor->Cancel();
- NotificationService::current()->
- RemoveObserver(this, NOTIFY_RENDER_WIDGET_HOST_DESTROYED,
- NotificationService::AllSources());
+ NotificationService::current()->RemoveObserver(
+ this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
+ NotificationService::AllSources());
}
// static
@@ -300,12 +301,11 @@ PluginInstaller* WebContents::GetPluginInstaller() {
void WebContents::Destroy() {
// Tell the notification service we no longer want notifications.
- NotificationService::current()->
- RemoveObserver(this, NOTIFY_URLS_STARRED,
- NotificationService::AllSources());
- NotificationService::current()->
- RemoveObserver(this, NOTIFY_BOOKMARK_MODEL_LOADED,
- NotificationService::AllSources());
+ NotificationService::current()->RemoveObserver(
+ this, NotificationType::URLS_STARRED, NotificationService::AllSources());
+ NotificationService::current()->RemoveObserver(
+ this, NotificationType::BOOKMARK_MODEL_LOADED,
+ NotificationService::AllSources());
// Destroy the print manager right now since a Print command may be pending.
printing_.Destroy();
@@ -829,10 +829,10 @@ void WebContents::DidStartProvisionalLoadForFrame(
ProvisionalLoadDetails details(is_main_frame,
controller()->IsURLInPageNavigation(url),
url, std::string(), false);
- NotificationService::current()->
- Notify(NOTIFY_FRAME_PROVISIONAL_LOAD_START,
- Source<NavigationController>(controller()),
- Details<ProvisionalLoadDetails>(&details));
+ NotificationService::current()->Notify(
+ NotificationType::FRAME_PROVISIONAL_LOAD_START,
+ Source<NavigationController>(controller()),
+ Details<ProvisionalLoadDetails>(&details));
}
void WebContents::DidRedirectProvisionalLoad(int32 page_id,
@@ -863,10 +863,10 @@ void WebContents::DidLoadResourceFromMemoryCache(
&security_bits);
LoadFromMemoryCacheDetails details(url, cert_id, cert_status);
- NotificationService::current()->
- Notify(NOTIFY_LOAD_FROM_MEMORY_CACHE,
- Source<NavigationController>(controller()),
- Details<LoadFromMemoryCacheDetails>(&details));
+ NotificationService::current()->Notify(
+ NotificationType::LOAD_FROM_MEMORY_CACHE,
+ Source<NavigationController>(controller()),
+ Details<LoadFromMemoryCacheDetails>(&details));
}
void WebContents::DidFailProvisionalLoadWithError(
@@ -918,10 +918,10 @@ void WebContents::DidFailProvisionalLoadWithError(
url, std::string(), false);
details.set_error_code(error_code);
- NotificationService::current()->
- Notify(NOTIFY_FAIL_PROVISIONAL_LOAD_WITH_ERROR,
- Source<NavigationController>(controller()),
- Details<ProvisionalLoadDetails>(&details));
+ NotificationService::current()->Notify(
+ NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR,
+ Source<NavigationController>(controller()),
+ Details<ProvisionalLoadDetails>(&details));
}
void WebContents::UpdateFavIconURL(RenderViewHost* render_view_host,
@@ -957,7 +957,7 @@ void WebContents::DomOperationResponse(const std::string& json_string,
int automation_id) {
DomOperationNotificationDetails details(json_string, automation_id);
NotificationService::current()->Notify(
- NOTIFY_DOM_OPERATION_RESPONSE, Source<WebContents>(this),
+ NotificationType::DOM_OPERATION_RESPONSE, Source<WebContents>(this),
Details<DomOperationNotificationDetails>(&details));
}
@@ -1138,9 +1138,9 @@ void WebContents::PageHasOSDD(RenderViewHost* render_view_host,
void WebContents::InspectElementReply(int num_resources) {
// We have received reply from inspect element request. Notify the
// automation provider in case we need to notify automation client.
- NotificationService::current()->
- Notify(NOTIFY_DOM_INSPECT_ELEMENT_RESPONSE, Source<WebContents>(this),
- Details<int>(&num_resources));
+ NotificationService::current()->Notify(
+ NotificationType::DOM_INSPECT_ELEMENT_RESPONSE, Source<WebContents>(this),
+ Details<int>(&num_resources));
}
void WebContents::DidGetPrintedPagesCount(int cookie, int number_pages) {
@@ -1385,10 +1385,11 @@ bool WebContents::CreateRenderViewForRenderManager(
void WebContents::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- switch (type) {
- case NOTIFY_BOOKMARK_MODEL_LOADED: // BookmarkModel finished loading, fall
- // through to update starred state.
- case NOTIFY_URLS_STARRED: { // Somewhere, a URL has been starred.
+ switch (type.value) {
+ case NotificationType::BOOKMARK_MODEL_LOADED:
+ // BookmarkModel finished loading, fall through to update starred state.
+ case NotificationType::URLS_STARRED: {
+ // Somewhere, a URL has been starred.
// Ignore notifications for profiles other than our current one.
Profile* source_profile = Source<Profile>(source).ptr();
if (!source_profile->IsSameProfile(profile()))
@@ -1397,7 +1398,7 @@ void WebContents::Observe(NotificationType type,
UpdateStarredStateForCurrentURL();
break;
}
- case NOTIFY_PREF_CHANGED: {
+ case NotificationType::PREF_CHANGED: {
std::wstring* pref_name_in = Details<std::wstring>(details).ptr();
DCHECK(Source<PrefService>(source).ptr() == profile()->GetPrefs());
if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) {
@@ -1411,7 +1412,7 @@ void WebContents::Observe(NotificationType type,
}
break;
}
- case NOTIFY_RENDER_WIDGET_HOST_DESTROYED:
+ case NotificationType::RENDER_WIDGET_HOST_DESTROYED:
view_->RenderWidgetHostDestroyed(Source<RenderWidgetHost>(source).ptr());
break;
default: {
@@ -1679,18 +1680,18 @@ void WebContents::NotifySwapped() {
// notification so that clients that pick up a pointer to |this| can NULL the
// pointer. See Bug 1230284.
notify_disconnection_ = true;
- NotificationService::current()->
- Notify(NOTIFY_WEB_CONTENTS_SWAPPED,
- Source<WebContents>(this),
- NotificationService::NoDetails());
+ NotificationService::current()->Notify(
+ NotificationType::WEB_CONTENTS_SWAPPED,
+ Source<WebContents>(this),
+ NotificationService::NoDetails());
}
void WebContents::NotifyConnected() {
notify_disconnection_ = true;
- NotificationService::current()->
- Notify(NOTIFY_WEB_CONTENTS_CONNECTED,
- Source<WebContents>(this),
- NotificationService::NoDetails());
+ NotificationService::current()->Notify(
+ NotificationType::WEB_CONTENTS_CONNECTED,
+ Source<WebContents>(this),
+ NotificationService::NoDetails());
}
void WebContents::NotifyDisconnected() {
@@ -1698,10 +1699,10 @@ void WebContents::NotifyDisconnected() {
return;
notify_disconnection_ = false;
- NotificationService::current()->
- Notify(NOTIFY_WEB_CONTENTS_DISCONNECTED,
- Source<WebContents>(this),
- NotificationService::NoDetails());
+ NotificationService::current()->Notify(
+ NotificationType::WEB_CONTENTS_DISCONNECTED,
+ Source<WebContents>(this),
+ NotificationService::NoDetails());
}
void WebContents::GenerateKeywordIfNecessary(