OLD | NEW |
---|---|
(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 #ifndef IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_OBSERVER_BRIDGE_H_ | |
6 #define IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_OBSERVER_BRIDGE_H_ | |
7 | |
8 #import <Foundation/Foundation.h> | |
9 | |
10 #include "base/macros.h" | |
11 #import "ios/shared/chrome/browser/tabs/web_state_list_observer.h" | |
12 | |
13 // Protocol that correspond to WebStateListObserver API. Allows registering | |
14 // Objective-C objects to listen to WebStateList events. | |
15 @protocol WebStateListObserver<NSObject> | |
rohitrao (ping after 24h)
2017/02/14 13:01:26
How does this compile? You can have a protocol wi
marq (ping after 24h)
2017/02/14 13:11:48
Protocols aren't types, so there's no compilation
sdefresne
2017/02/14 13:39:57
Done.
| |
16 | |
17 @optional | |
18 | |
19 // Invoked when a new WebState has been added to the WebStateList at the | |
20 // specified index. | |
21 - (void)webStateList:(WebStateList*)webStateList | |
22 webStateInserted:(web::WebState*)webState | |
rohitrao (ping after 24h)
2017/02/13 20:54:29
To match cocoa touch conventions, consider naming
marq (ping after 24h)
2017/02/14 13:11:48
Yeah, I should have caught this. +1.
sdefresne
2017/02/14 13:39:57
Done.
| |
23 atIndex:(NSUInteger)index; | |
24 | |
25 // Invoked when the WebState at the specified index is moved to another index. | |
26 - (void)webStateList:(WebStateList*)webStateList | |
27 webStateMoved:(web::WebState*)webState | |
28 fromIndex:(NSUInteger)fromIndex | |
29 toIndex:(NSUInteger)toIndex; | |
30 | |
31 // Invoked when the WebState at the specified index is replaced by another | |
32 // WebState. | |
33 - (void)webStateList:(WebStateList*)webStateList | |
34 webStateReplaced:(web::WebState*)oldWebState | |
rohitrao (ping after 24h)
2017/02/13 20:54:29
didReplaceWebState:withWebState:
sdefresne
2017/02/14 13:39:57
Done.
| |
35 byWebState:(web::WebState*)newWebState | |
36 atIndex:(NSUInteger)index; | |
37 | |
38 // Invoked when the WebState at the specified index is being removed. The | |
39 // WebState is still valid but is no longer in the WebStateList. | |
40 - (void)webStateList:(WebStateList*)webStateList | |
41 webStateRemoved:(web::WebState*)webState | |
42 atIndex:(NSUInteger)index; | |
43 | |
44 @end | |
45 | |
46 // Observer that bridges WebStateList events to an Objective-C observer that | |
47 // implements the WebStateListObserver protocol (the observer is owned). | |
48 class WebStateListObserverBridge : public WebStateListObserver { | |
49 public: | |
50 explicit WebStateListObserverBridge(id<WebStateListObserver> observer); | |
51 ~WebStateListObserverBridge() override; | |
52 | |
53 private: | |
54 // WebStateListObserver implementation. | |
55 void WebStateInsertedAt(WebStateList* web_state_list, | |
56 web::WebState* web_state, | |
57 size_t index) override; | |
58 void WebStateMoved(WebStateList* web_state_list, | |
59 web::WebState* web_state, | |
60 size_t from_index, | |
61 size_t to_index) override; | |
62 void WebStateReplacedAt(WebStateList* web_state_list, | |
63 web::WebState* old_web_state, | |
64 web::WebState* new_web_state, | |
65 size_t index) override; | |
66 void WebStateRemovedAt(WebStateList* web_state_list, | |
67 web::WebState* web_state, | |
68 size_t index) override; | |
69 | |
70 id<WebStateListObserver> observer_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(WebStateListObserverBridge); | |
73 }; | |
74 | |
75 #endif // IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_OBSERVER_BRIDGE_H_ | |
OLD | NEW |