OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ | |
6 #define CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ | |
7 | |
8 #include <set> | |
9 #include <vector> | |
10 | |
11 #include "content/public/common/stop_find_action.h" | |
12 #include "third_party/WebKit/public/web/WebFindOptions.h" | |
13 #include "ui/gfx/geometry/rect.h" | |
14 #include "ui/gfx/geometry/rect_f.h" | |
15 | |
16 namespace content { | |
17 | |
18 class RenderFrameHost; | |
19 class WebContentsImpl; | |
20 | |
21 // FindRequestManager manages all of the find-in-page requests/replies | |
22 // initiated/received through a WebContents. It coordinates searching across | |
23 // multiple (potentially out-of-process) frames, handles the aggregation of find | |
24 // results from each frame, and facilitates active match traversal. It is | |
25 // instantiated once per WebContents, and is owned by that WebContents. | |
26 // | |
27 // TODO(paulmeyer): FindRequestManager is currently incomplete and does not do | |
28 // all of these things yet, but will soon. | |
29 class FindRequestManager { | |
30 public: | |
31 explicit FindRequestManager(WebContentsImpl* web_contents); | |
32 ~FindRequestManager(); | |
33 | |
34 // Initiates a find operation for |search_text| with the options specified in | |
35 // |options|. |request_id| uniquely identifies the find request. | |
36 void Find(int request_id, | |
37 const base::string16& search_text, | |
38 const blink::WebFindOptions& options); | |
39 | |
40 // Stops the active find session and clears the general highlighting of the | |
41 // matches. |action| determines whether the last active match (if any) will be | |
42 // activated, cleared, or remain highlighted. | |
43 void StopFinding(StopFindAction action); | |
44 | |
45 // Called when a reply is received from a frame with the results from a | |
46 // find request. | |
47 void OnFindReply(RenderFrameHost* rfh, | |
48 int request_id, | |
49 int number_of_matches, | |
50 const gfx::Rect& selection_rect, | |
51 int active_match_ordinal, | |
52 bool final_update); | |
53 | |
54 #if defined(OS_ANDROID) | |
55 // Selects and zooms to the find result nearest to the point (x,y) defined in | |
56 // find-in-page coordinates. | |
57 void ActivateNearestFindResult(float x, float y); | |
58 | |
59 // Requests the rects of the current find matches from the renderer process. | |
60 void RequestFindMatchRects(int current_version); | |
61 | |
62 // Called when a reply is received in response to a request for find match | |
63 // rects. | |
64 void FindMatchRectsReply(RenderFrameHost* rfh, | |
ncarter (slow)
2016/04/07 18:19:14
Rename to OnFindMatchRectsReply, to match OnFindRe
paulmeyer
2016/04/11 19:35:49
Sorry, missed that. Done. I've also added Notify t
| |
65 int version, | |
66 const std::vector<gfx::RectF>& rects, | |
67 const gfx::RectF& active_rect); | |
68 #endif | |
69 | |
70 private: | |
71 // Reset all of the per-session state for a new find-in-page session. | |
72 void Reset(int new_session_id, const base::string16& new_search_text); | |
73 | |
74 // Send a find IPC to the RenderFrame associated with |rfh| to begin a find | |
75 // operation with the search text |current_search_text_| and the find options | |
76 // in |current_find_options_|. | |
77 void SendFindIPC(int request_id, RenderFrameHost* rfh); | |
78 | |
79 // Send a stop finding IPC to the RenderFrame associated with | |
80 // |render_frame_host|. | |
81 void SendStopFindingIPC(StopFindAction action, | |
82 RenderFrameHost* rfh) const; | |
83 | |
84 // Send the find results (as they currently are) to the WebContents. | |
85 void NotifyFindReply(int request_id, bool final_update) const; | |
86 | |
87 #if defined(OS_ANDROID) | |
88 // Request the latest find match rects from a frame. | |
89 void SendFindMatchRectsIPC(RenderFrameHost* rfh); | |
90 | |
91 // The latest find match rects version known by the requester. | |
92 int fmr_request_version_; | |
93 #endif | |
94 | |
95 // The WebContents that owns this FindRequestManager. | |
96 WebContentsImpl* const contents_; | |
97 | |
98 // The find request ID that uniquely identifies the current find request. | |
99 int current_request_id_; | |
100 | |
101 // The request ID of the initial find request in the current find-in-page | |
102 // session, which uniquely identifies this session. Request IDs are included | |
103 // in all find-related IPCs, which allows reply IPCs containing results from | |
104 // previous sessions (with |request_id| < |current_session_id_|) to be easily | |
105 // identified and ignored. | |
106 int current_session_id_; | |
107 | |
108 // The text that is being searched for in the current find-in-page session. | |
109 base::string16 current_search_text_; | |
110 | |
111 // The current set of find options in effect. | |
112 blink::WebFindOptions current_find_options_; | |
113 | |
114 // The total number of matches found in the current find-in-page session. | |
115 int number_of_matches_; | |
116 | |
117 // The overall active match ordinal for the current find-in-page session. | |
118 int active_match_ordinal_; | |
119 | |
120 // The rectangle around the active match, in screen coordinates. | |
121 gfx::Rect selection_rect_; | |
122 }; | |
123 | |
124 } // namespace content | |
125 | |
126 #endif // CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ | |
OLD | NEW |