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

Side by Side Diff: ios/chrome/browser/find_in_page/find_tab_helper.h

Issue 2724683002: [ios] Moves the Find in Page APIs into FindTabHelper. (Closed)
Patch Set: Review Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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>
9
10 #include "base/ios/block_types.h"
11 #import "base/mac/scoped_nsobject.h"
8 #include "base/macros.h" 12 #include "base/macros.h"
9 #include "ios/web/public/web_state/web_state_observer.h" 13 #include "ios/web/public/web_state/web_state_observer.h"
10 #import "ios/web/public/web_state/web_state_user_data.h" 14 #import "ios/web/public/web_state/web_state_user_data.h"
11 15
12 @class FindInPageController; 16 @class FindInPageController;
13 @protocol FindInPageControllerDelegate; 17 @protocol FindInPageControllerDelegate;
18 @class FindInPageModel;
19
20 typedef void (^FindInPageCompletionBlock)(FindInPageModel*);
14 21
15 // Adds support for the "Find in page" feature. 22 // Adds support for the "Find in page" feature.
16 class FindTabHelper : public web::WebStateObserver, 23 class FindTabHelper : public web::WebStateObserver,
17 public web::WebStateUserData<FindTabHelper> { 24 public web::WebStateUserData<FindTabHelper> {
18 public: 25 public:
26 enum FindDirection {
27 FORWARD,
28 REVERSE,
29 };
30
19 // Creates a FindTabHelper and attaches it to the given |web_state|. 31 // Creates a FindTabHelper and attaches it to the given |web_state|.
20 // |controller_delegate| can be nil. 32 // |controller_delegate| can be nil.
21 static void CreateForWebState( 33 static void CreateForWebState(
22 web::WebState* web_state, 34 web::WebState* web_state,
23 id<FindInPageControllerDelegate> controller_delegate); 35 id<FindInPageControllerDelegate> controller_delegate);
24 36
25 // Returns the find in page controller. 37 // Starts an asynchronous Find operation that will call the given completion
26 FindInPageController* GetController(); 38 // handler with results. Highlights matches on the current page. Always
39 // searches in the FORWARD direction.
40 void StartFinding(NSString* search_string,
41 FindInPageCompletionBlock completion);
42
43 // Runs an asynchronous Find operation that will call the given completion
44 // handler with results. Highlights matches on the current page. Uses the
45 // previously remembered search string and searches in the given |direction|.
46 void ContinueFinding(FindDirection direction,
47 FindInPageCompletionBlock completion);
48
49 // Stops any running find operations and runs the given completion block.
50 // Removes any highlighting from the current page.
51 void StopFinding(ProceduralBlock completion);
52
53 // Returns the FindInPageModel that contains the latest find results.
54 FindInPageModel* GetFindResult() const;
55
56 // Returns true if the currently loaded page supports Find in Page.
57 bool CurrentPageSupportsFindInPage() const;
58
59 // Returns true if the Find in Page UI is currently visible.
60 bool IsFindUIActive() const;
61
62 // Marks the Find in Page UI as visible or not. This method does not directly
63 // show or hide the UI. It simply acts as a marker for whether or not the UI
64 // is visible.
65 void SetFindUIActive(bool active);
66
67 // Saves the current find text to persistent storage.
68 void PersistSearchTerm();
69
70 // Restores the current find text from persistent storage.
71 void RestoreSearchTerm();
27 72
28 private: 73 private:
74 friend class FindTabHelperTest;
75
29 FindTabHelper(web::WebState* web_state, 76 FindTabHelper(web::WebState* web_state,
30 id<FindInPageControllerDelegate> controller_delegate); 77 id<FindInPageControllerDelegate> controller_delegate);
31 ~FindTabHelper() override; 78 ~FindTabHelper() override;
32 79
33 // web::WebStateObserver. 80 // web::WebStateObserver.
34 void NavigationItemCommitted( 81 void NavigationItemCommitted(
35 const web::LoadCommittedDetails& load_details) override; 82 const web::LoadCommittedDetails& load_details) override;
36 void WebStateDestroyed() override; 83 void WebStateDestroyed() override;
37 84
38 // The ObjC find in page controller. 85 // The ObjC find in page controller.
39 FindInPageController* controller_; 86 base::scoped_nsobject<FindInPageController> controller_;
40 87
41 DISALLOW_COPY_AND_ASSIGN(FindTabHelper); 88 DISALLOW_COPY_AND_ASSIGN(FindTabHelper);
42 }; 89 };
43 90
44 #endif // IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_ 91 #endif // IOS_CHROME_BROWSER_FIND_IN_PAGE_FIND_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/find_in_page/find_in_page_controller.mm ('k') | ios/chrome/browser/find_in_page/find_tab_helper.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698