OLD | NEW |
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 <queue> | 8 #include <queue> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 blink::WebFindOptions options; | 96 blink::WebFindOptions options; |
97 | 97 |
98 FindRequest() = default; | 98 FindRequest() = default; |
99 FindRequest(int id, | 99 FindRequest(int id, |
100 const base::string16& search_text, | 100 const base::string16& search_text, |
101 const blink::WebFindOptions& options) | 101 const blink::WebFindOptions& options) |
102 : id(id), search_text(search_text), options(options) {} | 102 : id(id), search_text(search_text), options(options) {} |
103 }; | 103 }; |
104 | 104 |
105 // WebContentsObserver implementation. | 105 // WebContentsObserver implementation. |
106 void DidFinishLoad(RenderFrameHost* rfh, const GURL& validated_url) override; | |
107 void RenderFrameDeleted(RenderFrameHost* rfh) override; | 106 void RenderFrameDeleted(RenderFrameHost* rfh) override; |
108 void RenderFrameHostChanged(RenderFrameHost* old_host, | 107 void RenderFrameHostChanged(RenderFrameHost* old_host, |
109 RenderFrameHost* new_host) override; | 108 RenderFrameHost* new_host) override; |
110 void FrameDeleted(RenderFrameHost* rfh) override; | 109 void FrameDeleted(RenderFrameHost* rfh) override; |
111 | 110 |
112 // Resets all of the per-session state for a new find-in-page session. | 111 // Resets all of the per-session state for a new find-in-page session. |
113 void Reset(const FindRequest& initial_request); | 112 void Reset(const FindRequest& initial_request); |
114 | 113 |
115 // Called internally as find requests come up in the queue. | 114 // Called internally as find requests come up in the queue. |
116 void FindInternal(const FindRequest& request); | 115 void FindInternal(const FindRequest& request); |
(...skipping 22 matching lines...) Expand all Loading... |
139 // then the traversal can wrap around past the last frame to the first one (or | 138 // then the traversal can wrap around past the last frame to the first one (or |
140 // vice-versa, if |forward| == false). If no frame can be found under these | 139 // vice-versa, if |forward| == false). If no frame can be found under these |
141 // conditions, nullptr is returned. | 140 // conditions, nullptr is returned. |
142 RenderFrameHost* Traverse(RenderFrameHost* from_rfh, | 141 RenderFrameHost* Traverse(RenderFrameHost* from_rfh, |
143 bool forward, | 142 bool forward, |
144 bool matches_only, | 143 bool matches_only, |
145 bool wrap) const; | 144 bool wrap) const; |
146 | 145 |
147 // Adds a frame to the set of frames that are being searched. The new frame | 146 // Adds a frame to the set of frames that are being searched. The new frame |
148 // will automatically be searched when added, using the same options (stored | 147 // will automatically be searched when added, using the same options (stored |
149 // in |current_request_.options|). |force| should be set to true when a | 148 // in |current_request_.options|). |
150 // dynamic content change is suspected, which will treat the frame as a newly | 149 void AddFrame(RenderFrameHost* rfh); |
151 // added frame even if it has already been searched. This will force a | |
152 // re-search of the frame. | |
153 void AddFrame(RenderFrameHost* rfh, bool force); | |
154 | 150 |
155 // Returns whether |rfh| is in the set of frames being searched in the current | 151 // Returns whether |rfh| is in the set of frames being searched in the current |
156 // find session. | 152 // find session. |
157 bool CheckFrame(RenderFrameHost* rfh) const; | 153 bool CheckFrame(RenderFrameHost* rfh) const; |
158 | 154 |
159 // Computes and updates |active_match_ordinal_| based on |active_frame_| and | 155 // Computes and updates |active_match_ordinal_| based on |active_frame_| and |
160 // |relative_active_match_ordinal_|. | 156 // |relative_active_match_ordinal_|. |
161 void UpdateActiveMatchOrdinal(); | 157 void UpdateActiveMatchOrdinal(); |
162 | 158 |
163 // Called when all pending find replies have been received for the find | 159 // Called when all pending find replies have been received for the find |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 std::queue<FindRequest> find_request_queue_; | 300 std::queue<FindRequest> find_request_queue_; |
305 | 301 |
306 // Keeps track of the find request ID of the last find reply reported via | 302 // Keeps track of the find request ID of the last find reply reported via |
307 // NotifyFindReply(). | 303 // NotifyFindReply(). |
308 int last_reported_id_; | 304 int last_reported_id_; |
309 }; | 305 }; |
310 | 306 |
311 } // namespace content | 307 } // namespace content |
312 | 308 |
313 #endif // CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ | 309 #endif // CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_ |
OLD | NEW |