summaryrefslogtreecommitdiffstats
path: root/chrome/browser/session_service.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/session_service.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/session_service.cc')
-rw-r--r--chrome/browser/session_service.cc59
1 files changed, 58 insertions, 1 deletions
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,