Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / sync / glue / synced_tab_delegate_android.cc
blob3e5470d1ae5e8fa8af18670fae6d30d4c66d6368
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/sync/sessions/sessions_util.h"
12 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h"
13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/web_contents.h"
16 using content::NavigationEntry;
18 namespace browser_sync {
19 SyncedTabDelegateAndroid::SyncedTabDelegateAndroid(TabAndroid* tab_android)
20 : web_contents_(NULL), tab_android_(tab_android) {}
22 SyncedTabDelegateAndroid::~SyncedTabDelegateAndroid() {}
24 SessionID::id_type SyncedTabDelegateAndroid::GetWindowId() const {
25 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
26 ->GetWindowId();
29 SessionID::id_type SyncedTabDelegateAndroid::GetSessionId() const {
30 return tab_android_->session_id().id();
33 bool SyncedTabDelegateAndroid::IsBeingDestroyed() const {
34 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
35 ->IsBeingDestroyed();
38 Profile* SyncedTabDelegateAndroid::profile() const {
39 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
40 ->profile();
43 std::string SyncedTabDelegateAndroid::GetExtensionAppId() const {
44 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
45 ->GetExtensionAppId();
48 int SyncedTabDelegateAndroid::GetCurrentEntryIndex() const {
49 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
50 ->GetCurrentEntryIndex();
53 int SyncedTabDelegateAndroid::GetEntryCount() const {
54 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
55 ->GetEntryCount();
58 int SyncedTabDelegateAndroid::GetPendingEntryIndex() const {
59 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
60 ->GetPendingEntryIndex();
63 NavigationEntry* SyncedTabDelegateAndroid::GetPendingEntry() const {
64 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
65 ->GetPendingEntry();
68 NavigationEntry* SyncedTabDelegateAndroid::GetEntryAtIndex(int i) const {
69 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
70 ->GetEntryAtIndex(i);
73 NavigationEntry* SyncedTabDelegateAndroid::GetActiveEntry() const {
74 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
75 ->GetActiveEntry();
78 bool SyncedTabDelegateAndroid::IsPinned() const {
79 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
80 ->IsPinned();
83 bool SyncedTabDelegateAndroid::HasWebContents() const {
84 return web_contents_ != NULL;
87 content::WebContents* SyncedTabDelegateAndroid::GetWebContents() const {
88 return web_contents_;
91 void SyncedTabDelegateAndroid::SetWebContents(
92 content::WebContents* web_contents) {
93 web_contents_ = web_contents;
94 TabContentsSyncedTabDelegate::CreateForWebContents(web_contents_);
97 void SyncedTabDelegateAndroid::ResetWebContents() { web_contents_ = NULL; }
99 bool SyncedTabDelegateAndroid::ProfileIsSupervised() const {
100 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
101 ->ProfileIsSupervised();
104 const std::vector<const content::NavigationEntry*>*
105 SyncedTabDelegateAndroid::GetBlockedNavigations() const {
106 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
107 ->GetBlockedNavigations();
110 int SyncedTabDelegateAndroid::GetSyncId() const {
111 return tab_android_->GetSyncId();
114 void SyncedTabDelegateAndroid::SetSyncId(int sync_id) {
115 tab_android_->SetSyncId(sync_id);
119 bool SyncedTabDelegateAndroid::ShouldSync() const {
120 return sessions_util::ShouldSyncTab(*this);
123 // static
124 SyncedTabDelegate* SyncedTabDelegate::ImplFromWebContents(
125 content::WebContents* web_contents) {
126 TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
127 return tab ? tab->GetSyncedTabDelegate() : NULL;
130 } // namespace browser_sync