OLD | NEW |
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 CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ |
6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ | 6 #define CHROME_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 22 matching lines...) Expand all Loading... |
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( |
40 content::WebContents* guest_web_contents, | 40 content::WebContents* guest_web_contents, |
41 const base::string16& search_text, | 41 const base::string16& search_text, |
42 const blink::WebFindOptions& options, | 42 const blink::WebFindOptions& options, |
43 scoped_refptr<extensions::WebViewInternalFindFunction> find_function); | 43 scoped_refptr<WebViewInternalFindFunction> find_function); |
44 | 44 |
45 // Helper function for WeViewGuest:FindReply(). | 45 // Helper function for WeViewGuest:FindReply(). |
46 void FindReply(int request_id, | 46 void FindReply(int request_id, |
47 int number_of_matches, | 47 int number_of_matches, |
48 const gfx::Rect& selection_rect, | 48 const gfx::Rect& selection_rect, |
49 int active_match_ordinal, | 49 int active_match_ordinal, |
50 bool final_update); | 50 bool final_update); |
51 | 51 |
52 private: | 52 private: |
53 // A wrapper to store find results. | 53 // A wrapper to store find results. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 DISALLOW_COPY_AND_ASSIGN(FindUpdateEvent); | 98 DISALLOW_COPY_AND_ASSIGN(FindUpdateEvent); |
99 }; | 99 }; |
100 | 100 |
101 // Handles all information about a find request and its results. | 101 // Handles all information about a find request and its results. |
102 class FindInfo { | 102 class FindInfo { |
103 public: | 103 public: |
104 FindInfo( | 104 FindInfo( |
105 int request_id, | 105 int request_id, |
106 const base::string16& search_text, | 106 const base::string16& search_text, |
107 const blink::WebFindOptions& options, | 107 const blink::WebFindOptions& options, |
108 scoped_refptr<extensions::WebViewInternalFindFunction> find_function); | 108 scoped_refptr<WebViewInternalFindFunction> find_function); |
109 ~FindInfo(); | 109 ~FindInfo(); |
110 | 110 |
111 // Add another request to |find_next_requests_|. | 111 // Add another request to |find_next_requests_|. |
112 void AddFindNextRequest(const base::WeakPtr<FindInfo>& request) { | 112 void AddFindNextRequest(const base::WeakPtr<FindInfo>& request) { |
113 find_next_requests_.push_back(request); | 113 find_next_requests_.push_back(request); |
114 } | 114 } |
115 | 115 |
116 // Aggregate the find results. | 116 // Aggregate the find results. |
117 void AggregateResults(int number_of_matches, | 117 void AggregateResults(int number_of_matches, |
118 const gfx::Rect& selection_rect, | 118 const gfx::Rect& selection_rect, |
(...skipping 19 matching lines...) Expand all Loading... |
138 } | 138 } |
139 | 139 |
140 // Calls the callback function within |find_function_| with the find results | 140 // Calls the callback function within |find_function_| with the find results |
141 // from within |find_results_|. | 141 // from within |find_results_|. |
142 void SendResponse(bool canceled); | 142 void SendResponse(bool canceled); |
143 | 143 |
144 private: | 144 private: |
145 const int request_id_; | 145 const int request_id_; |
146 const base::string16 search_text_; | 146 const base::string16 search_text_; |
147 blink::WebFindOptions options_; | 147 blink::WebFindOptions options_; |
148 scoped_refptr<extensions::WebViewInternalFindFunction> find_function_; | 148 scoped_refptr<WebViewInternalFindFunction> find_function_; |
149 FindResults find_results_; | 149 FindResults find_results_; |
150 | 150 |
151 // A find reply has been received for this find request. | 151 // A find reply has been received for this find request. |
152 bool replied_; | 152 bool replied_; |
153 | 153 |
154 // Stores pointers to all the find next requests if this is the first | 154 // Stores pointers to all the find next requests if this is the first |
155 // request of a find session. | 155 // request of a find session. |
156 std::vector<base::WeakPtr<FindInfo> > find_next_requests_; | 156 std::vector<base::WeakPtr<FindInfo> > find_next_requests_; |
157 | 157 |
158 // Weak pointer used to access the find info of fin. | 158 // Weak pointer used to access the find info of fin. |
(...skipping 22 matching lines...) Expand all Loading... |
181 // function can be called when its find results are available. | 181 // function can be called when its find results are available. |
182 typedef std::map<int, linked_ptr<FindInfo> > FindInfoMap; | 182 typedef std::map<int, linked_ptr<FindInfo> > FindInfoMap; |
183 FindInfoMap find_info_map_; | 183 FindInfoMap find_info_map_; |
184 | 184 |
185 DISALLOW_COPY_AND_ASSIGN(WebViewFindHelper); | 185 DISALLOW_COPY_AND_ASSIGN(WebViewFindHelper); |
186 }; | 186 }; |
187 | 187 |
188 } // namespace extensions | 188 } // namespace extensions |
189 | 189 |
190 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ | 190 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ |
OLD | NEW |