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 #include "chrome/browser/guest_view/web_view/web_view_find_helper.h" | 5 #include "chrome/browser/guest_view/web_view/web_view_find_helper.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "chrome/browser/extensions/api/web_view/web_view_internal_api.h" | 9 #include "chrome/browser/extensions/api/web_view/web_view_internal_api.h" |
10 #include "chrome/browser/guest_view/web_view/web_view_constants.h" | 10 #include "chrome/browser/guest_view/web_view/web_view_constants.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Erase the first find request's map entry to free the | 81 // Erase the first find request's map entry to free the |
82 // WebViewInternalFindFunction | 82 // WebViewInternalFindFunction |
83 // object. | 83 // object. |
84 find_info_map_.erase(session_request_id); | 84 find_info_map_.erase(session_request_id); |
85 } | 85 } |
86 | 86 |
87 void WebViewFindHelper::Find( | 87 void WebViewFindHelper::Find( |
88 content::WebContents* guest_web_contents, | 88 content::WebContents* guest_web_contents, |
89 const base::string16& search_text, | 89 const base::string16& search_text, |
90 const blink::WebFindOptions& options, | 90 const blink::WebFindOptions& options, |
91 scoped_refptr<extensions::WebViewInternalFindFunction> find_function) { | 91 scoped_refptr<WebViewInternalFindFunction> find_function) { |
92 // Need a new request_id for each new find request. | 92 // Need a new request_id for each new find request. |
93 ++current_find_request_id_; | 93 ++current_find_request_id_; |
94 | 94 |
95 // Stores the find request information by request_id so that its callback | 95 // Stores the find request information by request_id so that its callback |
96 // function can be called when the find results are available. | 96 // function can be called when the find results are available. |
97 std::pair<FindInfoMap::iterator, bool> insert_result = | 97 std::pair<FindInfoMap::iterator, bool> insert_result = |
98 find_info_map_.insert(std::make_pair( | 98 find_info_map_.insert(std::make_pair( |
99 current_find_request_id_, | 99 current_find_request_id_, |
100 linked_ptr< | 100 linked_ptr< |
101 WebViewFindHelper::FindInfo>(new WebViewFindHelper::FindInfo( | 101 WebViewFindHelper::FindInfo>(new WebViewFindHelper::FindInfo( |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 void WebViewFindHelper::FindUpdateEvent::PrepareResults( | 234 void WebViewFindHelper::FindUpdateEvent::PrepareResults( |
235 base::DictionaryValue* results) { | 235 base::DictionaryValue* results) { |
236 results->SetString(webview::kFindSearchText, search_text_); | 236 results->SetString(webview::kFindSearchText, search_text_); |
237 find_results_.PrepareResults(results); | 237 find_results_.PrepareResults(results); |
238 } | 238 } |
239 | 239 |
240 WebViewFindHelper::FindInfo::FindInfo( | 240 WebViewFindHelper::FindInfo::FindInfo( |
241 int request_id, | 241 int request_id, |
242 const base::string16& search_text, | 242 const base::string16& search_text, |
243 const blink::WebFindOptions& options, | 243 const blink::WebFindOptions& options, |
244 scoped_refptr<extensions::WebViewInternalFindFunction> find_function) | 244 scoped_refptr<WebViewInternalFindFunction> find_function) |
245 : request_id_(request_id), | 245 : request_id_(request_id), |
246 search_text_(search_text), | 246 search_text_(search_text), |
247 options_(options), | 247 options_(options), |
248 find_function_(find_function), | 248 find_function_(find_function), |
249 replied_(false), | 249 replied_(false), |
250 weak_ptr_factory_(this) { | 250 weak_ptr_factory_(this) { |
251 } | 251 } |
252 | 252 |
253 WebViewFindHelper::FindInfo::~FindInfo() { | 253 WebViewFindHelper::FindInfo::~FindInfo() { |
254 } | 254 } |
(...skipping 18 matching lines...) Expand all Loading... |
273 base::DictionaryValue results; | 273 base::DictionaryValue results; |
274 find_results_.PrepareResults(&results); | 274 find_results_.PrepareResults(&results); |
275 results.SetBoolean(webview::kFindCanceled, canceled); | 275 results.SetBoolean(webview::kFindCanceled, canceled); |
276 | 276 |
277 // Call the callback. | 277 // Call the callback. |
278 find_function_->SetResult(results.DeepCopy()); | 278 find_function_->SetResult(results.DeepCopy()); |
279 find_function_->SendResponse(true); | 279 find_function_->SendResponse(true); |
280 } | 280 } |
281 | 281 |
282 } // namespace extensions | 282 } // namespace extensions |
OLD | NEW |