Chromium Code Reviews| Index: ios/chrome/browser/find_in_page/find_tab_helper.h |
| diff --git a/ios/chrome/browser/find_in_page/find_tab_helper.h b/ios/chrome/browser/find_in_page/find_tab_helper.h |
| index fc1487421f83f788dcb9f81865f30f11de3e1a3c..17830358b4f0b5e672362e185a5f5898ce3a2e17 100644 |
| --- a/ios/chrome/browser/find_in_page/find_tab_helper.h |
| +++ b/ios/chrome/browser/find_in_page/find_tab_helper.h |
| @@ -5,27 +5,72 @@ |
| #ifndef IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_ |
| #define IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_ |
| +#include <Foundation/Foundation.h> |
| + |
| +#include "base/ios/block_types.h" |
| +#import "base/mac/scoped_nsobject.h" |
| #include "base/macros.h" |
| #include "ios/web/public/web_state/web_state_observer.h" |
| #import "ios/web/public/web_state/web_state_user_data.h" |
| @class FindInPageController; |
| @protocol FindInPageControllerDelegate; |
| +@class FindInPageModel; |
| + |
| +typedef void (^FindInPageCompletionBlock)(FindInPageModel*); |
| // Adds support for the "Find in page" feature. |
| class FindTabHelper : public web::WebStateObserver, |
| public web::WebStateUserData<FindTabHelper> { |
| public: |
| + enum FindDirection { |
| + FORWARD, |
| + REVERSE, |
| + }; |
| + |
| // Creates a FindTabHelper and attaches it to the given |web_state|. |
| // |controller_delegate| can be nil. |
| static void CreateForWebState( |
| web::WebState* web_state, |
| id<FindInPageControllerDelegate> controller_delegate); |
| - // Returns the find in page controller. |
| - FindInPageController* GetController(); |
| + // Starts an asynchronous Find operation that will call the given completion |
| + // handler with results. Always searches in the FORWARD direction. |
| + void StartFinding(NSString* search_string, |
| + FindInPageCompletionBlock completion); |
| + |
| + // Runs an asynchronous Find operation that will call the given completion |
| + // handler with results. Uses the previously remembered search string and |
| + // searches in the given |direction|. |
|
stkhapugin
2017/03/14 14:06:15
Specify how this and other methods can be called w
rohitrao (ping after 24h)
2017/03/14 14:50:53
Added a note about highlighting to the method comm
|
| + void ContinueFinding(FindDirection direction, |
| + FindInPageCompletionBlock completion); |
| + |
| + // Stops any running find operations and runs the given completion block. |
| + void StopFinding(ProceduralBlock completion); |
| + |
| + // Returns the FindInPageModel that contains the latest find results. |
| + FindInPageModel* GetFindResult() const; |
| + |
| + // Returns true if the currently loaded page supports Find in Page. |
| + bool CurrentPageSupportsFindInPage() const; |
| + |
| + // Returns true if the Find in Page UI is currently visible. |
| + bool IsFindUIActive() const; |
| + |
| + // Marks the Find in Page UI as visible or not. This method does not directly |
| + // show or hide the UI. It simply acts as a marker for whether or not the UI |
| + // is visible. |
| + void SetFindUIActive(bool active); |
| + |
| + // Saves the current find text to persistent storage. |
| + void PersistSearchTerm(); |
| + |
| + // Restores the current find text from persistent storage. |
| + void RestoreSearchTerm(); |
| private: |
| + friend class FindTabHelperTest; |
| + |
| FindTabHelper(web::WebState* web_state, |
| id<FindInPageControllerDelegate> controller_delegate); |
| ~FindTabHelper() override; |
| @@ -36,7 +81,7 @@ class FindTabHelper : public web::WebStateObserver, |
| void WebStateDestroyed() override; |
| // The ObjC find in page controller. |
| - FindInPageController* controller_; |
| + base::scoped_nsobject<FindInPageController> controller_; |
| DISALLOW_COPY_AND_ASSIGN(FindTabHelper); |
| }; |