| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/base/find_in_page_observer.h" | 5 #include "chrome/test/base/find_in_page_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 8 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 9 #include "content/public/test/test_utils.h" | 9 #include "content/public/test/test_utils.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 return; | 31 return; |
| 32 running_ = true; | 32 running_ = true; |
| 33 message_loop_runner_ = new content::MessageLoopRunner; | 33 message_loop_runner_ = new content::MessageLoopRunner; |
| 34 message_loop_runner_->Run(); | 34 message_loop_runner_->Run(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void FindInPageNotificationObserver::Observe( | 37 void FindInPageNotificationObserver::Observe( |
| 38 int type, | 38 int type, |
| 39 const content::NotificationSource& source, | 39 const content::NotificationSource& source, |
| 40 const content::NotificationDetails& details) { | 40 const content::NotificationDetails& details) { |
| 41 if (type == chrome::NOTIFICATION_FIND_RESULT_AVAILABLE) { | 41 DCHECK_EQ(chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, type); |
| 42 content::Details<FindNotificationDetails> find_details(details); | 42 |
| 43 if (find_details->request_id() == current_find_request_id_) { | 43 content::Details<FindNotificationDetails> find_details(details); |
| 44 // We get multiple responses and one of those will contain the ordinal. | 44 if (find_details->request_id() != current_find_request_id_) |
| 45 // This message comes to us before the final update is sent. | 45 return; |
| 46 if (find_details->active_match_ordinal() > -1) { | 46 |
| 47 active_match_ordinal_ = find_details->active_match_ordinal(); | 47 // We get multiple responses and one of those will contain the ordinal. |
| 48 selection_rect_ = find_details->selection_rect(); | 48 // This message comes to us before the final update is sent. |
| 49 } | 49 if (find_details->active_match_ordinal() > -1) { |
| 50 if (find_details->final_update()) { | 50 active_match_ordinal_ = find_details->active_match_ordinal(); |
| 51 number_of_matches_ = find_details->number_of_matches(); | 51 selection_rect_ = find_details->selection_rect(); |
| 52 seen_ = true; | 52 } |
| 53 if (running_) { | 53 if (find_details->final_update()) { |
| 54 running_ = false; | 54 number_of_matches_ = find_details->number_of_matches(); |
| 55 message_loop_runner_->Quit(); | 55 seen_ = true; |
| 56 } | 56 if (running_) { |
| 57 } else { | 57 running_ = false; |
| 58 DVLOG(1) << "Ignoring, since we only care about the final message"; | 58 message_loop_runner_->Quit(); |
| 59 } | |
| 60 } | 59 } |
| 61 } else { | 60 } else { |
| 62 NOTREACHED(); | 61 DVLOG(1) << "Ignoring, since we only care about the final message"; |
| 63 } | 62 } |
| 64 } | 63 } |
| 65 | 64 |
| 66 } // namespace ui_test_utils | 65 } // namespace ui_test_utils |
| 67 | 66 |
| OLD | NEW |