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

Side by Side Diff: chrome/browser/geolocation/geolocation_browsertest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 <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
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698