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

Unified Diff: content/browser/find_request_manager.h

Issue 1851793002: Implement a shell of FindRequestManager, and hook it up to WebContentsImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments by ncarter. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/find_bar/find_tab_helper.cc ('k') | content/browser/find_request_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9419d9479e4a3e44027efbc10101bbbbff2bc103
--- /dev/null
+++ b/content/browser/find_request_manager.h
@@ -0,0 +1,126 @@
+// 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.
+
+#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;
+
+// FindRequestManager manages all of the find-in-page requests/replies
+// initiated/received through a WebContents. It coordinates searching across
+// multiple (potentially out-of-process) frames, handles the aggregation of find
+// results from each frame, and facilitates active match traversal. It is
+// instantiated once per WebContents, and is owned by that WebContents.
+//
+// TODO(paulmeyer): FindRequestManager is currently incomplete and does not do
+// all of these things yet, but will soon.
+class FindRequestManager {
+ 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 OnFindReply(RenderFrameHost* rfh,
+ 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,
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
+ 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 NotifyFindReply(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_;
+#endif
+
+ // The WebContents that owns this FindRequestManager.
+ WebContentsImpl* const contents_;
+
+ // The find request ID that uniquely identifies the current find request.
+ int current_request_id_;
+
+ // The request ID of the initial find request in the current find-in-page
+ // session, which uniquely identifies this session. Request IDs are included
+ // in all find-related IPCs, which allows reply IPCs containing results from
+ // previous sessions (with |request_id| < |current_session_id_|) to be easily
+ // identified and ignored.
+ int current_session_id_;
+
+ // 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_
« no previous file with comments | « chrome/browser/ui/find_bar/find_tab_helper.cc ('k') | content/browser/find_request_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698