| 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 "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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) | 397 IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) |
| 398 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) | 398 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) |
| 399 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) | 399 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) |
| 400 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) | 400 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) |
| 401 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) | 401 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) |
| 402 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, | 402 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, |
| 403 ExecuteJavascript) | 403 ExecuteJavascript) |
| 404 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType, | 404 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType, |
| 405 OpenNewBrowserWindowOfType) | 405 OpenNewBrowserWindowOfType) |
| 406 IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) | 406 IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) |
| 407 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored, | |
| 408 WaitForTabToBeRestored) | |
| 409 IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState) | |
| 410 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType) | |
| 411 IPC_MESSAGE_HANDLER(AutomationMsg_GetMetricEventDuration, | 407 IPC_MESSAGE_HANDLER(AutomationMsg_GetMetricEventDuration, |
| 412 GetMetricEventDuration) | 408 GetMetricEventDuration) |
| 413 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ActionOnSSLBlockingPage, | |
| 414 ActionOnSSLBlockingPage) | |
| 415 IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) | 409 IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) |
| 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, |
| 423 WaitForBookmarkModelToLoad) | 417 WaitForBookmarkModelToLoad) |
| 424 IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkGroup, | 418 IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkGroup, |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 | 1234 |
| 1241 if (browser_tracker_->ContainsHandle(browser_handle)) { | 1235 if (browser_tracker_->ContainsHandle(browser_handle)) { |
| 1242 Browser* browser = browser_tracker_->GetResource(browser_handle); | 1236 Browser* browser = browser_tracker_->GetResource(browser_handle); |
| 1243 gfx::NativeWindow win = browser->window()->GetNativeWindow(); | 1237 gfx::NativeWindow win = browser->window()->GetNativeWindow(); |
| 1244 // Add() returns the existing handle for the resource if any. | 1238 // Add() returns the existing handle for the resource if any. |
| 1245 *handle = window_tracker_->Add(win); | 1239 *handle = window_tracker_->Add(win); |
| 1246 *success = true; | 1240 *success = true; |
| 1247 } | 1241 } |
| 1248 } | 1242 } |
| 1249 | 1243 |
| 1250 void TestingAutomationProvider::WaitForTabToBeRestored( | |
| 1251 int tab_handle, | |
| 1252 IPC::Message* reply_message) { | |
| 1253 if (tab_tracker_->ContainsHandle(tab_handle)) { | |
| 1254 NavigationController* tab = tab_tracker_->GetResource(tab_handle); | |
| 1255 restore_tracker_.reset( | |
| 1256 new NavigationControllerRestoredObserver(this, tab, reply_message)); | |
| 1257 } else { | |
| 1258 AutomationMsg_WaitForTabToBeRestored::WriteReplyParams( | |
| 1259 reply_message, false); | |
| 1260 Send(reply_message); | |
| 1261 } | |
| 1262 } | |
| 1263 | |
| 1264 void TestingAutomationProvider::GetSecurityState( | |
| 1265 int handle, | |
| 1266 bool* success, | |
| 1267 content::SecurityStyle* security_style, | |
| 1268 net::CertStatus* ssl_cert_status, | |
| 1269 int* insecure_content_status) { | |
| 1270 if (tab_tracker_->ContainsHandle(handle)) { | |
| 1271 NavigationController* tab = tab_tracker_->GetResource(handle); | |
| 1272 NavigationEntry* entry = tab->GetActiveEntry(); | |
| 1273 *success = true; | |
| 1274 *security_style = entry->GetSSL().security_style; | |
| 1275 *ssl_cert_status = entry->GetSSL().cert_status; | |
| 1276 *insecure_content_status = entry->GetSSL().content_status; | |
| 1277 } else { | |
| 1278 *success = false; | |
| 1279 *security_style = content::SECURITY_STYLE_UNKNOWN; | |
| 1280 *ssl_cert_status = 0; | |
| 1281 *insecure_content_status = 0; | |
| 1282 } | |
| 1283 } | |
| 1284 | |
| 1285 void TestingAutomationProvider::GetPageType( | |
| 1286 int handle, | |
| 1287 bool* success, | |
| 1288 content::PageType* page_type) { | |
| 1289 if (tab_tracker_->ContainsHandle(handle)) { | |
| 1290 NavigationController* tab = tab_tracker_->GetResource(handle); | |
| 1291 NavigationEntry* entry = tab->GetActiveEntry(); | |
| 1292 *page_type = entry->GetPageType(); | |
| 1293 *success = true; | |
| 1294 // In order to return the proper result when an interstitial is shown and | |
| 1295 // no navigation entry were created for it we need to ask the WebContents. | |
| 1296 if (*page_type == content::PAGE_TYPE_NORMAL && | |
| 1297 tab->GetWebContents()->ShowingInterstitialPage()) | |
| 1298 *page_type = content::PAGE_TYPE_INTERSTITIAL; | |
| 1299 } else { | |
| 1300 *success = false; | |
| 1301 *page_type = content::PAGE_TYPE_NORMAL; | |
| 1302 } | |
| 1303 } | |
| 1304 | |
| 1305 void TestingAutomationProvider::GetMetricEventDuration( | 1244 void TestingAutomationProvider::GetMetricEventDuration( |
| 1306 const std::string& event_name, | 1245 const std::string& event_name, |
| 1307 int* duration_ms) { | 1246 int* duration_ms) { |
| 1308 *duration_ms = metric_event_duration_observer_->GetEventDurationMs( | 1247 *duration_ms = metric_event_duration_observer_->GetEventDurationMs( |
| 1309 event_name); | 1248 event_name); |
| 1310 } | 1249 } |
| 1311 | 1250 |
| 1312 void TestingAutomationProvider::ActionOnSSLBlockingPage( | |
| 1313 int handle, | |
| 1314 bool proceed, | |
| 1315 IPC::Message* reply_message) { | |
| 1316 if (tab_tracker_->ContainsHandle(handle)) { | |
| 1317 NavigationController* tab = tab_tracker_->GetResource(handle); | |
| 1318 NavigationEntry* entry = tab->GetActiveEntry(); | |
| 1319 if (entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { | |
| 1320 WebContents* web_contents = tab->GetWebContents(); | |
| 1321 InterstitialPage* ssl_blocking_page = | |
| 1322 InterstitialPage::GetInterstitialPage(web_contents); | |
| 1323 if (ssl_blocking_page) { | |
| 1324 if (proceed) { | |
| 1325 new NavigationNotificationObserver(tab, this, reply_message, 1, | |
| 1326 false, false); | |
| 1327 ssl_blocking_page->Proceed(); | |
| 1328 return; | |
| 1329 } | |
| 1330 ssl_blocking_page->DontProceed(); | |
| 1331 AutomationMsg_ActionOnSSLBlockingPage::WriteReplyParams( | |
| 1332 reply_message, AUTOMATION_MSG_NAVIGATION_SUCCESS); | |
| 1333 Send(reply_message); | |
| 1334 return; | |
| 1335 } | |
| 1336 } | |
| 1337 } | |
| 1338 // We failed. | |
| 1339 AutomationMsg_ActionOnSSLBlockingPage::WriteReplyParams( | |
| 1340 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); | |
| 1341 Send(reply_message); | |
| 1342 } | |
| 1343 | |
| 1344 void TestingAutomationProvider::BringBrowserToFront(int browser_handle, | 1251 void TestingAutomationProvider::BringBrowserToFront(int browser_handle, |
| 1345 bool* success) { | 1252 bool* success) { |
| 1346 *success = false; | 1253 *success = false; |
| 1347 if (browser_tracker_->ContainsHandle(browser_handle)) { | 1254 if (browser_tracker_->ContainsHandle(browser_handle)) { |
| 1348 Browser* browser = browser_tracker_->GetResource(browser_handle); | 1255 Browser* browser = browser_tracker_->GetResource(browser_handle); |
| 1349 browser->window()->Activate(); | 1256 browser->window()->Activate(); |
| 1350 *success = true; | 1257 *success = true; |
| 1351 } | 1258 } |
| 1352 } | 1259 } |
| 1353 | 1260 |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 handler_map_["SendOSLevelKeyEventToTab"] = | 1646 handler_map_["SendOSLevelKeyEventToTab"] = |
| 1740 &TestingAutomationProvider::SendOSLevelKeyEventToTab; | 1647 &TestingAutomationProvider::SendOSLevelKeyEventToTab; |
| 1741 handler_map_["ProcessWebMouseEvent"] = | 1648 handler_map_["ProcessWebMouseEvent"] = |
| 1742 &TestingAutomationProvider::ProcessWebMouseEvent; | 1649 &TestingAutomationProvider::ProcessWebMouseEvent; |
| 1743 handler_map_["ActivateTab"] = | 1650 handler_map_["ActivateTab"] = |
| 1744 &TestingAutomationProvider::ActivateTabJSON; | 1651 &TestingAutomationProvider::ActivateTabJSON; |
| 1745 handler_map_["GetAppModalDialogMessage"] = | 1652 handler_map_["GetAppModalDialogMessage"] = |
| 1746 &TestingAutomationProvider::GetAppModalDialogMessage; | 1653 &TestingAutomationProvider::GetAppModalDialogMessage; |
| 1747 handler_map_["AcceptOrDismissAppModalDialog"] = | 1654 handler_map_["AcceptOrDismissAppModalDialog"] = |
| 1748 &TestingAutomationProvider::AcceptOrDismissAppModalDialog; | 1655 &TestingAutomationProvider::AcceptOrDismissAppModalDialog; |
| 1656 handler_map_["ActionOnSSLBlockingPage"] = |
| 1657 &TestingAutomationProvider::ActionOnSSLBlockingPage; |
| 1658 handler_map_["GetSecurityState"] = |
| 1659 &TestingAutomationProvider::GetSecurityState; |
| 1749 handler_map_["GetChromeDriverAutomationVersion"] = | 1660 handler_map_["GetChromeDriverAutomationVersion"] = |
| 1750 &TestingAutomationProvider::GetChromeDriverAutomationVersion; | 1661 &TestingAutomationProvider::GetChromeDriverAutomationVersion; |
| 1751 handler_map_["IsPageActionVisible"] = | 1662 handler_map_["IsPageActionVisible"] = |
| 1752 &TestingAutomationProvider::IsPageActionVisible; | 1663 &TestingAutomationProvider::IsPageActionVisible; |
| 1753 handler_map_["CreateNewAutomationProvider"] = | 1664 handler_map_["CreateNewAutomationProvider"] = |
| 1754 &TestingAutomationProvider::CreateNewAutomationProvider; | 1665 &TestingAutomationProvider::CreateNewAutomationProvider; |
| 1755 handler_map_["GetBrowserWindowCount"] = | 1666 handler_map_["GetBrowserWindowCount"] = |
| 1756 &TestingAutomationProvider::GetBrowserWindowCountJSON; | 1667 &TestingAutomationProvider::GetBrowserWindowCountJSON; |
| 1757 handler_map_["GetBrowserInfo"] = | 1668 handler_map_["GetBrowserInfo"] = |
| 1758 &TestingAutomationProvider::GetBrowserInfo; | 1669 &TestingAutomationProvider::GetBrowserInfo; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 // Look for command in handlers that take a Browser. | 2035 // Look for command in handlers that take a Browser. |
| 2125 if (browser_handler_map_.find(std::string(command)) != | 2036 if (browser_handler_map_.find(std::string(command)) != |
| 2126 browser_handler_map_.end() && browser) { | 2037 browser_handler_map_.end() && browser) { |
| 2127 (this->*browser_handler_map_[command])(browser, dict_value.get(), | 2038 (this->*browser_handler_map_[command])(browser, dict_value.get(), |
| 2128 reply_message); | 2039 reply_message); |
| 2129 // Look for command in handlers that don't take a Browser. | 2040 // Look for command in handlers that don't take a Browser. |
| 2130 } else if (handler_map_.find(std::string(command)) != handler_map_.end()) { | 2041 } else if (handler_map_.find(std::string(command)) != handler_map_.end()) { |
| 2131 (this->*handler_map_[command])(dict_value.get(), reply_message); | 2042 (this->*handler_map_[command])(dict_value.get(), reply_message); |
| 2132 // Command has no handler. | 2043 // Command has no handler. |
| 2133 } else { | 2044 } else { |
| 2134 error_string = "Unknown command. Options: "; | 2045 error_string = StringPrintf("Unknown command '%s'. Options: ", |
| 2046 command.c_str()); |
| 2135 for (std::map<std::string, JsonHandler>::const_iterator it = | 2047 for (std::map<std::string, JsonHandler>::const_iterator it = |
| 2136 handler_map_.begin(); it != handler_map_.end(); ++it) { | 2048 handler_map_.begin(); it != handler_map_.end(); ++it) { |
| 2137 error_string += it->first + ", "; | 2049 error_string += it->first + ", "; |
| 2138 } | 2050 } |
| 2139 for (std::map<std::string, BrowserJsonHandler>::const_iterator it = | 2051 for (std::map<std::string, BrowserJsonHandler>::const_iterator it = |
| 2140 browser_handler_map_.begin(); it != browser_handler_map_.end(); ++it) { | 2052 browser_handler_map_.begin(); it != browser_handler_map_.end(); ++it) { |
| 2141 error_string += it->first + ", "; | 2053 error_string += it->first + ", "; |
| 2142 } | 2054 } |
| 2143 AutomationJSONReply(this, reply_message).SendError(error_string); | 2055 AutomationJSONReply(this, reply_message).SendError(error_string); |
| 2144 } | 2056 } |
| (...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4488 | 4400 |
| 4489 if (action->HasPopup(ExtensionTabUtil::GetTabId(tab))) { | 4401 if (action->HasPopup(ExtensionTabUtil::GetTabId(tab))) { |
| 4490 // This observer will delete itself. | 4402 // This observer will delete itself. |
| 4491 new ExtensionPopupObserver( | 4403 new ExtensionPopupObserver( |
| 4492 this, reply_message, extension->id()); | 4404 this, reply_message, extension->id()); |
| 4493 } else { | 4405 } else { |
| 4494 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 4406 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 4495 } | 4407 } |
| 4496 } | 4408 } |
| 4497 | 4409 |
| 4410 void TestingAutomationProvider::ActionOnSSLBlockingPage( |
| 4411 DictionaryValue* args, |
| 4412 IPC::Message* reply_message) { |
| 4413 WebContents* web_contents; |
| 4414 bool proceed; |
| 4415 std::string error; |
| 4416 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 4417 AutomationJSONReply(this, reply_message).SendError(error); |
| 4418 return; |
| 4419 } |
| 4420 if (!args->GetBoolean("proceed", &proceed)) { |
| 4421 AutomationJSONReply(this, reply_message).SendError( |
| 4422 "'proceed' is missing or invalid"); |
| 4423 return; |
| 4424 } |
| 4425 NavigationController& controller = web_contents->GetController(); |
| 4426 NavigationEntry* entry = controller.GetActiveEntry(); |
| 4427 if (entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { |
| 4428 InterstitialPage* ssl_blocking_page = |
| 4429 InterstitialPage::GetInterstitialPage(web_contents); |
| 4430 if (ssl_blocking_page) { |
| 4431 if (proceed) { |
| 4432 new NavigationNotificationObserver(&controller, this, reply_message, 1, |
| 4433 false, true); |
| 4434 ssl_blocking_page->Proceed(); |
| 4435 return; |
| 4436 } |
| 4437 ssl_blocking_page->DontProceed(); |
| 4438 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 4439 return; |
| 4440 } |
| 4441 } |
| 4442 AutomationJSONReply(this, reply_message).SendError(error); |
| 4443 } |
| 4444 |
| 4445 void TestingAutomationProvider::GetSecurityState(DictionaryValue* args, |
| 4446 IPC::Message* reply_message) { |
| 4447 AutomationJSONReply reply(this, reply_message); |
| 4448 WebContents* web_contents; |
| 4449 std::string error; |
| 4450 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 4451 reply.SendError(error); |
| 4452 return; |
| 4453 } |
| 4454 NavigationEntry* entry = web_contents->GetController().GetActiveEntry(); |
| 4455 DictionaryValue dict; |
| 4456 dict.SetInteger("security_style", |
| 4457 static_cast<int>(entry->GetSSL().security_style)); |
| 4458 dict.SetInteger("ssl_cert_status", |
| 4459 static_cast<int>(entry->GetSSL().cert_status)); |
| 4460 dict.SetInteger("insecure_content_status", |
| 4461 static_cast<int>(entry->GetSSL().content_status)); |
| 4462 reply.SendSuccess(&dict); |
| 4463 } |
| 4464 |
| 4498 // Sample json input: { "command": "UpdateExtensionsNow" } | 4465 // Sample json input: { "command": "UpdateExtensionsNow" } |
| 4499 // Sample json output: {} | 4466 // Sample json output: {} |
| 4500 void TestingAutomationProvider::UpdateExtensionsNow( | 4467 void TestingAutomationProvider::UpdateExtensionsNow( |
| 4501 DictionaryValue* args, | 4468 DictionaryValue* args, |
| 4502 IPC::Message* reply_message) { | 4469 IPC::Message* reply_message) { |
| 4503 std::string error; | 4470 std::string error; |
| 4504 Browser* browser; | 4471 Browser* browser; |
| 4505 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 4472 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 4506 AutomationJSONReply(this, reply_message).SendError(error); | 4473 AutomationJSONReply(this, reply_message).SendError(error); |
| 4507 return; | 4474 return; |
| (...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6088 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { | 6055 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { |
| 6089 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 6056 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 6090 return; | 6057 return; |
| 6091 } | 6058 } |
| 6092 | 6059 |
| 6093 // This class will send the message immediately if no tab is loading. | 6060 // This class will send the message immediately if no tab is loading. |
| 6094 new AllViewsStoppedLoadingObserver( | 6061 new AllViewsStoppedLoadingObserver( |
| 6095 this, reply_message, profile()->GetExtensionProcessManager()); | 6062 this, reply_message, profile()->GetExtensionProcessManager()); |
| 6096 } | 6063 } |
| 6097 | 6064 |
| 6065 void TestingAutomationProvider::WaitForTabToBeRestored( |
| 6066 DictionaryValue* args, |
| 6067 IPC::Message* reply_message) { |
| 6068 WebContents* web_contents; |
| 6069 std::string error; |
| 6070 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 6071 AutomationJSONReply(this, reply_message).SendError(error); |
| 6072 return; |
| 6073 } |
| 6074 NavigationController& controller = web_contents->GetController(); |
| 6075 new NavigationControllerRestoredObserver(this, &controller, reply_message); |
| 6076 } |
| 6077 |
| 6098 void TestingAutomationProvider::GetPolicyDefinitionList( | 6078 void TestingAutomationProvider::GetPolicyDefinitionList( |
| 6099 DictionaryValue* args, | 6079 DictionaryValue* args, |
| 6100 IPC::Message* reply_message) { | 6080 IPC::Message* reply_message) { |
| 6101 AutomationJSONReply reply(this, reply_message); | 6081 AutomationJSONReply reply(this, reply_message); |
| 6102 | 6082 |
| 6103 #if !defined(ENABLE_CONFIGURATION_POLICY) | 6083 #if !defined(ENABLE_CONFIGURATION_POLICY) |
| 6104 reply.SendError("Configuration Policy disabled"); | 6084 reply.SendError("Configuration Policy disabled"); |
| 6105 #else | 6085 #else |
| 6106 DictionaryValue response; | 6086 DictionaryValue response; |
| 6107 | 6087 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6238 if (!args->GetString("url", &url)) { | 6218 if (!args->GetString("url", &url)) { |
| 6239 AutomationJSONReply(this, reply_message) | 6219 AutomationJSONReply(this, reply_message) |
| 6240 .SendError("'url' missing or invalid"); | 6220 .SendError("'url' missing or invalid"); |
| 6241 return; | 6221 return; |
| 6242 } | 6222 } |
| 6243 if (!args->GetInteger("navigation_count", &navigation_count)) { | 6223 if (!args->GetInteger("navigation_count", &navigation_count)) { |
| 6244 AutomationJSONReply(this, reply_message) | 6224 AutomationJSONReply(this, reply_message) |
| 6245 .SendError("'navigation_count' missing or invalid"); | 6225 .SendError("'navigation_count' missing or invalid"); |
| 6246 return; | 6226 return; |
| 6247 } | 6227 } |
| 6248 new NavigationNotificationObserver( | 6228 if (navigation_count > 0) { |
| 6249 &web_contents->GetController(), this, reply_message, | 6229 new NavigationNotificationObserver( |
| 6250 navigation_count, false, true); | 6230 &web_contents->GetController(), this, reply_message, |
| 6231 navigation_count, false, true); |
| 6232 } else { |
| 6233 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 6234 } |
| 6251 OpenURLParams params( | 6235 OpenURLParams params( |
| 6252 GURL(url), content::Referrer(), CURRENT_TAB, | 6236 GURL(url), content::Referrer(), CURRENT_TAB, |
| 6253 content::PageTransitionFromInt( | 6237 content::PageTransitionFromInt( |
| 6254 content::PAGE_TRANSITION_TYPED | | 6238 content::PAGE_TRANSITION_TYPED | |
| 6255 content::PAGE_TRANSITION_FROM_ADDRESS_BAR), | 6239 content::PAGE_TRANSITION_FROM_ADDRESS_BAR), |
| 6256 false); | 6240 false); |
| 6257 browser->OpenURLFromTab(web_contents, params); | 6241 browser->OpenURLFromTab(web_contents, params); |
| 6258 } | 6242 } |
| 6259 | 6243 |
| 6260 void TestingAutomationProvider::GetActiveTabIndexJSON( | 6244 void TestingAutomationProvider::GetActiveTabIndexJSON( |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6943 automation_util::DoesObjectWithIdExist(id, profile())); | 6927 automation_util::DoesObjectWithIdExist(id, profile())); |
| 6944 reply.SendSuccess(&dict); | 6928 reply.SendSuccess(&dict); |
| 6945 } | 6929 } |
| 6946 | 6930 |
| 6947 void TestingAutomationProvider::CloseTabJSON( | 6931 void TestingAutomationProvider::CloseTabJSON( |
| 6948 DictionaryValue* args, IPC::Message* reply_message) { | 6932 DictionaryValue* args, IPC::Message* reply_message) { |
| 6949 AutomationJSONReply reply(this, reply_message); | 6933 AutomationJSONReply reply(this, reply_message); |
| 6950 Browser* browser; | 6934 Browser* browser; |
| 6951 WebContents* tab; | 6935 WebContents* tab; |
| 6952 std::string error; | 6936 std::string error; |
| 6937 bool wait_until_closed = false; // ChromeDriver does not use this. |
| 6938 args->GetBoolean("wait_until_closed", &wait_until_closed); |
| 6953 // Close tabs synchronously. | 6939 // Close tabs synchronously. |
| 6954 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { | 6940 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { |
| 6941 if (wait_until_closed) { |
| 6942 new TabClosedNotificationObserver(this, wait_until_closed, reply_message, |
| 6943 true); |
| 6944 } |
| 6955 chrome::CloseWebContents(browser, tab); | 6945 chrome::CloseWebContents(browser, tab); |
| 6956 reply.SendSuccess(NULL); | 6946 if (!wait_until_closed) |
| 6947 reply.SendSuccess(NULL); |
| 6957 return; | 6948 return; |
| 6958 } | 6949 } |
| 6959 | |
| 6960 // Close other types of views asynchronously. | 6950 // Close other types of views asynchronously. |
| 6961 RenderViewHost* view; | 6951 RenderViewHost* view; |
| 6962 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 6952 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
| 6963 reply.SendError(error); | 6953 reply.SendError(error); |
| 6964 return; | 6954 return; |
| 6965 } | 6955 } |
| 6966 view->ClosePage(); | 6956 view->ClosePage(); |
| 6967 reply.SendSuccess(NULL); | 6957 reply.SendSuccess(NULL); |
| 6968 } | 6958 } |
| 6969 | 6959 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7177 void TestingAutomationProvider::OnRemoveProvider() { | 7167 void TestingAutomationProvider::OnRemoveProvider() { |
| 7178 if (g_browser_process) | 7168 if (g_browser_process) |
| 7179 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 7169 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 7180 } | 7170 } |
| 7181 | 7171 |
| 7182 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 7172 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 7183 WebContents* tab) { | 7173 WebContents* tab) { |
| 7184 if (chrome::GetActiveWebContents(browser) != tab) | 7174 if (chrome::GetActiveWebContents(browser) != tab) |
| 7185 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 7175 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
| 7186 } | 7176 } |
| OLD | NEW |