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

Side by Side Diff: content/browser/find_request_manager.h

Issue 1891773002: Implement the basic testing infrastructure for FindRequestManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments by nasko@. 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_
6 #define CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ 6 #define CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "content/common/content_export.h"
11 #include "content/public/common/stop_find_action.h" 12 #include "content/public/common/stop_find_action.h"
12 #include "third_party/WebKit/public/web/WebFindOptions.h" 13 #include "third_party/WebKit/public/web/WebFindOptions.h"
13 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/rect_f.h" 15 #include "ui/gfx/geometry/rect_f.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 class RenderFrameHost; 19 class RenderFrameHost;
19 class WebContentsImpl; 20 class WebContentsImpl;
20 21
21 // FindRequestManager manages all of the find-in-page requests/replies 22 // FindRequestManager manages all of the find-in-page requests/replies
22 // initiated/received through a WebContents. It coordinates searching across 23 // initiated/received through a WebContents. It coordinates searching across
23 // multiple (potentially out-of-process) frames, handles the aggregation of find 24 // multiple (potentially out-of-process) frames, handles the aggregation of find
24 // results from each frame, and facilitates active match traversal. It is 25 // results from each frame, and facilitates active match traversal. It is
25 // instantiated once per WebContents, and is owned by that WebContents. 26 // instantiated once per WebContents, and is owned by that WebContents.
26 // 27 //
27 // TODO(paulmeyer): FindRequestManager is currently incomplete and does not do 28 // TODO(paulmeyer): FindRequestManager is currently incomplete and does not do
28 // all of these things yet, but will soon. 29 // all of these things yet, but will soon.
29 class FindRequestManager { 30 class CONTENT_EXPORT FindRequestManager {
30 public: 31 public:
31 explicit FindRequestManager(WebContentsImpl* web_contents); 32 explicit FindRequestManager(WebContentsImpl* web_contents);
32 ~FindRequestManager(); 33 virtual ~FindRequestManager();
nasko 2016/04/18 21:02:39 We no longer need these extra virtuals, as there i
paulmeyer 2016/04/19 15:15:00 That's right. Done.
33 34
34 // Initiates a find operation for |search_text| with the options specified in 35 // Initiates a find operation for |search_text| with the options specified in
35 // |options|. |request_id| uniquely identifies the find request. 36 // |options|. |request_id| uniquely identifies the find request.
36 void Find(int request_id, 37 virtual void Find(int request_id,
37 const base::string16& search_text, 38 const base::string16& search_text,
38 const blink::WebFindOptions& options); 39 const blink::WebFindOptions& options);
39 40
40 // Stops the active find session and clears the general highlighting of the 41 // 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 // matches. |action| determines whether the last active match (if any) will be
42 // activated, cleared, or remain highlighted. 43 // activated, cleared, or remain highlighted.
43 void StopFinding(StopFindAction action); 44 void StopFinding(StopFindAction action);
44 45
45 // Called when a reply is received from a frame with the results from a 46 // Called when a reply is received from a frame with the results from a
46 // find request. 47 // find request.
47 void OnFindReply(RenderFrameHost* rfh, 48 void OnFindReply(RenderFrameHost* rfh,
48 int request_id, 49 int request_id,
(...skipping 11 matching lines...) Expand all
60 void RequestFindMatchRects(int current_version); 61 void RequestFindMatchRects(int current_version);
61 62
62 // Called when a reply is received in response to a request for find match 63 // Called when a reply is received in response to a request for find match
63 // rects. 64 // rects.
64 void OnFindMatchRectsReply(RenderFrameHost* rfh, 65 void OnFindMatchRectsReply(RenderFrameHost* rfh,
65 int version, 66 int version,
66 const std::vector<gfx::RectF>& rects, 67 const std::vector<gfx::RectF>& rects,
67 const gfx::RectF& active_rect); 68 const gfx::RectF& active_rect);
68 #endif 69 #endif
69 70
70 private: 71 protected:
71 // An invalid ID. This value is invalid for any render process ID, render 72 // An invalid ID. This value is invalid for any render process ID, render
72 // frame ID, or find request ID. 73 // frame ID, or find request ID.
73 static const int kInvalidId; 74 static const int kInvalidId;
74 75
75 // The request data for a single find request. 76 // The request data for a single find request.
76 struct FindRequest { 77 struct FindRequest {
77 // The find request ID that uniquely identifies this find request. 78 // The find request ID that uniquely identifies this find request.
78 int id = kInvalidId; 79 int id = kInvalidId;
79 80
80 // The text that is being searched for in this find request. 81 // The text that is being searched for in this find request.
(...skipping 13 matching lines...) Expand all
94 // associated with |rfh|. 95 // associated with |rfh|.
95 void SendFindIPC(const FindRequest& request, RenderFrameHost* rfh); 96 void SendFindIPC(const FindRequest& request, RenderFrameHost* rfh);
96 97
97 // Send a stop finding IPC to the RenderFrame associated with |rfh|. 98 // Send a stop finding IPC to the RenderFrame associated with |rfh|.
98 void SendStopFindingIPC(StopFindAction action, RenderFrameHost* rfh) const; 99 void SendStopFindingIPC(StopFindAction action, RenderFrameHost* rfh) const;
99 100
100 // Reset all of the per-session state for a new find-in-page session. 101 // Reset all of the per-session state for a new find-in-page session.
101 void Reset(const FindRequest& initial_request); 102 void Reset(const FindRequest& initial_request);
102 103
103 // Send the find results (as they currently are) to the WebContents. 104 // Send the find results (as they currently are) to the WebContents.
104 void NotifyFindReply(int request_id, bool final_update) const; 105 virtual void NotifyFindReply(int request_id, bool final_update) const;
105 106
106 #if defined(OS_ANDROID) 107 #if defined(OS_ANDROID)
107 // Request the latest find match rects from a frame. 108 // Request the latest find match rects from a frame.
108 void SendFindMatchRectsIPC(RenderFrameHost* rfh); 109 void SendFindMatchRectsIPC(RenderFrameHost* rfh);
109 110
110 // State related to FindMatchRects requests. 111 // State related to FindMatchRects requests.
111 struct FindMatchRectsState { 112 struct FindMatchRectsState {
112 // The latest find match rects version known by the requester. 113 // The latest find match rects version known by the requester.
113 int request_version = kInvalidId; 114 int request_version = kInvalidId;
114 } match_rects_; 115 } match_rects_;
(...skipping 18 matching lines...) Expand all
133 // The overall active match ordinal for the current find-in-page session. 134 // The overall active match ordinal for the current find-in-page session.
134 int active_match_ordinal_; 135 int active_match_ordinal_;
135 136
136 // The rectangle around the active match, in screen coordinates. 137 // The rectangle around the active match, in screen coordinates.
137 gfx::Rect selection_rect_; 138 gfx::Rect selection_rect_;
138 }; 139 };
139 140
140 } // namespace content 141 } // namespace content
141 142
142 #endif // CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ 143 #endif // CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/find_request_manager.cc » ('j') | content/browser/find_request_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698