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

Side by Side Diff: chrome/browser/sync/glue/synced_window_delegate_android.cc

Issue 10701030: Refactor SyncedWindowDelegateAndroid into TabModel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated file names, made requested changes. Created 8 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/glue/synced_window_delegate.h" 5 #include "chrome/browser/sync/glue/synced_window_delegate.h"
6 #include "chrome/browser/sync/glue/synced_window_delegate_android.h"
6 7
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/android/tab_model/tab_model.h"
10 #include "chrome/browser/ui/android/tab_model/tab_model_list.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents.h"
7 #include "chrome/browser/sessions/session_id.h" 12 #include "chrome/browser/sessions/session_id.h"
8 #include "chrome/browser/sync/glue/synced_window_delegate_registry.h"
9 13
10 namespace browser_sync { 14 namespace browser_sync {
11 15
16 // SyncedWindowDelegate implementations
17
12 const std::set<SyncedWindowDelegate*> 18 const std::set<SyncedWindowDelegate*>
13 SyncedWindowDelegate::GetSyncedWindowDelegates() { 19 SyncedWindowDelegate::GetSyncedWindowDelegates() {
14 return SyncedWindowDelegateRegistry::GetSyncedWindowDelegates(); 20 std::set<SyncedWindowDelegate*> synced_window_delegates;
21 for (TabModelList::const_iterator i = TabModelList::begin();
22 i != TabModelList::end(); ++i) {
23 synced_window_delegates.insert((*i)->GetSyncedWindowDelegate());
24 }
25 return synced_window_delegates;
15 } 26 }
16 27
17 const SyncedWindowDelegate* 28 const SyncedWindowDelegate*
18 SyncedWindowDelegate::FindSyncedWindowDelegateWithId( 29 SyncedWindowDelegate::FindSyncedWindowDelegateWithId(
19 SessionID::id_type session_id) { 30 SessionID::id_type session_id) {
20 std::set<SyncedWindowDelegate*> window = 31 TabModel* tab_model = TabModelList::FindTabModelWithId(
21 SyncedWindowDelegateRegistry::GetSyncedWindowDelegates(); 32 session_id);
22 for (std::set<SyncedWindowDelegate*>::const_iterator i = 33
23 window.begin(); i != window.end(); ++i) { 34 // In case we don't find the browser (e.g. for Developer Tools).
24 if ((*i)->GetSessionId() == session_id) 35 return tab_model ? tab_model->GetSyncedWindowDelegate() : NULL;
25 return *i; 36 }
26 } 37
27 return NULL; 38 // SyncedWindowDelegateAndroid implementations
39
40 SyncedWindowDelegateAndroid::SyncedWindowDelegateAndroid(
41 TabModel* tab_model)
42 : tab_model_(tab_model) {}
43
44 SyncedWindowDelegateAndroid::~SyncedWindowDelegateAndroid() {}
45
46 bool SyncedWindowDelegateAndroid::HasWindow() const {
47 return !tab_model_->GetProfile()->IsOffTheRecord();
48 }
49
50 SessionID::id_type SyncedWindowDelegateAndroid::GetSessionId() const {
51 return tab_model_->GetSessionId();
52 }
53
54 int SyncedWindowDelegateAndroid::GetTabCount() const {
55 return tab_model_->GetTabCount();
56 }
57
58 int SyncedWindowDelegateAndroid::GetActiveIndex() const {
59 return tab_model_->GetActiveIndex();
60 }
61
62 bool SyncedWindowDelegateAndroid::IsApp() const {
63 return false;
64 }
65
66 bool SyncedWindowDelegateAndroid::IsTypeTabbed() const {
67 return true;
68 }
69
70 bool SyncedWindowDelegateAndroid::IsTypePopup() const {
71 return false;
72 }
73
74 bool SyncedWindowDelegateAndroid::IsTabPinned(
75 const SyncedTabDelegate* tab) const {
76 return false;
77 }
78
79 SyncedTabDelegate* SyncedWindowDelegateAndroid::GetTabAt(int index) const {
80 TabContents* tab_contents = tab_model_->GetTabContentsAt(index);
81 return tab_contents ? tab_contents->synced_tab_delegate() : NULL;
82 }
83
84 SessionID::id_type SyncedWindowDelegateAndroid::GetTabIdAt(int index) const {
85 return tab_model_->GetTabIdAt(index);
86 }
87
88 bool SyncedWindowDelegateAndroid::IsSessionRestoreInProgress() const {
89 return tab_model_->IsSessionRestoreInProgress();
28 } 90 }
29 91
30 } // namespace browser_sync 92 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698