OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/web/public/web_state/web_state_observer.h" | 5 #import "ios/web/public/web_state/web_state_observer.h" |
6 #import "ios/web/public/web_state/web_state_user_data.h" | 6 #import "ios/web/public/web_state/web_state_user_data.h" |
7 | 7 |
8 @protocol SadTabTabHelperDelegate; | 8 @protocol SadTabTabHelperDelegate; |
9 | 9 |
10 #if !defined(__has_feature) || !__has_feature(objc_arc) | 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
11 #error "This file requires ARC support." | 11 #error "This file requires ARC support." |
12 #endif | 12 #endif |
13 | 13 |
14 // SadTabTabHelper listens to RenderProcessGone events and presents a | 14 // SadTabTabHelper listens to RenderProcessGone events and presents a |
15 // SadTabView view appropriately. | 15 // SadTabView view appropriately. |
16 class SadTabTabHelper : public web::WebStateUserData<SadTabTabHelper>, | 16 class SadTabTabHelper : public web::WebStateUserData<SadTabTabHelper>, |
17 public web::WebStateObserver { | 17 public web::WebStateObserver { |
18 public: | 18 public: |
| 19 ~SadTabTabHelper() override; |
| 20 |
19 // Creates a SadTabTabHelper and attaches it to a specific web_state object, | 21 // Creates a SadTabTabHelper and attaches it to a specific web_state object, |
20 // a delegate object controls presentation. | 22 // a delegate object controls presentation. |
21 static void CreateForWebState(web::WebState* web_state, | 23 static void CreateForWebState(web::WebState* web_state, |
22 id<SadTabTabHelperDelegate> delegate); | 24 id<SadTabTabHelperDelegate> delegate); |
23 | 25 |
24 private: | 26 private: |
25 // Constructor for SadTabTabHelper, assigning the helper to a web_state and | 27 // Constructor for SadTabTabHelper, assigning the helper to a web_state and |
26 // providing a delegate. | 28 // providing a delegate. |
27 SadTabTabHelper(web::WebState* web_state, | 29 SadTabTabHelper(web::WebState* web_state, |
28 id<SadTabTabHelperDelegate> delegate); | 30 id<SadTabTabHelperDelegate> delegate); |
29 | 31 |
30 ~SadTabTabHelper() override; | |
31 | |
32 // Presents a new SadTabView via the web_state object. | 32 // Presents a new SadTabView via the web_state object. |
33 void PresentSadTab(); | 33 void PresentSadTab(); |
34 | 34 |
35 // WebStateObserver: | 35 // WebStateObserver: |
36 void RenderProcessGone() override; | 36 void RenderProcessGone() override; |
37 | 37 |
38 // A TabHelperDelegate that can control aspects of this tab helper's behavior. | 38 // A TabHelperDelegate that can control aspects of this tab helper's behavior. |
39 __weak id<SadTabTabHelperDelegate> delegate_; | 39 __weak id<SadTabTabHelperDelegate> delegate_; |
40 }; | 40 }; |
OLD | NEW |