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

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_find_helper.h

Issue 579563002: Find working in app_shell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase+cleanup Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 18 matching lines...) Expand all
29 void CancelAllFindSessions(); 29 void CancelAllFindSessions();
30 30
31 // Dispatches the |findupdate| event. 31 // Dispatches the |findupdate| event.
32 void DispatchFindUpdateEvent(bool canceled, bool final_update); 32 void DispatchFindUpdateEvent(bool canceled, bool final_update);
33 33
34 // Ends the find session with id |session_request_id| and calls the 34 // Ends the find session with id |session_request_id| and calls the
35 // appropriate callbacks. 35 // appropriate callbacks.
36 void EndFindSession(int session_request_id, bool canceled); 36 void EndFindSession(int session_request_id, bool canceled);
37 37
38 // Helper function for WebViewGuest::Find(). 38 // Helper function for WebViewGuest::Find().
39 void Find( 39 void Find(content::WebContents* guest_web_contents,
40 content::WebContents* guest_web_contents, 40 const base::string16& search_text,
41 const base::string16& search_text, 41 const blink::WebFindOptions& options,
42 const blink::WebFindOptions& options, 42 WebViewInternalFindFunction* find_function);
43 scoped_refptr<WebViewInternalFindFunction> find_function);
44 43
45 // Helper function for WeViewGuest:FindReply(). 44 // Helper function for WeViewGuest:FindReply().
46 void FindReply(int request_id, 45 void FindReply(int request_id,
47 int number_of_matches, 46 int number_of_matches,
48 const gfx::Rect& selection_rect, 47 const gfx::Rect& selection_rect,
49 int active_match_ordinal, 48 int active_match_ordinal,
50 bool final_update); 49 bool final_update);
51 50
52 private: 51 private:
53 // A wrapper to store find results. 52 // A wrapper to store find results.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 private: 93 private:
95 const base::string16 search_text_; 94 const base::string16 search_text_;
96 FindResults find_results_; 95 FindResults find_results_;
97 96
98 DISALLOW_COPY_AND_ASSIGN(FindUpdateEvent); 97 DISALLOW_COPY_AND_ASSIGN(FindUpdateEvent);
99 }; 98 };
100 99
101 // Handles all information about a find request and its results. 100 // Handles all information about a find request and its results.
102 class FindInfo { 101 class FindInfo {
103 public: 102 public:
104 FindInfo( 103 FindInfo(int request_id,
105 int request_id, 104 const base::string16& search_text,
106 const base::string16& search_text, 105 const blink::WebFindOptions& options,
107 const blink::WebFindOptions& options, 106 WebViewInternalFindFunction* find_function);
Fady Samuel 2014/09/18 16:49:48 scoped_refptr?
108 scoped_refptr<WebViewInternalFindFunction> find_function);
109 ~FindInfo(); 107 ~FindInfo();
110 108
111 // Add another request to |find_next_requests_|. 109 // Add another request to |find_next_requests_|.
112 void AddFindNextRequest(const base::WeakPtr<FindInfo>& request) { 110 void AddFindNextRequest(const base::WeakPtr<FindInfo>& request) {
113 find_next_requests_.push_back(request); 111 find_next_requests_.push_back(request);
114 } 112 }
115 113
116 // Aggregate the find results. 114 // Aggregate the find results.
117 void AggregateResults(int number_of_matches, 115 void AggregateResults(int number_of_matches,
118 const gfx::Rect& selection_rect, 116 const gfx::Rect& selection_rect,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // A find reply has been received for this find request. 149 // A find reply has been received for this find request.
152 bool replied_; 150 bool replied_;
153 151
154 // Stores pointers to all the find next requests if this is the first 152 // Stores pointers to all the find next requests if this is the first
155 // request of a find session. 153 // request of a find session.
156 std::vector<base::WeakPtr<FindInfo> > find_next_requests_; 154 std::vector<base::WeakPtr<FindInfo> > find_next_requests_;
157 155
158 friend void WebViewFindHelper::EndFindSession(int session_request_id, 156 friend void WebViewFindHelper::EndFindSession(int session_request_id,
159 bool canceled); 157 bool canceled);
160 158
161 // Weak pointer used to access the find info of fin. 159 // Weak pointer used to access the find info of fin.
162 base::WeakPtrFactory<FindInfo> weak_ptr_factory_; 160 base::WeakPtrFactory<FindInfo> weak_ptr_factory_;
163 161
164 DISALLOW_COPY_AND_ASSIGN(FindInfo); 162 DISALLOW_COPY_AND_ASSIGN(FindInfo);
165 }; 163 };
166 164
167 // Pointer to the webview that is being helped. 165 // Pointer to the webview that is being helped.
168 WebViewGuest* const webview_guest_; 166 WebViewGuest* const webview_guest_;
169 167
170 // A counter to generate a unique request id for a find request. 168 // A counter to generate a unique request id for a find request.
171 // We only need the ids to be unique for a given WebViewGuest. 169 // We only need the ids to be unique for a given WebViewGuest.
172 int current_find_request_id_; 170 int current_find_request_id_;
173 171
174 // Stores aggregated find results and other info for the |findupdate| event. 172 // Stores aggregated find results and other info for the |findupdate| event.
175 scoped_ptr<FindUpdateEvent> find_update_event_; 173 scoped_ptr<FindUpdateEvent> find_update_event_;
176 174
177 // Pointer to the first request of the current find session. 175 // Pointer to the first request of the current find session.
178 linked_ptr<FindInfo> current_find_session_; 176 linked_ptr<FindInfo> current_find_session_;
179 177
180 // Stores each find request's information by request_id so that its callback 178 // Stores each find request's information by request_id so that its callback
181 // function can be called when its find results are available. 179 // function can be called when its find results are available.
182 typedef std::map<int, linked_ptr<FindInfo> > FindInfoMap; 180 typedef std::map<int, linked_ptr<FindInfo> > FindInfoMap;
183 FindInfoMap find_info_map_; 181 FindInfoMap find_info_map_;
184 182
185 DISALLOW_COPY_AND_ASSIGN(WebViewFindHelper); 183 DISALLOW_COPY_AND_ASSIGN(WebViewFindHelper);
186 }; 184 };
187 185
188 } // namespace extensions 186 } // namespace extensions
189 187
190 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ 188 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698