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

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

Powered by Google App Engine
This is Rietveld 408576698