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

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

Issue 1408643002: [Sync] Componentize synced_tab_delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test broken by rebase Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_tab_delegate_android.h" 5 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "chrome/browser/android/tab_android.h" 8 #include "chrome/browser/android/tab_android.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/glue/synced_window_delegates_getter_android.h" 10 #include "chrome/browser/sync/glue/synced_window_delegates_getter_android.h"
11 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" 11 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h"
12 #include "components/sync_driver/glue/synced_window_delegate.h" 12 #include "components/sync_driver/glue/synced_window_delegate.h"
13 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 15
16 using content::NavigationEntry; 16 using content::NavigationEntry;
17 17
18 namespace browser_sync { 18 namespace browser_sync {
19 SyncedTabDelegateAndroid::SyncedTabDelegateAndroid(TabAndroid* tab_android) 19 SyncedTabDelegateAndroid::SyncedTabDelegateAndroid(TabAndroid* tab_android)
20 : web_contents_(nullptr), 20 : web_contents_(nullptr),
21 tab_android_(tab_android), 21 tab_android_(tab_android),
22 tab_contents_delegate_(nullptr) { 22 tab_contents_delegate_(nullptr) {
23 SetSyncedWindowGetter(
24 make_scoped_ptr(new SyncedWindowDelegatesGetterAndroid()));
25 } 23 }
26 24
27 SyncedTabDelegateAndroid::~SyncedTabDelegateAndroid() {} 25 SyncedTabDelegateAndroid::~SyncedTabDelegateAndroid() {}
28 26
29 SessionID::id_type SyncedTabDelegateAndroid::GetWindowId() const { 27 SessionID::id_type SyncedTabDelegateAndroid::GetWindowId() const {
30 return tab_contents_delegate_->GetWindowId(); 28 return tab_contents_delegate_->GetWindowId();
31 } 29 }
32 30
33 SessionID::id_type SyncedTabDelegateAndroid::GetSessionId() const { 31 SessionID::id_type SyncedTabDelegateAndroid::GetSessionId() const {
34 return tab_android_->session_id().id(); 32 return tab_android_->session_id().id();
35 } 33 }
36 34
37 bool SyncedTabDelegateAndroid::IsBeingDestroyed() const { 35 bool SyncedTabDelegateAndroid::IsBeingDestroyed() const {
38 return tab_contents_delegate_->IsBeingDestroyed(); 36 return tab_contents_delegate_->IsBeingDestroyed();
39 } 37 }
40 38
41 Profile* SyncedTabDelegateAndroid::profile() const {
42 return tab_contents_delegate_->profile();
43 }
44
45 std::string SyncedTabDelegateAndroid::GetExtensionAppId() const { 39 std::string SyncedTabDelegateAndroid::GetExtensionAppId() const {
46 return tab_contents_delegate_->GetExtensionAppId(); 40 return tab_contents_delegate_->GetExtensionAppId();
47 } 41 }
48 42
49 bool SyncedTabDelegateAndroid::IsInitialBlankNavigation() const { 43 bool SyncedTabDelegateAndroid::IsInitialBlankNavigation() const {
50 return tab_contents_delegate_->IsInitialBlankNavigation(); 44 return tab_contents_delegate_->IsInitialBlankNavigation();
51 } 45 }
52 46
53 int SyncedTabDelegateAndroid::GetCurrentEntryIndex() const { 47 int SyncedTabDelegateAndroid::GetCurrentEntryIndex() const {
54 return tab_contents_delegate_->GetCurrentEntryIndex(); 48 return tab_contents_delegate_->GetCurrentEntryIndex();
55 } 49 }
56 50
57 int SyncedTabDelegateAndroid::GetEntryCount() const { 51 int SyncedTabDelegateAndroid::GetEntryCount() const {
58 return tab_contents_delegate_->GetEntryCount(); 52 return tab_contents_delegate_->GetEntryCount();
59 } 53 }
60 54
61 int SyncedTabDelegateAndroid::GetPendingEntryIndex() const { 55 GURL SyncedTabDelegateAndroid::GetVirtualURLAtIndex(int i) const {
62 return tab_contents_delegate_->GetPendingEntryIndex(); 56 return tab_contents_delegate_->GetVirtualURLAtIndex(i);
63 } 57 }
64 58
65 NavigationEntry* SyncedTabDelegateAndroid::GetPendingEntry() const { 59 GURL SyncedTabDelegateAndroid::GetFaviconURLAtIndex(int i) const {
66 return tab_contents_delegate_->GetPendingEntry(); 60 return tab_contents_delegate_->GetFaviconURLAtIndex(i);
67 } 61 }
68 62
69 NavigationEntry* SyncedTabDelegateAndroid::GetEntryAtIndex(int i) const { 63 ui::PageTransition SyncedTabDelegateAndroid::GetTransitionAtIndex(int i) const {
70 return tab_contents_delegate_->GetEntryAtIndex(i); 64 return tab_contents_delegate_->GetTransitionAtIndex(i);
71 } 65 }
72 66
73 NavigationEntry* SyncedTabDelegateAndroid::GetActiveEntry() const { 67 void SyncedTabDelegateAndroid::GetSerializedNavigationAtIndex(
74 return tab_contents_delegate_->GetActiveEntry(); 68 int i,
69 sessions::SerializedNavigationEntry* serialized_entry) const {
70 tab_contents_delegate_->GetSerializedNavigationAtIndex(i, serialized_entry);
75 } 71 }
76 72
77 bool SyncedTabDelegateAndroid::IsPinned() const { 73 bool SyncedTabDelegateAndroid::IsPlaceholderTab() const {
78 return tab_contents_delegate_->IsPinned(); 74 return web_contents_ == nullptr;
79 }
80
81 bool SyncedTabDelegateAndroid::HasWebContents() const {
82 return web_contents_ != NULL;
83 }
84
85 content::WebContents* SyncedTabDelegateAndroid::GetWebContents() const {
86 return web_contents_;
87 } 75 }
88 76
89 void SyncedTabDelegateAndroid::SetWebContents( 77 void SyncedTabDelegateAndroid::SetWebContents(
90 content::WebContents* web_contents) { 78 content::WebContents* web_contents) {
91 web_contents_ = web_contents; 79 web_contents_ = web_contents;
92 TabContentsSyncedTabDelegate::CreateForWebContents(web_contents_); 80 TabContentsSyncedTabDelegate::CreateForWebContents(web_contents_);
93 // Store the TabContentsSyncedTabDelegate object that was created. 81 // Store the TabContentsSyncedTabDelegate object that was created.
94 tab_contents_delegate_ = 82 tab_contents_delegate_ =
95 TabContentsSyncedTabDelegate::FromWebContents(web_contents_); 83 TabContentsSyncedTabDelegate::FromWebContents(web_contents_);
96 // Tell it how to get SyncedWindowDelegates or some calls will fail.
97 tab_contents_delegate_->SetSyncedWindowGetter(
98 make_scoped_ptr(new SyncedWindowDelegatesGetterAndroid()));
99 } 84 }
100 85
101 void SyncedTabDelegateAndroid::ResetWebContents() { web_contents_ = NULL; } 86 void SyncedTabDelegateAndroid::ResetWebContents() {
87 web_contents_ = nullptr;
88 }
102 89
103 bool SyncedTabDelegateAndroid::ProfileIsSupervised() const { 90 bool SyncedTabDelegateAndroid::ProfileIsSupervised() const {
104 return tab_contents_delegate_->ProfileIsSupervised(); 91 return tab_contents_delegate_->ProfileIsSupervised();
105 } 92 }
106 93
107 const std::vector<const content::NavigationEntry*>* 94 const std::vector<const sessions::SerializedNavigationEntry*>*
108 SyncedTabDelegateAndroid::GetBlockedNavigations() const { 95 SyncedTabDelegateAndroid::GetBlockedNavigations() const {
109 return tab_contents_delegate_->GetBlockedNavigations(); 96 return tab_contents_delegate_->GetBlockedNavigations();
110 } 97 }
111 98
112 int SyncedTabDelegateAndroid::GetSyncId() const { 99 int SyncedTabDelegateAndroid::GetSyncId() const {
113 return tab_android_->GetSyncId(); 100 return tab_android_->GetSyncId();
114 } 101 }
115 102
116 void SyncedTabDelegateAndroid::SetSyncId(int sync_id) { 103 void SyncedTabDelegateAndroid::SetSyncId(int sync_id) {
117 tab_android_->SetSyncId(sync_id); 104 tab_android_->SetSyncId(sync_id);
118 } 105 }
119 106
120 // static 107 bool SyncedTabDelegateAndroid::ShouldSync(
121 SyncedTabDelegate* SyncedTabDelegate::ImplFromWebContents( 108 sync_sessions::SyncSessionsClient* sessions_client) {
122 content::WebContents* web_contents) { 109 return tab_contents_delegate_->ShouldSync(sessions_client);
123 TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
124 return tab ? tab->GetSyncedTabDelegate() : nullptr;
125 } 110 }
126 111
127 } // namespace browser_sync 112 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698