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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 const content::NotificationSource& source, | 109 const content::NotificationSource& source, |
110 const content::NotificationDetails& details) { | 110 const content::NotificationDetails& details) { |
111 if (type == content::NOTIFICATION_LOAD_STOP) { | 111 if (type == content::NOTIFICATION_LOAD_STOP) { |
112 navigation_completed_ = true; | 112 navigation_completed_ = true; |
113 } else if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { | 113 } else if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { |
114 content::Details<DomOperationNotificationDetails> dom_op_details(details); | 114 content::Details<DomOperationNotificationDetails> dom_op_details(details); |
115 javascript_response_ = dom_op_details->json; | 115 javascript_response_ = dom_op_details->json; |
116 javascript_completed_ = true; | 116 javascript_completed_ = true; |
117 } | 117 } |
118 if (javascript_completed_ && navigation_completed_) | 118 if (javascript_completed_ && navigation_completed_) |
119 MessageLoopForUI::current()->Quit(); | 119 base::MessageLoopForUI::current()->Quit(); |
120 } | 120 } |
121 | 121 |
122 | 122 |
123 // GeolocationNotificationObserver -------------------------------------------- | 123 // GeolocationNotificationObserver -------------------------------------------- |
124 | 124 |
125 class GeolocationNotificationObserver : public content::NotificationObserver { | 125 class GeolocationNotificationObserver : public content::NotificationObserver { |
126 public: | 126 public: |
127 // If |wait_for_infobar| is true, AddWatchAndWaitForNotification will block | 127 // If |wait_for_infobar| is true, AddWatchAndWaitForNotification will block |
128 // until the infobar has been displayed; otherwise it will block until the | 128 // until the infobar has been displayed; otherwise it will block until the |
129 // navigation is completed. | 129 // navigation is completed. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } else if (type == content::NOTIFICATION_LOAD_STOP) { | 187 } else if (type == content::NOTIFICATION_LOAD_STOP) { |
188 if (navigation_started_) { | 188 if (navigation_started_) { |
189 navigation_started_ = false; | 189 navigation_started_ = false; |
190 navigation_completed_ = true; | 190 navigation_completed_ = true; |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 // We're either waiting for just the inforbar, or for both a javascript | 194 // We're either waiting for just the inforbar, or for both a javascript |
195 // prompt and response. | 195 // prompt and response. |
196 if (wait_for_infobar_ && infobar_) | 196 if (wait_for_infobar_ && infobar_) |
197 MessageLoopForUI::current()->Quit(); | 197 base::MessageLoopForUI::current()->Quit(); |
198 else if (navigation_completed_ && !javascript_response_.empty()) | 198 else if (navigation_completed_ && !javascript_response_.empty()) |
199 MessageLoopForUI::current()->Quit(); | 199 base::MessageLoopForUI::current()->Quit(); |
200 } | 200 } |
201 | 201 |
202 void GeolocationNotificationObserver::AddWatchAndWaitForNotification( | 202 void GeolocationNotificationObserver::AddWatchAndWaitForNotification( |
203 content::RenderViewHost* render_view_host, | 203 content::RenderViewHost* render_view_host, |
204 const std::string& iframe_xpath) { | 204 const std::string& iframe_xpath) { |
205 LOG(WARNING) << "will add geolocation watch"; | 205 LOG(WARNING) << "will add geolocation watch"; |
206 std::string script = | 206 std::string script = |
207 "window.domAutomationController.setAutomationId(0);" | 207 "window.domAutomationController.setAutomationId(0);" |
208 "window.domAutomationController.send(geoStart());"; | 208 "window.domAutomationController.send(geoStart());"; |
209 render_view_host->ExecuteJavascriptInWebFrame(UTF8ToUTF16(iframe_xpath), | 209 render_view_host->ExecuteJavascriptInWebFrame(UTF8ToUTF16(iframe_xpath), |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 AddGeolocationWatch(false); | 734 AddGeolocationWatch(false); |
735 | 735 |
736 std::string script = | 736 std::string script = |
737 "window.domAutomationController.send(window.close());"; | 737 "window.domAutomationController.send(window.close());"; |
738 bool result = | 738 bool result = |
739 content::ExecuteScript( | 739 content::ExecuteScript( |
740 current_browser_->tab_strip_model()->GetActiveWebContents(), | 740 current_browser_->tab_strip_model()->GetActiveWebContents(), |
741 script); | 741 script); |
742 EXPECT_EQ(result, true); | 742 EXPECT_EQ(result, true); |
743 } | 743 } |
OLD | NEW |