| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 const content::NotificationSource& source, | 82 const content::NotificationSource& source, |
| 83 const content::NotificationDetails& details) OVERRIDE { | 83 const content::NotificationDetails& details) OVERRIDE { |
| 84 if (type == content::NOTIFICATION_LOAD_STOP) { | 84 if (type == content::NOTIFICATION_LOAD_STOP) { |
| 85 navigation_completed_ = true; | 85 navigation_completed_ = true; |
| 86 } else if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { | 86 } else if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { |
| 87 content::Details<DomOperationNotificationDetails> dom_op_details(details); | 87 content::Details<DomOperationNotificationDetails> dom_op_details(details); |
| 88 javascript_response_ = dom_op_details->json; | 88 javascript_response_ = dom_op_details->json; |
| 89 javascript_completed_ = true; | 89 javascript_completed_ = true; |
| 90 } | 90 } |
| 91 if (javascript_completed_ && navigation_completed_) | 91 if (javascript_completed_ && navigation_completed_) |
| 92 MessageLoopForUI::current()->Quit(); | 92 base::MessageLoopForUI::current()->Quit(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 content::NotificationRegistrar registrar_; | 96 content::NotificationRegistrar registrar_; |
| 97 | 97 |
| 98 // If true the navigation has completed. | 98 // If true the navigation has completed. |
| 99 bool navigation_completed_; | 99 bool navigation_completed_; |
| 100 | 100 |
| 101 // If true the javascript call has completed. | 101 // If true the javascript call has completed. |
| 102 bool javascript_completed_; | 102 bool javascript_completed_; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } else if (type == content::NOTIFICATION_LOAD_STOP) { | 171 } else if (type == content::NOTIFICATION_LOAD_STOP) { |
| 172 if (navigation_started_) { | 172 if (navigation_started_) { |
| 173 navigation_started_ = false; | 173 navigation_started_ = false; |
| 174 navigation_completed_ = true; | 174 navigation_completed_ = true; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 // We're either waiting for just the inforbar, or for both a javascript | 178 // We're either waiting for just the inforbar, or for both a javascript |
| 179 // prompt and response. | 179 // prompt and response. |
| 180 if (wait_for_infobar_ && infobar_) | 180 if (wait_for_infobar_ && infobar_) |
| 181 MessageLoopForUI::current()->Quit(); | 181 base::MessageLoopForUI::current()->Quit(); |
| 182 else if (navigation_completed_ && !javascript_response_.empty()) | 182 else if (navigation_completed_ && !javascript_response_.empty()) |
| 183 MessageLoopForUI::current()->Quit(); | 183 base::MessageLoopForUI::current()->Quit(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 content::NotificationRegistrar registrar_; | 186 content::NotificationRegistrar registrar_; |
| 187 bool wait_for_infobar_; | 187 bool wait_for_infobar_; |
| 188 InfoBarDelegate* infobar_; | 188 InfoBarDelegate* infobar_; |
| 189 bool navigation_started_; | 189 bool navigation_started_; |
| 190 bool navigation_completed_; | 190 bool navigation_completed_; |
| 191 std::string javascript_response_; | 191 std::string javascript_response_; |
| 192 }; | 192 }; |
| 193 | 193 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 std::string script = | 676 std::string script = |
| 677 "window.domAutomationController.send(window.close());"; | 677 "window.domAutomationController.send(window.close());"; |
| 678 bool result = | 678 bool result = |
| 679 content::ExecuteScript( | 679 content::ExecuteScript( |
| 680 current_browser_->tab_strip_model()->GetActiveWebContents(), | 680 current_browser_->tab_strip_model()->GetActiveWebContents(), |
| 681 script); | 681 script); |
| 682 EXPECT_EQ(result, true); | 682 EXPECT_EQ(result, true); |
| 683 } | 683 } |
| 684 | 684 |
| 685 } // namespace | 685 } // namespace |
| OLD | NEW |