Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: chrome/browser/ui/find_bar/find_tab_helper.cc

Issue 10905058: Upstream the Android port find-in-page feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit fixes. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/find_bar/find_tab_helper.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/find_bar/find_bar_state.h" 10 #include "chrome/browser/ui/find_bar/find_bar_state.h"
11 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" 11 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h"
12 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
13 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/stop_find_action.h" 16 #include "content/public/common/stop_find_action.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
18 #include "ui/gfx/rect_f.h"
18 19
19 using WebKit::WebFindOptions; 20 using WebKit::WebFindOptions;
20 using content::WebContents; 21 using content::WebContents;
21 22
22 // static 23 // static
23 int FindTabHelper::find_request_id_counter_ = -1; 24 int FindTabHelper::find_request_id_counter_ = -1;
24 25
25 FindTabHelper::FindTabHelper(WebContents* web_contents) 26 FindTabHelper::FindTabHelper(WebContents* web_contents)
26 : content::WebContentsObserver(web_contents), 27 : content::WebContentsObserver(web_contents),
27 find_ui_active_(false), 28 find_ui_active_(false),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 case FindBarController::kActivateSelectionOnPage: 118 case FindBarController::kActivateSelectionOnPage:
118 action = content::STOP_FIND_ACTION_ACTIVATE_SELECTION; 119 action = content::STOP_FIND_ACTION_ACTIVATE_SELECTION;
119 break; 120 break;
120 default: 121 default:
121 NOTREACHED(); 122 NOTREACHED();
122 action = content::STOP_FIND_ACTION_KEEP_SELECTION; 123 action = content::STOP_FIND_ACTION_KEEP_SELECTION;
123 } 124 }
124 web_contents()->GetRenderViewHost()->StopFinding(action); 125 web_contents()->GetRenderViewHost()->StopFinding(action);
125 } 126 }
126 127
128 #if defined(OS_ANDROID)
129 void FindTabHelper::ActivateNearestFindResult(float x, float y) {
130 if (!find_op_aborted_ && !find_text_.empty()) {
131 web_contents()->GetRenderViewHost()->ActivateNearestFindResult(
132 current_find_request_id_, x, y);
133 }
134 }
135
136 void FindTabHelper::RequestFindMatchRects(int current_version) {
137 if (!find_op_aborted_ && !find_text_.empty())
138 web_contents()->GetRenderViewHost()->RequestFindMatchRects(current_version);
139 }
140 #endif
141
127 void FindTabHelper::HandleFindReply(int request_id, 142 void FindTabHelper::HandleFindReply(int request_id,
128 int number_of_matches, 143 int number_of_matches,
129 const gfx::Rect& selection_rect, 144 const gfx::Rect& selection_rect,
130 int active_match_ordinal, 145 int active_match_ordinal,
131 bool final_update) { 146 bool final_update) {
132 // Ignore responses for requests that have been aborted. 147 // Ignore responses for requests that have been aborted.
133 // Ignore responses for requests other than the one we have most recently 148 // Ignore responses for requests other than the one we have most recently
134 // issued. That way we won't act on stale results when the user has 149 // issued. That way we won't act on stale results when the user has
135 // already typed in another query. 150 // already typed in another query.
136 if (!find_op_aborted_ && request_id == current_find_request_id_) { 151 if (!find_op_aborted_ && request_id == current_find_request_id_) {
(...skipping 12 matching lines...) Expand all
149 // found. 164 // found.
150 last_search_result_ = FindNotificationDetails( 165 last_search_result_ = FindNotificationDetails(
151 request_id, number_of_matches, selection, active_match_ordinal, 166 request_id, number_of_matches, selection, active_match_ordinal,
152 final_update); 167 final_update);
153 content::NotificationService::current()->Notify( 168 content::NotificationService::current()->Notify(
154 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, 169 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE,
155 content::Source<WebContents>(web_contents()), 170 content::Source<WebContents>(web_contents()),
156 content::Details<FindNotificationDetails>(&last_search_result_)); 171 content::Details<FindNotificationDetails>(&last_search_result_));
157 } 172 }
158 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/find_bar/find_tab_helper.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698