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 "chrome/browser/ui/find_bar/find_tab_helper.h" | 5 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // Keep track of what the last search was across the tabs. | 82 // Keep track of what the last search was across the tabs. |
83 Profile* profile = | 83 Profile* profile = |
84 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 84 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
85 FindBarState* find_bar_state = FindBarStateFactory::GetForProfile(profile); | 85 FindBarState* find_bar_state = FindBarStateFactory::GetForProfile(profile); |
86 find_bar_state->set_last_prepopulate_text(find_text_); | 86 find_bar_state->set_last_prepopulate_text(find_text_); |
87 | 87 |
88 WebFindOptions options; | 88 WebFindOptions options; |
89 options.forward = forward_direction; | 89 options.forward = forward_direction; |
90 options.matchCase = case_sensitive; | 90 options.matchCase = case_sensitive; |
91 options.findNext = find_next; | 91 options.findNext = find_next; |
92 web_contents()->GetRenderViewHost()->Find(current_find_request_id_, | 92 web_contents()->Find(current_find_request_id_, find_text_, options); |
93 find_text_, options); | |
94 } | 93 } |
95 | 94 |
96 void FindTabHelper::StopFinding( | 95 void FindTabHelper::StopFinding( |
97 FindBarController::SelectionAction selection_action) { | 96 FindBarController::SelectionAction selection_action) { |
98 if (selection_action == FindBarController::kClearSelectionOnPage) { | 97 if (selection_action == FindBarController::kClearSelectionOnPage) { |
99 // kClearSelection means the find string has been cleared by the user, but | 98 // kClearSelection means the find string has been cleared by the user, but |
100 // the UI has not been dismissed. In that case we want to clear the | 99 // the UI has not been dismissed. In that case we want to clear the |
101 // previously remembered search (http://crbug.com/42639). | 100 // previously remembered search (http://crbug.com/42639). |
102 previous_find_text_ = base::string16(); | 101 previous_find_text_ = base::string16(); |
103 } else { | 102 } else { |
(...skipping 13 matching lines...) Expand all Loading... |
117 case FindBarController::kKeepSelectionOnPage: | 116 case FindBarController::kKeepSelectionOnPage: |
118 action = content::STOP_FIND_ACTION_KEEP_SELECTION; | 117 action = content::STOP_FIND_ACTION_KEEP_SELECTION; |
119 break; | 118 break; |
120 case FindBarController::kActivateSelectionOnPage: | 119 case FindBarController::kActivateSelectionOnPage: |
121 action = content::STOP_FIND_ACTION_ACTIVATE_SELECTION; | 120 action = content::STOP_FIND_ACTION_ACTIVATE_SELECTION; |
122 break; | 121 break; |
123 default: | 122 default: |
124 NOTREACHED(); | 123 NOTREACHED(); |
125 action = content::STOP_FIND_ACTION_KEEP_SELECTION; | 124 action = content::STOP_FIND_ACTION_KEEP_SELECTION; |
126 } | 125 } |
127 web_contents()->GetRenderViewHost()->StopFinding(action); | 126 web_contents()->StopFinding(action); |
128 } | 127 } |
129 | 128 |
130 #if defined(OS_ANDROID) | 129 #if defined(OS_ANDROID) |
131 void FindTabHelper::ActivateNearestFindResult(float x, float y) { | 130 void FindTabHelper::ActivateNearestFindResult(float x, float y) { |
132 if (!find_op_aborted_ && !find_text_.empty()) { | 131 if (!find_op_aborted_ && !find_text_.empty()) { |
133 web_contents()->GetRenderViewHost()->ActivateNearestFindResult( | 132 web_contents()->GetRenderViewHost()->ActivateNearestFindResult( |
134 current_find_request_id_, x, y); | 133 current_find_request_id_, x, y); |
135 } | 134 } |
136 } | 135 } |
137 | 136 |
(...skipping 28 matching lines...) Expand all Loading... |
166 // found. | 165 // found. |
167 last_search_result_ = FindNotificationDetails( | 166 last_search_result_ = FindNotificationDetails( |
168 request_id, number_of_matches, selection, active_match_ordinal, | 167 request_id, number_of_matches, selection, active_match_ordinal, |
169 final_update); | 168 final_update); |
170 content::NotificationService::current()->Notify( | 169 content::NotificationService::current()->Notify( |
171 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, | 170 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, |
172 content::Source<WebContents>(web_contents()), | 171 content::Source<WebContents>(web_contents()), |
173 content::Details<FindNotificationDetails>(&last_search_result_)); | 172 content::Details<FindNotificationDetails>(&last_search_result_)); |
174 } | 173 } |
175 } | 174 } |
OLD | NEW |