OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "android_webview/browser/find_helper.h" | 5 #include "android_webview/browser/find_helper.h" |
6 | 6 |
7 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" | 7 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 weak_factory_(this) { | 28 weak_factory_(this) { |
29 } | 29 } |
30 | 30 |
31 FindHelper::~FindHelper() { | 31 FindHelper::~FindHelper() { |
32 } | 32 } |
33 | 33 |
34 void FindHelper::SetListener(Listener* listener) { | 34 void FindHelper::SetListener(Listener* listener) { |
35 listener_ = listener; | 35 listener_ = listener; |
36 } | 36 } |
37 | 37 |
38 void FindHelper::FindAllAsync(const string16& search_string) { | 38 void FindHelper::FindAllAsync(const base::string16& search_string) { |
39 // Stop any ongoing asynchronous request. | 39 // Stop any ongoing asynchronous request. |
40 web_contents()->GetRenderViewHost()->StopFinding( | 40 web_contents()->GetRenderViewHost()->StopFinding( |
41 content::STOP_FIND_ACTION_KEEP_SELECTION); | 41 content::STOP_FIND_ACTION_KEEP_SELECTION); |
42 | 42 |
43 sync_find_started_ = false; | 43 sync_find_started_ = false; |
44 async_find_started_ = true; | 44 async_find_started_ = true; |
45 | 45 |
46 WebFindOptions options; | 46 WebFindOptions options; |
47 options.forward = true; | 47 options.forward = true; |
48 options.matchCase = false; | 48 options.matchCase = false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 web_contents()->GetRenderViewHost()->StopFinding( | 83 web_contents()->GetRenderViewHost()->StopFinding( |
84 content::STOP_FIND_ACTION_CLEAR_SELECTION); | 84 content::STOP_FIND_ACTION_CLEAR_SELECTION); |
85 | 85 |
86 sync_find_started_ = false; | 86 sync_find_started_ = false; |
87 async_find_started_ = false; | 87 async_find_started_ = false; |
88 last_search_string_.clear(); | 88 last_search_string_.clear(); |
89 last_match_count_ = -1; | 89 last_match_count_ = -1; |
90 last_active_ordinal_ = -1; | 90 last_active_ordinal_ = -1; |
91 } | 91 } |
92 | 92 |
93 void FindHelper::StartNewRequest(const string16& search_string) { | 93 void FindHelper::StartNewRequest(const base::string16& search_string) { |
94 current_request_id_ = find_request_id_counter_++; | 94 current_request_id_ = find_request_id_counter_++; |
95 last_search_string_ = search_string; | 95 last_search_string_ = search_string; |
96 last_match_count_ = -1; | 96 last_match_count_ = -1; |
97 last_active_ordinal_ = -1; | 97 last_active_ordinal_ = -1; |
98 } | 98 } |
99 | 99 |
100 void FindHelper::NotifyResults(int active_ordinal, | 100 void FindHelper::NotifyResults(int active_ordinal, |
101 int match_count, | 101 int match_count, |
102 bool finished) { | 102 bool finished) { |
103 // Match count or ordinal values set to -1 refer to the received replies. | 103 // Match count or ordinal values set to -1 refer to the received replies. |
(...skipping 25 matching lines...) Expand all Loading... |
129 | 129 |
130 // WebView.FindListener active match ordinals are 0-based while WebKit sends | 130 // WebView.FindListener active match ordinals are 0-based while WebKit sends |
131 // 1-based ordinals. Still we can receive 0 ordinal in case of no results. | 131 // 1-based ordinals. Still we can receive 0 ordinal in case of no results. |
132 active_ordinal = std::max(active_ordinal - 1, 0); | 132 active_ordinal = std::max(active_ordinal - 1, 0); |
133 | 133 |
134 if (listener_) | 134 if (listener_) |
135 listener_->OnFindResultReceived(active_ordinal, match_count, finished); | 135 listener_->OnFindResultReceived(active_ordinal, match_count, finished); |
136 } | 136 } |
137 | 137 |
138 } // namespace android_webview | 138 } // namespace android_webview |
OLD | NEW |