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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 10830193: Remove SWIGged use of BrowserProxy and TabProxy from PyAuto tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 "chrome/browser/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) 395 IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType)
396 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) 396 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab)
397 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) 397 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle)
398 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) 398 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex)
399 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) 399 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL)
400 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, 400 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation,
401 ExecuteJavascript) 401 ExecuteJavascript)
402 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType, 402 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType,
403 OpenNewBrowserWindowOfType) 403 OpenNewBrowserWindowOfType)
404 IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) 404 IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser)
405 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored,
406 WaitForTabToBeRestored)
407 IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState)
408 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType)
409 IPC_MESSAGE_HANDLER(AutomationMsg_GetMetricEventDuration, 405 IPC_MESSAGE_HANDLER(AutomationMsg_GetMetricEventDuration,
410 GetMetricEventDuration) 406 GetMetricEventDuration)
411 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ActionOnSSLBlockingPage,
412 ActionOnSSLBlockingPage)
413 IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) 407 IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront)
414 IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPage, 408 IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPage,
415 HandleOpenFindInPageRequest) 409 HandleOpenFindInPageRequest)
416 IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibility, 410 IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibility,
417 GetFindWindowVisibility) 411 GetFindWindowVisibility)
418 IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibility, 412 IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibility,
419 GetBookmarkBarVisibility) 413 GetBookmarkBarVisibility)
420 IPC_MESSAGE_HANDLER(AutomationMsg_GetBookmarksAsJSON, 414 IPC_MESSAGE_HANDLER(AutomationMsg_GetBookmarksAsJSON,
421 GetBookmarksAsJSON) 415 GetBookmarksAsJSON)
422 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForBookmarkModelToLoad, 416 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForBookmarkModelToLoad,
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 1196
1203 if (browser_tracker_->ContainsHandle(browser_handle)) { 1197 if (browser_tracker_->ContainsHandle(browser_handle)) {
1204 Browser* browser = browser_tracker_->GetResource(browser_handle); 1198 Browser* browser = browser_tracker_->GetResource(browser_handle);
1205 gfx::NativeWindow win = browser->window()->GetNativeWindow(); 1199 gfx::NativeWindow win = browser->window()->GetNativeWindow();
1206 // Add() returns the existing handle for the resource if any. 1200 // Add() returns the existing handle for the resource if any.
1207 *handle = window_tracker_->Add(win); 1201 *handle = window_tracker_->Add(win);
1208 *success = true; 1202 *success = true;
1209 } 1203 }
1210 } 1204 }
1211 1205
1212 void TestingAutomationProvider::WaitForTabToBeRestored(
1213 int tab_handle,
1214 IPC::Message* reply_message) {
1215 if (tab_tracker_->ContainsHandle(tab_handle)) {
1216 NavigationController* tab = tab_tracker_->GetResource(tab_handle);
1217 restore_tracker_.reset(
1218 new NavigationControllerRestoredObserver(this, tab, reply_message));
1219 } else {
1220 AutomationMsg_WaitForTabToBeRestored::WriteReplyParams(
1221 reply_message, false);
1222 Send(reply_message);
1223 }
1224 }
1225
1226 void TestingAutomationProvider::GetSecurityState(
1227 int handle,
1228 bool* success,
1229 content::SecurityStyle* security_style,
1230 net::CertStatus* ssl_cert_status,
1231 int* insecure_content_status) {
1232 if (tab_tracker_->ContainsHandle(handle)) {
1233 NavigationController* tab = tab_tracker_->GetResource(handle);
1234 NavigationEntry* entry = tab->GetActiveEntry();
1235 *success = true;
1236 *security_style = entry->GetSSL().security_style;
1237 *ssl_cert_status = entry->GetSSL().cert_status;
1238 *insecure_content_status = entry->GetSSL().content_status;
1239 } else {
1240 *success = false;
1241 *security_style = content::SECURITY_STYLE_UNKNOWN;
1242 *ssl_cert_status = 0;
1243 *insecure_content_status = 0;
1244 }
1245 }
1246
1247 void TestingAutomationProvider::GetPageType(
1248 int handle,
1249 bool* success,
1250 content::PageType* page_type) {
1251 if (tab_tracker_->ContainsHandle(handle)) {
1252 NavigationController* tab = tab_tracker_->GetResource(handle);
1253 NavigationEntry* entry = tab->GetActiveEntry();
1254 *page_type = entry->GetPageType();
1255 *success = true;
1256 // In order to return the proper result when an interstitial is shown and
1257 // no navigation entry were created for it we need to ask the WebContents.
1258 if (*page_type == content::PAGE_TYPE_NORMAL &&
1259 tab->GetWebContents()->ShowingInterstitialPage())
1260 *page_type = content::PAGE_TYPE_INTERSTITIAL;
1261 } else {
1262 *success = false;
1263 *page_type = content::PAGE_TYPE_NORMAL;
1264 }
1265 }
1266
1267 void TestingAutomationProvider::GetMetricEventDuration( 1206 void TestingAutomationProvider::GetMetricEventDuration(
1268 const std::string& event_name, 1207 const std::string& event_name,
1269 int* duration_ms) { 1208 int* duration_ms) {
1270 *duration_ms = metric_event_duration_observer_->GetEventDurationMs( 1209 *duration_ms = metric_event_duration_observer_->GetEventDurationMs(
1271 event_name); 1210 event_name);
1272 } 1211 }
1273 1212
1274 void TestingAutomationProvider::ActionOnSSLBlockingPage(
1275 int handle,
1276 bool proceed,
1277 IPC::Message* reply_message) {
1278 if (tab_tracker_->ContainsHandle(handle)) {
1279 NavigationController* tab = tab_tracker_->GetResource(handle);
1280 NavigationEntry* entry = tab->GetActiveEntry();
1281 if (entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) {
1282 WebContents* web_contents = tab->GetWebContents();
1283 InterstitialPage* ssl_blocking_page =
1284 InterstitialPage::GetInterstitialPage(web_contents);
1285 if (ssl_blocking_page) {
1286 if (proceed) {
1287 new NavigationNotificationObserver(tab, this, reply_message, 1,
1288 false, false);
1289 ssl_blocking_page->Proceed();
1290 return;
1291 }
1292 ssl_blocking_page->DontProceed();
1293 AutomationMsg_ActionOnSSLBlockingPage::WriteReplyParams(
1294 reply_message, AUTOMATION_MSG_NAVIGATION_SUCCESS);
1295 Send(reply_message);
1296 return;
1297 }
1298 }
1299 }
1300 // We failed.
1301 AutomationMsg_ActionOnSSLBlockingPage::WriteReplyParams(
1302 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR);
1303 Send(reply_message);
1304 }
1305
1306 void TestingAutomationProvider::BringBrowserToFront(int browser_handle, 1213 void TestingAutomationProvider::BringBrowserToFront(int browser_handle,
1307 bool* success) { 1214 bool* success) {
1308 *success = false; 1215 *success = false;
1309 if (browser_tracker_->ContainsHandle(browser_handle)) { 1216 if (browser_tracker_->ContainsHandle(browser_handle)) {
1310 Browser* browser = browser_tracker_->GetResource(browser_handle); 1217 Browser* browser = browser_tracker_->GetResource(browser_handle);
1311 browser->window()->Activate(); 1218 browser->window()->Activate();
1312 *success = true; 1219 *success = true;
1313 } 1220 }
1314 } 1221 }
1315 1222
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 handler_map_["SendOSLevelKeyEventToTab"] = 1600 handler_map_["SendOSLevelKeyEventToTab"] =
1694 &TestingAutomationProvider::SendOSLevelKeyEventToTab; 1601 &TestingAutomationProvider::SendOSLevelKeyEventToTab;
1695 handler_map_["ProcessWebMouseEvent"] = 1602 handler_map_["ProcessWebMouseEvent"] =
1696 &TestingAutomationProvider::ProcessWebMouseEvent; 1603 &TestingAutomationProvider::ProcessWebMouseEvent;
1697 handler_map_["ActivateTab"] = 1604 handler_map_["ActivateTab"] =
1698 &TestingAutomationProvider::ActivateTabJSON; 1605 &TestingAutomationProvider::ActivateTabJSON;
1699 handler_map_["GetAppModalDialogMessage"] = 1606 handler_map_["GetAppModalDialogMessage"] =
1700 &TestingAutomationProvider::GetAppModalDialogMessage; 1607 &TestingAutomationProvider::GetAppModalDialogMessage;
1701 handler_map_["AcceptOrDismissAppModalDialog"] = 1608 handler_map_["AcceptOrDismissAppModalDialog"] =
1702 &TestingAutomationProvider::AcceptOrDismissAppModalDialog; 1609 &TestingAutomationProvider::AcceptOrDismissAppModalDialog;
1610 handler_map_["ActionOnSSLBlockingPage"] =
1611 &TestingAutomationProvider::ActionOnSSLBlockingPage;
1612 handler_map_["GetSecurityState"] =
1613 &TestingAutomationProvider::GetSecurityState;
1703 handler_map_["GetChromeDriverAutomationVersion"] = 1614 handler_map_["GetChromeDriverAutomationVersion"] =
1704 &TestingAutomationProvider::GetChromeDriverAutomationVersion; 1615 &TestingAutomationProvider::GetChromeDriverAutomationVersion;
1705 handler_map_["IsPageActionVisible"] = 1616 handler_map_["IsPageActionVisible"] =
1706 &TestingAutomationProvider::IsPageActionVisible; 1617 &TestingAutomationProvider::IsPageActionVisible;
1707 handler_map_["CreateNewAutomationProvider"] = 1618 handler_map_["CreateNewAutomationProvider"] =
1708 &TestingAutomationProvider::CreateNewAutomationProvider; 1619 &TestingAutomationProvider::CreateNewAutomationProvider;
1709 handler_map_["GetBrowserInfo"] = 1620 handler_map_["GetBrowserInfo"] =
1710 &TestingAutomationProvider::GetBrowserInfo; 1621 &TestingAutomationProvider::GetBrowserInfo;
1711 handler_map_["GetTabInfo"] = 1622 handler_map_["GetTabInfo"] =
1712 &TestingAutomationProvider::GetTabInfo; 1623 &TestingAutomationProvider::GetTabInfo;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 // Look for command in handlers that take a Browser. 1985 // Look for command in handlers that take a Browser.
2075 if (browser_handler_map_.find(std::string(command)) != 1986 if (browser_handler_map_.find(std::string(command)) !=
2076 browser_handler_map_.end() && browser) { 1987 browser_handler_map_.end() && browser) {
2077 (this->*browser_handler_map_[command])(browser, dict_value.get(), 1988 (this->*browser_handler_map_[command])(browser, dict_value.get(),
2078 reply_message); 1989 reply_message);
2079 // Look for command in handlers that don't take a Browser. 1990 // Look for command in handlers that don't take a Browser.
2080 } else if (handler_map_.find(std::string(command)) != handler_map_.end()) { 1991 } else if (handler_map_.find(std::string(command)) != handler_map_.end()) {
2081 (this->*handler_map_[command])(dict_value.get(), reply_message); 1992 (this->*handler_map_[command])(dict_value.get(), reply_message);
2082 // Command has no handler. 1993 // Command has no handler.
2083 } else { 1994 } else {
2084 error_string = "Unknown command. Options: "; 1995 error_string = StringPrintf("Unknown command '%s'. Options: ",
1996 command.c_str());
2085 for (std::map<std::string, JsonHandler>::const_iterator it = 1997 for (std::map<std::string, JsonHandler>::const_iterator it =
2086 handler_map_.begin(); it != handler_map_.end(); ++it) { 1998 handler_map_.begin(); it != handler_map_.end(); ++it) {
2087 error_string += it->first + ", "; 1999 error_string += it->first + ", ";
2088 } 2000 }
2089 for (std::map<std::string, BrowserJsonHandler>::const_iterator it = 2001 for (std::map<std::string, BrowserJsonHandler>::const_iterator it =
2090 browser_handler_map_.begin(); it != browser_handler_map_.end(); ++it) { 2002 browser_handler_map_.begin(); it != browser_handler_map_.end(); ++it) {
2091 error_string += it->first + ", "; 2003 error_string += it->first + ", ";
2092 } 2004 }
2093 AutomationJSONReply(this, reply_message).SendError(error_string); 2005 AutomationJSONReply(this, reply_message).SendError(error_string);
2094 } 2006 }
(...skipping 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after
4405 4317
4406 if (action->HasPopup(ExtensionTabUtil::GetTabId(tab))) { 4318 if (action->HasPopup(ExtensionTabUtil::GetTabId(tab))) {
4407 // This observer will delete itself. 4319 // This observer will delete itself.
4408 new ExtensionPopupObserver( 4320 new ExtensionPopupObserver(
4409 this, reply_message, extension->id()); 4321 this, reply_message, extension->id());
4410 } else { 4322 } else {
4411 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 4323 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
4412 } 4324 }
4413 } 4325 }
4414 4326
4327 void TestingAutomationProvider::ActionOnSSLBlockingPage(
4328 DictionaryValue* args,
4329 IPC::Message* reply_message) {
4330 WebContents* web_contents;
4331 bool proceed;
4332 std::string error;
4333 if (!GetTabFromJSONArgs(args, &web_contents, &error)) {
4334 AutomationJSONReply(this, reply_message).SendError(error);
4335 return;
4336 }
4337 if (!args->GetBoolean("proceed", &proceed)) {
4338 AutomationJSONReply(this, reply_message).SendError(
4339 "'proceed' is missing or invalid");
4340 return;
4341 }
4342 NavigationController& controller = web_contents->GetController();
4343 NavigationEntry* entry = controller.GetActiveEntry();
4344 if (entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) {
4345 InterstitialPage* ssl_blocking_page =
4346 InterstitialPage::GetInterstitialPage(web_contents);
4347 if (ssl_blocking_page) {
4348 if (proceed) {
4349 new NavigationNotificationObserver(&controller, this, reply_message, 1,
4350 false, true);
4351 ssl_blocking_page->Proceed();
4352 return;
4353 }
4354 ssl_blocking_page->DontProceed();
4355 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
4356 return;
4357 }
4358 }
4359 AutomationJSONReply(this, reply_message).SendError(error);
4360 }
4361
4362 void TestingAutomationProvider::GetSecurityState(DictionaryValue* args,
4363 IPC::Message* reply_message) {
4364 AutomationJSONReply reply(this, reply_message);
4365 WebContents* web_contents;
4366 std::string error;
4367 if (!GetTabFromJSONArgs(args, &web_contents, &error)) {
4368 reply.SendError(error);
4369 return;
4370 }
4371 NavigationEntry* entry = web_contents->GetController().GetActiveEntry();
4372 DictionaryValue dict;
4373 dict.SetInteger("security_style",
4374 static_cast<int>(entry->GetSSL().security_style));
4375 dict.SetInteger("ssl_cert_status",
4376 static_cast<int>(entry->GetSSL().cert_status));
4377 dict.SetInteger("insecure_content_status",
4378 static_cast<int>(entry->GetSSL().content_status));
4379 reply.SendSuccess(&dict);
4380 }
4381
4415 // Sample json input: { "command": "UpdateExtensionsNow" } 4382 // Sample json input: { "command": "UpdateExtensionsNow" }
4416 // Sample json output: {} 4383 // Sample json output: {}
4417 void TestingAutomationProvider::UpdateExtensionsNow( 4384 void TestingAutomationProvider::UpdateExtensionsNow(
4418 DictionaryValue* args, 4385 DictionaryValue* args,
4419 IPC::Message* reply_message) { 4386 IPC::Message* reply_message) {
4420 std::string error; 4387 std::string error;
4421 Browser* browser; 4388 Browser* browser;
4422 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { 4389 if (!GetBrowserFromJSONArgs(args, &browser, &error)) {
4423 AutomationJSONReply(this, reply_message).SendError(error); 4390 AutomationJSONReply(this, reply_message).SendError(error);
4424 return; 4391 return;
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
6005 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { 5972 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) {
6006 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 5973 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
6007 return; 5974 return;
6008 } 5975 }
6009 5976
6010 // This class will send the message immediately if no tab is loading. 5977 // This class will send the message immediately if no tab is loading.
6011 new AllViewsStoppedLoadingObserver( 5978 new AllViewsStoppedLoadingObserver(
6012 this, reply_message, profile()->GetExtensionProcessManager()); 5979 this, reply_message, profile()->GetExtensionProcessManager());
6013 } 5980 }
6014 5981
5982 void TestingAutomationProvider::WaitForTabToBeRestored(
5983 DictionaryValue* args,
5984 IPC::Message* reply_message) {
5985 WebContents* web_contents;
5986 std::string error;
5987 if (!GetTabFromJSONArgs(args, &web_contents, &error)) {
5988 AutomationJSONReply(this, reply_message).SendError(error);
5989 return;
5990 }
5991 NavigationController& controller = web_contents->GetController();
5992 new NavigationControllerRestoredObserver(this, &controller, reply_message);
5993 }
5994
6015 void TestingAutomationProvider::GetPolicyDefinitionList( 5995 void TestingAutomationProvider::GetPolicyDefinitionList(
6016 DictionaryValue* args, 5996 DictionaryValue* args,
6017 IPC::Message* reply_message) { 5997 IPC::Message* reply_message) {
6018 AutomationJSONReply reply(this, reply_message); 5998 AutomationJSONReply reply(this, reply_message);
6019 5999
6020 #if !defined(ENABLE_CONFIGURATION_POLICY) 6000 #if !defined(ENABLE_CONFIGURATION_POLICY)
6021 reply.SendError("Configuration Policy disabled"); 6001 reply.SendError("Configuration Policy disabled");
6022 #else 6002 #else
6023 DictionaryValue response; 6003 DictionaryValue response;
6024 6004
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
6155 if (!args->GetString("url", &url)) { 6135 if (!args->GetString("url", &url)) {
6156 AutomationJSONReply(this, reply_message) 6136 AutomationJSONReply(this, reply_message)
6157 .SendError("'url' missing or invalid"); 6137 .SendError("'url' missing or invalid");
6158 return; 6138 return;
6159 } 6139 }
6160 if (!args->GetInteger("navigation_count", &navigation_count)) { 6140 if (!args->GetInteger("navigation_count", &navigation_count)) {
6161 AutomationJSONReply(this, reply_message) 6141 AutomationJSONReply(this, reply_message)
6162 .SendError("'navigation_count' missing or invalid"); 6142 .SendError("'navigation_count' missing or invalid");
6163 return; 6143 return;
6164 } 6144 }
6165 new NavigationNotificationObserver( 6145 if (navigation_count > 0) {
6166 &web_contents->GetController(), this, reply_message, 6146 new NavigationNotificationObserver(
6167 navigation_count, false, true); 6147 &web_contents->GetController(), this, reply_message,
6148 navigation_count, false, true);
6149 } else {
6150 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
6151 }
6168 OpenURLParams params( 6152 OpenURLParams params(
6169 GURL(url), content::Referrer(), CURRENT_TAB, 6153 GURL(url), content::Referrer(), CURRENT_TAB,
6170 content::PageTransitionFromInt( 6154 content::PageTransitionFromInt(
6171 content::PAGE_TRANSITION_TYPED | 6155 content::PAGE_TRANSITION_TYPED |
6172 content::PAGE_TRANSITION_FROM_ADDRESS_BAR), 6156 content::PAGE_TRANSITION_FROM_ADDRESS_BAR),
6173 false); 6157 false);
6174 browser->OpenURLFromTab(web_contents, params); 6158 browser->OpenURLFromTab(web_contents, params);
6175 } 6159 }
6176 6160
6177 void TestingAutomationProvider::GetActiveTabIndexJSON( 6161 void TestingAutomationProvider::GetActiveTabIndexJSON(
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
6860 automation_util::DoesObjectWithIdExist(id, profile())); 6844 automation_util::DoesObjectWithIdExist(id, profile()));
6861 reply.SendSuccess(&dict); 6845 reply.SendSuccess(&dict);
6862 } 6846 }
6863 6847
6864 void TestingAutomationProvider::CloseTabJSON( 6848 void TestingAutomationProvider::CloseTabJSON(
6865 DictionaryValue* args, IPC::Message* reply_message) { 6849 DictionaryValue* args, IPC::Message* reply_message) {
6866 AutomationJSONReply reply(this, reply_message); 6850 AutomationJSONReply reply(this, reply_message);
6867 Browser* browser; 6851 Browser* browser;
6868 WebContents* tab; 6852 WebContents* tab;
6869 std::string error; 6853 std::string error;
6854 bool wait_until_closed = false; // ChromeDriver does not use this.
Nirnimesh 2012/08/07 00:37:35 nit: need 2 spaces before //
craigdh 2012/08/07 21:08:51 Done.
6855 args->GetBoolean("wait_until_closed", &wait_until_closed);
6870 // Close tabs synchronously. 6856 // Close tabs synchronously.
6871 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { 6857 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) {
6858 if (wait_until_closed) {
6859 new TabClosedNotificationObserver(this, wait_until_closed, reply_message,
6860 true);
6861 }
6872 chrome::CloseWebContents(browser, tab); 6862 chrome::CloseWebContents(browser, tab);
6873 reply.SendSuccess(NULL); 6863 if (!wait_until_closed)
6864 reply.SendSuccess(NULL);
6874 return; 6865 return;
6875 } 6866 }
6876
6877 // Close other types of views asynchronously. 6867 // Close other types of views asynchronously.
6878 RenderViewHost* view; 6868 RenderViewHost* view;
6879 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { 6869 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) {
6880 reply.SendError(error); 6870 reply.SendError(error);
6881 return; 6871 return;
6882 } 6872 }
6883 view->ClosePage(); 6873 view->ClosePage();
6884 reply.SendSuccess(NULL); 6874 reply.SendSuccess(NULL);
6885 } 6875 }
6886 6876
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
7084 void TestingAutomationProvider::OnRemoveProvider() { 7074 void TestingAutomationProvider::OnRemoveProvider() {
7085 if (g_browser_process) 7075 if (g_browser_process)
7086 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 7076 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
7087 } 7077 }
7088 7078
7089 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 7079 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
7090 WebContents* tab) { 7080 WebContents* tab) {
7091 if (chrome::GetActiveWebContents(browser) != tab) 7081 if (chrome::GetActiveWebContents(browser) != tab)
7092 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); 7082 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
7093 } 7083 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698