| 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 "extensions/browser/guest_view/web_view/web_view_find_helper.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_find_helper.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "components/guest_view/browser/guest_view_event.h" | 9 #include "components/guest_view/browser/guest_view_event.h" |
| 10 #include "extensions/browser/api/guest_view/web_view/web_view_internal_api.h" | 10 #include "extensions/browser/api/guest_view/web_view/web_view_internal_api.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (full_options->findNext && current_find_session_.get()) { | 125 if (full_options->findNext && current_find_session_.get()) { |
| 126 DCHECK(current_find_request_id_ != current_find_session_->request_id()); | 126 DCHECK(current_find_request_id_ != current_find_session_->request_id()); |
| 127 current_find_session_->AddFindNextRequest( | 127 current_find_session_->AddFindNextRequest( |
| 128 insert_result.first->second->AsWeakPtr()); | 128 insert_result.first->second->AsWeakPtr()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Update the current find session, if necessary. | 131 // Update the current find session, if necessary. |
| 132 if (!full_options->findNext) | 132 if (!full_options->findNext) |
| 133 current_find_session_ = insert_result.first->second; | 133 current_find_session_ = insert_result.first->second; |
| 134 | 134 |
| 135 // Handle the empty |search_text| case internally. |
| 136 if (search_text.empty()) { |
| 137 guest_web_contents->StopFinding(content::STOP_FIND_ACTION_CLEAR_SELECTION); |
| 138 FindReply(current_find_request_id_, 0, gfx::Rect(), 0, true); |
| 139 return; |
| 140 } |
| 141 |
| 135 guest_web_contents->Find(current_find_request_id_, | 142 guest_web_contents->Find(current_find_request_id_, |
| 136 search_text, *full_options); | 143 search_text, *full_options); |
| 137 } | 144 } |
| 138 | 145 |
| 139 void WebViewFindHelper::FindReply(int request_id, | 146 void WebViewFindHelper::FindReply(int request_id, |
| 140 int number_of_matches, | 147 int number_of_matches, |
| 141 const gfx::Rect& selection_rect, | 148 const gfx::Rect& selection_rect, |
| 142 int active_match_ordinal, | 149 int active_match_ordinal, |
| 143 bool final_update) { | 150 bool final_update) { |
| 144 FindInfoMap::iterator find_iterator = find_info_map_.find(request_id); | 151 FindInfoMap::iterator find_iterator = find_info_map_.find(request_id); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 base::DictionaryValue results; | 283 base::DictionaryValue results; |
| 277 find_results_.PrepareResults(&results); | 284 find_results_.PrepareResults(&results); |
| 278 results.SetBoolean(webview::kFindCanceled, canceled); | 285 results.SetBoolean(webview::kFindCanceled, canceled); |
| 279 | 286 |
| 280 // Call the callback. | 287 // Call the callback. |
| 281 find_function_->SetResult(results.DeepCopy()); | 288 find_function_->SetResult(results.DeepCopy()); |
| 282 find_function_->SendResponse(true); | 289 find_function_->SendResponse(true); |
| 283 } | 290 } |
| 284 | 291 |
| 285 } // namespace extensions | 292 } // namespace extensions |
| OLD | NEW |