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

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: 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
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/browser/ui/find_bar/find_match_rects_details.h"
12 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
13 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/stop_find_action.h" 17 #include "content/public/common/stop_find_action.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
19 #include "ui/gfx/rect_f.h"
18 20
19 using WebKit::WebFindOptions; 21 using WebKit::WebFindOptions;
20 using content::WebContents; 22 using content::WebContents;
21 23
22 // static 24 // static
23 int FindTabHelper::find_request_id_counter_ = -1; 25 int FindTabHelper::find_request_id_counter_ = -1;
24 26
25 FindTabHelper::FindTabHelper(WebContents* web_contents) 27 FindTabHelper::FindTabHelper(WebContents* web_contents)
26 : content::WebContentsObserver(web_contents), 28 : content::WebContentsObserver(web_contents),
27 find_ui_active_(false), 29 find_ui_active_(false),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 case FindBarController::kActivateSelectionOnPage: 119 case FindBarController::kActivateSelectionOnPage:
118 action = content::STOP_FIND_ACTION_ACTIVATE_SELECTION; 120 action = content::STOP_FIND_ACTION_ACTIVATE_SELECTION;
119 break; 121 break;
120 default: 122 default:
121 NOTREACHED(); 123 NOTREACHED();
122 action = content::STOP_FIND_ACTION_KEEP_SELECTION; 124 action = content::STOP_FIND_ACTION_KEEP_SELECTION;
123 } 125 }
124 web_contents()->GetRenderViewHost()->StopFinding(action); 126 web_contents()->GetRenderViewHost()->StopFinding(action);
125 } 127 }
126 128
129 #if defined(OS_ANDROID)
130 void FindTabHelper::ActivateNearestFindResult(float x, float y) {
131 if (!find_op_aborted_ && !find_text_.empty()) {
jam 2012/09/04 16:39:09 here and below, are these checks really necessary?
Leandro GraciĆ” Gil 2012/09/04 18:25:50 Probably not if we abort find (it should hide the
132 web_contents()->GetRenderViewHost()->ActivateNearestFindResult(
133 current_find_request_id_, x, y);
134 }
135 }
136
137 void FindTabHelper::RequestFindMatchRects(int current_version) {
138 if (!find_op_aborted_ && !find_text_.empty())
139 web_contents()->GetRenderViewHost()->RequestFindMatchRects(current_version);
140 }
141
142 void FindTabHelper::HandleGetFindMatchRectsReply(
143 int version,
144 const std::vector<gfx::RectF>& rects,
145 const gfx::RectF& active_rect) {
146 FindMatchRectsDetails match_rects(version, rects, active_rect);
147 content::NotificationService::current()->Notify(
148 chrome::NOTIFICATION_FIND_MATCH_RECTS_AVAILABLE,
149 content::Source<WebContents>(web_contents()),
150 content::Details<FindMatchRectsDetails>(&match_rects));
151 }
152 #endif
153
127 void FindTabHelper::HandleFindReply(int request_id, 154 void FindTabHelper::HandleFindReply(int request_id,
128 int number_of_matches, 155 int number_of_matches,
129 const gfx::Rect& selection_rect, 156 const gfx::Rect& selection_rect,
130 int active_match_ordinal, 157 int active_match_ordinal,
131 bool final_update) { 158 bool final_update) {
132 // Ignore responses for requests that have been aborted. 159 // Ignore responses for requests that have been aborted.
133 // Ignore responses for requests other than the one we have most recently 160 // 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 161 // issued. That way we won't act on stale results when the user has
135 // already typed in another query. 162 // already typed in another query.
136 if (!find_op_aborted_ && request_id == current_find_request_id_) { 163 if (!find_op_aborted_ && request_id == current_find_request_id_) {
(...skipping 12 matching lines...) Expand all
149 // found. 176 // found.
150 last_search_result_ = FindNotificationDetails( 177 last_search_result_ = FindNotificationDetails(
151 request_id, number_of_matches, selection, active_match_ordinal, 178 request_id, number_of_matches, selection, active_match_ordinal,
152 final_update); 179 final_update);
153 content::NotificationService::current()->Notify( 180 content::NotificationService::current()->Notify(
154 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, 181 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE,
155 content::Source<WebContents>(web_contents()), 182 content::Source<WebContents>(web_contents()),
156 content::Details<FindNotificationDetails>(&last_search_result_)); 183 content::Details<FindNotificationDetails>(&last_search_result_));
157 } 184 }
158 } 185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698