| 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 #ifndef IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_ | 5 #ifndef IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_ |
| 6 #define IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_ | 6 #define IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include <Foundation/Foundation.h> | 8 #include <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #include "base/ios/block_types.h" | 10 #include "base/ios/block_types.h" |
| 11 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "ios/web/public/web_state/web_state_observer.h" | 13 #include "ios/web/public/web_state/web_state_observer.h" |
| 14 #import "ios/web/public/web_state/web_state_user_data.h" | 14 #import "ios/web/public/web_state/web_state_user_data.h" |
| 15 | 15 |
| 16 @class FindInPageController; | 16 @class FindInPageController; |
| 17 @protocol FindInPageControllerDelegate; | 17 @protocol FindInPageControllerDelegate; |
| 18 @class FindInPageModel; | 18 @class FindInPageModel; |
| 19 | 19 |
| 20 typedef void (^FindInPageCompletionBlock)(FindInPageModel*); | 20 typedef void (^FindInPageCompletionBlock)(FindInPageModel*); |
| 21 | 21 |
| 22 // Adds support for the "Find in page" feature. | 22 // Adds support for the "Find in page" feature. |
| 23 class FindTabHelper : public web::WebStateObserver, | 23 class FindTabHelper : public web::WebStateObserver, |
| 24 public web::WebStateUserData<FindTabHelper> { | 24 public web::WebStateUserData<FindTabHelper> { |
| 25 public: | 25 public: |
| 26 ~FindTabHelper() override; |
| 27 |
| 26 enum FindDirection { | 28 enum FindDirection { |
| 27 FORWARD, | 29 FORWARD, |
| 28 REVERSE, | 30 REVERSE, |
| 29 }; | 31 }; |
| 30 | 32 |
| 31 // Creates a FindTabHelper and attaches it to the given |web_state|. | 33 // Creates a FindTabHelper and attaches it to the given |web_state|. |
| 32 // |controller_delegate| can be nil. | 34 // |controller_delegate| can be nil. |
| 33 static void CreateForWebState( | 35 static void CreateForWebState( |
| 34 web::WebState* web_state, | 36 web::WebState* web_state, |
| 35 id<FindInPageControllerDelegate> controller_delegate); | 37 id<FindInPageControllerDelegate> controller_delegate); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 void PersistSearchTerm(); | 70 void PersistSearchTerm(); |
| 69 | 71 |
| 70 // Restores the current find text from persistent storage. | 72 // Restores the current find text from persistent storage. |
| 71 void RestoreSearchTerm(); | 73 void RestoreSearchTerm(); |
| 72 | 74 |
| 73 private: | 75 private: |
| 74 friend class FindTabHelperTest; | 76 friend class FindTabHelperTest; |
| 75 | 77 |
| 76 FindTabHelper(web::WebState* web_state, | 78 FindTabHelper(web::WebState* web_state, |
| 77 id<FindInPageControllerDelegate> controller_delegate); | 79 id<FindInPageControllerDelegate> controller_delegate); |
| 78 ~FindTabHelper() override; | |
| 79 | 80 |
| 80 // web::WebStateObserver. | 81 // web::WebStateObserver. |
| 81 void NavigationItemCommitted( | 82 void NavigationItemCommitted( |
| 82 const web::LoadCommittedDetails& load_details) override; | 83 const web::LoadCommittedDetails& load_details) override; |
| 83 void WebStateDestroyed() override; | 84 void WebStateDestroyed() override; |
| 84 | 85 |
| 85 // The ObjC find in page controller. | 86 // The ObjC find in page controller. |
| 86 base::scoped_nsobject<FindInPageController> controller_; | 87 base::scoped_nsobject<FindInPageController> controller_; |
| 87 | 88 |
| 88 DISALLOW_COPY_AND_ASSIGN(FindTabHelper); | 89 DISALLOW_COPY_AND_ASSIGN(FindTabHelper); |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 #endif // IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_ | 92 #endif // IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_ |
| OLD | NEW |