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

Side by Side Diff: ios/chrome/browser/snapshots/snapshot_cache_web_state_list_observer.mm

Issue 2703333006: Move the notion of current Tab from TabModel to WebStateList. (Closed)
Patch Set: Rebase. Created 3 years, 9 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/snapshots/snapshot_cache_web_state_list_observer.h"
6
7 #include "base/logging.h"
8 #import "ios/chrome/browser/snapshots/snapshot_cache.h"
9 #import "ios/chrome/browser/tabs/legacy_tab_helper.h"
10 #import "ios/chrome/browser/tabs/tab.h"
11 #import "ios/shared/chrome/browser/tabs/web_state_list.h"
12
13 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support."
15 #endif
16
17 SnapshotCacheWebStateListObserver::SnapshotCacheWebStateListObserver(
18 SnapshotCache* snapshot_cache)
19 : snapshot_cache_(snapshot_cache) {
20 DCHECK(snapshot_cache_);
21 }
22
23 SnapshotCacheWebStateListObserver::~SnapshotCacheWebStateListObserver() =
24 default;
25
26 void SnapshotCacheWebStateListObserver::WebStateActivatedAt(
27 WebStateList* web_state_list,
28 web::WebState* old_web_state,
29 web::WebState* new_web_state,
30 int active_index,
31 bool user_action) {
32 if (!user_action)
33 return;
34
35 NSMutableSet<NSString*>* set = [NSMutableSet set];
36 if (active_index > 0) {
37 web::WebState* web_state = web_state_list->GetWebStateAt(active_index - 1);
38 [set addObject:LegacyTabHelper::GetTabForWebState(web_state).tabId];
39 }
40
41 if (active_index + 1 < web_state_list->count()) {
42 web::WebState* web_state = web_state_list->GetWebStateAt(active_index + 1);
43 [set addObject:LegacyTabHelper::GetTabForWebState(web_state).tabId];
44 }
45
46 snapshot_cache_.pinnedIDs = [set copy];
47 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/snapshots/snapshot_cache_web_state_list_observer.h ('k') | ios/chrome/browser/tabs/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698