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

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: Nit fixes Created 8 years, 4 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_android.h"
6 6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/android/tab_model/tab_model.h"
9 #include "chrome/browser/ui/android/tab_model/tab_model_list.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
7 #include "chrome/browser/sessions/session_id.h" 11 #include "chrome/browser/sessions/session_id.h"
8 #include "chrome/browser/sync/glue/synced_window_delegate_registry.h"
9 12
10 namespace browser_sync { 13 namespace browser_sync {
11 14
15 // SyncedWindowDelegate implementations
16
12 const std::set<SyncedWindowDelegate*> 17 const std::set<SyncedWindowDelegate*>
13 SyncedWindowDelegate::GetSyncedWindowDelegates() { 18 SyncedWindowDelegate::GetSyncedWindowDelegates() {
14 return SyncedWindowDelegateRegistry::GetSyncedWindowDelegates(); 19 std::set<SyncedWindowDelegate*> synced_window_delegates;
20 for (TabModelList::const_iterator i = TabModelList::begin();
21 i != TabModelList::end(); ++i) {
22 synced_window_delegates.insert((*i)->GetSyncedWindowDelegate());
23 }
24 return synced_window_delegates;
15 } 25 }
16 26
17 const SyncedWindowDelegate* 27 const SyncedWindowDelegate*
18 SyncedWindowDelegate::FindSyncedWindowDelegateWithId( 28 SyncedWindowDelegate::FindSyncedWindowDelegateWithId(
19 SessionID::id_type session_id) { 29 SessionID::id_type session_id) {
20 std::set<SyncedWindowDelegate*> window = 30 TabModel* tab_model = TabModelList::FindTabModelWithId(
21 SyncedWindowDelegateRegistry::GetSyncedWindowDelegates(); 31 session_id);
22 for (std::set<SyncedWindowDelegate*>::const_iterator i = 32
23 window.begin(); i != window.end(); ++i) { 33 // In case we don't find the browser (e.g. for Developer Tools).
24 if ((*i)->GetSessionId() == session_id) 34 return tab_model ? tab_model->GetSyncedWindowDelegate() : NULL;
25 return *i; 35 }
26 } 36
27 return NULL; 37 // SyncedWindowDelegateAndroid implementations
38
39 SyncedWindowDelegateAndroid::SyncedWindowDelegateAndroid(
40 TabModel* tab_model)
41 : tab_model_(tab_model) {}
42
43 SyncedWindowDelegateAndroid::~SyncedWindowDelegateAndroid() {}
44
45 bool SyncedWindowDelegateAndroid::HasWindow() const {
46 return !tab_model_->GetProfile()->IsOffTheRecord();
47 }
48
49 SessionID::id_type SyncedWindowDelegateAndroid::GetSessionId() const {
50 return tab_model_->GetSessionId();
51 }
52
53 int SyncedWindowDelegateAndroid::GetTabCount() const {
54 return tab_model_->GetTabCount();
55 }
56
57 int SyncedWindowDelegateAndroid::GetActiveIndex() const {
58 return tab_model_->GetActiveIndex();
59 }
60
61 bool SyncedWindowDelegateAndroid::IsApp() const {
62 return false;
63 }
64
65 bool SyncedWindowDelegateAndroid::IsTypeTabbed() const {
66 return true;
67 }
68
69 bool SyncedWindowDelegateAndroid::IsTypePopup() const {
70 return false;
71 }
72
73 bool SyncedWindowDelegateAndroid::IsTabPinned(
74 const SyncedTabDelegate* tab) const {
75 return false;
76 }
77
78 SyncedTabDelegate* SyncedWindowDelegateAndroid::GetTabAt(int index) const {
79 TabContents* tab_contents = tab_model_->GetTabContentsAt(index);
80 return tab_contents ? tab_contents->synced_tab_delegate() : NULL;
81 }
82
83 SessionID::id_type SyncedWindowDelegateAndroid::GetTabIdAt(int index) const {
84 return tab_model_->GetTabIdAt(index);
85 }
86
87 bool SyncedWindowDelegateAndroid::IsSessionRestoreInProgress() const {
88 return tab_model_->IsSessionRestoreInProgress();
28 } 89 }
29 90
30 } // namespace browser_sync 91 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/synced_window_delegate_android.h ('k') | chrome/browser/sync/glue/synced_window_delegate_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698