Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1395)

Unified Diff: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc

Issue 74653002: sync: Add --enable-sync-sessions-v2 and necessary plumbing to use SessionsSyncManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
index 4049cc4b4fd6cf044128e28560846171a494af6f..e2e1b3dbe7a4f8e483247fd80a2561742e3e943b 100644
--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
@@ -17,8 +17,8 @@
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_delegate.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
-#include "chrome/browser/sync/glue/session_model_associator.h"
#include "chrome/browser/sync/glue/synced_session.h"
+#include "chrome/browser/sync/open_tabs_ui_delegate.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
@@ -167,10 +167,10 @@ const int RecentTabsSubMenuModel::kDisabledRecentlyClosedHeaderCommandId = 1121;
RecentTabsSubMenuModel::RecentTabsSubMenuModel(
ui::AcceleratorProvider* accelerator_provider,
Browser* browser,
- browser_sync::SessionModelAssociator* associator)
+ browser_sync::OpenTabsUIDelegate* delegate)
: ui::SimpleMenuModel(this),
browser_(browser),
- associator_(associator),
+ open_tabs_(delegate),
last_local_model_index_(-1),
default_favicon_(ResourceBundle::GetSharedInstance().
GetNativeImageNamed(IDR_DEFAULT_FAVICON)),
@@ -285,11 +285,11 @@ void RecentTabsSubMenuModel::ExecuteCommand(int command_id, int event_flags) {
browser_->host_desktop_type(), disposition);
}
} else { // Restore tab of session from other devices.
- browser_sync::SessionModelAssociator* associator = GetModelAssociator();
- if (!associator)
+ browser_sync::OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate();
+ if (!open_tabs)
return;
const SessionTab* tab;
- if (!associator->GetForeignTab(item.session_tag, item.tab_id, &tab))
+ if (!open_tabs->GetForeignTab(item.session_tag, item.tab_id, &tab))
return;
if (tab->navigations.empty())
return;
@@ -422,9 +422,9 @@ void RecentTabsSubMenuModel::BuildTabsFromOtherDevices() {
// a menu item, because they are always only built once (i.e. invoked from
// Constructor()) and don't change after that.
- browser_sync::SessionModelAssociator* associator = GetModelAssociator();
+ browser_sync::OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate();
std::vector<const browser_sync::SyncedSession*> sessions;
- if (!associator || !associator->GetAllForeignSessions(&sessions)) {
+ if (!open_tabs || !open_tabs->GetAllForeignSessions(&sessions)) {
AddSeparator(ui::NORMAL_SEPARATOR);
AddItemWithStringId(IDC_RECENT_TABS_NO_DEVICE_TABS,
IDS_RECENT_TABS_NO_DEVICE_TABS);
@@ -443,7 +443,7 @@ void RecentTabsSubMenuModel::BuildTabsFromOtherDevices() {
// Get windows of session.
std::vector<const SessionWindow*> windows;
- if (!associator->GetForeignSession(session_tag, &windows) ||
+ if (!open_tabs->GetForeignSession(session_tag, &windows) ||
windows.empty()) {
continue;
}
@@ -588,10 +588,10 @@ void RecentTabsSubMenuModel::AddTabFavicon(int command_id, const GURL& url) {
// --sync-tab-favicons switch is on; according to zea@, this flag is now
// automatically enabled for iOS and android, and they're looking into
// enabling it for other platforms.
- browser_sync::SessionModelAssociator* associator = GetModelAssociator();
+ browser_sync::OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate();
scoped_refptr<base::RefCountedMemory> favicon_png;
- if (associator &&
- associator->GetSyncedFaviconForPageURL(url.spec(), &favicon_png)) {
+ if (open_tabs &&
+ open_tabs->GetSyncedFaviconForPageURL(url.spec(), &favicon_png)) {
gfx::Image image = gfx::Image::CreateFrom1xPNGBytes(favicon_png->front(),
favicon_png->size());
SetIcon(index_in_menu, image);
@@ -660,16 +660,16 @@ void RecentTabsSubMenuModel::ClearLocalEntries() {
local_window_items_.clear();
}
-browser_sync::SessionModelAssociator*
- RecentTabsSubMenuModel::GetModelAssociator() {
- if (!associator_) {
+browser_sync::OpenTabsUIDelegate*
+ RecentTabsSubMenuModel::GetOpenTabsUIDelegate() {
+ if (!open_tabs_) {
ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()->
GetForProfile(browser_->profile());
- // Only return the associator if it exists and it is done syncing sessions.
+ // Only return the delegate if it exists and it is done syncing sessions.
if (service && service->ShouldPushChanges())
- associator_ = service->GetSessionModelAssociator();
+ open_tabs_ = service->GetOpenTabsUIDelegate();
}
- return associator_;
+ return open_tabs_;
}
void RecentTabsSubMenuModel::TabRestoreServiceChanged(

Powered by Google App Engine
This is Rietveld 408576698