OLD | NEW |
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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 SessionID::id_type SyncedTabDelegateAndroid::GetSessionId() const { | 33 SessionID::id_type SyncedTabDelegateAndroid::GetSessionId() const { |
34 return tab_android_->session_id().id(); | 34 return tab_android_->session_id().id(); |
35 } | 35 } |
36 | 36 |
37 bool SyncedTabDelegateAndroid::IsBeingDestroyed() const { | 37 bool SyncedTabDelegateAndroid::IsBeingDestroyed() const { |
38 return tab_contents_delegate_->IsBeingDestroyed(); | 38 return tab_contents_delegate_->IsBeingDestroyed(); |
39 } | 39 } |
40 | 40 |
41 Profile* SyncedTabDelegateAndroid::profile() const { | |
42 return tab_contents_delegate_->profile(); | |
43 } | |
44 | |
45 std::string SyncedTabDelegateAndroid::GetExtensionAppId() const { | 41 std::string SyncedTabDelegateAndroid::GetExtensionAppId() const { |
46 return tab_contents_delegate_->GetExtensionAppId(); | 42 return tab_contents_delegate_->GetExtensionAppId(); |
47 } | 43 } |
48 | 44 |
49 bool SyncedTabDelegateAndroid::IsInitialBlankNavigation() const { | 45 bool SyncedTabDelegateAndroid::IsInitialBlankNavigation() const { |
50 return tab_contents_delegate_->IsInitialBlankNavigation(); | 46 return tab_contents_delegate_->IsInitialBlankNavigation(); |
51 } | 47 } |
52 | 48 |
53 int SyncedTabDelegateAndroid::GetCurrentEntryIndex() const { | 49 int SyncedTabDelegateAndroid::GetCurrentEntryIndex() const { |
54 return tab_contents_delegate_->GetCurrentEntryIndex(); | 50 return tab_contents_delegate_->GetCurrentEntryIndex(); |
55 } | 51 } |
56 | 52 |
57 int SyncedTabDelegateAndroid::GetEntryCount() const { | 53 int SyncedTabDelegateAndroid::GetEntryCount() const { |
58 return tab_contents_delegate_->GetEntryCount(); | 54 return tab_contents_delegate_->GetEntryCount(); |
59 } | 55 } |
60 | 56 |
61 int SyncedTabDelegateAndroid::GetPendingEntryIndex() const { | 57 GURL SyncedTabDelegateAndroid::GetVirtualURLAtIndex(int i) const { |
62 return tab_contents_delegate_->GetPendingEntryIndex(); | 58 return tab_contents_delegate_->GetVirtualURLAtIndex(i); |
63 } | 59 } |
64 | 60 |
65 NavigationEntry* SyncedTabDelegateAndroid::GetPendingEntry() const { | 61 GURL SyncedTabDelegateAndroid::GetFaviconURLAtIndex(int i) const { |
66 return tab_contents_delegate_->GetPendingEntry(); | 62 return tab_contents_delegate_->GetFaviconURLAtIndex(i); |
67 } | 63 } |
68 | 64 |
69 NavigationEntry* SyncedTabDelegateAndroid::GetEntryAtIndex(int i) const { | 65 ui::PageTransition SyncedTabDelegateAndroid::GetTransitionAtIndex( |
70 return tab_contents_delegate_->GetEntryAtIndex(i); | 66 int i) const { |
| 67 return tab_contents_delegate_->GetTransitionAtIndex(i); |
71 } | 68 } |
72 | 69 |
73 NavigationEntry* SyncedTabDelegateAndroid::GetActiveEntry() const { | 70 void SyncedTabDelegateAndroid::GetSerializedNavigationAtIndex( |
74 return tab_contents_delegate_->GetActiveEntry(); | 71 int i, |
| 72 sessions::SerializedNavigationEntry* serialized_entry) const { |
| 73 tab_contents_delegate_->GetSerializedNavigationAtIndex(i, serialized_entry); |
75 } | 74 } |
76 | 75 |
77 bool SyncedTabDelegateAndroid::IsPinned() const { | 76 bool SyncedTabDelegateAndroid::IsPinned() const { |
78 return tab_contents_delegate_->IsPinned(); | 77 return tab_contents_delegate_->IsPinned(); |
79 } | 78 } |
80 | 79 |
81 bool SyncedTabDelegateAndroid::HasWebContents() const { | 80 bool SyncedTabDelegateAndroid::HasWebContents() const { |
82 return web_contents_ != NULL; | 81 return web_contents_ != NULL; |
83 } | 82 } |
84 | 83 |
85 content::WebContents* SyncedTabDelegateAndroid::GetWebContents() const { | |
86 return web_contents_; | |
87 } | |
88 | |
89 void SyncedTabDelegateAndroid::SetWebContents( | 84 void SyncedTabDelegateAndroid::SetWebContents( |
90 content::WebContents* web_contents) { | 85 content::WebContents* web_contents) { |
91 web_contents_ = web_contents; | 86 web_contents_ = web_contents; |
92 TabContentsSyncedTabDelegate::CreateForWebContents(web_contents_); | 87 TabContentsSyncedTabDelegate::CreateForWebContents(web_contents_); |
93 // Store the TabContentsSyncedTabDelegate object that was created. | 88 // Store the TabContentsSyncedTabDelegate object that was created. |
94 tab_contents_delegate_ = | 89 tab_contents_delegate_ = |
95 TabContentsSyncedTabDelegate::FromWebContents(web_contents_); | 90 TabContentsSyncedTabDelegate::FromWebContents(web_contents_); |
96 // Tell it how to get SyncedWindowDelegates or some calls will fail. | 91 // Tell it how to get SyncedWindowDelegates or some calls will fail. |
97 tab_contents_delegate_->SetSyncedWindowGetter( | 92 tab_contents_delegate_->SetSyncedWindowGetter( |
98 make_scoped_ptr(new SyncedWindowDelegatesGetterAndroid())); | 93 make_scoped_ptr(new SyncedWindowDelegatesGetterAndroid())); |
99 } | 94 } |
100 | 95 |
101 void SyncedTabDelegateAndroid::ResetWebContents() { web_contents_ = NULL; } | 96 void SyncedTabDelegateAndroid::ResetWebContents() { web_contents_ = NULL; } |
102 | 97 |
103 bool SyncedTabDelegateAndroid::ProfileIsSupervised() const { | 98 bool SyncedTabDelegateAndroid::ProfileIsSupervised() const { |
104 return tab_contents_delegate_->ProfileIsSupervised(); | 99 return tab_contents_delegate_->ProfileIsSupervised(); |
105 } | 100 } |
106 | 101 |
107 const std::vector<const content::NavigationEntry*>* | 102 const std::vector<const sessions::SerializedNavigationEntry*>* |
108 SyncedTabDelegateAndroid::GetBlockedNavigations() const { | 103 SyncedTabDelegateAndroid::GetBlockedNavigations() const { |
109 return tab_contents_delegate_->GetBlockedNavigations(); | 104 return tab_contents_delegate_->GetBlockedNavigations(); |
110 } | 105 } |
111 | 106 |
112 int SyncedTabDelegateAndroid::GetSyncId() const { | 107 int SyncedTabDelegateAndroid::GetSyncId() const { |
113 return tab_android_->GetSyncId(); | 108 return tab_android_->GetSyncId(); |
114 } | 109 } |
115 | 110 |
116 void SyncedTabDelegateAndroid::SetSyncId(int sync_id) { | 111 void SyncedTabDelegateAndroid::SetSyncId(int sync_id) { |
117 tab_android_->SetSyncId(sync_id); | 112 tab_android_->SetSyncId(sync_id); |
118 } | 113 } |
119 | 114 |
120 // static | |
121 SyncedTabDelegate* SyncedTabDelegate::ImplFromWebContents( | |
122 content::WebContents* web_contents) { | |
123 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); | |
124 return tab ? tab->GetSyncedTabDelegate() : nullptr; | |
125 } | |
126 | |
127 } // namespace browser_sync | 115 } // namespace browser_sync |
OLD | NEW |