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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h"
7 #include "base/memory/ref_counted.h"
8 #include "chrome/browser/android/tab_android.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/glue/synced_window_delegate.h"
11 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h"
12 #include "content/public/browser/navigation_entry.h"
13 #include "content/public/browser/web_contents.h"
15 using content::NavigationEntry
;
17 namespace browser_sync
{
18 SyncedTabDelegateAndroid::SyncedTabDelegateAndroid(TabAndroid
* tab_android
)
19 : web_contents_(NULL
), tab_android_(tab_android
) {}
21 SyncedTabDelegateAndroid::~SyncedTabDelegateAndroid() {}
23 SessionID::id_type
SyncedTabDelegateAndroid::GetWindowId() const {
24 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
28 SessionID::id_type
SyncedTabDelegateAndroid::GetSessionId() const {
29 return tab_android_
->session_id().id();
32 bool SyncedTabDelegateAndroid::IsBeingDestroyed() const {
33 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
37 Profile
* SyncedTabDelegateAndroid::profile() const {
38 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
42 std::string
SyncedTabDelegateAndroid::GetExtensionAppId() const {
43 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
44 ->GetExtensionAppId();
47 int SyncedTabDelegateAndroid::GetCurrentEntryIndex() const {
48 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
49 ->GetCurrentEntryIndex();
52 int SyncedTabDelegateAndroid::GetEntryCount() const {
53 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
57 int SyncedTabDelegateAndroid::GetPendingEntryIndex() const {
58 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
59 ->GetPendingEntryIndex();
62 NavigationEntry
* SyncedTabDelegateAndroid::GetPendingEntry() const {
63 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
67 NavigationEntry
* SyncedTabDelegateAndroid::GetEntryAtIndex(int i
) const {
68 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
72 NavigationEntry
* SyncedTabDelegateAndroid::GetActiveEntry() const {
73 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
77 bool SyncedTabDelegateAndroid::IsPinned() const {
78 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
82 bool SyncedTabDelegateAndroid::HasWebContents() const {
83 return web_contents_
!= NULL
;
86 content::WebContents
* SyncedTabDelegateAndroid::GetWebContents() const {
90 void SyncedTabDelegateAndroid::SetWebContents(
91 content::WebContents
* web_contents
) {
92 web_contents_
= web_contents
;
93 TabContentsSyncedTabDelegate::CreateForWebContents(web_contents_
);
96 void SyncedTabDelegateAndroid::ResetWebContents() { web_contents_
= NULL
; }
98 bool SyncedTabDelegateAndroid::ProfileIsSupervised() const {
99 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
100 ->ProfileIsSupervised();
103 const std::vector
<const content::NavigationEntry
*>*
104 SyncedTabDelegateAndroid::GetBlockedNavigations() const {
105 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_
)
106 ->GetBlockedNavigations();
109 int SyncedTabDelegateAndroid::GetSyncId() const {
110 return tab_android_
->GetSyncId();
113 void SyncedTabDelegateAndroid::SetSyncId(int sync_id
) {
114 tab_android_
->SetSyncId(sync_id
);
118 SyncedTabDelegate
* SyncedTabDelegate::ImplFromWebContents(
119 content::WebContents
* web_contents
) {
120 TabAndroid
* tab
= TabAndroid::FromWebContents(web_contents
);
121 return tab
? tab
->GetSyncedTabDelegate() : NULL
;
124 } // namespace browser_sync