Index: content/browser/find_request_manager.h |
diff --git a/content/browser/find_request_manager.h b/content/browser/find_request_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c7334ed09d063c399d64df2c83ff064f408eef8b |
--- /dev/null |
+++ b/content/browser/find_request_manager.h |
@@ -0,0 +1,117 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// FindRequestManager manages all of the find-in-page requests/replies |
+// initiated/received through a WebContents. |
+ |
+#ifndef CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ |
+#define CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ |
+ |
+#include <set> |
+#include <vector> |
+ |
+#include "content/public/common/stop_find_action.h" |
+#include "third_party/WebKit/public/web/WebFindOptions.h" |
+#include "ui/gfx/geometry/rect.h" |
+#include "ui/gfx/geometry/rect_f.h" |
+ |
+namespace content { |
+ |
+class RenderFrameHost; |
+class WebContentsImpl; |
+ |
+class FindRequestManager { |
ncarter (slow)
2016/04/06 19:08:03
Could you add a class comment here?
You can proba
paulmeyer
2016/04/07 17:36:14
Done.
|
+ public: |
+ explicit FindRequestManager(WebContentsImpl* web_contents); |
+ ~FindRequestManager(); |
+ |
+ // Initiates a find operation for |search_text| with the options specified in |
+ // |options|. |request_id| uniquely identifies the find request. |
+ void Find(int request_id, |
+ const base::string16& search_text, |
+ const blink::WebFindOptions& options); |
+ |
+ // Stops the active find session and clears the general highlighting of the |
+ // matches. |action| determines whether the last active match (if any) will be |
+ // activated, cleared, or remain highlighted. |
+ void StopFinding(StopFindAction action); |
+ |
+ // Called when a reply is received from a frame with the results from a |
+ // find request. |
+ void FindReply(RenderFrameHost* rfh, |
ncarter (slow)
2016/04/06 19:08:03
What would you think about naming this method (and
paulmeyer
2016/04/07 17:36:15
That sounds reasonable. Done.
|
+ int request_id, |
+ int number_of_matches, |
+ const gfx::Rect& selection_rect, |
+ int active_match_ordinal, |
+ bool final_update); |
+ |
+#if defined(OS_ANDROID) |
+ // Selects and zooms to the find result nearest to the point (x,y) defined in |
+ // find-in-page coordinates. |
+ void ActivateNearestFindResult(float x, float y); |
+ |
+ // Requests the rects of the current find matches from the renderer process. |
+ void RequestFindMatchRects(int current_version); |
+ |
+ // Called when a reply is received in response to a request for find match |
+ // rects. |
+ void FindMatchRectsReply(RenderFrameHost* rfh, |
+ int version, |
+ const std::vector<gfx::RectF>& rects, |
+ const gfx::RectF& active_rect); |
+#endif |
+ |
+private: |
+ // Reset all of the per-session state for a new find-in-page session. |
+ void Reset(int new_session_id, const base::string16& new_search_text); |
+ |
+ // Send a find IPC to the RenderFrame associated with |rfh| to begin a find |
+ // operation with the search text |current_search_text_| and the find options |
+ // in |current_find_options_|. |
+ void SendFindIPC(int request_id, RenderFrameHost* rfh); |
+ |
+ // Send a stop finding IPC to the RenderFrame associated with |
+ // |render_frame_host|. |
+ void SendStopFindingIPC(StopFindAction action, |
+ RenderFrameHost* rfh) const; |
+ |
+ // Send the find results (as they currently are) to the WebContents. |
+ void SendFindReply(int request_id, bool final_update) const; |
+ |
+#if defined(OS_ANDROID) |
+ // Request the latest find match rects from a frame. |
+ void SendFindMatchRectsIPC(RenderFrameHost* rfh); |
+ |
+ // The latest find match rects version known by the requester. |
+ int fmr_request_version_; |
ncarter (slow)
2016/04/06 19:08:03
fmr -> former ( https://google.github.io/styleguid
paulmeyer
2016/04/07 17:36:15
Actually, "fmr" here means "Find Match Rects". In
ncarter (slow)
2016/04/07 18:19:14
We almost always avoid abbreviations in the names
paulmeyer
2016/04/11 19:35:49
I like the idea of grouping. I've decided to also
|
+#endif |
+ |
+ // The WebContents that owns this FindRequestManager. |
+ WebContentsImpl* const contents_; |
+ |
+ // The find request ID that uniquely identifies this find-in-page session (The |
+ // ID of the initial request of this session). Request IDs are included in all |
+ // find-related IPCs, which allows IPCs containing results from previous |
+ // sessions to be easily identified and ignored. |
+ int current_session_id_; |
ncarter (slow)
2016/04/06 19:08:03
We could consider making find-in-page code use typ
paulmeyer
2016/04/07 17:36:15
I would prefer to keep these as ints. Session IDs
ncarter (slow)
2016/04/07 18:19:14
OK.
|
+ |
+ // The text that is being searched for in the current find-in-page session. |
+ base::string16 current_search_text_; |
+ |
+ // The current set of find options in effect. |
+ blink::WebFindOptions current_find_options_; |
+ |
+ // The total number of matches found in the current find-in-page session. |
+ int number_of_matches_; |
+ |
+ // The overall active match ordinal for the current find-in-page session. |
+ int active_match_ordinal_; |
+ |
+ // The rectangle around the active match, in screen coordinates. |
+ gfx::Rect selection_rect_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ |