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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/snapshots/snapshot_cache_web_state_list_observer.mm
diff --git a/ios/chrome/browser/snapshots/snapshot_cache_web_state_list_observer.mm b/ios/chrome/browser/snapshots/snapshot_cache_web_state_list_observer.mm
new file mode 100644
index 0000000000000000000000000000000000000000..c1031e3af4616a05b44e1da50600d4d0252b67df
--- /dev/null
+++ b/ios/chrome/browser/snapshots/snapshot_cache_web_state_list_observer.mm
@@ -0,0 +1,47 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/snapshots/snapshot_cache_web_state_list_observer.h"
+
+#include "base/logging.h"
+#import "ios/chrome/browser/snapshots/snapshot_cache.h"
+#import "ios/chrome/browser/tabs/legacy_tab_helper.h"
+#import "ios/chrome/browser/tabs/tab.h"
+#import "ios/shared/chrome/browser/tabs/web_state_list.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+SnapshotCacheWebStateListObserver::SnapshotCacheWebStateListObserver(
+ SnapshotCache* snapshot_cache)
+ : snapshot_cache_(snapshot_cache) {
+ DCHECK(snapshot_cache_);
+}
+
+SnapshotCacheWebStateListObserver::~SnapshotCacheWebStateListObserver() =
+ default;
+
+void SnapshotCacheWebStateListObserver::WebStateActivatedAt(
+ WebStateList* web_state_list,
+ web::WebState* old_web_state,
+ web::WebState* new_web_state,
+ int active_index,
+ bool user_action) {
+ if (!user_action)
+ return;
+
+ NSMutableSet<NSString*>* set = [NSMutableSet set];
+ if (active_index > 0) {
+ web::WebState* web_state = web_state_list->GetWebStateAt(active_index - 1);
+ [set addObject:LegacyTabHelper::GetTabForWebState(web_state).tabId];
+ }
+
+ if (active_index + 1 < web_state_list->count()) {
+ web::WebState* web_state = web_state_list->GetWebStateAt(active_index + 1);
+ [set addObject:LegacyTabHelper::GetTabForWebState(web_state).tabId];
+ }
+
+ snapshot_cache_.pinnedIDs = [set copy];
+}
« 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