Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / sync / glue / synced_tab_delegate_android.cc
blob3de039e6a987d3227fa9584914ac92ad5800f8e0
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/extensions/tab_helper.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sessions/session_tab_helper.h"
12 #include "chrome/browser/sync/glue/synced_window_delegate.h"
13 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h"
14 #include "content/public/browser/navigation_controller.h"
15 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/web_contents.h"
17 #include "extensions/common/extension.h"
19 using content::NavigationEntry;
21 namespace browser_sync {
22 SyncedTabDelegateAndroid::SyncedTabDelegateAndroid(TabAndroid* tab_android)
23 : web_contents_(NULL), tab_android_(tab_android) {}
25 SyncedTabDelegateAndroid::~SyncedTabDelegateAndroid() {}
27 SessionID::id_type SyncedTabDelegateAndroid::GetWindowId() const {
28 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
29 ->GetWindowId();
32 SessionID::id_type SyncedTabDelegateAndroid::GetSessionId() const {
33 return tab_android_->session_id().id();
36 bool SyncedTabDelegateAndroid::IsBeingDestroyed() const {
37 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
38 ->IsBeingDestroyed();
41 Profile* SyncedTabDelegateAndroid::profile() const {
42 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
43 ->profile();
46 std::string SyncedTabDelegateAndroid::GetExtensionAppId() const {
47 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
48 ->GetExtensionAppId();
51 int SyncedTabDelegateAndroid::GetCurrentEntryIndex() const {
52 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
53 ->GetCurrentEntryIndex();
56 int SyncedTabDelegateAndroid::GetEntryCount() const {
57 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
58 ->GetEntryCount();
61 int SyncedTabDelegateAndroid::GetPendingEntryIndex() const {
62 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
63 ->GetPendingEntryIndex();
66 NavigationEntry* SyncedTabDelegateAndroid::GetPendingEntry() const {
67 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
68 ->GetPendingEntry();
71 NavigationEntry* SyncedTabDelegateAndroid::GetEntryAtIndex(int i) const {
72 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
73 ->GetEntryAtIndex(i);
76 NavigationEntry* SyncedTabDelegateAndroid::GetActiveEntry() const {
77 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
78 ->GetActiveEntry();
81 bool SyncedTabDelegateAndroid::IsPinned() const {
82 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
83 ->IsPinned();
86 bool SyncedTabDelegateAndroid::HasWebContents() const {
87 return web_contents_ != NULL;
90 content::WebContents* SyncedTabDelegateAndroid::GetWebContents() const {
91 return web_contents_;
94 void SyncedTabDelegateAndroid::SetWebContents(
95 content::WebContents* web_contents) {
96 web_contents_ = web_contents;
97 TabContentsSyncedTabDelegate::CreateForWebContents(web_contents_);
100 void SyncedTabDelegateAndroid::ResetWebContents() { web_contents_ = NULL; }
102 bool SyncedTabDelegateAndroid::ProfileIsManaged() const {
103 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
104 ->ProfileIsManaged();
107 const std::vector<const content::NavigationEntry*>*
108 SyncedTabDelegateAndroid::GetBlockedNavigations() const {
109 return TabContentsSyncedTabDelegate::FromWebContents(web_contents_)
110 ->GetBlockedNavigations();
113 int SyncedTabDelegateAndroid::GetSyncId() const {
114 return tab_android_->GetSyncId();
117 void SyncedTabDelegateAndroid::SetSyncId(int sync_id) {
118 tab_android_->SetSyncId(sync_id);
121 // static
122 SyncedTabDelegate* SyncedTabDelegate::ImplFromWebContents(
123 content::WebContents* web_contents) {
124 TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
125 return tab ? tab->GetSyncedTabDelegate() : NULL;
127 } // namespace browser_sync