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

Side by Side Diff: ios/chrome/browser/tabs/tab_model_synced_window_delegate.mm

Issue 2845353002: [ios] ARCMigrate i/c/b/tabs/tab_model_synced_window_delegate*. (Closed)
Patch Set: Created 3 years, 7 months 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "ios/chrome/browser/tabs/tab_model_synced_window_delegate.h" 5 #include "ios/chrome/browser/tabs/tab_model_synced_window_delegate.h"
6 6
7 #include <set>
8
9 #include "base/logging.h" 7 #include "base/logging.h"
10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 8 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
11 #include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h" 9 #include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h"
12 #include "ios/chrome/browser/tabs/tab.h" 10 #import "ios/chrome/browser/web_state_list/web_state_list.h"
13 #include "ios/chrome/browser/tabs/tab_model.h"
14 #import "ios/web/public/web_state/web_state.h" 11 #import "ios/web/public/web_state/web_state.h"
15 12
16 TabModelSyncedWindowDelegate::TabModelSyncedWindowDelegate(TabModel* tab_model) 13 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 : tab_model_(tab_model) {} 14 #error "This file requires ARC support."
15 #endif
16
17 TabModelSyncedWindowDelegate::TabModelSyncedWindowDelegate(
18 WebStateList* web_state_list,
19 SessionID session_id)
20 : web_state_list_(web_state_list), session_id_(session_id) {}
18 21
19 TabModelSyncedWindowDelegate::~TabModelSyncedWindowDelegate() {} 22 TabModelSyncedWindowDelegate::~TabModelSyncedWindowDelegate() {}
20 23
21 bool TabModelSyncedWindowDelegate::IsTabPinned( 24 bool TabModelSyncedWindowDelegate::IsTabPinned(
22 const sync_sessions::SyncedTabDelegate* tab) const { 25 const sync_sessions::SyncedTabDelegate* tab) const {
23 return false; 26 return false;
24 } 27 }
25 28
26 sync_sessions::SyncedTabDelegate* TabModelSyncedWindowDelegate::GetTabAt( 29 sync_sessions::SyncedTabDelegate* TabModelSyncedWindowDelegate::GetTabAt(
27 int index) const { 30 int index) const {
28 sync_sessions::SyncedTabDelegate* delegate = 31 return IOSChromeSyncedTabDelegate::FromWebState(
29 IOSChromeSyncedTabDelegate::FromWebState( 32 web_state_list_->GetWebStateAt(index));
30 [tab_model_ tabAtIndex:index].webState);
31 if (!delegate) {
rohitrao (ping after 24h) 2017/05/04 10:50:04 I wonder why we had this conditional in the old co
sdefresne 2017/05/09 13:06:18 I guess it came from successive refactoring/tinker
32 return nullptr;
33 }
34 return delegate;
35 } 33 }
36 34
37 SessionID::id_type TabModelSyncedWindowDelegate::GetTabIdAt(int index) const { 35 SessionID::id_type TabModelSyncedWindowDelegate::GetTabIdAt(int index) const {
38 return GetTabAt(index)->GetSessionId(); 36 return GetTabAt(index)->GetSessionId();
39 } 37 }
40 38
41 bool TabModelSyncedWindowDelegate::IsSessionRestoreInProgress() const { 39 bool TabModelSyncedWindowDelegate::IsSessionRestoreInProgress() const {
42 return false; 40 return false;
43 } 41 }
44 42
45 bool TabModelSyncedWindowDelegate::HasWindow() const { 43 bool TabModelSyncedWindowDelegate::HasWindow() const {
46 return true; 44 return true;
47 } 45 }
48 46
49 SessionID::id_type TabModelSyncedWindowDelegate::GetSessionId() const { 47 SessionID::id_type TabModelSyncedWindowDelegate::GetSessionId() const {
50 return tab_model_.sessionID.id(); 48 return session_id_.id();
51 } 49 }
52 50
53 int TabModelSyncedWindowDelegate::GetTabCount() const { 51 int TabModelSyncedWindowDelegate::GetTabCount() const {
54 return [tab_model_ count]; 52 return web_state_list_->count();
55 } 53 }
56 54
57 int TabModelSyncedWindowDelegate::GetActiveIndex() const { 55 int TabModelSyncedWindowDelegate::GetActiveIndex() const {
58 Tab* current_tab = [tab_model_ currentTab]; 56 DCHECK_NE(web_state_list_->active_index(), WebStateList::kInvalidIndex);
59 DCHECK(current_tab); 57 return web_state_list_->active_index();
60 return [tab_model_ indexOfTab:current_tab];
61 } 58 }
62 59
63 bool TabModelSyncedWindowDelegate::IsApp() const { 60 bool TabModelSyncedWindowDelegate::IsApp() const {
64 return false; 61 return false;
65 } 62 }
66 63
67 bool TabModelSyncedWindowDelegate::IsTypeTabbed() const { 64 bool TabModelSyncedWindowDelegate::IsTypeTabbed() const {
68 return true; 65 return true;
69 } 66 }
70 67
71 bool TabModelSyncedWindowDelegate::IsTypePopup() const { 68 bool TabModelSyncedWindowDelegate::IsTypePopup() const {
72 return false; 69 return false;
73 } 70 }
74 71
75 bool TabModelSyncedWindowDelegate::ShouldSync() const { 72 bool TabModelSyncedWindowDelegate::ShouldSync() const {
76 return true; 73 return true;
77 } 74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698