diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 15:40:09 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 15:40:09 +0000 |
commit | 534e54bfc89ebbdbb345c3b643dc20b2643f1fee (patch) | |
tree | 5fcb98f948baf24f15b7c4c136a71df6b85cc1bc /chrome | |
parent | 8988699d12335b2830dbc4e167244bc0244c97cd (diff) | |
download | chromium_src-534e54bfc89ebbdbb345c3b643dc20b2643f1fee.zip chromium_src-534e54bfc89ebbdbb345c3b643dc20b2643f1fee.tar.gz chromium_src-534e54bfc89ebbdbb345c3b643dc20b2643f1fee.tar.bz2 |
First, this removes the dependency of NavigationController on the
SessionService. There were already some notifications that could be used to
tell what's going on, and I filled out the rest. I moved some notifications from
various places to the NavigationController.
In ssl_blocking_page, I removed a notification because it also calls
DidNavigateToEntry which does the notification (we got duplicate calls before).
In browser.cc I removed the tab parented notification since this is already
called by NavigationController::SetWindowID.
I removed some obsolete notifications and associated structures, especially in
history (like HOST_DELETED that was never issued).
I renamed the window_map_ in the MetricsService becuase it was actually a map
of controllers and Windows.
This also reorders the navigation_types header file to try to bring some order
to it.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/alternate_nav_url_fetcher.cc | 6 | ||||
-rw-r--r-- | chrome/browser/alternate_nav_url_fetcher.h | 7 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 8 | ||||
-rw-r--r-- | chrome/browser/history/history_notifications.h | 12 | ||||
-rw-r--r-- | chrome/browser/jsmessage_box_handler.cc | 6 | ||||
-rw-r--r-- | chrome/browser/metrics_service.cc | 37 | ||||
-rw-r--r-- | chrome/browser/metrics_service.h | 3 | ||||
-rw-r--r-- | chrome/browser/native_ui_contents.cc | 4 | ||||
-rw-r--r-- | chrome/browser/navigation_controller.cc | 92 | ||||
-rw-r--r-- | chrome/browser/navigation_controller.h | 48 | ||||
-rw-r--r-- | chrome/browser/navigation_controller_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/session_service.cc | 59 | ||||
-rw-r--r-- | chrome/browser/session_service.h | 6 | ||||
-rw-r--r-- | chrome/browser/ssl_blocking_page.cc | 3 | ||||
-rw-r--r-- | chrome/browser/template_url_model.cc | 18 | ||||
-rw-r--r-- | chrome/browser/template_url_model.h | 2 | ||||
-rw-r--r-- | chrome/browser/web_contents.cc | 7 | ||||
-rw-r--r-- | chrome/common/notification_types.h | 384 |
19 files changed, 360 insertions, 346 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index 04495fb..a791106 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -41,14 +41,14 @@ AlternateNavURLFetcher::AlternateNavURLFetcher( state_(NOT_STARTED), navigated_to_entry_(false) { NotificationService::current()->AddObserver(this, - NOTIFY_NAVIGATION_STATE_CHANGED, NotificationService::AllSources()); + NOTIFY_NAV_STATE_CHANGED, NotificationService::AllSources()); } AlternateNavURLFetcher::~AlternateNavURLFetcher() { if (state_ == NOT_STARTED) { // Never caught the NavigationController notification. NotificationService::current()->RemoveObserver(this, - NOTIFY_NAVIGATION_STATE_CHANGED, NotificationService::AllSources()); + NOTIFY_NAV_STATE_CHANGED, NotificationService::AllSources()); } // Otherwise, Observe() removed the observer already. } @@ -69,7 +69,7 @@ void AlternateNavURLFetcher::Observe(NotificationType type, controller_->SetAlternateNavURLFetcher(this); NotificationService::current()->RemoveObserver(this, - NOTIFY_NAVIGATION_STATE_CHANGED, NotificationService::AllSources()); + NOTIFY_NAV_STATE_CHANGED, NotificationService::AllSources()); DCHECK_EQ(NOT_STARTED, state_); state_ = IN_PROGRESS; diff --git a/chrome/browser/alternate_nav_url_fetcher.h b/chrome/browser/alternate_nav_url_fetcher.h index b62aeee..fbef709 100644 --- a/chrome/browser/alternate_nav_url_fetcher.h +++ b/chrome/browser/alternate_nav_url_fetcher.h @@ -26,8 +26,6 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// TODO describe this file #ifndef CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H__ #define CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H__ @@ -39,6 +37,11 @@ class NavigationController; +// Attempts to get the HEAD of a host name and displays an info bar if the +// request was successful. This is used for single-word queries where we can't +// tell if the entry was a search or an intranet hostname. The autocomplete bar +// assumes it's a query and issues an AlternateNavURLFetcher to display a "did +// you mean" infobar suggesting a navigation. class AlternateNavURLFetcher : public NotificationObserver, public URLFetcher::Delegate { public: diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index ae675bf..a634a38 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -344,7 +344,7 @@ class TabAppendedNotificationObserver : public TabStripNotificationObserver { public: TabAppendedNotificationObserver(Browser* parent, AutomationProvider* automation, int32 routing_id) - : TabStripNotificationObserver(parent, NOTIFY_TAB_APPENDED, automation, + : TabStripNotificationObserver(parent, NOTIFY_TAB_PARENTED, automation, routing_id) { } diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index b325d05..127312b 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1355,14 +1355,6 @@ void Browser::TabInsertedAt(TabContents* contents, int index, bool foreground) { contents->set_delegate(this); - - NavigationController* controller = contents->controller(); - DCHECK(controller); - NotificationService::current()-> - Notify(NOTIFY_TAB_APPENDED, - Source<NavigationController>(controller), - Details<Browser>(this)); - contents->controller()->SetWindowID(session_id()); SyncHistoryWithTabs(tabstrip_model_.GetIndexOfTabContents(contents)); diff --git a/chrome/browser/history/history_notifications.h b/chrome/browser/history/history_notifications.h index 5cc0180..d5146ea 100644 --- a/chrome/browser/history/history_notifications.h +++ b/chrome/browser/history/history_notifications.h @@ -70,11 +70,6 @@ struct URLsDeletedDetails : public HistoryDetails { std::set<GURL> urls; }; -// Details for NOTIFY_HOST_DELETED_FROM_HISTORY. -struct HostDeletedDetails : public HistoryDetails { - std::string host_name; -}; - // Details for NOTIFY_URLS_STARRED. struct URLsStarredDetails : public HistoryDetails { @@ -97,13 +92,6 @@ struct StarredEntryDetails : public HistoryDetails { StarredEntry entry; }; -// Details for NOTIFY_PAGE_PRESENTATION_INDEX_CHANGED. -struct PresentationIndexDetails : public HistoryDetails { - GURL url; - URLID url_id; - int index; -}; - // Details for NOTIFY_STARRED_FAVICON_CHANGED. struct FavIconChangeDetails : public HistoryDetails { std::set<GURL> urls; diff --git a/chrome/browser/jsmessage_box_handler.cc b/chrome/browser/jsmessage_box_handler.cc index 1576a21..bed59dc 100644 --- a/chrome/browser/jsmessage_box_handler.cc +++ b/chrome/browser/jsmessage_box_handler.cc @@ -60,7 +60,7 @@ void JavascriptMessageBoxHandler::RunJavascriptMessageBox( JavascriptMessageBoxHandler::~JavascriptMessageBoxHandler() { NotificationService::current()-> - RemoveObserver(this, NOTIFY_NAVIGATION_STATE_CHANGED, + RemoveObserver(this, NOTIFY_NAV_STATE_CHANGED, NotificationService::AllSources()); NotificationService::current()-> RemoveObserver(this, NOTIFY_TAB_CONTENTS_DESTROYED, @@ -176,7 +176,7 @@ void JavascriptMessageBoxHandler::Observe(NotificationType type, if (!web_contents_) return; - if (type == NOTIFY_NAVIGATION_STATE_CHANGED && + if (type == NOTIFY_NAV_STATE_CHANGED && Source<NavigationController>(source).ptr() == web_contents_->controller()) web_contents_gone = true; @@ -218,7 +218,7 @@ JavascriptMessageBoxHandler::JavascriptMessageBoxHandler( // Make sure we get navigation notifications so we know when our parent // contents will disappear or navigate to a different page. NotificationService::current()-> - AddObserver(this, NOTIFY_NAVIGATION_STATE_CHANGED, + AddObserver(this, NOTIFY_NAV_STATE_CHANGED, NotificationService::AllSources()); NotificationService::current()-> AddObserver(this, NOTIFY_TAB_CONTENTS_DESTROYED, diff --git a/chrome/browser/metrics_service.cc b/chrome/browser/metrics_service.cc index 85690a8..524b4eb 100644 --- a/chrome/browser/metrics_service.cc +++ b/chrome/browser/metrics_service.cc @@ -429,7 +429,7 @@ void MetricsService::Observe(NotificationType type, LogWindowChange(type, source, details); break; - case NOTIFY_TAB_APPENDED: + case NOTIFY_TAB_PARENTED: case NOTIFY_TAB_CLOSING: LogWindowChange(type, source, details); break; @@ -678,7 +678,7 @@ void MetricsService::ListenerRegistration(bool start_listening) { AddOrRemoveObserver(this, NOTIFY_BROWSER_OPENED, start_listening); AddOrRemoveObserver(this, NOTIFY_BROWSER_CLOSED, start_listening); AddOrRemoveObserver(this, NOTIFY_USER_ACTION, start_listening); - AddOrRemoveObserver(this, NOTIFY_TAB_APPENDED, start_listening); + AddOrRemoveObserver(this, NOTIFY_TAB_PARENTED, start_listening); AddOrRemoveObserver(this, NOTIFY_TAB_CLOSING, start_listening); AddOrRemoveObserver(this, NOTIFY_LOAD_START, start_listening); AddOrRemoveObserver(this, NOTIFY_LOAD_STOP, start_listening); @@ -1176,36 +1176,30 @@ void MetricsService::GetSettingsFromConfigNode(xmlNodePtr config_node) { void MetricsService::LogWindowChange(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - int window_id = -1; - int parent_id = -1; - uintptr_t window_key = source.map_key(); + int controller_id = -1; + uintptr_t window_or_tab = source.map_key(); MetricsLog::WindowEventType window_type; // Note: since we stop all logging when a single OTR session is active, it is // possible that we start getting notifications about a window that we don't // know about. - if (window_map_.find(window_key) == window_map_.end()) { - window_id = next_window_id_++; - window_map_[window_key] = window_id; + if (window_map_.find(window_or_tab) == window_map_.end()) { + controller_id = next_window_id_++; + window_map_[window_or_tab] = controller_id; } else { - window_id = window_map_[window_key]; - } - - DCHECK(window_id != -1); - - if (type == NOTIFY_TAB_APPENDED) { - parent_id = window_map_[details.map_key()]; + controller_id = window_map_[window_or_tab]; } + DCHECK(controller_id != -1); switch (type) { - case NOTIFY_TAB_APPENDED: + case NOTIFY_TAB_PARENTED: case NOTIFY_BROWSER_OPENED: window_type = MetricsLog::WINDOW_CREATE; break; case NOTIFY_TAB_CLOSING: case NOTIFY_BROWSER_CLOSED: - window_map_.erase(window_map_.find(window_key)); + window_map_.erase(window_map_.find(window_or_tab)); window_type = MetricsLog::WINDOW_DESTROY; break; @@ -1214,7 +1208,8 @@ void MetricsService::LogWindowChange(NotificationType type, break; } - current_log_->RecordWindowEvent(window_type, window_id, parent_id); + // TODO(brettw) we should have some kind of ID for the parent. + current_log_->RecordWindowEvent(window_type, controller_id, 0); } void MetricsService::LogLoadComplete(NotificationType type, @@ -1224,10 +1219,8 @@ void MetricsService::LogLoadComplete(NotificationType type, return; const Details<LoadNotificationDetails> load_details(details); - - int window_id = - window_map_[reinterpret_cast<uintptr_t>(load_details->controller())]; - current_log_->RecordLoadEvent(window_id, + int controller_id = window_map_[details.map_key()]; + current_log_->RecordLoadEvent(controller_id, load_details->url(), load_details->origin(), load_details->session_index(), diff --git a/chrome/browser/metrics_service.h b/chrome/browser/metrics_service.h index 4524bc6..6ffb5f1 100644 --- a/chrome/browser/metrics_service.h +++ b/chrome/browser/metrics_service.h @@ -333,6 +333,9 @@ class MetricsService : public NotificationObserver, std::vector<std::string> unsent_initial_logs_; std::vector<std::string> unsent_ongoing_logs_; + // Maps NavigationControllers (corresponding to tabs) or Browser + // (corresponding to Windows) to a unique integer that we will use to identify + // it. |next_window_id_| is used to track which IDs we have used so far. typedef std::map<uintptr_t, int> WindowMap; WindowMap window_map_; int next_window_id_; diff --git a/chrome/browser/native_ui_contents.cc b/chrome/browser/native_ui_contents.cc index e9965dd..67b1186 100644 --- a/chrome/browser/native_ui_contents.cc +++ b/chrome/browser/native_ui_contents.cc @@ -241,7 +241,7 @@ void NativeUIContents::SetPageState(PageState* page_state) { state_->GetByteRepresentation(&rep); ne->SetContentState(rep); // This is not a WebContents, so we use a NULL SiteInstance. - ctrl->SyncSessionWithEntryByPageID(type(), NULL, ne->GetPageID()); + ctrl->NotifyEntryChangedByPageID(type(), NULL, ne->GetPageID()); } } } @@ -294,7 +294,7 @@ bool NativeUIContents::Navigate(const NavigationEntry& entry, bool reload) { const int32 page_id = new_entry->GetPageID(); DidNavigateToEntry(new_entry); // This is not a WebContents, so we use a NULL SiteInstance. - controller()->SyncSessionWithEntryByPageID(type(), NULL, page_id); + controller()->NotifyEntryChangedByPageID(type(), NULL, page_id); return true; } diff --git a/chrome/browser/navigation_controller.cc b/chrome/browser/navigation_controller.cc index d56d6b1..ef6e767 100644 --- a/chrome/browser/navigation_controller.cc +++ b/chrome/browser/navigation_controller.cc @@ -178,16 +178,10 @@ NavigationController::~NavigationController() { DCHECK(tab_contents_map_.empty()); DCHECK(tab_contents_collector_map_.empty()); - SessionService* session_service = GetSessionService(); - if (session_service) - session_service->TabClosed(window_id_, session_id()); - profile_->UnregisterNavigationController(this); - - NotificationService::current()->Notify( - NOTIFY_TAB_CLOSED, - Source<NavigationController>(this), - NotificationService::NoDetails()); + NotificationService::current()->Notify(NOTIFY_TAB_CLOSED, + Source<NavigationController>(this), + NotificationService::NoDetails()); } TabContents* NavigationController::GetTabContents(TabContentsType t) { @@ -438,23 +432,18 @@ void NavigationController::DiscardPendingEntry() { } void NavigationController::InsertEntry(NavigationEntry* entry) { - DCHECK(entry); - NavigationControllerBase::InsertEntry(entry); - - int index = GetIndexOfEntry(entry); - DCHECK(entries_.size() > 0 && index != -1); - SyncSessionWithSelectedIndex(index); - + NotificationService::current()->Notify(NOTIFY_NAV_INDEX_CHANGED, + Source<NavigationController>(this), + NotificationService::NoDetails()); active_contents_->NotifyDidNavigate(NAVIGATION_NEW, 0); } void NavigationController::SetWindowID(const SessionID& id) { window_id_ = id; - - SessionService* session_service = GetSessionService(); - if (session_service) - session_service->SetTabWindow(window_id_, session_id()); + NotificationService::current()->Notify(NOTIFY_TAB_PARENTED, + Source<NavigationController>(this), + NotificationService::NoDetails()); } void NavigationController::NavigateToPendingEntry(bool reload) { @@ -513,18 +502,15 @@ void NavigationController::NotifyNavigationStateChanged() { active_contents_->NotifyNavigationStateChanged( TabContents::INVALIDATE_EVERYTHING); - NotificationService::current()->Notify( - NOTIFY_NAVIGATION_STATE_CHANGED, - Source<NavigationController>(this), - NotificationService::NoDetails()); + NotificationService::current()->Notify(NOTIFY_NAV_STATE_CHANGED, + Source<NavigationController>(this), + NotificationService::NoDetails()); } void NavigationController::NotifyPrunedEntries() { - SessionService* session_service = GetSessionService(); - if (!session_service) - return; - session_service->TabNavigationPathPruned(window_id(), session_id(), - GetEntryCount()); + NotificationService::current()->Notify(NOTIFY_NAV_LIST_PRUNED, + Source<NavigationController>(this), + NotificationService::NoDetails()); } void NavigationController::IndexOfActiveEntryChanged( @@ -536,8 +522,12 @@ void NavigationController::IndexOfActiveEntryChanged( nav_type = NAVIGATION_REPLACE; } active_contents_->NotifyDidNavigate(nav_type, relative_navigation_offset); - if (GetCurrentEntryIndex() != -1) - SyncSessionWithSelectedIndex(GetCurrentEntryIndex()); + if (GetCurrentEntryIndex() != -1) { + NotificationService::current()->Notify( + NOTIFY_NAV_INDEX_CHANGED, + Source<NavigationController>(this), + NotificationService::NoDetails()); + } } TabContents* NavigationController::GetTabContentsCreateIfNecessary( @@ -587,20 +577,13 @@ void NavigationController::RegisterTabContents(TabContents* some_contents) { some_contents->AsDOMUIHost()->AttachMessageHandlers(); } -SessionService* NavigationController::GetSessionService() const { - if (profile_->HasSessionService()) - return profile_->GetSessionService(); - - return NULL; -} - -void NavigationController::SyncSessionWithEntryByPageID( +void NavigationController::NotifyEntryChangedByPageID( TabContentsType type, SiteInstance *instance, - int32 page_id) const { + int32 page_id) { int index = GetEntryIndexWithPageID(type, instance, page_id); if (index != -1) - SyncSessionWithEntry(entries_[index], index); + NotifyEntryChanged(entries_[index], index); } // static @@ -631,25 +614,14 @@ void NavigationController::LoadIfNecessary() { NavigateToPendingEntry(false); } -void NavigationController::SyncSessionWithEntry(const NavigationEntry* entry, - int index) const { - SessionService* session_service = GetSessionService(); - if (!session_service) - return; - - DCHECK(entry && index != -1); - if (entry->GetDisplayURL().is_valid()) - session_service->UpdateTabNavigation(window_id(), session_id(), index, - *entry); -} - -void NavigationController::SyncSessionWithSelectedIndex(int index) const { - DCHECK(index != -1); - SessionService* session_service = GetSessionService(); - if (!session_service) - return; - - session_service->SetSelectedNavigationIndex(window_id(), session_id(), index); +void NavigationController::NotifyEntryChanged(const NavigationEntry* entry, + int index) { + EntryChangedDetails det; + det.changed_entry = entry; + det.index = index; + NotificationService::current()->Notify(NOTIFY_NAV_ENTRY_CHANGED, + Source<NavigationController>(this), + Details<EntryChangedDetails>(&det)); } int NavigationController::GetMaxPageID() const { diff --git a/chrome/browser/navigation_controller.h b/chrome/browser/navigation_controller.h index 9b452c0..070abfa 100644 --- a/chrome/browser/navigation_controller.h +++ b/chrome/browser/navigation_controller.h @@ -27,8 +27,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef CHROME_BROWSER_NAVIGATION_CONTROLLER_H__ -#define CHROME_BROWSER_NAVIGATION_CONTROLLER_H__ +#ifndef CHROME_BROWSER_NAVIGATION_CONTROLLER_H_ +#define CHROME_BROWSER_NAVIGATION_CONTROLLER_H_ #include <hash_map> @@ -41,7 +41,6 @@ class GURL; class Profile; -class SessionService; class TabContents; class WebContents; class TabContentsCollector; @@ -64,6 +63,15 @@ class PrintViewManager; //////////////////////////////////////////////////////////////////////////////// class NavigationController : public NavigationControllerBase { public: + // Provides the details for a NOTIFY_NAV_ENTRY_CHANGED notification. + struct EntryChangedDetails { + // The changed navigation entry after it has been updated. + const NavigationEntry* changed_entry; + + // Indicates the current index in the back/forward list of the entry. + int index; + }; + NavigationController(TabContents* initial_contents, Profile* profile); // Creates a NavigationController from the specified history. Processing // for this is asynchronous and handled via the RestoreHelper (in @@ -152,14 +160,12 @@ class NavigationController : public NavigationControllerBase { SSLManager* ssl_manager() { return &ssl_manager_; } - // Synchronizes the session saving database with the entry that has the same - // page id, instance, and contents type as the specified entry. - // NOTE: This is invoked by WebContents. Any custom TabContents that - // modify a NavigationEntries state/url/transition must explicitly invoke - // this. - void SyncSessionWithEntryByPageID(TabContentsType type, - SiteInstance* instance, - int32 page_id) const; + // Broadcasts the NOTIFY_NAV_ENTRY_CHANGED notification for the + // navigation corresponding to the given page. This will keep things in sync + // like saved session. + void NotifyEntryChangedByPageID(TabContentsType type, + SiteInstance* instance, + int32 page_id); void SetActive(bool is_active); @@ -216,19 +222,8 @@ class NavigationController : public NavigationControllerBase { // and deleted by this navigation controller void RegisterTabContents(TabContents* some_contents); - // Returns the session service for the profile. This returns NULL if the - // profile doesn't have a session service. - SessionService* GetSessionService() const; - - // If the active entry is valid, the session database is updated accordingly. - void SyncSessionWithActiveEntry() const; - - // Updates the session database with the specified entry and index. - void SyncSessionWithEntry(const NavigationEntry* entry, int index) const; - - // Lets the history database know index is the selected index for this - // navigation controller. - void SyncSessionWithSelectedIndex(int index) const; + // Broadcasts a notification that the given entry changed. + void NotifyEntryChanged(const NavigationEntry* entry, int index); // Sets the max restored page ID this NavigationController has seen, if it // was restored from a previous session. @@ -298,6 +293,7 @@ class NavigationController : public NavigationControllerBase { // when testing. static bool check_for_repost_; - DISALLOW_EVIL_CONSTRUCTORS(NavigationController); + DISALLOW_COPY_AND_ASSIGN(NavigationController); }; -#endif // CHROME_BROWSER_NAVIGATION_CONTROLLER_H__ + +#endif // CHROME_BROWSER_NAVIGATION_CONTROLLER_H_ diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index 5986b31..51eeb67 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -74,7 +74,7 @@ class TestContents : public TabContents { DCHECK(pending_entry_.get()); pending_entry_->SetPageID(page_id); DidNavigateToEntry(pending_entry_.get()); - controller()->SyncSessionWithEntryByPageID(type(), NULL, page_id); + controller()->NotifyEntryChangedByPageID(type(), NULL, page_id); pending_entry_.release(); } diff --git a/chrome/browser/session_service.cc b/chrome/browser/session_service.cc index e90f8b8..6e78f9c 100644 --- a/chrome/browser/session_service.cc +++ b/chrome/browser/session_service.cc @@ -149,6 +149,18 @@ SessionService::~SessionService() { // deleted. Otherwise the backend is deleted after all pending requests on // the file thread complete, which is done before the process exits. backend_ = NULL; + + // Unregister our notifications. + NotificationService::current()->RemoveObserver( + this, NOTIFY_TAB_PARENTED, NotificationService::AllSources()); + NotificationService::current()->RemoveObserver( + this, NOTIFY_TAB_CLOSED, NotificationService::AllSources()); + NotificationService::current()->RemoveObserver( + this, NOTIFY_NAV_LIST_PRUNED, NotificationService::AllSources()); + NotificationService::current()->RemoveObserver( + this, NOTIFY_NAV_ENTRY_CHANGED, NotificationService::AllSources()); + NotificationService::current()->RemoveObserver( + this, NOTIFY_NAV_INDEX_CHANGED, NotificationService::AllSources()); } void SessionService::ResetFromCurrentBrowsers() { @@ -303,7 +315,8 @@ void SessionService::UpdateTabNavigation(const SessionID& window_id, const SessionID& tab_id, int index, const NavigationEntry& entry) { - if (!ShouldTrackChangesToWindow(window_id)) + if (!entry.GetDisplayURL().is_valid() || + !ShouldTrackChangesToWindow(window_id)) return; if (tab_to_available_range_.find(tab_id.id()) != @@ -394,6 +407,18 @@ void SessionService::CopyLastSessionToSavedSession() { } void SessionService::Init(const std::wstring& path) { + // Register for the notifications we're interested in. + NotificationService::current()->AddObserver( + this, NOTIFY_TAB_PARENTED, NotificationService::AllSources()); + NotificationService::current()->AddObserver( + this, NOTIFY_TAB_CLOSED, NotificationService::AllSources()); + NotificationService::current()->AddObserver( + this, NOTIFY_NAV_LIST_PRUNED, NotificationService::AllSources()); + NotificationService::current()->AddObserver( + this, NOTIFY_NAV_ENTRY_CHANGED, NotificationService::AllSources()); + NotificationService::current()->AddObserver( + this, NOTIFY_NAV_INDEX_CHANGED, NotificationService::AllSources()); + DCHECK(!path.empty()); commands_since_reset_ = 0; backend_ = new SessionBackend(path); @@ -403,6 +428,38 @@ void SessionService::Init(const std::wstring& path) { // If backend_thread, backend will init itself as appropriate. } +void SessionService::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + // All of our messages have the NavigationController as the source. + NavigationController* controller = Source<NavigationController>(source).ptr(); + switch (type) { + case NOTIFY_TAB_PARENTED: + SetTabWindow(controller->window_id(), controller->session_id()); + break; + case NOTIFY_TAB_CLOSED: + TabClosed(controller->window_id(), controller->session_id()); + break; + case NOTIFY_NAV_LIST_PRUNED: + TabNavigationPathPruned(controller->window_id(), controller->session_id(), + controller->GetEntryCount()); + break; + case NOTIFY_NAV_ENTRY_CHANGED: { + Details<NavigationController::EntryChangedDetails> changed(details); + UpdateTabNavigation(controller->window_id(), controller->session_id(), + changed->index, *changed->changed_entry); + break; + } + case NOTIFY_NAV_INDEX_CHANGED: + SetSelectedNavigationIndex(controller->window_id(), + controller->session_id(), + controller->GetCurrentEntryIndex()); + break; + default: + NOTREACHED(); + } +} + SessionService::Handle SessionService::GetSessionImpl( CancelableRequestConsumerBase* consumer, SavedSessionCallback* callback, diff --git a/chrome/browser/session_service.h b/chrome/browser/session_service.h index 3877701..df932f9 100644 --- a/chrome/browser/session_service.h +++ b/chrome/browser/session_service.h @@ -38,6 +38,7 @@ #include "base/time.h" #include "chrome/browser/browser_type.h" #include "chrome/browser/cancelable_request.h" +#include "chrome/common/notification_service.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/stl_util-inl.h" #include "googleurl/src/gurl.h" @@ -220,6 +221,7 @@ struct SessionWindow { // of the browser. class SessionService : public CancelableRequestProvider, + public NotificationObserver, public base::RefCountedThreadSafe<SessionService> { friend class SessionServiceTestHelper; public: @@ -373,6 +375,10 @@ class SessionService : public CancelableRequestProvider, // Various initialization; called from the constructor. void Init(const std::wstring& path); + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + // Get*Session call into this to schedule the request. The request // does NOT directly invoke the callback, rather the callback invokes // OnGotSessionCommands from which we map the SessionCommands to browser diff --git a/chrome/browser/ssl_blocking_page.cc b/chrome/browser/ssl_blocking_page.cc index 220328a..bd99b30 100644 --- a/chrome/browser/ssl_blocking_page.cc +++ b/chrome/browser/ssl_blocking_page.cc @@ -179,9 +179,6 @@ void SSLBlockingPage::Show() { // The controller will own the entry. int page_id = nav_entry->GetPageID(); tab_->controller()->DidNavigateToEntry(nav_entry); - tab_->controller()->SyncSessionWithEntryByPageID(TAB_CONTENTS_WEB, - NULL, - page_id); tab->ShowInterstitialPage(html_text, NULL); } diff --git a/chrome/browser/template_url_model.cc b/chrome/browser/template_url_model.cc index ee1e885..aa3884b 100644 --- a/chrome/browser/template_url_model.cc +++ b/chrome/browser/template_url_model.cc @@ -90,8 +90,6 @@ TemplateURLModel::TemplateURLModel(Profile* profile) next_id_(1) { DCHECK(profile_); NotificationService* ns = NotificationService::current(); - ns->AddObserver(this, NOTIFY_HOST_DELETED_FROM_HISTORY, - Source<Profile>(profile_->GetOriginalProfile())); // TODO(sky): bug 1166191. The keywords should be moved into the history // db, which will mean we no longer need this notification and the history // backend can handle automatically adding the search terms as the user @@ -123,8 +121,6 @@ TemplateURLModel::~TemplateURLModel() { if (profile_) { NotificationService* ns = NotificationService::current(); - ns->RemoveObserver(this, NOTIFY_HOST_DELETED_FROM_HISTORY, - Source<Profile>(profile_->GetOriginalProfile())); ns->RemoveObserver(this, NOTIFY_HISTORY_URL_VISITED, Source<Profile>(profile_->GetOriginalProfile())); ns->RemoveObserver(this, NOTIFY_GOOGLE_URL_UPDATED, @@ -661,19 +657,7 @@ void TemplateURLModel::OnWebDataServiceRequestDone( void TemplateURLModel::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - if (type == NOTIFY_HOST_DELETED_FROM_HISTORY) { - Details<std::string> utf8_host(details); - std::wstring host(UTF8ToWide(*(utf8_host.ptr()))); - if (!loaded()) { - // We're not loaded, so that we can't delete the url. Save the host to - // hosts_to_delete_ and schedule a load. When done loading we'll delete - // the keyword. - hosts_to_delete_.push_back(host); - Load(); - } else { - DeleteGeneratedKeywordsMatchingHost(host); - } - } else if (type == NOTIFY_HISTORY_URL_VISITED) { + if (type == NOTIFY_HISTORY_URL_VISITED) { Details<history::URLVisitedDetails> visit_details(details); if (!loaded()) diff --git a/chrome/browser/template_url_model.h b/chrome/browser/template_url_model.h index 9ea3137..d09d3c8 100644 --- a/chrome/browser/template_url_model.h +++ b/chrome/browser/template_url_model.h @@ -205,8 +205,6 @@ class TemplateURLModel : public WebDataServiceConsumer, // NotificationObserver method. TemplateURLModel listens for three // notification types: - // . NOTIFY_HOST_DELETED_FROM_HISTORY: deletes generated keywords for the - // host that was deleted. // . NOTIFY_HISTORY_URL_VISITED: adds keyword search terms if the visit // corresponds to a keyword. // . NOTIFY_GOOGLE_URL_UPDATED: updates mapping for any keywords containing diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index d9d7f1c..1774c1d 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -1513,9 +1513,8 @@ void WebContents::DidNavigateAnyFramePostCommit( RenderViewHost* render_view_host, const ViewHostMsg_FrameNavigate_Params& params) { // Have the controller save the current session. - controller()->SyncSessionWithEntryByPageID(type(), - site_instance(), - params.page_id); + controller()->NotifyEntryChangedByPageID(type(), site_instance(), + params.page_id); BroadcastProvisionalLoadCommit(render_view_host, params); } @@ -1680,7 +1679,7 @@ void WebContents::UpdateState(RenderViewHost* rvh, // Notify everybody of the changes (only when the current page changed). if (changed_flags && entry == controller()->GetActiveEntry()) NotifyNavigationStateChanged(changed_flags); - controller()->SyncSessionWithEntryByPageID(type(), site_instance(), page_id); + controller()->NotifyEntryChangedByPageID(type(), site_instance(), page_id); } void WebContents::UpdateTitle(RenderViewHost* rvh, diff --git a/chrome/common/notification_types.h b/chrome/common/notification_types.h index 1feae5f..4724c0b 100644 --- a/chrome/common/notification_types.h +++ b/chrome/common/notification_types.h @@ -34,6 +34,8 @@ #define CHROME_COMMON_NOTIFICATION_TYPES_H__ enum NotificationType { + // General ------------------------------------------------------------------- + // Special signal value to represent an interest in all notifications. // Not valid when posting a notification. NOTIFY_ALL = 0, @@ -46,6 +48,39 @@ enum NotificationType { // to a user action, and that background processes shouldn't run if avoidable. NOTIFY_BUSY, + // This is sent when the user does a gesture resulting in a noteworthy + // action taking place. This is typically used for logging. The + // source is the profile, and the details is a wstring identifying the action. + NOTIFY_USER_ACTION, + + // NavigationController ------------------------------------------------------ + + // A NavigationController's state has changed (a new pending load has been + // added, a load has committed, etc.). + // + // TODO(brettw) this is vague and I'm not sure that it covers every case. We + // need to figure out the exact cases where this notificaion should be sent + // and make sure it is sent in those cases. + NOTIFY_NAV_STATE_CHANGED, + + // Indicates that the NavigationController given in the Source has decreased + // its back/forward list count. This is usually the result of going back and + // then doing a new navigation, meaning all the "forward" items are deleted. + // There are no details. + NOTIFY_NAV_LIST_PRUNED, + + // Indicates that a NavigationEntry has changed. The source will be the + // NavigationController that owns the NavigationEntry. The details will be + // a NavigationController::EntryChangedDetails struct. + NOTIFY_NAV_ENTRY_CHANGED, + + // Indicates that the index of the currently active NavigationEntry has + // changed. The source will be the NavigationController whose current item + // changed, and there are no details. + NOTIFY_NAV_INDEX_CHANGED, + + // Other load-related (not from NavigationController) ------------------------ + // A content load is starting. The source will be a // Source<NavigationController> corresponding to the tab // in which the load is occurring. No details are @@ -58,10 +93,6 @@ enum NotificationType { // LoadNotificationDetails object are optional. NOTIFY_LOAD_STOP, - // A NavigationController's state has changed (a new pending load has been - // added, a load has committed, etc.). - NOTIFY_NAVIGATION_STATE_CHANGED, - // A frame is staring a provisional load. The source is a // Source<NavigationController> corresponding to the tab in which the load // occurs. Details is a bool specifying if the load occurs in the main @@ -103,6 +134,28 @@ enum NotificationType { // was issued. Details in the form of a ResourceRedirectDetails are provided. NOTIFY_RESOURCE_RECEIVED_REDIRECT, + // Download start and stop notifications. Stop notifications can occur on both + // normal completion or via a cancel operation. + NOTIFY_DOWNLOAD_START, + NOTIFY_DOWNLOAD_STOP, + + // This is sent when an interstitial page showing in a WebContents is closed + // (as the result of a navigation to another page). The source is the + // WebContents the interstitial page is in. + // Note that you should not initiate a navigation as part of the processing of + // this notification, since this notification may be triggered as part of the + // destruction of the tab contents (the navigation controller would reuse + // the tab contents right before it would be destroyed). + NOTIFY_INTERSTITIAL_PAGE_CLOSED, + + // Views --------------------------------------------------------------------- + + // Notification that a view was removed from a view hierarchy. The source is + // the view, the details is the parent view. + NOTIFY_VIEW_REMOVED, + + // Browser-window ------------------------------------------------------------ + // This message is sent after a window has been opened. The source is // a Source<Browser> with a pointer to the new window. // No details are expected. @@ -116,12 +169,16 @@ enum NotificationType { // only valid for the duration of this call. NOTIFY_BROWSER_CLOSED, + // Indicates that a top window has been closed. The source is the HWND that + // was closed, no details are expected. + NOTIFY_WINDOW_CLOSED, + + // Tabs ---------------------------------------------------------------------- + // This notification is sent after a tab has been appended to the tab_strip. // The source is a Source<NavigationController> with a pointer to - // controller for the added tab. - // The details is a Detail<Browser> with a pointer to the window - // that the tab is being added to. - NOTIFY_TAB_APPENDED, + // controller for the added tab. There are no details. + NOTIFY_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 @@ -157,6 +214,94 @@ enum NotificationType { // No details are expected. NOTIFY_WEB_CONTENTS_DISCONNECTED, + // This is sent when an externally hosted tab is created. The details contain + // the ExternalTabContainer that contains the tab + NOTIFY_EXTERNAL_TAB_CREATED, + + // This is sent when an externally hosted tab is closed. + // No details are expected. + NOTIFY_EXTERNAL_TAB_CLOSED, + + // Indicates that the new page tab has finished loading. This is + // used for performance testing to see how fast we can load it after startup, + // and is only called once for the lifetime of the browser. The source is + // unused. Details is an integer: the number of milliseconds elapsed between + // starting and finishing all painting. + NOTIFY_INITIAL_NEW_TAB_UI_LOAD, + + // This notification is sent when a TabContents is being hidden, e.g. due to + // switching away from this tab. The source is a Source<TabContents>. + NOTIFY_TAB_CONTENTS_HIDDEN, + + // This notification is sent when a TabContents is being destroyed. Any object + // holding a reference to a TabContents can listen to that notification to + // properly reset the reference. The source is a Source<TabContents>. + NOTIFY_TAB_CONTENTS_DESTROYED, + + // Stuff inside the tabs ----------------------------------------------------- + + // This message is sent after a constrained window has been closed. The + // source is a Source<ConstrainedWindow> with a pointer to the closed child + // window. (The pointer isn't usable, except for identification.) No details + // are expected. + NOTIFY_CWINDOW_CLOSED, + + // Indicates that a render process has terminated. The source will be the + // RenderProcessHost that corresponds to the process, and the details is a + // bool specifying whether the termination was expected, i.e. if false it + // means the process crashed. + NOTIFY_RENDERER_PROCESS_TERMINATED, + + // Indicates that a render process has become unresponsive for a period of + // time. The source will be the RenderWidgetHost that corresponds to the hung + // view, and no details are expected. + NOTIFY_RENDERER_PROCESS_HANG, + + // Indicates that a render process is created in the sandbox. The source + // will be the RenderProcessHost that corresponds to the created process + // and the detail is a bool telling us if the process got created on the + // sandbox desktop or not. + NOTIFY_RENDERER_PROCESS_IN_SBOX, + + // This is sent to notify that the RenderViewHost displayed in a WebContents + // has changed. Source is the WebContents for which the change happened, + // details is the previous RenderViewHost (can be NULL when the first + // RenderViewHost is set). + NOTIFY_RENDER_VIEW_HOST_CHANGED, + + // Notification from WebContents that we have received a response from + // the renderer after using the dom inspector. + NOTIFY_DOM_INSPECT_ELEMENT_RESPONSE, + + // Notification from WebContents that we have received a response from + // the renderer in response to a dom automation controller action. + NOTIFY_DOM_OPERATION_RESPONSE, + + // Sent when the bookmark bubble hides. The source is the profile, the + // details unused. + NOTIFY_BOOKMARK_BUBBLE_HIDDEN, + + // This notification is sent when the result of a find-in-page search is + // available with the browser process. The source is a Source<TabContents> + // with a pointer to the WebContents. Details encompass a + // FindNotificationDetail object that tells whether the match was + // found or not found. + NOTIFY_FIND_RESULT_AVAILABLE, + + // This is sent when the users preference for when the bookmark bar should + // be shown changes. The source is the profile, and the details are + // NoDetails. + NOTIFY_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, + + // Used to monitor web cache usage by notifying whenever the CacheManagerHost + // observes new UsageStats. The source will be the RenderProcessHost that + // corresponds to the new statistics. Details are a UsageStats object sent + // by the renderer, and should be copied - ptr not guaranteed to be valid + // after the notification. + NOTIFY_WEB_CACHE_STATS_OBSERVED, + + // Plugins ------------------------------------------------------------------- + // This notification is sent when a plugin process host has connected to a // plugin process. There is no usable source, since it is sent from an // ephemeral task; register for AllSources() to receive this notification. @@ -196,12 +341,31 @@ enum NotificationType { // if you need to keep it). NOTIFY_PLUGIN_INSTANCE_CREATED, - // This notification is sent when the result of a find-in-page search is - // available with the browser process. The source is a Source<TabContents> - // with a pointer to the WebContents. Details encompass a - // FindNotificationDetail object that tells whether the match was - // found or not found. - NOTIFY_FIND_RESULT_AVAILABLE, + // This is sent when network interception is disabled for a plugin, or the + // plugin is unloaded. This should only be sent/received on the browser IO + // thread or the plugin thread. The source is the plugin that is disabling + // interception. No details are expected. + NOTIFY_CHROME_PLUGIN_UNLOADED, + + // This is sent when a login prompt is shown. The source is the + // Source<NavigationController> for the tab in which the prompt is shown. + // Details are a LoginNotificationDetails which provide the LoginHandler + // that should be given authentication. + NOTIFY_AUTH_NEEDED, + + // This is sent when authentication credentials have been supplied (either + // by the user or by an automation service), but before we've actually + // received another response from the server. The source is the + // Source<NavigationController> for the tab in which the prompt was shown. + // No details are expected. + NOTIFY_AUTH_SUPPLIED, + + // History, bookmarks -------------------------------------------------------- + + // Sent when a history service is created. The source is the profile that the + // history service belongs to, and the details is the pointer to the newly + // created HistoryService object. + NOTIFY_HISTORY_CREATED, // Sent when a URL that has been typed has been added or modified. This is // used by the in-memory URL database (used by autocomplete) to track changes @@ -244,142 +408,48 @@ enum NotificationType { // was created. NOTIFY_STAR_GROUP_CREATED, - // This is sent when a login prompt is shown. The source is the - // Source<NavigationController> for the tab in which the prompt is shown. - // Details are a LoginNotificationDetails which provide the LoginHandler - // that should be given authentication. - NOTIFY_AUTH_NEEDED, - - // This is sent when authentication credentials have been supplied (either - // by the user or by an automation service), but before we've actually - // received another response from the server. The source is the - // Source<NavigationController> for the tab in which the prompt was shown. - // No details are expected. - NOTIFY_AUTH_SUPPLIED, - - // This is sent when the user does a gesture resulting in a noteworthy - // action taking place. This is typically used for logging. The - // source is the profile, and the details is a wstring identifying the action. - NOTIFY_USER_ACTION, - - // This message is sent after a constrained window has been closed. The - // source is a Source<ConstrainedWindow> with a pointer to the closed child - // window. (The pointer isn't usable, except for identification.) No details - // are expected. - NOTIFY_CWINDOW_CLOSED, - - // This is sent whenever a feed's unread count has changed. - // This happens in two cases: - // 1) we've polled the feed and found new entries - // 2) the user has visited a page that had unread entries, so the unread - // count is now reset to zero. - // The source is the Profile and the details is the FeedStatus object. - NOTIFY_FEED_UNREADS_CHANGED, - - // Sent when a history service is created. The source is the profile that the - // history service belongs to, and the details is the pointer to the newly - // created HistoryService object. - NOTIFY_HISTORY_CREATED, - - // Indicates that the new page tab has finished loading. This is - // used for performance testing to see how fast we can load it after startup, - // and is only called once for the lifetime of the browser. The source is - // unused. Details is an integer: the number of milliseconds elapsed between - // starting and finishing all painting. - NOTIFY_INITIAL_NEW_TAB_UI_LOAD, - - // Indicates that a render process has terminated. The source will be the - // RenderProcessHost that corresponds to the process, and the details is a - // bool specifying whether the termination was expected, i.e. if false it - // means the process crashed. - NOTIFY_RENDERER_PROCESS_TERMINATED, - - // Indicates that a render process has become unresponsive for a period of - // time. The source will be the RenderWidgetHost that corresponds to the hung - // view, and no details are expected. - NOTIFY_RENDERER_PROCESS_HANG, - - // Indicates that a top window has been closed. The source is the HWND that - // was closed, no details are expected. - NOTIFY_WINDOW_CLOSED, - - // Indicates that a render process is created in the sandbox. The source - // will be the RenderProcessHost that corresponds to the created process - // and the detail is a bool telling us if the process got created on the - // sandbox desktop or not. - NOTIFY_RENDERER_PROCESS_IN_SBOX, - - // Notification triggered when a web application has been installed or - // uninstalled. Any application view should reload its data. - // The source is the profile. No details are provided. - NOTIFY_WEB_APP_INSTALL_CHANGED, - - // Download start and stop notifications. Stop notifications can occur on both - // normal completion or via a cancel operation. - NOTIFY_DOWNLOAD_START, - NOTIFY_DOWNLOAD_STOP, - - // Used to monitor web cache usage by notifying whenever the CacheManagerHost - // observes new UsageStats. The source will be the RenderProcessHost that - // corresponds to the new statistics. Details are a UsageStats object sent - // by the renderer, and should be copied - ptr not guaranteed to be valid - // after the notification. - NOTIFY_WEB_CACHE_STATS_OBSERVED, + // Sent by history when the favicon of a starred URL changes. In the future, + // we may want a notification for all URLs so that the history view can stay + // up-to-date. In that case, we should change this notification rather than + // adding a new one for non-starred favicons. + // The source is the profile, and the details is + // history::FavIconChangeDetails (see history_notifications.h). + NOTIFY_STARRED_FAVICON_CHANGED, - // Notification that all URLs with a particular host have been removed. - // The source is the profile the host was deleted in, and the details is a - // history::HostDeletedDetails struct. - NOTIFY_HOST_DELETED_FROM_HISTORY, + // Sent when the bookmark bubble is shown for a particular URL. The source + // is the profile, the details the URL. + NOTIFY_BOOKMARK_BUBBLE_SHOWN, - // Notification that a view was removed from a view hierarchy. The source is - // the view, the details is the parent view. - NOTIFY_VIEW_REMOVED, + // Non-history storage services ---------------------------------------------- // Notification that the TemplateURLModel has finished loading from the // database. The source is the TemplateURLModel, and the details are // NoDetails. TEMPLATE_URL_MODEL_LOADED, - // Notification from WebContents that we have received a response from - // the renderer after using the dom inspector. - NOTIFY_DOM_INSPECT_ELEMENT_RESPONSE, + // Notification triggered when a web application has been installed or + // uninstalled. Any application view should reload its data. + // The source is the profile. No details are provided. + NOTIFY_WEB_APP_INSTALL_CHANGED, - // Notification from WebContents that we have received a response from - // the renderer in response to a dom automation controller action. - NOTIFY_DOM_OPERATION_RESPONSE, + // This is sent to a pref observer when a pref is changed. + NOTIFY_PREF_CHANGED, - // Notification that a page's presentation index has changed (this is the - // index that the user has manually overridden in the most visited view). - // The source is the profile, and the details is a - // history::PresentationIndexDetails. - NOTIFY_PAGE_PRESENTATION_INDEX_CHANGED, + // Autocomplete -------------------------------------------------------------- // This is sent when an item of the Omnibox popup is selected. The source is // the profile. NOTIFY_OMNIBOX_OPENED_URL, - // This is sent when the users preference for when the bookmark bar should - // be shown changes. The source is the profile, and the details are - // NoDetails. - NOTIFY_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, - - // This is sent when an interstitial page showing in a WebContents is closed - // (as the result of a navigation to another page). The source is the - // NavigationController associated with the tab. - // - // Note that you should not initiate a navigation as part of the processing of - // this notification, since this notification may be triggered as part of the - // destruction of the tab contents (the navigation controller would reuse - // the tab contents right before it would be destroyed). - NOTIFY_INTERSTITIAL_PAGE_CLOSED, + // Sent by the autocomplete edit when it is destroyed. + NOTIFY_AUTOCOMPLETE_EDIT_DESTROYED, - // This is sent when an externally hosted tab is created. The details contain - // the ExternalTabContainer that contains the tab - NOTIFY_EXTERNAL_TAB_CREATED, + // Sent when the main Google URL has been updated. Some services cache this + // value and need to update themselves when it changes. See + // google_util::GetGoogleURLAndUpdateIfNecessary(). + NOTIFY_GOOGLE_URL_UPDATED, - // This is sent when an externally hosted tab is closed. - // No details are expected. - NOTIFY_EXTERNAL_TAB_CLOSED, + // Printing ------------------------------------------------------------------ // Notification from a PrintedDocument that it has been updated. It may be // that a printed page has just been generated or that the document's number @@ -392,62 +462,18 @@ enum NotificationType { // PrintJob::EventDetails. NOTIFY_PRINT_JOB_EVENT, - // This is sent when network interception is disabled for a plugin, or the - // plugin is unloaded. This should only be sent/received on the browser IO - // thread or the plugin thread. The source is the plugin that is disabling - // interception. No details are expected. - NOTIFY_CHROME_PLUGIN_UNLOADED, - - // This is sent to a pref observer when a pref is changed. - NOTIFY_PREF_CHANGED, - - // This is sent to notify that the RenderViewHost displayed in a WebContents - // has changed. Source is the NavigationController for which the change - // happened, and details is RenderViewHostSwitchedDetails - // (see render_view_host_manager.h). - NOTIFY_RENDER_VIEW_HOST_CHANGED, - - // This notification is sent when a TabContents is being hidden, e.g. due to - // switching away from this tab. The source is a Source<TabContents>. - NOTIFY_TAB_CONTENTS_HIDDEN, - - // This notification is sent when a TabContents is being destroyed. Any object - // holding a reference to a TabContents can listen to that notification to - // properly reset the reference. The source is a Source<TabContents>. - NOTIFY_TAB_CONTENTS_DESTROYED, - - // Sent by the autocomplete edit when it is destroyed. - NOTIFY_AUTOCOMPLETE_EDIT_DESTROYED, - - // Sent by history when the favicon of a starred URL changes. In the future, - // we may want a notification for all URLs so that the history view can stay - // up-to-date. In that case, we should change this notification rather than - // adding a new one for non-starred favicons. - // The source is the profile, and the details is - // history::FavIconChangeDetails (see history_notifications.h). - NOTIFY_STARRED_FAVICON_CHANGED, + // Shutdown ------------------------------------------------------------------ // Sent on the browser IO thread when an URLRequestContext is released by its // owning Profile. The source is a pointer to the URLRequestContext. NOTIFY_URL_REQUEST_CONTEXT_RELEASED, - // Sent when the main Google URL has been updated. Some services cache this - // value and need to update themselves when it changes. See - // google_util::GetGoogleURLAndUpdateIfNecessary(). - NOTIFY_GOOGLE_URL_UPDATED, - // Sent when WM_ENDSESSION has been received, after the browsers have been // closed but before browser process has been shutdown. The source/details // are all source and no details. NOTIFY_SESSION_END, - // Sent when the bookmark bubble is shown for a particular URL. The source - // is the profile, the details the URL. - NOTIFY_BOOKMARK_BUBBLE_SHOWN, - - // Sent when the bookmark bubble hides. The source is the profile, the - // details unused. - NOTIFY_BOOKMARK_BUBBLE_HIDDEN, + // Count (must be last) ------------------------------------------------------ // Used to determine the number of notification types. Not valid as // a type parameter when registering for or posting notifications. |