| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "content/common/notification_service.h" | 14 #include "content/common/notification_service.h" |
| 15 #include "content/common/view_messages.h" | 15 #include "content/common/view_message_enums.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" |
| 17 | 17 |
| 18 using WebKit::WebFindOptions; | 18 using WebKit::WebFindOptions; |
| 19 | 19 |
| 20 // static | 20 // static |
| 21 int FindTabHelper::find_request_id_counter_ = -1; | 21 int FindTabHelper::find_request_id_counter_ = -1; |
| 22 | 22 |
| 23 FindTabHelper::FindTabHelper(TabContents* tab_contents) | 23 FindTabHelper::FindTabHelper(TabContents* tab_contents) |
| 24 : TabContentsObserver(tab_contents), | 24 : TabContentsObserver(tab_contents), |
| 25 find_ui_active_(false), | 25 find_ui_active_(false), |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 case FindBarController::kKeepSelection: | 112 case FindBarController::kKeepSelection: |
| 113 params.action = ViewMsg_StopFinding_Params::kKeepSelection; | 113 params.action = ViewMsg_StopFinding_Params::kKeepSelection; |
| 114 break; | 114 break; |
| 115 case FindBarController::kActivateSelection: | 115 case FindBarController::kActivateSelection: |
| 116 params.action = ViewMsg_StopFinding_Params::kActivateSelection; | 116 params.action = ViewMsg_StopFinding_Params::kActivateSelection; |
| 117 break; | 117 break; |
| 118 default: | 118 default: |
| 119 NOTREACHED(); | 119 NOTREACHED(); |
| 120 params.action = ViewMsg_StopFinding_Params::kKeepSelection; | 120 params.action = ViewMsg_StopFinding_Params::kKeepSelection; |
| 121 } | 121 } |
| 122 tab_contents()->render_view_host()->Send(new ViewMsg_StopFinding( | 122 tab_contents()->render_view_host()->StopFinding(params); |
| 123 tab_contents()->render_view_host()->routing_id(), params)); | |
| 124 } | 123 } |
| 125 | 124 |
| 126 void FindTabHelper::HandleFindReply(int request_id, | 125 void FindTabHelper::HandleFindReply(int request_id, |
| 127 int number_of_matches, | 126 int number_of_matches, |
| 128 const gfx::Rect& selection_rect, | 127 const gfx::Rect& selection_rect, |
| 129 int active_match_ordinal, | 128 int active_match_ordinal, |
| 130 bool final_update) { | 129 bool final_update) { |
| 131 // Ignore responses for requests that have been aborted. | 130 // Ignore responses for requests that have been aborted. |
| 132 // Ignore responses for requests other than the one we have most recently | 131 // Ignore responses for requests other than the one we have most recently |
| 133 // issued. That way we won't act on stale results when the user has | 132 // issued. That way we won't act on stale results when the user has |
| (...skipping 11 matching lines...) Expand all Loading... |
| 145 // Notify the UI, automation and any other observers that a find result was | 144 // Notify the UI, automation and any other observers that a find result was |
| 146 // found. | 145 // found. |
| 147 last_search_result_ = FindNotificationDetails( | 146 last_search_result_ = FindNotificationDetails( |
| 148 request_id, number_of_matches, selection, active_match_ordinal, | 147 request_id, number_of_matches, selection, active_match_ordinal, |
| 149 final_update); | 148 final_update); |
| 150 NotificationService::current()->Notify( | 149 NotificationService::current()->Notify( |
| 151 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, | 150 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, |
| 152 Source<TabContents>(tab_contents()), | 151 Source<TabContents>(tab_contents()), |
| 153 Details<FindNotificationDetails>(&last_search_result_)); | 152 Details<FindNotificationDetails>(&last_search_result_)); |
| 154 } | 153 } |
| 155 | |
| 156 // Send a notification to the renderer that we are ready to receive more | |
| 157 // results from the scoping effort of the Find operation. The FindInPage | |
| 158 // scoping is asynchronous and periodically sends results back up to the | |
| 159 // browser using IPC. In an effort to not spam the browser we have the | |
| 160 // browser send an ACK for each FindReply message and have the renderer | |
| 161 // queue up the latest status message while waiting for this ACK. | |
| 162 Send(new ViewMsg_FindReplyACK(routing_id())); | |
| 163 } | 154 } |
| OLD | NEW |