Commit 3c53f865 authored by tim@chromium.org's avatar tim@chromium.org

sync: Route local sessions events to SessionsSyncManager

Builds on https://codereview.chromium.org/74653002/

What's left after this:
- Full reassociation on ProcessSyncChanges errors.
- Integration Tests
- Stale Session pruning.

Since GetActiveEntry is now deprecated, switched to use GetVisibleEntry instead per bug 273710.

BUG=98892
R=rlarocque@chromium.org, zea@chromium.org

Review URL: https://codereview.chromium.org/79973002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238317 0039d316-1c4b-4281-b951-d872f2087c98
parent e1e7a767
...@@ -45,9 +45,11 @@ ...@@ -45,9 +45,11 @@
#include "chrome/browser/sync/glue/session_model_associator.h" #include "chrome/browser/sync/glue/session_model_associator.h"
#include "chrome/browser/sync/glue/sync_backend_host.h" #include "chrome/browser/sync/glue/sync_backend_host.h"
#include "chrome/browser/sync/glue/sync_backend_host_impl.h" #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
#include "chrome/browser/sync/glue/sync_start_util.h"
#include "chrome/browser/sync/glue/synced_device_tracker.h" #include "chrome/browser/sync/glue/synced_device_tracker.h"
#include "chrome/browser/sync/glue/typed_url_data_type_controller.h" #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
#include "chrome/browser/sync/profile_sync_components_factory_impl.h" #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
#include "chrome/browser/sync/sessions2/notification_service_sessions_router.h"
#include "chrome/browser/sync/sessions2/sessions_sync_manager.h" #include "chrome/browser/sync/sessions2/sessions_sync_manager.h"
#include "chrome/browser/sync/sync_global_error.h" #include "chrome/browser/sync/sync_global_error.h"
#include "chrome/browser/sync/user_selectable_sync_type.h" #include "chrome/browser/sync/user_selectable_sync_type.h"
...@@ -91,6 +93,7 @@ using browser_sync::ChangeProcessor; ...@@ -91,6 +93,7 @@ using browser_sync::ChangeProcessor;
using browser_sync::DataTypeController; using browser_sync::DataTypeController;
using browser_sync::DataTypeManager; using browser_sync::DataTypeManager;
using browser_sync::FailedDataTypesHandler; using browser_sync::FailedDataTypesHandler;
using browser_sync::NotificationServiceSessionsRouter;
using browser_sync::SyncBackendHost; using browser_sync::SyncBackendHost;
using syncer::ModelType; using syncer::ModelType;
using syncer::ModelTypeSet; using syncer::ModelTypeSet;
...@@ -196,7 +199,12 @@ ProfileSyncService::ProfileSyncService( ...@@ -196,7 +199,12 @@ ProfileSyncService::ProfileSyncService(
if (CommandLine::ForCurrentProcess()->HasSwitch( if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableSyncSessionsV2)) { switches::kEnableSyncSessionsV2)) {
sessions_sync_manager_.reset(new SessionsSyncManager(profile, this)); syncer::SyncableService::StartSyncFlare flare(
sync_start_util::GetFlareForSyncableService(profile->GetPath()));
scoped_ptr<browser_sync::LocalSessionEventRouter> router(
new NotificationServiceSessionsRouter(profile, flare));
sessions_sync_manager_.reset(
new SessionsSyncManager(profile, this, router.Pass()));
} }
} }
......
// Copyright 2013 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.
#include "chrome/browser/sync/sessions2/notification_service_sessions_router.h"
#include "base/logging.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/favicon/favicon_changed_details.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/sync_start_util.h"
#include "chrome/browser/sync/glue/synced_tab_delegate.h"
#include "chrome/browser/ui/browser.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
#if defined(ENABLE_MANAGED_USERS)
#include "chrome/browser/managed_mode/managed_user_service.h"
#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#endif
using content::NavigationController;
using content::WebContents;
namespace browser_sync {
NotificationServiceSessionsRouter::NotificationServiceSessionsRouter(
Profile* profile, const syncer::SyncableService::StartSyncFlare& flare)
: handler_(NULL),
profile_(profile),
flare_(flare),
weak_ptr_factory_(this) {
registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED,
content::NotificationService::AllSources());
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::NotificationService::AllSources());
registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED,
content::NotificationService::AllSources());
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED,
content::NotificationService::AllSources());
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::NotificationService::AllSources());
registrar_.Add(this,
chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED,
content::NotificationService::AllSources());
registrar_.Add(this,
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
content::NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED,
content::Source<Profile>(profile_));
#if defined(ENABLE_MANAGED_USERS)
if (profile_->IsManaged()) {
ManagedUserService* managed_user_service =
ManagedUserServiceFactory::GetForProfile(profile_);
managed_user_service->AddNavigationBlockedCallback(
base::Bind(&NotificationServiceSessionsRouter::OnNavigationBlocked,
weak_ptr_factory_.GetWeakPtr()));
}
#endif
}
NotificationServiceSessionsRouter::~NotificationServiceSessionsRouter() {}
void NotificationServiceSessionsRouter::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_FAVICON_CHANGED: {
content::Details<FaviconChangedDetails> favicon_details(details);
if (handler_)
handler_->OnFaviconPageUrlsUpdated(favicon_details->urls);
return;
}
// Source<WebContents>.
case chrome::NOTIFICATION_TAB_PARENTED:
case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME:
case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: {
WebContents* web_contents = content::Source<WebContents>(source).ptr();
SyncedTabDelegate* tab =
SyncedTabDelegate::ImplFromWebContents(web_contents);
if (!tab || tab->profile() != profile_)
return;
if (handler_)
handler_->OnLocalTabModified(tab);
break;
}
// Source<NavigationController>.
case content::NOTIFICATION_NAV_LIST_PRUNED:
case content::NOTIFICATION_NAV_ENTRY_CHANGED:
case content::NOTIFICATION_NAV_ENTRY_COMMITTED: {
SyncedTabDelegate* tab = SyncedTabDelegate::ImplFromWebContents(
content::Source<NavigationController>(source).ptr()->
GetWebContents());
if (!tab || tab->profile() != profile_)
return;
if (handler_)
handler_->OnLocalTabModified(tab);
break;
}
case chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: {
extensions::TabHelper* extension_tab_helper =
content::Source<extensions::TabHelper>(source).ptr();
if (extension_tab_helper->web_contents()->GetBrowserContext() !=
profile_) {
return;
}
if (extension_tab_helper->extension_app()) {
SyncedTabDelegate* tab = SyncedTabDelegate::ImplFromWebContents(
extension_tab_helper->web_contents());
if (handler_)
handler_->OnLocalTabModified(tab);
break;
}
return;
}
default:
LOG(ERROR) << "Received unexpected notification of type " << type;
return;
}
if (!flare_.is_null()) {
flare_.Run(syncer::SESSIONS);
flare_.Reset();
}
}
void NotificationServiceSessionsRouter::OnNavigationBlocked(
content::WebContents* web_contents) {
SyncedTabDelegate* tab =
SyncedTabDelegate::ImplFromWebContents(web_contents);
if (!tab)
return;
DCHECK(tab->profile() == profile_);
handler_->OnLocalTabModified(tab);
}
void NotificationServiceSessionsRouter::StartRoutingTo(
LocalSessionEventHandler* handler) {
DCHECK(!handler_);
handler_ = handler;
}
void NotificationServiceSessionsRouter::Stop() {
weak_ptr_factory_.InvalidateWeakPtrs();
registrar_.RemoveAll();
handler_ = NULL;
}
} // namespace browser_sync
// Copyright 2013 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.
#ifndef CHROME_BROWSER_SYNC_SESSIONS2_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_
#define CHROME_BROWSER_SYNC_SESSIONS2_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_
#include "base/memory/weak_ptr.h"
#include "chrome/browser/sync/sessions2/sessions_sync_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class Profile;
namespace content {
class WebContents;
}
namespace browser_sync {
// A SessionsSyncManager::LocalEventRouter that drives session sync via
// the NotificationService.
class NotificationServiceSessionsRouter
: public LocalSessionEventRouter,
public content::NotificationObserver {
public:
NotificationServiceSessionsRouter(
Profile* profile,
const syncer::SyncableService::StartSyncFlare& flare);
virtual ~NotificationServiceSessionsRouter();
// content::NotificationObserver implementation.
// BrowserSessionProvider -> sync API model change application.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
// SessionsSyncManager::LocalEventRouter implementation.
virtual void StartRoutingTo(LocalSessionEventHandler* handler) OVERRIDE;
virtual void Stop() OVERRIDE;
private:
// Called when the URL visited in |web_contents| was blocked by the
// ManagedUserService. We forward this on to our handler_ via the
// normal OnLocalTabModified, but pass through here via a WeakPtr
// callback from ManagedUserService and to extract the tab delegate
// from WebContents.
void OnNavigationBlocked(content::WebContents* web_contents);
LocalSessionEventHandler* handler_;
content::NotificationRegistrar registrar_;
Profile* const profile_;
syncer::SyncableService::StartSyncFlare flare_;
base::WeakPtrFactory<NotificationServiceSessionsRouter> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(NotificationServiceSessionsRouter);
};
} // namespace browser_sync
#endif // CHROME_BROWSER_SYNC_SESSIONS2_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_
...@@ -37,16 +37,24 @@ static const int kMaxSyncFavicons = 200; ...@@ -37,16 +37,24 @@ static const int kMaxSyncFavicons = 200;
// The maximum number of navigations in each direction we care to sync. // The maximum number of navigations in each direction we care to sync.
static const int kMaxSyncNavigationCount = 6; static const int kMaxSyncNavigationCount = 6;
// The URL at which the set of synced tabs is displayed. We treat it differently
// from all other URL's as accessing it triggers a sync refresh of Sessions.
static const char kNTPOpenTabSyncURL[] = "chrome://newtab/#open_tabs";
SessionsSyncManager::SessionsSyncManager( SessionsSyncManager::SessionsSyncManager(
Profile* profile, Profile* profile,
SyncInternalApiDelegate* delegate) SyncInternalApiDelegate* delegate,
scoped_ptr<LocalSessionEventRouter> router)
: favicon_cache_(profile, kMaxSyncFavicons), : favicon_cache_(profile, kMaxSyncFavicons),
sync_prefs_(profile->GetPrefs()), sync_prefs_(profile->GetPrefs()),
profile_(profile), profile_(profile),
delegate_(delegate), delegate_(delegate),
local_session_header_node_id_(TabNodePool2::kInvalidTabNodeID) { local_session_header_node_id_(TabNodePool2::kInvalidTabNodeID),
local_event_router_(router.Pass()) {
} }
LocalSessionEventRouter::~LocalSessionEventRouter() {}
SessionsSyncManager::~SessionsSyncManager() { SessionsSyncManager::~SessionsSyncManager() {
} }
...@@ -116,6 +124,8 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing( ...@@ -116,6 +124,8 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing(
merge_result.set_error( merge_result.set_error(
sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes)); sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
local_event_router_->StartRoutingTo(this);
return merge_result; return merge_result;
} }
...@@ -293,13 +303,43 @@ void SessionsSyncManager::AssociateTab(SyncedTabDelegate* const tab, ...@@ -293,13 +303,43 @@ void SessionsSyncManager::AssociateTab(SyncedTabDelegate* const tab,
base::Time::Now(); base::Time::Now();
} }
void SessionsSyncManager::OnLocalTabModified( void SessionsSyncManager::OnLocalTabModified(SyncedTabDelegate* modified_tab) {
const SyncedTabDelegate& modified_tab, syncer::SyncError* error) { const content::NavigationEntry* entry = modified_tab->GetActiveEntry();
NOTIMPLEMENTED() << "TODO(tim): SessionModelAssociator::Observe equivalent."; if (!modified_tab->IsBeingDestroyed() &&
entry &&
entry->GetVirtualURL().is_valid() &&
entry->GetVirtualURL().spec() == kNTPOpenTabSyncURL) {
DVLOG(1) << "Triggering sync refresh for sessions datatype.";
const syncer::ModelTypeSet types(syncer::SESSIONS);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
content::Source<Profile>(profile_),
content::Details<const syncer::ModelTypeSet>(&types));
}
syncer::SyncChangeList changes;
// Associate tabs first so the synced session tracker is aware of them.
AssociateTab(modified_tab, &changes);
// Note, we always associate windows because it's possible a tab became
// "interesting" by going to a valid URL, in which case it needs to be added
// to the window's tab information.
AssociateWindows(DONT_RELOAD_TABS, &changes);
sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
} }
void SessionsSyncManager::OnBrowserOpened() { void SessionsSyncManager::OnFaviconPageUrlsUpdated(
NOTIMPLEMENTED() << "TODO(tim): SessionModelAssociator::Observe equivalent."; const std::set<GURL>& updated_favicon_page_urls) {
// TODO(zea): consider a separate container for tabs with outstanding favicon
// loads so we don't have to iterate through all tabs comparing urls.
for (std::set<GURL>::const_iterator i = updated_favicon_page_urls.begin();
i != updated_favicon_page_urls.end(); ++i) {
for (TabLinksMap::iterator tab_iter = local_tab_map_.begin();
tab_iter != local_tab_map_.end();
++tab_iter) {
if (tab_iter->second->url() == *i)
favicon_cache_.OnPageFaviconUpdated(*i);
}
}
} }
bool SessionsSyncManager::ShouldSyncTab(const SyncedTabDelegate& tab) const { bool SessionsSyncManager::ShouldSyncTab(const SyncedTabDelegate& tab) const {
...@@ -345,21 +385,6 @@ bool SessionsSyncManager::ShouldSyncWindow( ...@@ -345,21 +385,6 @@ bool SessionsSyncManager::ShouldSyncWindow(
return window->IsTypeTabbed() || window->IsTypePopup(); return window->IsTypeTabbed() || window->IsTypePopup();
} }
void SessionsSyncManager::ForwardRelevantFaviconUpdatesToFaviconCache(
const std::set<GURL>& updated_favicon_page_urls) {
// TODO(zea): consider a separate container for tabs with outstanding favicon
// loads so we don't have to iterate through all tabs comparing urls.
for (std::set<GURL>::const_iterator i = updated_favicon_page_urls.begin();
i != updated_favicon_page_urls.end(); ++i) {
for (TabLinksMap::iterator tab_iter = local_tab_map_.begin();
tab_iter != local_tab_map_.end();
++tab_iter) {
if (tab_iter->second->url() == *i)
favicon_cache_.OnPageFaviconUpdated(*i);
}
}
}
void SessionsSyncManager::StopSyncing(syncer::ModelType type) { void SessionsSyncManager::StopSyncing(syncer::ModelType type) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
...@@ -396,6 +421,8 @@ syncer::SyncError SessionsSyncManager::ProcessSyncChanges( ...@@ -396,6 +421,8 @@ syncer::SyncError SessionsSyncManager::ProcessSyncChanges(
// Another client has attempted to delete our local data (possibly by // Another client has attempted to delete our local data (possibly by
// error or a clock is inaccurate). Just ignore the deletion for now // error or a clock is inaccurate). Just ignore the deletion for now
// to avoid any possible ping-pong delete/reassociate sequence. // to avoid any possible ping-pong delete/reassociate sequence.
// TODO(tim): Bug 98892. This corrupts TabNodePool. Perform full
// re-association.
LOG(WARNING) << "Local session data deleted. Ignoring until next " LOG(WARNING) << "Local session data deleted. Ignoring until next "
<< "local navigation event."; << "local navigation event.";
} else if (session.has_header()) { } else if (session.has_header()) {
...@@ -868,7 +895,6 @@ void SessionsSyncManager::SetSessionTabFromDelegate( ...@@ -868,7 +895,6 @@ void SessionsSyncManager::SetSessionTabFromDelegate(
session_tab->session_storage_persistent_id.clear(); session_tab->session_storage_persistent_id.clear();
} }
FaviconCache* SessionsSyncManager::GetFaviconCache() { FaviconCache* SessionsSyncManager::GetFaviconCache() {
return &favicon_cache_; return &favicon_cache_;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/sessions/session_id.h" #include "chrome/browser/sessions/session_id.h"
#include "chrome/browser/sessions/session_types.h" #include "chrome/browser/sessions/session_types.h"
...@@ -45,14 +46,46 @@ class DataTypeErrorHandler; ...@@ -45,14 +46,46 @@ class DataTypeErrorHandler;
class SyncedTabDelegate; class SyncedTabDelegate;
class SyncedWindowDelegate; class SyncedWindowDelegate;
// An interface defining the ways in which local open tab events can interact
// with session sync. All local tab events flow to sync via this interface.
// In that way it is analogous to sync changes flowing to the local model
// via ProcessSyncChanges, just with a more granular breakdown.
class LocalSessionEventHandler {
public:
// A local navigation event took place that affects the synced session
// for this instance of Chrome.
virtual void OnLocalTabModified(SyncedTabDelegate* modified_tab) = 0;
// A local navigation occurred that triggered updates to favicon data for
// each URL in |updated_page_urls|. This is routed through Sessions Sync so
// that we can filter (exclude) favicon updates for pages that aren't
// currently part of the set of local open tabs, and pass relevant updates
// on to FaviconCache for out-of-band favicon syncing.
virtual void OnFaviconPageUrlsUpdated(
const std::set<GURL>& updated_page_urls) = 0;
};
// The LocalSessionEventRouter is responsible for hooking itself up to various
// notification sources in the browser process and forwarding relevant
// events to a handler as defined in the LocalSessionEventHandler contract.
class LocalSessionEventRouter {
public:
virtual ~LocalSessionEventRouter();
virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0;
virtual void Stop() = 0;
};
// Contains all logic for associating the Chrome sessions model and // Contains all logic for associating the Chrome sessions model and
// the sync sessions model. // the sync sessions model.
class SessionsSyncManager : public syncer::SyncableService, class SessionsSyncManager : public syncer::SyncableService,
public OpenTabsUIDelegate { public OpenTabsUIDelegate,
public LocalSessionEventHandler {
public: public:
// Isolates SessionsSyncManager from having to depend on sync internals. // Isolates SessionsSyncManager from having to depend on sync internals.
class SyncInternalApiDelegate { class SyncInternalApiDelegate {
public: public:
virtual ~SyncInternalApiDelegate() {}
// Returns sync's representation of the local device info. // Returns sync's representation of the local device info.
// Return value is an empty scoped_ptr if the device info is unavailable. // Return value is an empty scoped_ptr if the device info is unavailable.
virtual scoped_ptr<DeviceInfo> GetLocalDeviceInfo() const = 0; virtual scoped_ptr<DeviceInfo> GetLocalDeviceInfo() const = 0;
...@@ -62,33 +95,10 @@ class SessionsSyncManager : public syncer::SyncableService, ...@@ -62,33 +95,10 @@ class SessionsSyncManager : public syncer::SyncableService,
}; };
SessionsSyncManager(Profile* profile, SessionsSyncManager(Profile* profile,
SyncInternalApiDelegate* delegate); SyncInternalApiDelegate* delegate,
scoped_ptr<LocalSessionEventRouter> router);
virtual ~SessionsSyncManager(); virtual ~SessionsSyncManager();
// A local navigation event took place that affects the synced session
// for this instance of Chrome.
void OnLocalTabModified(const SyncedTabDelegate& modified_tab,
syncer::SyncError* error);
// When a Browser window is opened, we want to know so we can make sure our
// bookkeeping of open windows / sessions on this device is up-to-date.
void OnBrowserOpened();
// A local navigation occurred that triggered updates to favicon data for
// each URL in |updated_page_urls|. This is routed through Sessions Sync so
// that we can filter (exclude) favicon updates for pages that aren't
// currently part of the set of local open tabs, and pass relevant updates
// on to FaviconCache for out-of-band favicon syncing.
void ForwardRelevantFaviconUpdatesToFaviconCache(
const std::set<GURL>& updated_favicon_page_urls);
// Returns the tag used to uniquely identify this machine's session in the
// sync model.
const std::string& current_machine_tag() const {
DCHECK(!current_machine_tag_.empty());
return current_machine_tag_;
}
// syncer::SyncableService implementation. // syncer::SyncableService implementation.
virtual syncer::SyncMergeResult MergeDataAndStartSyncing( virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type, syncer::ModelType type,
...@@ -102,14 +112,6 @@ class SessionsSyncManager : public syncer::SyncableService, ...@@ -102,14 +112,6 @@ class SessionsSyncManager : public syncer::SyncableService,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
const syncer::SyncChangeList& change_list) OVERRIDE; const syncer::SyncChangeList& change_list) OVERRIDE;
// Return the virtual URL of the current tab, even if it's pending.
static GURL GetCurrentVirtualURL(const SyncedTabDelegate& tab_delegate);
// Return the favicon url of the current tab, even if it's pending.
static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate);
FaviconCache* GetFaviconCache();
// OpenTabsUIDelegate implementation. // OpenTabsUIDelegate implementation.
virtual bool GetSyncedFaviconForPageURL( virtual bool GetSyncedFaviconForPageURL(
const std::string& pageurl, const std::string& pageurl,
...@@ -124,6 +126,26 @@ class SessionsSyncManager : public syncer::SyncableService, ...@@ -124,6 +126,26 @@ class SessionsSyncManager : public syncer::SyncableService,
const SessionTab** tab) OVERRIDE; const SessionTab** tab) OVERRIDE;
virtual void DeleteForeignSession(const std::string& tag) OVERRIDE; virtual void DeleteForeignSession(const std::string& tag) OVERRIDE;
// LocalSessionEventHandler implementation.
virtual void OnLocalTabModified(SyncedTabDelegate* modified_tab) OVERRIDE;
virtual void OnFaviconPageUrlsUpdated(
const std::set<GURL>& updated_favicon_page_urls) OVERRIDE;
// Returns the tag used to uniquely identify this machine's session in the
// sync model.
const std::string& current_machine_tag() const {
DCHECK(!current_machine_tag_.empty());
return current_machine_tag_;
}
// Return the virtual URL of the current tab, even if it's pending.
static GURL GetCurrentVirtualURL(const SyncedTabDelegate& tab_delegate);
// Return the favicon url of the current tab, even if it's pending.
static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate);
FaviconCache* GetFaviconCache();
private: private:
// Keep all the links to local tab data in one place. A tab_node_id and tab // Keep all the links to local tab data in one place. A tab_node_id and tab
// must be passed at creation. The tab_node_id is not mutable, although // must be passed at creation. The tab_node_id is not mutable, although
...@@ -308,6 +330,8 @@ class SessionsSyncManager : public syncer::SyncableService, ...@@ -308,6 +330,8 @@ class SessionsSyncManager : public syncer::SyncableService,
// client. // client.
int local_session_header_node_id_; int local_session_header_node_id_;
scoped_ptr<LocalSessionEventRouter> local_event_router_;
DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager);
}; };
......
...@@ -71,7 +71,7 @@ NavigationEntry* TabContentsSyncedTabDelegate::GetEntryAtIndex(int i) const { ...@@ -71,7 +71,7 @@ NavigationEntry* TabContentsSyncedTabDelegate::GetEntryAtIndex(int i) const {
} }
NavigationEntry* TabContentsSyncedTabDelegate::GetActiveEntry() const { NavigationEntry* TabContentsSyncedTabDelegate::GetActiveEntry() const {
return web_contents_->GetController().GetActiveEntry(); return web_contents_->GetController().GetVisibleEntry();
} }
bool TabContentsSyncedTabDelegate::ProfileIsManaged() const { bool TabContentsSyncedTabDelegate::ProfileIsManaged() const {
......
...@@ -2340,6 +2340,8 @@ ...@@ -2340,6 +2340,8 @@
'browser/sync/profile_sync_service_observer.h', 'browser/sync/profile_sync_service_observer.h',
'browser/sync/retry_verifier.cc', 'browser/sync/retry_verifier.cc',
'browser/sync/retry_verifier.h', 'browser/sync/retry_verifier.h',
'browser/sync/sessions2/notification_service_sessions_router.cc',
'browser/sync/sessions2/notification_service_sessions_router.h',
'browser/sync/sessions2/session_data_type_controller2.cc', 'browser/sync/sessions2/session_data_type_controller2.cc',
'browser/sync/sessions2/session_data_type_controller2.h', 'browser/sync/sessions2/session_data_type_controller2.h',
'browser/sync/sessions2/sessions_sync_manager.cc', 'browser/sync/sessions2/sessions_sync_manager.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment