diff options
38 files changed, 180 insertions, 136 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index e346278..8e3d997 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -161,7 +161,7 @@ void AlternateNavURLFetcher::Observe( // WARNING: |this| may be deleted! break; - case content::NOTIFICATION_TAB_CLOSED: + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: // We have been closed. In order to prevent the URLFetcher from trying to // access the controller that will be invalid, we delete ourselves. // This deletes the URLFetcher and insures its callback won't be called. @@ -184,8 +184,10 @@ void AlternateNavURLFetcher::OnURLFetchComplete( void AlternateNavURLFetcher::StartFetch(NavigationController* controller) { controller_ = controller; - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, - content::Source<NavigationController>(controller_)); + registrar_.Add( + this, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<content::WebContents>(controller_->GetWebContents())); DCHECK_EQ(NOT_STARTED, state_); state_ = IN_PROGRESS; diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 32e61b1..aebb84e 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -381,9 +381,12 @@ void TabStripNotificationObserver::Observe( const content::NotificationSource& source, const content::NotificationDetails& details) { if (type == notification_) { - if (type == content::NOTIFICATION_TAB_PARENTED) { + if (type == chrome::NOTIFICATION_TAB_PARENTED) { ObserveTab(&(content::Source<TabContentsWrapper>(source).ptr()-> web_contents()->GetController())); + } else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { + ObserveTab(&(content::Source<content::WebContents>(source).ptr()-> + GetController())); } else { ObserveTab(content::Source<NavigationController>(source).ptr()); } @@ -396,7 +399,7 @@ void TabStripNotificationObserver::Observe( TabAppendedNotificationObserver::TabAppendedNotificationObserver( Browser* parent, AutomationProvider* automation, IPC::Message* reply_message) - : TabStripNotificationObserver(content::NOTIFICATION_TAB_PARENTED, + : TabStripNotificationObserver(chrome::NOTIFICATION_TAB_PARENTED, automation), parent_(parent), reply_message_(reply_message) { @@ -423,8 +426,10 @@ void TabAppendedNotificationObserver::ObserveTab( TabClosedNotificationObserver::TabClosedNotificationObserver( AutomationProvider* automation, bool wait_until_closed, IPC::Message* reply_message) - : TabStripNotificationObserver(wait_until_closed ? - content::NOTIFICATION_TAB_CLOSED : content::NOTIFICATION_TAB_CLOSING, + : TabStripNotificationObserver( + wait_until_closed + ? static_cast<int>(content::NOTIFICATION_WEB_CONTENTS_DESTROYED) + : static_cast<int>(chrome::NOTIFICATION_TAB_CLOSING), automation), reply_message_(reply_message), for_browser_command_(false) { @@ -1016,11 +1021,11 @@ struct CommandNotification { }; const struct CommandNotification command_notifications[] = { - {IDC_DUPLICATE_TAB, content::NOTIFICATION_TAB_PARENTED}, + {IDC_DUPLICATE_TAB, chrome::NOTIFICATION_TAB_PARENTED}, // Returns as soon as the restored tab is created. To further wait until // the content page is loaded, use WaitForTabToBeRestored. - {IDC_RESTORE_TAB, content::NOTIFICATION_TAB_PARENTED}, + {IDC_RESTORE_TAB, chrome::NOTIFICATION_TAB_PARENTED}, // For the following commands, we need to wait for a new tab to be created, // load to finish, and title to change. @@ -2683,14 +2688,14 @@ NewTabObserver::NewTabObserver(AutomationProvider* automation, reply_message_(reply_message) { // Use TAB_PARENTED to detect the new tab. registrar_.Add(this, - content::NOTIFICATION_TAB_PARENTED, + chrome::NOTIFICATION_TAB_PARENTED, content::NotificationService::AllSources()); } void NewTabObserver::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - DCHECK_EQ(content::NOTIFICATION_TAB_PARENTED, type); + DCHECK_EQ(chrome::NOTIFICATION_TAB_PARENTED, type); NavigationController* controller = &(content::Source<TabContentsWrapper>(source).ptr()-> web_contents()->GetController()); diff --git a/chrome/browser/automation/automation_tab_tracker.cc b/chrome/browser/automation/automation_tab_tracker.cc index 7f7e2cc..348651e 100644 --- a/chrome/browser/automation/automation_tab_tracker.cc +++ b/chrome/browser/automation/automation_tab_tracker.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -20,7 +20,7 @@ AutomationTabTracker::~AutomationTabTracker() { void AutomationTabTracker::AddObserver(NavigationController* resource) { // This tab could either be a regular tab or an external tab // Register for both notifications. - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, + registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING, content::Source<NavigationController>(resource)); registrar_.Add(this, chrome::NOTIFICATION_EXTERNAL_TAB_CLOSED, content::Source<NavigationController>(resource)); @@ -31,7 +31,7 @@ void AutomationTabTracker::AddObserver(NavigationController* resource) { } void AutomationTabTracker::RemoveObserver(NavigationController* resource) { - registrar_.Remove(this, content::NOTIFICATION_TAB_CLOSING, + registrar_.Remove(this, chrome::NOTIFICATION_TAB_CLOSING, content::Source<NavigationController>(resource)); registrar_.Remove(this, chrome::NOTIFICATION_EXTERNAL_TAB_CLOSED, content::Source<NavigationController>(resource)); @@ -50,7 +50,7 @@ void AutomationTabTracker::Observe( base::Time::Now(); return; case chrome::NOTIFICATION_EXTERNAL_TAB_CLOSED: - case content::NOTIFICATION_TAB_CLOSING: + case chrome::NOTIFICATION_TAB_CLOSING: { std::map<NavigationController*, base::Time>::iterator iter = last_navigation_times_.find( diff --git a/chrome/browser/browser_keyevents_browsertest.cc b/chrome/browser/browser_keyevents_browsertest.cc index edf9fa3..5cac985 100644 --- a/chrome/browser/browser_keyevents_browsertest.cc +++ b/chrome/browser/browser_keyevents_browsertest.cc @@ -687,7 +687,7 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, MAYBE_ReservedAccelerators) { }; ui_test_utils::WindowedNotificationObserver wait_for_new_tab( - content::NOTIFICATION_TAB_PARENTED, + chrome::NOTIFICATION_TAB_PARENTED, content::NotificationService::AllSources()); // Press Ctrl/Cmd+T, which will open a new tab. It cannot be suppressed. @@ -701,7 +701,7 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, MAYBE_ReservedAccelerators) { EXPECT_EQ(2, browser()->tab_count()); ASSERT_EQ(1, browser()->active_index()); - // Because of issue http://crbug.com/65375, switching back to the first tab + // Because of issue <http://crbug.com/65375>, switching back to the first tab // may cause the focus to be grabbed by omnibox. So instead, we load our // testing page in the newly created tab and try Cmd-W here. ui_test_utils::NavigateToURL(browser(), url); @@ -714,9 +714,8 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, MAYBE_ReservedAccelerators) { ASSERT_NO_FATAL_FAILURE(SuppressAllEvents(1, true)); ui_test_utils::WindowedNotificationObserver wait_for_tab_closed( - content::NOTIFICATION_TAB_CLOSED, - content::Source<NavigationController>( - &browser()->GetWebContentsAt(1)->GetController())); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<content::WebContents>(browser()->GetWebContentsAt(1))); // Press Ctrl/Cmd+W, which will close the tab. #if defined(OS_MACOSX) diff --git a/chrome/browser/chrome_main_browsertest.cc b/chrome/browser/chrome_main_browsertest.cc index 513b203..b34080a 100644 --- a/chrome/browser/chrome_main_browsertest.cc +++ b/chrome/browser/chrome_main_browsertest.cc @@ -73,7 +73,7 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { FilePath(), FilePath().AppendASCII("empty.html")); new_command_line_.AppendArgPath(test_file_path); ui_test_utils::WindowedNotificationObserver observer( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); Relaunch(); observer.Wait(); @@ -136,7 +136,7 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { FilePath(), FilePath().AppendASCII("empty.html")); new_command_line_.AppendArgPath(test_file_path); ui_test_utils::WindowedNotificationObserver tab_observer( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); Relaunch(); tab_observer.Wait(); diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index 2c191e5..30c8457 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -215,7 +215,7 @@ DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents, &tab_contents_->web_contents()->GetController())); registrar_.Add( this, - content::NOTIFICATION_TAB_CLOSING, + chrome::NOTIFICATION_TAB_CLOSING, content::Source<NavigationController>( &tab_contents_->web_contents()->GetController())); registrar_.Add( @@ -487,7 +487,7 @@ void DevToolsWindow::Observe(int type, UpdateTheme(); DoAction(); AddDevToolsExtensionsToClient(); - } else if (type == content::NOTIFICATION_TAB_CLOSING) { + } else if (type == chrome::NOTIFICATION_TAB_CLOSING) { if (content::Source<NavigationController>(source).ptr() == &tab_contents_->web_contents()->GetController()) { // This happens when browser closes all of its tabs as a result diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc index 829e353..631d89d 100644 --- a/chrome/browser/download/download_request_limiter.cc +++ b/chrome/browser/download/download_request_limiter.cc @@ -37,9 +37,12 @@ DownloadRequestLimiter::TabDownloadState::TabDownloadState( download_count_(0), infobar_(NULL) { content::Source<NavigationController> notification_source(controller); + content::Source<content::WebContents> web_contents_source( + controller->GetWebContents()); registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, notification_source); - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, notification_source); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + web_contents_source); NavigationEntry* active_entry = originating_controller ? originating_controller->GetActiveEntry() : controller->GetActiveEntry(); @@ -101,12 +104,22 @@ void DownloadRequestLimiter::TabDownloadState::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - if ((type != content::NOTIFICATION_NAV_ENTRY_PENDING && - type != content::NOTIFICATION_TAB_CLOSED) || + if (type != content::NOTIFICATION_NAV_ENTRY_PENDING && + type != content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { + NOTREACHED(); + return; + } + if (type == content::NOTIFICATION_NAV_ENTRY_PENDING && content::Source<NavigationController>(source).ptr() != controller_) { NOTREACHED(); return; } + if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED && + &content::Source<content::WebContents>(source).ptr()-> + GetController() != controller_) { + NOTREACHED(); + return; + } switch (type) { case content::NOTIFICATION_NAV_ENTRY_PENDING: { @@ -138,7 +151,7 @@ void DownloadRequestLimiter::TabDownloadState::Observe( break; } - case content::NOTIFICATION_TAB_CLOSED: + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: // Tab closed, no need to handle closing the dialog as it's owned by the // TabContents, break so that we get deleted after switch. break; diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc index da4f945..d87fc60 100644 --- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc @@ -404,7 +404,7 @@ void WebNavigationEventRouter::Init() { chrome::NOTIFICATION_RETARGETING, content::NotificationService::AllSources()); registrar_.Add(this, - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, @@ -426,7 +426,7 @@ void WebNavigationEventRouter::Observe( break; } - case content::NOTIFICATION_TAB_ADDED: + case chrome::NOTIFICATION_TAB_ADDED: TabAdded(content::Details<WebContents>(details).ptr()); break; diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc index fea468a..1e0872e 100644 --- a/chrome/browser/extensions/app_process_apitest.cc +++ b/chrome/browser/extensions/app_process_apitest.cc @@ -12,6 +12,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_file_util.h" @@ -126,7 +127,7 @@ class AppApiTest : public ExtensionApiTest { EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI()); ui_test_utils::WindowedNotificationObserver tab_added_observer( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); browser()->NewTab(); tab_added_observer.Wait(); @@ -197,7 +198,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) { LOG(INFO) << "Nav 2."; ui_test_utils::WindowedNotificationObserver tab_added_observer( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); browser()->NewTab(); tab_added_observer.Wait(); @@ -314,7 +315,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, BookmarkAppGetsNormalProcess) { EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI()); ui_test_utils::WindowedNotificationObserver tab_added_observer( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); browser()->NewTab(); tab_added_observer.Wait(); diff --git a/chrome/browser/extensions/extension_tab_id_map.cc b/chrome/browser/extensions/extension_tab_id_map.cc index caf7b5a..5ede659 100644 --- a/chrome/browser/extensions/extension_tab_id_map.cc +++ b/chrome/browser/extensions/extension_tab_id_map.cc @@ -51,7 +51,7 @@ ExtensionTabIdMap::TabObserver::TabObserver() { content::NotificationService::AllBrowserContextsAndSources()); registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, content::NotificationService::AllBrowserContextsAndSources()); - registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, + registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, content::NotificationService::AllBrowserContextsAndSources()); registrar_.Add(this, chrome::NOTIFICATION_RETARGETING, content::NotificationService::AllBrowserContextsAndSources()); @@ -84,7 +84,7 @@ void ExtensionTabIdMap::TabObserver::Observe( tab->restore_tab_helper()->window_id().id())); break; } - case content::NOTIFICATION_TAB_PARENTED: { + case chrome::NOTIFICATION_TAB_PARENTED: { TabContentsWrapper* tab = content::Source<TabContentsWrapper>(source).ptr(); RenderViewHost* host = tab->web_contents()->GetRenderViewHost(); diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index e7bbd73..932d248 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -1800,7 +1800,7 @@ bool DetectTabLanguageFunction::RunImpl() { registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, content::Source<WebContents>(contents->web_contents())); registrar_.Add( - this, content::NOTIFICATION_TAB_CLOSING, + this, chrome::NOTIFICATION_TAB_CLOSING, content::Source<NavigationController>( &(contents->web_contents()->GetController()))); registrar_.Add( diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index cff1bd6..ee240f2 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -327,12 +327,16 @@ void GoogleURLTracker::Observe(int type, } case content::NOTIFICATION_NAV_ENTRY_COMMITTED: - case content::NOTIFICATION_TAB_CLOSED: OnNavigationCommittedOrTabClosed( content::Source<NavigationController>(source).ptr()-> GetWebContents(), type); break; + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: + OnNavigationCommittedOrTabClosed( + content::Source<content::WebContents>(source).ptr(), type); + break; + default: NOTREACHED() << "Unknown notification received:" << type; } @@ -363,8 +367,10 @@ void GoogleURLTracker::OnNavigationPending( // tab close command since that means the load will never commit. registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>(controller_)); - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, - content::Source<NavigationController>(controller_)); + registrar_.Add( + this, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<content::WebContents>(controller_->GetWebContents())); } void GoogleURLTracker::OnNavigationCommittedOrTabClosed( diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc index 45d38be..7d856c5 100644 --- a/chrome/browser/instant/instant_browsertest.cc +++ b/chrome/browser/instant/instant_browsertest.cc @@ -619,7 +619,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SearchServerDoesntSupportInstant)) { SetupInstantProvider("empty.html"); ui_test_utils::WindowedNotificationObserver tab_closed_observer( - content::NOTIFICATION_TAB_CLOSED, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); omnibox()->SetUserText(ASCIIToUTF16("d")); @@ -645,7 +645,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, EXPECT_FALSE(preview()); ui_test_utils::WindowedNotificationObserver tab_closed_observer( - content::NOTIFICATION_TAB_CLOSED, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); // Now type in some search text. diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 8fb2d08..9fc36d0 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -499,9 +499,9 @@ void MetricsService::SetUpNotifications( content::NotificationService::AllSources()); registrar->Add(observer, content::NOTIFICATION_USER_ACTION, content::NotificationService::AllSources()); - registrar->Add(observer, content::NOTIFICATION_TAB_PARENTED, + registrar->Add(observer, chrome::NOTIFICATION_TAB_PARENTED, content::NotificationService::AllSources()); - registrar->Add(observer, content::NOTIFICATION_TAB_CLOSING, + registrar->Add(observer, chrome::NOTIFICATION_TAB_CLOSING, content::NotificationService::AllSources()); registrar->Add(observer, content::NOTIFICATION_LOAD_START, content::NotificationService::AllSources()); @@ -545,8 +545,8 @@ void MetricsService::Observe(int type, LogWindowChange(type, source, details); break; - case content::NOTIFICATION_TAB_PARENTED: - case content::NOTIFICATION_TAB_CLOSING: + case chrome::NOTIFICATION_TAB_PARENTED: + case chrome::NOTIFICATION_TAB_CLOSING: LogWindowChange(type, source, details); break; @@ -1311,12 +1311,12 @@ void MetricsService::LogWindowChange( DCHECK_NE(controller_id, -1); switch (type) { - case content::NOTIFICATION_TAB_PARENTED: + case chrome::NOTIFICATION_TAB_PARENTED: case chrome::NOTIFICATION_BROWSER_OPENED: window_type = MetricsLog::WINDOW_CREATE; break; - case content::NOTIFICATION_TAB_CLOSING: + case chrome::NOTIFICATION_TAB_CLOSING: case chrome::NOTIFICATION_BROWSER_CLOSED: window_map_.erase(window_map_.find(window_or_tab)); window_type = MetricsLog::WINDOW_DESTROY; diff --git a/chrome/browser/printing/print_dialog_cloud_interative_uitest.cc b/chrome/browser/printing/print_dialog_cloud_interative_uitest.cc index 9ae5e52..be481b4 100644 --- a/chrome/browser/printing/print_dialog_cloud_interative_uitest.cc +++ b/chrome/browser/printing/print_dialog_cloud_interative_uitest.cc @@ -246,7 +246,7 @@ IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, HandlersRegistered) { // Close the dialog before finishing the test. ui_test_utils::WindowedNotificationObserver tab_closed_observer( - content::NOTIFICATION_TAB_CLOSED, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); // Can't use ui_test_utils::SendKeyPressSync or diff --git a/chrome/browser/sessions/restore_tab_helper.cc b/chrome/browser/sessions/restore_tab_helper.cc index 277fc5e..2f1188b 100644 --- a/chrome/browser/sessions/restore_tab_helper.cc +++ b/chrome/browser/sessions/restore_tab_helper.cc @@ -5,9 +5,9 @@ #include "chrome/browser/sessions/restore_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension_messages.h" #include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -28,7 +28,7 @@ void RestoreTabHelper::SetWindowID(const SessionID& id) { TabContentsWrapper::GetCurrentWrapperForContents(web_contents()); if (tab) { content::NotificationService::current()->Notify( - content::NOTIFICATION_TAB_PARENTED, + chrome::NOTIFICATION_TAB_PARENTED, content::Source<TabContentsWrapper>(tab), content::NotificationService::NoDetails()); } diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index 317c31d..4eb3f65 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -503,9 +503,9 @@ void SessionService::Save() { void SessionService::Init() { // Register for the notifications we're interested in. - registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, + registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, content::NotificationService::AllSources()); - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, content::NotificationService::AllSources()); @@ -582,7 +582,7 @@ void SessionService::Observe(int type, break; } - case content::NOTIFICATION_TAB_PARENTED: { + case chrome::NOTIFICATION_TAB_PARENTED: { TabContentsWrapper* tab = content::Source<TabContentsWrapper>(source).ptr(); if (tab->profile() != profile()) @@ -598,17 +598,17 @@ void SessionService::Observe(int type, break; } - case content::NOTIFICATION_TAB_CLOSED: { + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( - content::Source<content::NavigationController>( - source).ptr()->GetWebContents()); + content::Source<content::WebContents>(source).ptr()); if (!tab || tab->profile() != profile()) return; TabClosed(tab->restore_tab_helper()->window_id(), tab->restore_tab_helper()->session_id(), tab->web_contents()->GetClosedByUserGesture()); - RecordSessionUpdateHistogramData(content::NOTIFICATION_TAB_CLOSED, + RecordSessionUpdateHistogramData( + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, &last_updated_tab_closed_time_); break; } @@ -1511,7 +1511,7 @@ void SessionService::RecordSessionUpdateHistogramData(int type, RecordUpdatedSaveTime(delta, use_long_period); RecordUpdatedSessionNavigationOrTab(delta, use_long_period); break; - case content::NOTIFICATION_TAB_CLOSED: + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: RecordUpdatedTabClosed(delta, use_long_period); RecordUpdatedSessionNavigationOrTab(delta, use_long_period); break; diff --git a/chrome/browser/sync/glue/session_change_processor.cc b/chrome/browser/sync/glue/session_change_processor.cc index 6786f2c1..8d3fea3 100644 --- a/chrome/browser/sync/glue/session_change_processor.cc +++ b/chrome/browser/sync/glue/session_change_processor.cc @@ -109,7 +109,7 @@ void SessionChangeProcessor::Observe( break; } - case content::NOTIFICATION_TAB_PARENTED: { + case chrome::NOTIFICATION_TAB_PARENTED: { SyncedTabDelegate* tab = content::Source<TabContentsWrapper>(source).ptr()-> synced_tab_delegate(); @@ -137,13 +137,20 @@ void SessionChangeProcessor::Observe( break; } - case content::NOTIFICATION_TAB_CLOSED: { - SyncedTabDelegate* tab = ExtractSyncedTabDelegate(source); + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { + TabContentsWrapper* tab_contents_wrapper = + TabContentsWrapper::GetCurrentWrapperForContents( + content::Source<WebContents>(source).ptr()); + if (!tab_contents_wrapper) { + return; + } + SyncedTabDelegate* tab = tab_contents_wrapper->synced_tab_delegate(); if (!tab || tab->profile() != profile_) { return; } modified_tabs.push_back(tab); - DVLOG(1) << "Received TAB_CLOSED for profile " << profile_; + DVLOG(1) << "Received NOTIFICATION_WEB_CONTENTS_DESTROYED for profile " + << profile_; break; } @@ -341,9 +348,10 @@ void SessionChangeProcessor::StartObserving() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!profile_) return; - notification_registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, + notification_registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, content::NotificationService::AllSources()); - notification_registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, + notification_registrar_.Add(this, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); notification_registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, content::NotificationService::AllSources()); diff --git a/chrome/browser/tab_restore_browsertest.cc b/chrome/browser/tab_restore_browsertest.cc index 5042720..1fcfb14 100644 --- a/chrome/browser/tab_restore_browsertest.cc +++ b/chrome/browser/tab_restore_browsertest.cc @@ -64,7 +64,7 @@ class TabRestoreTest : public InProcessBrowserTest { void CloseTab(int index) { content::WebContents* new_tab = browser()->GetWebContentsAt(index); ui_test_utils::WindowedNotificationObserver tab_close_observer( - content::NOTIFICATION_TAB_CLOSED, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); browser()->CloseTabContents(new_tab); tab_close_observer.Wait(); @@ -94,7 +94,7 @@ class TabRestoreTest : public InProcessBrowserTest { // Restore the tab. ui_test_utils::WindowedNotificationObserver tab_added_observer( - content::NOTIFICATION_TAB_PARENTED, + chrome::NOTIFICATION_TAB_PARENTED, content::NotificationService::AllSources()); ui_test_utils::WindowedNotificationObserver tab_loaded_observer( content::NOTIFICATION_LOAD_STOP, diff --git a/chrome/browser/tabs/tab_finder.cc b/chrome/browser/tabs/tab_finder.cc index c218ccd..33c16f9 100644 --- a/chrome/browser/tabs/tab_finder.cc +++ b/chrome/browser/tabs/tab_finder.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -13,12 +13,12 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/common/frame_navigate_params.h" @@ -119,7 +119,7 @@ WebContents* TabFinder::FindTab(Browser* browser, void TabFinder::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - DCHECK_EQ(type, content::NOTIFICATION_TAB_PARENTED); + DCHECK_EQ(type, chrome::NOTIFICATION_TAB_PARENTED); // The tab was added to a browser. Query for its state now. TabContentsWrapper* tab = content::Source<TabContentsWrapper>(source).ptr(); @@ -127,7 +127,7 @@ void TabFinder::Observe(int type, } TabFinder::TabFinder() { - registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, + registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, content::NotificationService::AllSources()); } diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 0d1b529..2d15f70 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -3509,7 +3509,7 @@ void Browser::TabClosingAt(TabStripModel* tab_strip_model, int index) { fullscreen_controller_->OnTabClosing(contents->web_contents()); content::NotificationService::current()->Notify( - content::NOTIFICATION_TAB_CLOSING, + chrome::NOTIFICATION_TAB_CLOSING, content::Source<NavigationController>( &contents->web_contents()->GetController()), content::NotificationService::NoDetails()); diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index 20df9d2..8e65ade 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -537,7 +537,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { redirect_popup += "\";"; ui_test_utils::WindowedNotificationObserver popup_observer( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); ui_test_utils::WindowedNotificationObserver nav_observer( content::NOTIFICATION_NAV_ENTRY_COMMITTED, @@ -571,7 +571,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { refresh_popup += "\">');w.document.close();"; ui_test_utils::WindowedNotificationObserver popup_observer2( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); ui_test_utils::WindowedNotificationObserver nav_observer2( content::NOTIFICATION_NAV_ENTRY_COMMITTED, @@ -625,7 +625,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { dont_fork_popup += "\";"; ui_test_utils::WindowedNotificationObserver popup_observer( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); ui_test_utils::WindowedNotificationObserver nav_observer( content::NOTIFICATION_NAV_ENTRY_COMMITTED, diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index 898ed6f..3154eec 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -618,7 +618,7 @@ void Navigate(NavigateParams* params) { if (params->disposition != CURRENT_TAB) { content::NotificationService::current()->Notify( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::Source<content::WebContentsDelegate>(params->browser), content::Details<WebContents>(params->target_contents->web_contents())); } diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm index ba611fd..e3b2c32 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm @@ -46,7 +46,7 @@ BookmarkBubbleNotificationBridge::BookmarkBubbleNotificationBridge( // don't need to do so explicitly. registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, content::NotificationService::AllSources()); - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); } diff --git a/chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.mm b/chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.mm index c816c69..7a8b977 100644 --- a/chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.mm @@ -37,7 +37,7 @@ ChromeToMobileBubbleNotificationBridge::ChromeToMobileBubbleNotificationBridge( selector_(selector) { registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, content::NotificationService::AllSources()); - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); } diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc index f8ceebc..ccaa248 100644 --- a/chrome/browser/ui/intents/web_intent_picker_controller.cc +++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc @@ -184,7 +184,7 @@ WebIntentPickerController::WebIntentPickerController( &wrapper->web_contents()->GetController(); registrar_.Add(this, content::NOTIFICATION_LOAD_START, content::Source<content::NavigationController>(controller)); - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, + registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING, content::Source<content::NavigationController>(controller)); } @@ -242,7 +242,7 @@ void WebIntentPickerController::Observe( const content::NotificationSource& source, const content::NotificationDetails& details) { DCHECK(type == content::NOTIFICATION_LOAD_START || - type == content::NOTIFICATION_TAB_CLOSING); + type == chrome::NOTIFICATION_TAB_CLOSING); ClosePicker(); } diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc index 8c4ee14..a96634a 100644 --- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc +++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc @@ -224,11 +224,12 @@ class OmniboxViewTest : public InProcessBrowserTest, return; content::NotificationRegistrar registrar; - registrar.Add(this, - (tab_count < expected_tab_count ? - content::NOTIFICATION_TAB_PARENTED : - content::NOTIFICATION_TAB_CLOSED), - content::NotificationService::AllSources()); + registrar.Add( + this, + tab_count < expected_tab_count + ? static_cast<int>(chrome::NOTIFICATION_TAB_PARENTED) + : static_cast<int>(content::NOTIFICATION_WEB_CONTENTS_DESTROYED), + content::NotificationService::AllSources()); while (!HasFailure() && browser->tab_count() != expected_tab_count) ui_test_utils::RunMessageLoop(); @@ -370,8 +371,8 @@ class OmniboxViewTest : public InProcessBrowserTest, const content::NotificationSource& source, const content::NotificationDetails& details) { switch (type) { - case content::NOTIFICATION_TAB_CLOSED: - case content::NOTIFICATION_TAB_PARENTED: + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: + case chrome::NOTIFICATION_TAB_PARENTED: case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED: case chrome::NOTIFICATION_HISTORY_LOADED: diff --git a/chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc b/chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc index e1538ed..8eaa55e 100644 --- a/chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc +++ b/chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc @@ -5,9 +5,9 @@ #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" #include "chrome/browser/ui/constrained_window.h" +#include "chrome/common/chrome_notification_types.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/notification_source.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -22,7 +22,7 @@ TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate( NavigationController* controller = &web_contents->GetController(); registrar_.Add(this, content::NOTIFICATION_LOAD_START, content::Source<NavigationController>(controller)); - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, + registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING, content::Source<NavigationController>(controller)); } @@ -62,7 +62,7 @@ void TabModalConfirmDialogDelegate::Observe( // Close the dialog if we load a page (because the action might not apply to // the same page anymore) or if the tab is closed. if (type == content::NOTIFICATION_LOAD_START || - type == content::NOTIFICATION_TAB_CLOSING) { + type == chrome::NOTIFICATION_TAB_CLOSING) { Cancel(); } else { NOTREACHED(); diff --git a/chrome/browser/ui/web_applications/web_app_ui.cc b/chrome/browser/ui/web_applications/web_app_ui.cc index 6a034f4..ba2ebfd 100644 --- a/chrome/browser/ui/web_applications/web_app_ui.cc +++ b/chrome/browser/ui/web_applications/web_app_ui.cc @@ -15,12 +15,12 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/web_applications/web_app.h" +#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_source.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" #if defined(OS_POSIX) && !defined(OS_MACOSX) @@ -104,7 +104,7 @@ UpdateShortcutWorker::UpdateShortcutWorker(TabContentsWrapper* tab_contents) registrar_.Add( this, - content::NOTIFICATION_TAB_CLOSING, + chrome::NOTIFICATION_TAB_CLOSING, content::Source<NavigationController>( &tab_contents_->web_contents()->GetController())); } @@ -118,7 +118,7 @@ void UpdateShortcutWorker::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - if (type == content::NOTIFICATION_TAB_CLOSING && + if (type == chrome::NOTIFICATION_TAB_CLOSING && content::Source<NavigationController>(source).ptr() == &tab_contents_->web_contents()->GetController()) { // Underlying tab is closing. diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc index d20a2a2..4c5b071 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc @@ -91,7 +91,7 @@ void SyncPromoHandler::RegisterMessages() { if (!web_ui()->GetWebContents()->GetController().GetActiveEntry()-> IsViewSourceMode()) { // Listen to see if the tab we're in gets closed. - registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, + registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING, content::Source<NavigationController>( &web_ui()->GetWebContents()->GetController())); // Listen to see if the window we're in gets closed. @@ -148,7 +148,7 @@ void SyncPromoHandler::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { switch (type) { - case content::NOTIFICATION_TAB_CLOSING: { + case chrome::NOTIFICATION_TAB_CLOSING: { if (!window_already_closed_) RecordUserFlowAction(SYNC_PROMO_CLOSED_TAB); break; diff --git a/chrome/browser/unload_browsertest.cc b/chrome/browser/unload_browsertest.cc index f60f01a..0b4ab30e 100644 --- a/chrome/browser/unload_browsertest.cc +++ b/chrome/browser/unload_browsertest.cc @@ -384,7 +384,7 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseTabWhenOtherTabHasListener) { // popup will be constrained, which isn't what we want to test. ui_test_utils::WindowedNotificationObserver observer( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); ui_test_utils::WindowedNotificationObserver load_stop_observer( content::NOTIFICATION_LOAD_STOP, @@ -396,7 +396,7 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseTabWhenOtherTabHasListener) { CheckTitle("popup"); ui_test_utils::WindowedNotificationObserver tab_close_observer( - content::NOTIFICATION_TAB_CLOSED, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); browser()->CloseTab(); tab_close_observer.Wait(); diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h index 86c556a..a42adf7 100644 --- a/chrome/common/chrome_notification_types.h +++ b/chrome/common/chrome_notification_types.h @@ -135,6 +135,25 @@ enum NotificationType { // RenderViewHost and the details are not used. NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, + // Tabs -------------------------------------------------------------------- + + // Sent when a tab is added to a WebContentsDelegate. The source is the + // WebContentsDelegate and the details is the added WebContents. + NOTIFICATION_TAB_ADDED, + + // This notification is sent after a tab has been appended to the tab_strip. + // The source is a Source<TabContentsWrapper> of the tab being added. There + // are no details. + NOTIFICATION_TAB_PARENTED, + + // This message is sent before a tab has been closed. The source is a + // Source<NavigationController> with a pointer to the controller for the + // closed tab. No details are expected. + // + // See also content::NOTIFICATION_WEB_CONTENTS_DESTROYED, which is sent when + // the WebContents containing the NavigationController is destroyed. + NOTIFICATION_TAB_CLOSING, + // Stuff inside the tabs --------------------------------------------------- // Sent when the bookmark bubble hides. The source is the profile, the diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc index e91d355..7bb1acb 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -342,7 +342,7 @@ void WaitForNavigations(NavigationController* controller, void WaitForNewTab(Browser* browser) { TestNotificationObserver observer; - RegisterAndWait(&observer, content::NOTIFICATION_TAB_ADDED, + RegisterAndWait(&observer, chrome::NOTIFICATION_TAB_ADDED, content::Source<content::WebContentsDelegate>(browser)); } @@ -433,7 +433,7 @@ static void NavigateToURLWithDispositionBlockUntilNavigationsComplete( } WindowedNotificationObserver tab_added_observer( - content::NOTIFICATION_TAB_ADDED, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); WindowedNotificationObserver auth_observer( @@ -974,6 +974,11 @@ void WindowedNotificationObserver::Observe( } } +WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver( + const content::NotificationSource& source) + : WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source) { +} + TitleWatcher::TitleWatcher(WebContents* web_contents, const string16& expected_title) : web_contents_(web_contents), diff --git a/chrome/test/base/ui_test_utils.h b/chrome/test/base/ui_test_utils.h index 7bbc2f1..68ea3c2 100644 --- a/chrome/test/base/ui_test_utils.h +++ b/chrome/test/base/ui_test_utils.h @@ -448,6 +448,21 @@ class WindowedNotificationObserver : public content::NotificationObserver { DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserver); }; +// A WindowedNotificationObserver hard-wired to observe +// chrome::NOTIFICATION_TAB_ADDED. +class WindowedTabAddedNotificationObserver + : public WindowedNotificationObserver { + public: + // Register to listen for notifications of NOTIFICATION_TAB_ADDED from either + // a specific source, or from all sources if |source| is + // NotificationService::AllSources(). + WindowedTabAddedNotificationObserver( + const content::NotificationSource& source); + + private: + DISALLOW_COPY_AND_ASSIGN(WindowedTabAddedNotificationObserver); +}; + // Similar to WindowedNotificationObserver but also provides a way of retrieving // the details associated with the notification. // Note that in order to use that class the details class should be copiable, diff --git a/content/browser/renderer_host/render_view_host_manager_browsertest.cc b/content/browser/renderer_host/render_view_host_manager_browsertest.cc index 1032bef..e392536 100644 --- a/content/browser/renderer_host/render_view_host_manager_browsertest.cc +++ b/content/browser/renderer_host/render_view_host_manager_browsertest.cc @@ -67,9 +67,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, NoScriptAccessAfterSwapOut) { EXPECT_TRUE(orig_site_instance != NULL); // Open a same-site link in a new tab. - ui_test_utils::WindowedNotificationObserver new_tab_observer( - content::NOTIFICATION_TAB_ADDED, - content::Source<content::WebContentsDelegate>(browser())); + ui_test_utils::WindowedTabAddedNotificationObserver new_tab_observer(( + content::Source<content::WebContentsDelegate>(browser()))); bool success = false; EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", @@ -364,9 +363,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, EXPECT_TRUE(orig_site_instance != NULL); // Test clicking a target=foo link. - ui_test_utils::WindowedNotificationObserver new_tab_observer( - content::NOTIFICATION_TAB_ADDED, - content::Source<content::WebContentsDelegate>(browser())); + ui_test_utils::WindowedTabAddedNotificationObserver new_tab_observer(( + content::Source<content::WebContentsDelegate>(browser()))); bool success = false; EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", @@ -447,9 +445,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, EXPECT_TRUE(orig_site_instance != NULL); // Test clicking a target=foo link. - ui_test_utils::WindowedNotificationObserver new_tab_observer( - content::NOTIFICATION_TAB_ADDED, - content::Source<content::WebContentsDelegate>(browser())); + ui_test_utils::WindowedTabAddedNotificationObserver new_tab_observer(( + content::Source<content::WebContentsDelegate>(browser()))); bool success = false; EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", diff --git a/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc index 18b72e2..77508cc 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc @@ -9,7 +9,6 @@ #include "chrome/test/base/ui_test_utils.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" #include "net/test/test_server.h" class ResourceDispatcherHostBrowserTest : public InProcessBrowserTest { @@ -30,8 +29,7 @@ bool ResourceDispatcherHostBrowserTest::GetPopupTitle(const GURL& url, string16* title) { ui_test_utils::NavigateToURL(browser(), url); - ui_test_utils::WindowedNotificationObserver observer( - content::NOTIFICATION_TAB_ADDED, + ui_test_utils::WindowedTabAddedNotificationObserver observer( content::NotificationService::AllSources()); // Create dynamic popup. diff --git a/content/browser/web_contents/navigation_controller_impl.cc b/content/browser/web_contents/navigation_controller_impl.cc index a89d494..4126e1f 100644 --- a/content/browser/web_contents/navigation_controller_impl.cc +++ b/content/browser/web_contents/navigation_controller_impl.cc @@ -194,11 +194,6 @@ NavigationControllerImpl::NavigationControllerImpl( NavigationControllerImpl::~NavigationControllerImpl() { DiscardNonCommittedEntriesInternal(); - - content::NotificationService::current()->Notify( - content::NOTIFICATION_TAB_CLOSED, - content::Source<NavigationController>(this), - content::NotificationService::NoDetails()); } WebContents* NavigationControllerImpl::GetWebContents() const { diff --git a/content/public/browser/notification_types.h b/content/public/browser/notification_types.h index 09fbe9f..98ed71d 100644 --- a/content/public/browser/notification_types.h +++ b/content/public/browser/notification_types.h @@ -186,27 +186,7 @@ enum NotificationType { // BrowserContext* and the details is the inspected RenderViewHost*. NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, - // Tabs -------------------------------------------------------------------- - - // Sent when a tab is added to a WebContentsDelegate. The source is the - // WebContentsDelegate and the details is the added WebContents. - NOTIFICATION_TAB_ADDED, - - // This notification is sent after a tab has been appended to the tab_strip. - // The source is a Source<TabContentsWrapper> of the tab being added. There - // are no details. - NOTIFICATION_TAB_PARENTED, - - // This message is sent before a tab has been closed. The source is a - // Source<NavigationController> with a pointer to the controller for the - // closed tab. No details are expected. - // - // See also TAB_CLOSED. - NOTIFICATION_TAB_CLOSING, - - // Notification that a tab has been closed. The source is the - // NavigationController with no details. - NOTIFICATION_TAB_CLOSED, + // WebContents --------------------------------------------------------------- // This notification is sent when a render view host has connected to a // renderer process. The source is a Source<WebContents> with a pointer to |