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

Unified Diff: ios/shared/chrome/browser/tabs/web_state_list_observer_bridge.mm

Issue 2812623002: Revert of [ios] Move WebStateList to ios/chrome/browser/web_state_list. (Closed)
Patch Set: Created 3 years, 8 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/shared/chrome/browser/tabs/web_state_list_observer_bridge.mm
diff --git a/ios/shared/chrome/browser/tabs/web_state_list_observer_bridge.mm b/ios/shared/chrome/browser/tabs/web_state_list_observer_bridge.mm
new file mode 100644
index 0000000000000000000000000000000000000000..86e847f6f9f305c8231eceea945c8113a1f0df0a
--- /dev/null
+++ b/ios/shared/chrome/browser/tabs/web_state_list_observer_bridge.mm
@@ -0,0 +1,116 @@
+// 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/shared/chrome/browser/tabs/web_state_list_observer_bridge.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+WebStateListObserverBridge::WebStateListObserverBridge(
+ id<WebStateListObserving> observer)
+ : observer_(observer) {}
+
+WebStateListObserverBridge::~WebStateListObserverBridge() {}
+
+void WebStateListObserverBridge::WebStateInsertedAt(
+ WebStateList* web_state_list,
+ web::WebState* web_state,
+ int index) {
+ const SEL selector = @selector(webStateList:didInsertWebState:atIndex:);
+ if (![observer_ respondsToSelector:selector])
+ return;
+
+ [observer_ webStateList:web_state_list
+ didInsertWebState:web_state
+ atIndex:index];
+}
+
+void WebStateListObserverBridge::WebStateMoved(WebStateList* web_state_list,
+ web::WebState* web_state,
+ int from_index,
+ int to_index) {
+ const SEL selector =
+ @selector(webStateList:didMoveWebState:fromIndex:toIndex:);
+ if (![observer_ respondsToSelector:selector])
+ return;
+
+ [observer_ webStateList:web_state_list
+ didMoveWebState:web_state
+ fromIndex:from_index
+ toIndex:to_index];
+}
+
+void WebStateListObserverBridge::WebStateReplacedAt(
+ WebStateList* web_state_list,
+ web::WebState* old_web_state,
+ web::WebState* new_web_state,
+ int index) {
+ const SEL selector =
+ @selector(webStateList:didReplaceWebState:withWebState:atIndex:);
+ if (![observer_ respondsToSelector:selector])
+ return;
+
+ [observer_ webStateList:web_state_list
+ didReplaceWebState:old_web_state
+ withWebState:new_web_state
+ atIndex:index];
+}
+
+void WebStateListObserverBridge::WillDetachWebStateAt(
+ WebStateList* web_state_list,
+ web::WebState* web_state,
+ int index) {
+ const SEL selector = @selector(webStateList:willDetachWebState:atIndex:);
+ if (![observer_ respondsToSelector:selector])
+ return;
+
+ [observer_ webStateList:web_state_list
+ willDetachWebState:web_state
+ atIndex:index];
+}
+
+void WebStateListObserverBridge::WebStateDetachedAt(
+ WebStateList* web_state_list,
+ web::WebState* web_state,
+ int index) {
+ const SEL selector = @selector(webStateList:didDetachWebState:atIndex:);
+ if (![observer_ respondsToSelector:selector])
+ return;
+
+ [observer_ webStateList:web_state_list
+ didDetachWebState:web_state
+ atIndex:index];
+}
+
+void WebStateListObserverBridge::WillCloseWebStateAt(
+ WebStateList* web_state_list,
+ web::WebState* web_state,
+ int index) {
+ const SEL selector = @selector(webStateList:willCloseWebState:atIndex:);
+ if (![observer_ respondsToSelector:selector])
+ return;
+
+ [observer_ webStateList:web_state_list
+ willCloseWebState:web_state
+ atIndex:index];
+}
+
+void WebStateListObserverBridge::WebStateActivatedAt(
+ WebStateList* web_state_list,
+ web::WebState* old_web_state,
+ web::WebState* new_web_state,
+ int active_index,
+ bool user_action) {
+ const SEL selector = @selector
+ (webStateList:didChangeActiveWebState:oldWebState:atIndex:userAction:);
+ if (![observer_ respondsToSelector:selector])
+ return;
+
+ [observer_ webStateList:web_state_list
+ didChangeActiveWebState:new_web_state
+ oldWebState:old_web_state
+ atIndex:active_index
+ userAction:(user_action ? YES : NO)];
+}

Powered by Google App Engine
This is Rietveld 408576698