summaryrefslogtreecommitdiffstats
path: root/chrome/browser/navigation_controller.cc
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-13 15:40:09 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-13 15:40:09 +0000
commit534e54bfc89ebbdbb345c3b643dc20b2643f1fee (patch)
tree5fcb98f948baf24f15b7c4c136a71df6b85cc1bc /chrome/browser/navigation_controller.cc
parent8988699d12335b2830dbc4e167244bc0244c97cd (diff)
downloadchromium_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/browser/navigation_controller.cc')
-rw-r--r--chrome/browser/navigation_controller.cc92
1 files changed, 32 insertions, 60 deletions
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 {