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

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

Issue 2687303003: Convert some of TabModel logic to WebStateListObservers. (Closed)
Patch Set: Rebase. Created 3 years, 10 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
(Empty)
1 // Copyright 2017 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.
4
5 #import "ios/chrome/browser/tabs/tab_model_observers_bridge.h"
6
7 #include "base/logging.h"
8 #import "ios/chrome/browser/tabs/legacy_tab_helper.h"
9 #import "ios/chrome/browser/tabs/tab_model.h"
10 #import "ios/chrome/browser/tabs/tab_model_observers.h"
11
12 #if !defined(__has_feature) || !__has_feature(objc_arc)
13 #error "This file requires ARC support."
14 #endif
15
16 @implementation TabModelObserversBridge {
17 __weak TabModel* _tabModel;
18 __weak TabModelObservers* _tabModelObservers;
19 }
20
21 - (instancetype)initWithTabModel:(TabModel*)tabModel
22 tabModelObservers:(TabModelObservers*)tabModelObservers {
23 DCHECK(tabModel);
24 DCHECK(tabModelObservers);
25 if ((self = [super init])) {
26 _tabModel = tabModel;
27 _tabModelObservers = tabModelObservers;
28 }
29 return self;
30 }
31
32 #pragma mark WebStateListObserving
33
34 - (void)webStateList:(WebStateList*)webStateList
35 didInsertWebState:(web::WebState*)webState
36 atIndex:(int)index {
37 DCHECK_GE(index, 0);
38 [_tabModelObservers tabModel:_tabModel
39 didInsertTab:LegacyTabHelper::GetTabForWebState(webState)
40 atIndex:static_cast<NSUInteger>(index)
41 inForeground:NO];
42 [_tabModelObservers tabModelDidChangeTabCount:_tabModel];
43 }
44
45 - (void)webStateList:(WebStateList*)webStateList
46 didMoveWebState:(web::WebState*)webState
47 fromIndex:(int)fromIndex
48 toIndex:(int)toIndex {
49 DCHECK_GE(fromIndex, 0);
50 DCHECK_GE(toIndex, 0);
51 [_tabModelObservers tabModel:_tabModel
52 didMoveTab:LegacyTabHelper::GetTabForWebState(webState)
53 fromIndex:static_cast<NSUInteger>(fromIndex)
54 toIndex:static_cast<NSUInteger>(toIndex)];
55 }
56
57 - (void)webStateList:(WebStateList*)webStateList
58 didReplaceWebState:(web::WebState*)oldWebState
59 withWebState:(web::WebState*)newWebState
60 atIndex:(int)index {
61 DCHECK_GE(index, 0);
62 [_tabModelObservers tabModel:_tabModel
63 didReplaceTab:LegacyTabHelper::GetTabForWebState(oldWebState)
64 withTab:LegacyTabHelper::GetTabForWebState(newWebState)
65 atIndex:static_cast<NSUInteger>(index)];
66 }
67
68 - (void)webStateList:(WebStateList*)webStateList
69 didDetachWebState:(web::WebState*)webState
70 atIndex:(int)index {
71 DCHECK_GE(index, 0);
72 [_tabModelObservers tabModel:_tabModel
73 didRemoveTab:LegacyTabHelper::GetTabForWebState(webState)
74 atIndex:static_cast<NSUInteger>(index)];
75 [_tabModelObservers tabModelDidChangeTabCount:_tabModel];
76 }
77
78 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab_model_observers_bridge.h ('k') | ios/chrome/browser/tabs/tab_parenting_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698