OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 #include "chrome/browser/download/download_shelf.h" | 148 #include "chrome/browser/download/download_shelf.h" |
149 #endif | 149 #endif |
150 | 150 |
151 using automation::Error; | 151 using automation::Error; |
152 using automation::ErrorCode; | 152 using automation::ErrorCode; |
153 using automation_util::SendErrorIfModalDialogActive; | 153 using automation_util::SendErrorIfModalDialogActive; |
154 using content::BrowserThread; | 154 using content::BrowserThread; |
155 using content::ChildProcessHost; | 155 using content::ChildProcessHost; |
156 using content::DownloadItem; | 156 using content::DownloadItem; |
157 using content::DownloadManager; | 157 using content::DownloadManager; |
| 158 using content::NavigationController; |
158 using content::NavigationEntry; | 159 using content::NavigationEntry; |
159 using content::PluginService; | 160 using content::PluginService; |
160 using content::OpenURLParams; | 161 using content::OpenURLParams; |
161 using content::Referrer; | 162 using content::Referrer; |
162 using content::SSLStatus; | 163 using content::SSLStatus; |
163 using content::WebContents; | 164 using content::WebContents; |
164 | 165 |
165 namespace { | 166 namespace { |
166 | 167 |
167 void SendMouseClick(int flags) { | 168 void SendMouseClick(int flags) { |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 if (browser_tracker_->ContainsHandle(handle)) { | 565 if (browser_tracker_->ContainsHandle(handle)) { |
565 Browser* browser = browser_tracker_->GetResource(handle); | 566 Browser* browser = browser_tracker_->GetResource(handle); |
566 *active_tab_index = browser->active_index(); | 567 *active_tab_index = browser->active_index(); |
567 } | 568 } |
568 } | 569 } |
569 | 570 |
570 void TestingAutomationProvider::CloseTab(int tab_handle, | 571 void TestingAutomationProvider::CloseTab(int tab_handle, |
571 bool wait_until_closed, | 572 bool wait_until_closed, |
572 IPC::Message* reply_message) { | 573 IPC::Message* reply_message) { |
573 if (tab_tracker_->ContainsHandle(tab_handle)) { | 574 if (tab_tracker_->ContainsHandle(tab_handle)) { |
574 content::NavigationController* controller = | 575 NavigationController* controller = tab_tracker_->GetResource(tab_handle); |
575 tab_tracker_->GetResource(tab_handle); | |
576 int index; | 576 int index; |
577 Browser* browser = Browser::GetBrowserForController(controller, &index); | 577 Browser* browser = Browser::GetBrowserForController(controller, &index); |
578 DCHECK(browser); | 578 DCHECK(browser); |
579 new TabClosedNotificationObserver(this, wait_until_closed, reply_message); | 579 new TabClosedNotificationObserver(this, wait_until_closed, reply_message); |
580 browser->CloseTabContents(controller->GetWebContents()); | 580 browser->CloseTabContents(controller->GetWebContents()); |
581 return; | 581 return; |
582 } | 582 } |
583 | 583 |
584 AutomationMsg_CloseTab::WriteReplyParams(reply_message, false); | 584 AutomationMsg_CloseTab::WriteReplyParams(reply_message, false); |
585 Send(reply_message); | 585 Send(reply_message); |
(...skipping 21 matching lines...) Expand all Loading... |
607 int handle, bool* success) { | 607 int handle, bool* success) { |
608 WebContents* contents = tab_tracker_->ContainsHandle(handle) ? | 608 WebContents* contents = tab_tracker_->ContainsHandle(handle) ? |
609 tab_tracker_->GetResource(handle)->GetWebContents() : NULL; | 609 tab_tracker_->GetResource(handle)->GetWebContents() : NULL; |
610 automation_util::DeleteCookie(url, cookie_name, contents, success); | 610 automation_util::DeleteCookie(url, cookie_name, contents, success); |
611 } | 611 } |
612 | 612 |
613 void TestingAutomationProvider::ShowCollectedCookiesDialog( | 613 void TestingAutomationProvider::ShowCollectedCookiesDialog( |
614 int handle, bool* success) { | 614 int handle, bool* success) { |
615 *success = false; | 615 *success = false; |
616 if (tab_tracker_->ContainsHandle(handle)) { | 616 if (tab_tracker_->ContainsHandle(handle)) { |
617 content::NavigationController* controller = | 617 NavigationController* controller = tab_tracker_->GetResource(handle); |
618 tab_tracker_->GetResource(handle); | |
619 WebContents* tab_contents = controller->GetWebContents(); | 618 WebContents* tab_contents = controller->GetWebContents(); |
620 Browser* browser = Browser::GetBrowserForController(controller, NULL); | 619 Browser* browser = Browser::GetBrowserForController(controller, NULL); |
621 browser->ShowCollectedCookiesDialog( | 620 browser->ShowCollectedCookiesDialog( |
622 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)); | 621 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)); |
623 *success = true; | 622 *success = true; |
624 } | 623 } |
625 } | 624 } |
626 | 625 |
627 void TestingAutomationProvider::NavigateToURLBlockUntilNavigationsComplete( | 626 void TestingAutomationProvider::NavigateToURLBlockUntilNavigationsComplete( |
628 int handle, const GURL& url, int number_of_navigations, | 627 int handle, const GURL& url, int number_of_navigations, |
629 IPC::Message* reply_message) { | 628 IPC::Message* reply_message) { |
630 if (tab_tracker_->ContainsHandle(handle)) { | 629 if (tab_tracker_->ContainsHandle(handle)) { |
631 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 630 NavigationController* tab = tab_tracker_->GetResource(handle); |
632 | 631 |
633 // Simulate what a user would do. Activate the tab and then navigate. | 632 // Simulate what a user would do. Activate the tab and then navigate. |
634 // We could allow navigating in a background tab in future. | 633 // We could allow navigating in a background tab in future. |
635 Browser* browser = FindAndActivateTab(tab); | 634 Browser* browser = FindAndActivateTab(tab); |
636 | 635 |
637 if (browser) { | 636 if (browser) { |
638 new NavigationNotificationObserver(tab, this, reply_message, | 637 new NavigationNotificationObserver(tab, this, reply_message, |
639 number_of_navigations, false, false); | 638 number_of_navigations, false, false); |
640 | 639 |
641 // TODO(darin): avoid conversion to GURL. | 640 // TODO(darin): avoid conversion to GURL. |
(...skipping 16 matching lines...) Expand all Loading... |
658 } | 657 } |
659 | 658 |
660 void TestingAutomationProvider::NavigationAsyncWithDisposition( | 659 void TestingAutomationProvider::NavigationAsyncWithDisposition( |
661 int handle, | 660 int handle, |
662 const GURL& url, | 661 const GURL& url, |
663 WindowOpenDisposition disposition, | 662 WindowOpenDisposition disposition, |
664 bool* status) { | 663 bool* status) { |
665 *status = false; | 664 *status = false; |
666 | 665 |
667 if (tab_tracker_->ContainsHandle(handle)) { | 666 if (tab_tracker_->ContainsHandle(handle)) { |
668 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 667 NavigationController* tab = tab_tracker_->GetResource(handle); |
669 | 668 |
670 // Simulate what a user would do. Activate the tab and then navigate. | 669 // Simulate what a user would do. Activate the tab and then navigate. |
671 // We could allow navigating in a background tab in future. | 670 // We could allow navigating in a background tab in future. |
672 Browser* browser = FindAndActivateTab(tab); | 671 Browser* browser = FindAndActivateTab(tab); |
673 | 672 |
674 if (browser) { | 673 if (browser) { |
675 // Don't add any listener unless a callback mechanism is desired. | 674 // Don't add any listener unless a callback mechanism is desired. |
676 // TODO(vibhor): Do this if such a requirement arises in future. | 675 // TODO(vibhor): Do this if such a requirement arises in future. |
677 OpenURLParams params( | 676 OpenURLParams params( |
678 url, Referrer(), disposition, content::PAGE_TRANSITION_TYPED, false); | 677 url, Referrer(), disposition, content::PAGE_TRANSITION_TYPED, false); |
679 browser->OpenURL(params); | 678 browser->OpenURL(params); |
680 *status = true; | 679 *status = true; |
681 } | 680 } |
682 } | 681 } |
683 } | 682 } |
684 | 683 |
685 void TestingAutomationProvider::Reload(int handle, | 684 void TestingAutomationProvider::Reload(int handle, |
686 IPC::Message* reply_message) { | 685 IPC::Message* reply_message) { |
687 if (tab_tracker_->ContainsHandle(handle)) { | 686 if (tab_tracker_->ContainsHandle(handle)) { |
688 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 687 NavigationController* tab = tab_tracker_->GetResource(handle); |
689 Browser* browser = FindAndActivateTab(tab); | 688 Browser* browser = FindAndActivateTab(tab); |
690 if (browser && browser->command_updater()->IsCommandEnabled(IDC_RELOAD)) { | 689 if (browser && browser->command_updater()->IsCommandEnabled(IDC_RELOAD)) { |
691 new NavigationNotificationObserver( | 690 new NavigationNotificationObserver( |
692 tab, this, reply_message, 1, false, false); | 691 tab, this, reply_message, 1, false, false); |
693 browser->Reload(CURRENT_TAB); | 692 browser->Reload(CURRENT_TAB); |
694 return; | 693 return; |
695 } | 694 } |
696 } | 695 } |
697 | 696 |
698 AutomationMsg_Reload::WriteReplyParams( | 697 AutomationMsg_Reload::WriteReplyParams( |
699 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); | 698 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); |
700 Send(reply_message); | 699 Send(reply_message); |
701 } | 700 } |
702 | 701 |
703 void TestingAutomationProvider::SetAuth(int tab_handle, | 702 void TestingAutomationProvider::SetAuth(int tab_handle, |
704 const std::wstring& username, | 703 const std::wstring& username, |
705 const std::wstring& password, | 704 const std::wstring& password, |
706 IPC::Message* reply_message) { | 705 IPC::Message* reply_message) { |
707 if (tab_tracker_->ContainsHandle(tab_handle)) { | 706 if (tab_tracker_->ContainsHandle(tab_handle)) { |
708 content::NavigationController* tab = tab_tracker_->GetResource(tab_handle); | 707 NavigationController* tab = tab_tracker_->GetResource(tab_handle); |
709 LoginHandlerMap::iterator iter = login_handler_map_.find(tab); | 708 LoginHandlerMap::iterator iter = login_handler_map_.find(tab); |
710 | 709 |
711 if (iter != login_handler_map_.end()) { | 710 if (iter != login_handler_map_.end()) { |
712 // If auth is needed again after this, assume login has failed. This is | 711 // If auth is needed again after this, assume login has failed. This is |
713 // not strictly correct, because a navigation can require both proxy and | 712 // not strictly correct, because a navigation can require both proxy and |
714 // server auth, but it should be OK for now. | 713 // server auth, but it should be OK for now. |
715 LoginHandler* handler = iter->second; | 714 LoginHandler* handler = iter->second; |
716 new NavigationNotificationObserver( | 715 new NavigationNotificationObserver( |
717 tab, this, reply_message, 1, false, false); | 716 tab, this, reply_message, 1, false, false); |
718 handler->SetAuth(WideToUTF16Hack(username), WideToUTF16Hack(password)); | 717 handler->SetAuth(WideToUTF16Hack(username), WideToUTF16Hack(password)); |
719 return; | 718 return; |
720 } | 719 } |
721 } | 720 } |
722 | 721 |
723 AutomationMsg_SetAuth::WriteReplyParams( | 722 AutomationMsg_SetAuth::WriteReplyParams( |
724 reply_message, AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED); | 723 reply_message, AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED); |
725 Send(reply_message); | 724 Send(reply_message); |
726 } | 725 } |
727 | 726 |
728 void TestingAutomationProvider::CancelAuth(int tab_handle, | 727 void TestingAutomationProvider::CancelAuth(int tab_handle, |
729 IPC::Message* reply_message) { | 728 IPC::Message* reply_message) { |
730 if (tab_tracker_->ContainsHandle(tab_handle)) { | 729 if (tab_tracker_->ContainsHandle(tab_handle)) { |
731 content::NavigationController* tab = tab_tracker_->GetResource(tab_handle); | 730 NavigationController* tab = tab_tracker_->GetResource(tab_handle); |
732 LoginHandlerMap::iterator iter = login_handler_map_.find(tab); | 731 LoginHandlerMap::iterator iter = login_handler_map_.find(tab); |
733 | 732 |
734 if (iter != login_handler_map_.end()) { | 733 if (iter != login_handler_map_.end()) { |
735 // If auth is needed again after this, something is screwy. | 734 // If auth is needed again after this, something is screwy. |
736 LoginHandler* handler = iter->second; | 735 LoginHandler* handler = iter->second; |
737 new NavigationNotificationObserver( | 736 new NavigationNotificationObserver( |
738 tab, this, reply_message, 1, false, false); | 737 tab, this, reply_message, 1, false, false); |
739 handler->CancelAuth(); | 738 handler->CancelAuth(); |
740 return; | 739 return; |
741 } | 740 } |
742 } | 741 } |
743 | 742 |
744 AutomationMsg_CancelAuth::WriteReplyParams( | 743 AutomationMsg_CancelAuth::WriteReplyParams( |
745 reply_message, AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED); | 744 reply_message, AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED); |
746 Send(reply_message); | 745 Send(reply_message); |
747 } | 746 } |
748 | 747 |
749 void TestingAutomationProvider::NeedsAuth(int tab_handle, bool* needs_auth) { | 748 void TestingAutomationProvider::NeedsAuth(int tab_handle, bool* needs_auth) { |
750 *needs_auth = false; | 749 *needs_auth = false; |
751 | 750 |
752 if (tab_tracker_->ContainsHandle(tab_handle)) { | 751 if (tab_tracker_->ContainsHandle(tab_handle)) { |
753 content::NavigationController* tab = tab_tracker_->GetResource(tab_handle); | 752 NavigationController* tab = tab_tracker_->GetResource(tab_handle); |
754 LoginHandlerMap::iterator iter = login_handler_map_.find(tab); | 753 LoginHandlerMap::iterator iter = login_handler_map_.find(tab); |
755 | 754 |
756 if (iter != login_handler_map_.end()) { | 755 if (iter != login_handler_map_.end()) { |
757 // The LoginHandler will be in our map IFF the tab needs auth. | 756 // The LoginHandler will be in our map IFF the tab needs auth. |
758 *needs_auth = true; | 757 *needs_auth = true; |
759 } | 758 } |
760 } | 759 } |
761 } | 760 } |
762 | 761 |
763 void TestingAutomationProvider::GetRedirectsFrom(int tab_handle, | 762 void TestingAutomationProvider::GetRedirectsFrom(int tab_handle, |
764 const GURL& source_url, | 763 const GURL& source_url, |
765 IPC::Message* reply_message) { | 764 IPC::Message* reply_message) { |
766 if (redirect_query_) { | 765 if (redirect_query_) { |
767 LOG(ERROR) << "Can only handle one redirect query at once."; | 766 LOG(ERROR) << "Can only handle one redirect query at once."; |
768 } else if (tab_tracker_->ContainsHandle(tab_handle)) { | 767 } else if (tab_tracker_->ContainsHandle(tab_handle)) { |
769 content::NavigationController* tab = tab_tracker_->GetResource(tab_handle); | 768 NavigationController* tab = tab_tracker_->GetResource(tab_handle); |
770 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 769 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
771 HistoryService* history_service = | 770 HistoryService* history_service = |
772 profile->GetHistoryService(Profile::EXPLICIT_ACCESS); | 771 profile->GetHistoryService(Profile::EXPLICIT_ACCESS); |
773 | 772 |
774 DCHECK(history_service) << "Tab " << tab_handle << "'s profile " << | 773 DCHECK(history_service) << "Tab " << tab_handle << "'s profile " << |
775 "has no history service"; | 774 "has no history service"; |
776 if (history_service) { | 775 if (history_service) { |
777 DCHECK(!reply_message_); | 776 DCHECK(!reply_message_); |
778 reply_message_ = reply_message; | 777 reply_message_ = reply_message; |
779 // Schedule a history query for redirects. The response will be sent | 778 // Schedule a history query for redirects. The response will be sent |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 if (rph) | 1278 if (rph) |
1280 *process_id = base::GetProcId(rph->GetHandle()); | 1279 *process_id = base::GetProcId(rph->GetHandle()); |
1281 } | 1280 } |
1282 } | 1281 } |
1283 | 1282 |
1284 void TestingAutomationProvider::GetTabTitle(int handle, | 1283 void TestingAutomationProvider::GetTabTitle(int handle, |
1285 int* title_string_size, | 1284 int* title_string_size, |
1286 std::wstring* title) { | 1285 std::wstring* title) { |
1287 *title_string_size = -1; // -1 is the error code | 1286 *title_string_size = -1; // -1 is the error code |
1288 if (tab_tracker_->ContainsHandle(handle)) { | 1287 if (tab_tracker_->ContainsHandle(handle)) { |
1289 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 1288 NavigationController* tab = tab_tracker_->GetResource(handle); |
1290 NavigationEntry* entry = tab->GetActiveEntry(); | 1289 NavigationEntry* entry = tab->GetActiveEntry(); |
1291 if (entry != NULL) { | 1290 if (entry != NULL) { |
1292 *title = UTF16ToWideHack(entry->GetTitleForDisplay("")); | 1291 *title = UTF16ToWideHack(entry->GetTitleForDisplay("")); |
1293 } else { | 1292 } else { |
1294 *title = std::wstring(); | 1293 *title = std::wstring(); |
1295 } | 1294 } |
1296 *title_string_size = static_cast<int>(title->size()); | 1295 *title_string_size = static_cast<int>(title->size()); |
1297 } | 1296 } |
1298 } | 1297 } |
1299 | 1298 |
1300 void TestingAutomationProvider::GetTabIndex(int handle, int* tabstrip_index) { | 1299 void TestingAutomationProvider::GetTabIndex(int handle, int* tabstrip_index) { |
1301 *tabstrip_index = -1; // -1 is the error code | 1300 *tabstrip_index = -1; // -1 is the error code |
1302 | 1301 |
1303 if (tab_tracker_->ContainsHandle(handle)) { | 1302 if (tab_tracker_->ContainsHandle(handle)) { |
1304 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 1303 NavigationController* tab = tab_tracker_->GetResource(handle); |
1305 Browser* browser = Browser::GetBrowserForController(tab, NULL); | 1304 Browser* browser = Browser::GetBrowserForController(tab, NULL); |
1306 *tabstrip_index = browser->tabstrip_model()->GetIndexOfController(tab); | 1305 *tabstrip_index = browser->tabstrip_model()->GetIndexOfController(tab); |
1307 } | 1306 } |
1308 } | 1307 } |
1309 | 1308 |
1310 void TestingAutomationProvider::GetTabURL(int handle, | 1309 void TestingAutomationProvider::GetTabURL(int handle, |
1311 bool* success, | 1310 bool* success, |
1312 GURL* url) { | 1311 GURL* url) { |
1313 *success = false; | 1312 *success = false; |
1314 if (tab_tracker_->ContainsHandle(handle)) { | 1313 if (tab_tracker_->ContainsHandle(handle)) { |
1315 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 1314 NavigationController* tab = tab_tracker_->GetResource(handle); |
1316 // Return what the user would see in the location bar. | 1315 // Return what the user would see in the location bar. |
1317 *url = tab->GetActiveEntry()->GetVirtualURL(); | 1316 *url = tab->GetActiveEntry()->GetVirtualURL(); |
1318 *success = true; | 1317 *success = true; |
1319 } | 1318 } |
1320 } | 1319 } |
1321 | 1320 |
1322 void TestingAutomationProvider::GetShelfVisibility(int handle, bool* visible) { | 1321 void TestingAutomationProvider::GetShelfVisibility(int handle, bool* visible) { |
1323 *visible = false; | 1322 *visible = false; |
1324 | 1323 |
1325 if (browser_tracker_->ContainsHandle(handle)) { | 1324 if (browser_tracker_->ContainsHandle(handle)) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 new DomOperationMessageSender(this, reply_message, false); | 1393 new DomOperationMessageSender(this, reply_message, false); |
1395 ExecuteJavascriptInRenderViewFrame(WideToUTF16Hack(frame_xpath), | 1394 ExecuteJavascriptInRenderViewFrame(WideToUTF16Hack(frame_xpath), |
1396 WideToUTF16Hack(script), reply_message, | 1395 WideToUTF16Hack(script), reply_message, |
1397 web_contents->GetRenderViewHost()); | 1396 web_contents->GetRenderViewHost()); |
1398 } | 1397 } |
1399 | 1398 |
1400 void TestingAutomationProvider::GetConstrainedWindowCount(int handle, | 1399 void TestingAutomationProvider::GetConstrainedWindowCount(int handle, |
1401 int* count) { | 1400 int* count) { |
1402 *count = -1; // -1 is the error code | 1401 *count = -1; // -1 is the error code |
1403 if (tab_tracker_->ContainsHandle(handle)) { | 1402 if (tab_tracker_->ContainsHandle(handle)) { |
1404 content::NavigationController* nav_controller = tab_tracker_->GetResource(ha
ndle); | 1403 NavigationController* nav_controller = tab_tracker_->GetResource(handle); |
1405 WebContents* web_contents = nav_controller->GetWebContents(); | 1404 WebContents* web_contents = nav_controller->GetWebContents(); |
1406 if (web_contents) { | 1405 if (web_contents) { |
1407 TabContentsWrapper* wrapper = | 1406 TabContentsWrapper* wrapper = |
1408 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 1407 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); |
1409 if (wrapper) { | 1408 if (wrapper) { |
1410 *count = static_cast<int>(wrapper->constrained_window_tab_helper()-> | 1409 *count = static_cast<int>(wrapper->constrained_window_tab_helper()-> |
1411 constrained_window_count()); | 1410 constrained_window_count()); |
1412 } | 1411 } |
1413 } | 1412 } |
1414 } | 1413 } |
1415 } | 1414 } |
1416 | 1415 |
1417 void TestingAutomationProvider::HandleInspectElementRequest( | 1416 void TestingAutomationProvider::HandleInspectElementRequest( |
1418 int handle, int x, int y, IPC::Message* reply_message) { | 1417 int handle, int x, int y, IPC::Message* reply_message) { |
1419 WebContents* web_contents = GetWebContentsForHandle(handle, NULL); | 1418 WebContents* web_contents = GetWebContentsForHandle(handle, NULL); |
1420 if (web_contents) { | 1419 if (web_contents) { |
1421 DCHECK(!reply_message_); | 1420 DCHECK(!reply_message_); |
1422 reply_message_ = reply_message; | 1421 reply_message_ = reply_message; |
1423 | 1422 |
1424 DevToolsWindow::InspectElement(web_contents->GetRenderViewHost(), x, y); | 1423 DevToolsWindow::InspectElement(web_contents->GetRenderViewHost(), x, y); |
1425 } else { | 1424 } else { |
1426 AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1); | 1425 AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1); |
1427 Send(reply_message); | 1426 Send(reply_message); |
1428 } | 1427 } |
1429 } | 1428 } |
1430 | 1429 |
1431 void TestingAutomationProvider::GetDownloadDirectory( | 1430 void TestingAutomationProvider::GetDownloadDirectory( |
1432 int handle, FilePath* download_directory) { | 1431 int handle, FilePath* download_directory) { |
1433 if (tab_tracker_->ContainsHandle(handle)) { | 1432 if (tab_tracker_->ContainsHandle(handle)) { |
1434 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 1433 NavigationController* tab = tab_tracker_->GetResource(handle); |
1435 DownloadManager* dlm = tab->GetBrowserContext()->GetDownloadManager(); | 1434 DownloadManager* dlm = tab->GetBrowserContext()->GetDownloadManager(); |
1436 *download_directory = | 1435 *download_directory = |
1437 DownloadPrefs::FromDownloadManager(dlm)->download_path(); | 1436 DownloadPrefs::FromDownloadManager(dlm)->download_path(); |
1438 } | 1437 } |
1439 } | 1438 } |
1440 | 1439 |
1441 // Sample json input: { "command": "OpenNewBrowserWindowWithNewProfile" } | 1440 // Sample json input: { "command": "OpenNewBrowserWindowWithNewProfile" } |
1442 // Sample output: {} | 1441 // Sample output: {} |
1443 void TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile( | 1442 void TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile( |
1444 base::DictionaryValue* args, IPC::Message* reply_message) { | 1443 base::DictionaryValue* args, IPC::Message* reply_message) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 return; | 1517 return; |
1519 } | 1518 } |
1520 } | 1519 } |
1521 } | 1520 } |
1522 | 1521 |
1523 void TestingAutomationProvider::ShowInterstitialPage( | 1522 void TestingAutomationProvider::ShowInterstitialPage( |
1524 int tab_handle, | 1523 int tab_handle, |
1525 const std::string& html_text, | 1524 const std::string& html_text, |
1526 IPC::Message* reply_message) { | 1525 IPC::Message* reply_message) { |
1527 if (tab_tracker_->ContainsHandle(tab_handle)) { | 1526 if (tab_tracker_->ContainsHandle(tab_handle)) { |
1528 content::NavigationController* controller = | 1527 NavigationController* controller = tab_tracker_->GetResource(tab_handle); |
1529 tab_tracker_->GetResource(tab_handle); | |
1530 WebContents* web_contents = controller->GetWebContents(); | 1528 WebContents* web_contents = controller->GetWebContents(); |
1531 | 1529 |
1532 new NavigationNotificationObserver(controller, this, reply_message, 1, | 1530 new NavigationNotificationObserver(controller, this, reply_message, 1, |
1533 false, false); | 1531 false, false); |
1534 | 1532 |
1535 AutomationInterstitialPage* interstitial = | 1533 AutomationInterstitialPage* interstitial = |
1536 new AutomationInterstitialPage(static_cast<TabContents*>(web_contents), | 1534 new AutomationInterstitialPage(static_cast<TabContents*>(web_contents), |
1537 GURL("about:interstitial"), | 1535 GURL("about:interstitial"), |
1538 html_text); | 1536 html_text); |
1539 interstitial->Show(); | 1537 interstitial->Show(); |
(...skipping 12 matching lines...) Expand all Loading... |
1552 if (web_contents && web_contents->GetInterstitialPage()) { | 1550 if (web_contents && web_contents->GetInterstitialPage()) { |
1553 web_contents->GetInterstitialPage()->DontProceed(); | 1551 web_contents->GetInterstitialPage()->DontProceed(); |
1554 *success = true; | 1552 *success = true; |
1555 } | 1553 } |
1556 } | 1554 } |
1557 | 1555 |
1558 void TestingAutomationProvider::WaitForTabToBeRestored( | 1556 void TestingAutomationProvider::WaitForTabToBeRestored( |
1559 int tab_handle, | 1557 int tab_handle, |
1560 IPC::Message* reply_message) { | 1558 IPC::Message* reply_message) { |
1561 if (tab_tracker_->ContainsHandle(tab_handle)) { | 1559 if (tab_tracker_->ContainsHandle(tab_handle)) { |
1562 content::NavigationController* tab = tab_tracker_->GetResource(tab_handle); | 1560 NavigationController* tab = tab_tracker_->GetResource(tab_handle); |
1563 restore_tracker_.reset( | 1561 restore_tracker_.reset( |
1564 new NavigationControllerRestoredObserver(this, tab, reply_message)); | 1562 new NavigationControllerRestoredObserver(this, tab, reply_message)); |
1565 } else { | 1563 } else { |
1566 AutomationMsg_WaitForTabToBeRestored::WriteReplyParams( | 1564 AutomationMsg_WaitForTabToBeRestored::WriteReplyParams( |
1567 reply_message, false); | 1565 reply_message, false); |
1568 Send(reply_message); | 1566 Send(reply_message); |
1569 } | 1567 } |
1570 } | 1568 } |
1571 | 1569 |
1572 void TestingAutomationProvider::GetSecurityState( | 1570 void TestingAutomationProvider::GetSecurityState( |
1573 int handle, | 1571 int handle, |
1574 bool* success, | 1572 bool* success, |
1575 content::SecurityStyle* security_style, | 1573 content::SecurityStyle* security_style, |
1576 net::CertStatus* ssl_cert_status, | 1574 net::CertStatus* ssl_cert_status, |
1577 int* insecure_content_status) { | 1575 int* insecure_content_status) { |
1578 if (tab_tracker_->ContainsHandle(handle)) { | 1576 if (tab_tracker_->ContainsHandle(handle)) { |
1579 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 1577 NavigationController* tab = tab_tracker_->GetResource(handle); |
1580 NavigationEntry* entry = tab->GetActiveEntry(); | 1578 NavigationEntry* entry = tab->GetActiveEntry(); |
1581 *success = true; | 1579 *success = true; |
1582 *security_style = entry->GetSSL().security_style; | 1580 *security_style = entry->GetSSL().security_style; |
1583 *ssl_cert_status = entry->GetSSL().cert_status; | 1581 *ssl_cert_status = entry->GetSSL().cert_status; |
1584 *insecure_content_status = entry->GetSSL().content_status; | 1582 *insecure_content_status = entry->GetSSL().content_status; |
1585 } else { | 1583 } else { |
1586 *success = false; | 1584 *success = false; |
1587 *security_style = content::SECURITY_STYLE_UNKNOWN; | 1585 *security_style = content::SECURITY_STYLE_UNKNOWN; |
1588 *ssl_cert_status = 0; | 1586 *ssl_cert_status = 0; |
1589 *insecure_content_status = 0; | 1587 *insecure_content_status = 0; |
1590 } | 1588 } |
1591 } | 1589 } |
1592 | 1590 |
1593 void TestingAutomationProvider::GetPageType( | 1591 void TestingAutomationProvider::GetPageType( |
1594 int handle, | 1592 int handle, |
1595 bool* success, | 1593 bool* success, |
1596 content::PageType* page_type) { | 1594 content::PageType* page_type) { |
1597 if (tab_tracker_->ContainsHandle(handle)) { | 1595 if (tab_tracker_->ContainsHandle(handle)) { |
1598 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 1596 NavigationController* tab = tab_tracker_->GetResource(handle); |
1599 NavigationEntry* entry = tab->GetActiveEntry(); | 1597 NavigationEntry* entry = tab->GetActiveEntry(); |
1600 *page_type = entry->GetPageType(); | 1598 *page_type = entry->GetPageType(); |
1601 *success = true; | 1599 *success = true; |
1602 // In order to return the proper result when an interstitial is shown and | 1600 // In order to return the proper result when an interstitial is shown and |
1603 // no navigation entry were created for it we need to ask the TabContents. | 1601 // no navigation entry were created for it we need to ask the TabContents. |
1604 if (*page_type == content::PAGE_TYPE_NORMAL && | 1602 if (*page_type == content::PAGE_TYPE_NORMAL && |
1605 tab->GetWebContents()->ShowingInterstitialPage()) | 1603 tab->GetWebContents()->ShowingInterstitialPage()) |
1606 *page_type = content::PAGE_TYPE_INTERSTITIAL; | 1604 *page_type = content::PAGE_TYPE_INTERSTITIAL; |
1607 } else { | 1605 } else { |
1608 *success = false; | 1606 *success = false; |
1609 *page_type = content::PAGE_TYPE_NORMAL; | 1607 *page_type = content::PAGE_TYPE_NORMAL; |
1610 } | 1608 } |
1611 } | 1609 } |
1612 | 1610 |
1613 void TestingAutomationProvider::GetMetricEventDuration( | 1611 void TestingAutomationProvider::GetMetricEventDuration( |
1614 const std::string& event_name, | 1612 const std::string& event_name, |
1615 int* duration_ms) { | 1613 int* duration_ms) { |
1616 *duration_ms = metric_event_duration_observer_->GetEventDurationMs( | 1614 *duration_ms = metric_event_duration_observer_->GetEventDurationMs( |
1617 event_name); | 1615 event_name); |
1618 } | 1616 } |
1619 | 1617 |
1620 void TestingAutomationProvider::ActionOnSSLBlockingPage( | 1618 void TestingAutomationProvider::ActionOnSSLBlockingPage( |
1621 int handle, | 1619 int handle, |
1622 bool proceed, | 1620 bool proceed, |
1623 IPC::Message* reply_message) { | 1621 IPC::Message* reply_message) { |
1624 if (tab_tracker_->ContainsHandle(handle)) { | 1622 if (tab_tracker_->ContainsHandle(handle)) { |
1625 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 1623 NavigationController* tab = tab_tracker_->GetResource(handle); |
1626 NavigationEntry* entry = tab->GetActiveEntry(); | 1624 NavigationEntry* entry = tab->GetActiveEntry(); |
1627 if (entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { | 1625 if (entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { |
1628 WebContents* web_contents = tab->GetWebContents(); | 1626 WebContents* web_contents = tab->GetWebContents(); |
1629 InterstitialPage* ssl_blocking_page = | 1627 InterstitialPage* ssl_blocking_page = |
1630 InterstitialPage::GetInterstitialPage( | 1628 InterstitialPage::GetInterstitialPage( |
1631 static_cast<TabContents*>(web_contents)); | 1629 static_cast<TabContents*>(web_contents)); |
1632 if (ssl_blocking_page) { | 1630 if (ssl_blocking_page) { |
1633 if (proceed) { | 1631 if (proceed) { |
1634 new NavigationNotificationObserver(tab, this, reply_message, 1, | 1632 new NavigationNotificationObserver(tab, this, reply_message, 1, |
1635 false, false); | 1633 false, false); |
(...skipping 30 matching lines...) Expand all Loading... |
1666 *menu_item_enabled = false; | 1664 *menu_item_enabled = false; |
1667 if (browser_tracker_->ContainsHandle(browser_handle)) { | 1665 if (browser_tracker_->ContainsHandle(browser_handle)) { |
1668 Browser* browser = browser_tracker_->GetResource(browser_handle); | 1666 Browser* browser = browser_tracker_->GetResource(browser_handle); |
1669 *menu_item_enabled = | 1667 *menu_item_enabled = |
1670 browser->command_updater()->IsCommandEnabled(message_num); | 1668 browser->command_updater()->IsCommandEnabled(message_num); |
1671 } | 1669 } |
1672 } | 1670 } |
1673 | 1671 |
1674 void TestingAutomationProvider::PrintNow(int tab_handle, | 1672 void TestingAutomationProvider::PrintNow(int tab_handle, |
1675 IPC::Message* reply_message) { | 1673 IPC::Message* reply_message) { |
1676 content::NavigationController* tab = NULL; | 1674 NavigationController* tab = NULL; |
1677 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); | 1675 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); |
1678 if (web_contents) { | 1676 if (web_contents) { |
1679 FindAndActivateTab(tab); | 1677 FindAndActivateTab(tab); |
1680 | 1678 |
1681 content::NotificationObserver* observer = | 1679 content::NotificationObserver* observer = |
1682 new DocumentPrintedNotificationObserver(this, reply_message); | 1680 new DocumentPrintedNotificationObserver(this, reply_message); |
1683 | 1681 |
1684 TabContentsWrapper* wrapper = | 1682 TabContentsWrapper* wrapper = |
1685 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 1683 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); |
1686 if (!wrapper->print_view_manager()->PrintNow()) { | 1684 if (!wrapper->print_view_manager()->PrintNow()) { |
(...skipping 20 matching lines...) Expand all Loading... |
1707 save_type > SavePackage::SAVE_AS_COMPLETE_HTML) { | 1705 save_type > SavePackage::SAVE_AS_COMPLETE_HTML) { |
1708 *success = false; | 1706 *success = false; |
1709 return; | 1707 return; |
1710 } | 1708 } |
1711 | 1709 |
1712 if (!tab_tracker_->ContainsHandle(tab_handle)) { | 1710 if (!tab_tracker_->ContainsHandle(tab_handle)) { |
1713 *success = false; | 1711 *success = false; |
1714 return; | 1712 return; |
1715 } | 1713 } |
1716 | 1714 |
1717 content::NavigationController* nav = tab_tracker_->GetResource(tab_handle); | 1715 NavigationController* nav = tab_tracker_->GetResource(tab_handle); |
1718 Browser* browser = FindAndActivateTab(nav); | 1716 Browser* browser = FindAndActivateTab(nav); |
1719 if (!browser->command_updater()->IsCommandEnabled(IDC_SAVE_PAGE)) { | 1717 if (!browser->command_updater()->IsCommandEnabled(IDC_SAVE_PAGE)) { |
1720 *success = false; | 1718 *success = false; |
1721 return; | 1719 return; |
1722 } | 1720 } |
1723 | 1721 |
1724 nav->GetWebContents()->SavePage(file_name, dir_path, save_type); | 1722 nav->GetWebContents()->SavePage(file_name, dir_path, save_type); |
1725 *success = true; | 1723 *success = true; |
1726 } | 1724 } |
1727 | 1725 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 *success = true; | 1964 *success = true; |
1967 } | 1965 } |
1968 } | 1966 } |
1969 } | 1967 } |
1970 *success = false; | 1968 *success = false; |
1971 } | 1969 } |
1972 | 1970 |
1973 void TestingAutomationProvider::GetInfoBarCount(int handle, size_t* count) { | 1971 void TestingAutomationProvider::GetInfoBarCount(int handle, size_t* count) { |
1974 *count = static_cast<size_t>(-1); // -1 means error. | 1972 *count = static_cast<size_t>(-1); // -1 means error. |
1975 if (tab_tracker_->ContainsHandle(handle)) { | 1973 if (tab_tracker_->ContainsHandle(handle)) { |
1976 content::NavigationController* nav_controller = | 1974 NavigationController* nav_controller = tab_tracker_->GetResource(handle); |
1977 tab_tracker_->GetResource(handle); | |
1978 if (nav_controller) { | 1975 if (nav_controller) { |
1979 TabContentsWrapper* wrapper = | 1976 TabContentsWrapper* wrapper = |
1980 TabContentsWrapper::GetCurrentWrapperForContents( | 1977 TabContentsWrapper::GetCurrentWrapperForContents( |
1981 nav_controller->GetWebContents()); | 1978 nav_controller->GetWebContents()); |
1982 *count = wrapper->infobar_tab_helper()->infobar_count(); | 1979 *count = wrapper->infobar_tab_helper()->infobar_count(); |
1983 } | 1980 } |
1984 } | 1981 } |
1985 } | 1982 } |
1986 | 1983 |
1987 void TestingAutomationProvider::ClickInfoBarAccept( | 1984 void TestingAutomationProvider::ClickInfoBarAccept( |
1988 int handle, | 1985 int handle, |
1989 size_t info_bar_index, | 1986 size_t info_bar_index, |
1990 bool wait_for_navigation, | 1987 bool wait_for_navigation, |
1991 IPC::Message* reply_message) { | 1988 IPC::Message* reply_message) { |
1992 bool success = false; | 1989 bool success = false; |
1993 if (tab_tracker_->ContainsHandle(handle)) { | 1990 if (tab_tracker_->ContainsHandle(handle)) { |
1994 content::NavigationController* nav_controller = | 1991 NavigationController* nav_controller = tab_tracker_->GetResource(handle); |
1995 tab_tracker_->GetResource(handle); | |
1996 if (nav_controller) { | 1992 if (nav_controller) { |
1997 InfoBarTabHelper* infobar_helper = | 1993 InfoBarTabHelper* infobar_helper = |
1998 TabContentsWrapper::GetCurrentWrapperForContents( | 1994 TabContentsWrapper::GetCurrentWrapperForContents( |
1999 nav_controller->GetWebContents())->infobar_tab_helper(); | 1995 nav_controller->GetWebContents())->infobar_tab_helper(); |
2000 if (info_bar_index < infobar_helper->infobar_count()) { | 1996 if (info_bar_index < infobar_helper->infobar_count()) { |
2001 if (wait_for_navigation) { | 1997 if (wait_for_navigation) { |
2002 new NavigationNotificationObserver(nav_controller, this, | 1998 new NavigationNotificationObserver(nav_controller, this, |
2003 reply_message, 1, false, false); | 1999 reply_message, 1, false, false); |
2004 } | 2000 } |
2005 InfoBarDelegate* delegate = | 2001 InfoBarDelegate* delegate = |
(...skipping 18 matching lines...) Expand all Loading... |
2024 void TestingAutomationProvider::GetLastNavigationTime( | 2020 void TestingAutomationProvider::GetLastNavigationTime( |
2025 int handle, | 2021 int handle, |
2026 int64* last_navigation_time) { | 2022 int64* last_navigation_time) { |
2027 base::Time time(tab_tracker_->GetLastNavigationTime(handle)); | 2023 base::Time time(tab_tracker_->GetLastNavigationTime(handle)); |
2028 *last_navigation_time = time.ToInternalValue(); | 2024 *last_navigation_time = time.ToInternalValue(); |
2029 } | 2025 } |
2030 | 2026 |
2031 void TestingAutomationProvider::WaitForNavigation(int handle, | 2027 void TestingAutomationProvider::WaitForNavigation(int handle, |
2032 int64 last_navigation_time, | 2028 int64 last_navigation_time, |
2033 IPC::Message* reply_message) { | 2029 IPC::Message* reply_message) { |
2034 content::NavigationController* controller = tab_tracker_->GetResource(handle); | 2030 NavigationController* controller = tab_tracker_->GetResource(handle); |
2035 base::Time time(tab_tracker_->GetLastNavigationTime(handle)); | 2031 base::Time time(tab_tracker_->GetLastNavigationTime(handle)); |
2036 | 2032 |
2037 if (time.ToInternalValue() > last_navigation_time || !controller) { | 2033 if (time.ToInternalValue() > last_navigation_time || !controller) { |
2038 AutomationMsg_WaitForNavigation::WriteReplyParams(reply_message, | 2034 AutomationMsg_WaitForNavigation::WriteReplyParams(reply_message, |
2039 controller == NULL ? AUTOMATION_MSG_NAVIGATION_ERROR : | 2035 controller == NULL ? AUTOMATION_MSG_NAVIGATION_ERROR : |
2040 AUTOMATION_MSG_NAVIGATION_SUCCESS); | 2036 AUTOMATION_MSG_NAVIGATION_SUCCESS); |
2041 Send(reply_message); | 2037 Send(reply_message); |
2042 return; | 2038 return; |
2043 } | 2039 } |
2044 | 2040 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2155 return; | 2151 return; |
2156 } | 2152 } |
2157 | 2153 |
2158 // Set up an observer (it will delete itself). | 2154 // Set up an observer (it will delete itself). |
2159 new AppModalDialogShownObserver(this, reply_message); | 2155 new AppModalDialogShownObserver(this, reply_message); |
2160 } | 2156 } |
2161 | 2157 |
2162 void TestingAutomationProvider::GoBackBlockUntilNavigationsComplete( | 2158 void TestingAutomationProvider::GoBackBlockUntilNavigationsComplete( |
2163 int handle, int number_of_navigations, IPC::Message* reply_message) { | 2159 int handle, int number_of_navigations, IPC::Message* reply_message) { |
2164 if (tab_tracker_->ContainsHandle(handle)) { | 2160 if (tab_tracker_->ContainsHandle(handle)) { |
2165 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 2161 NavigationController* tab = tab_tracker_->GetResource(handle); |
2166 Browser* browser = FindAndActivateTab(tab); | 2162 Browser* browser = FindAndActivateTab(tab); |
2167 if (browser && browser->command_updater()->IsCommandEnabled(IDC_BACK)) { | 2163 if (browser && browser->command_updater()->IsCommandEnabled(IDC_BACK)) { |
2168 new NavigationNotificationObserver(tab, this, reply_message, | 2164 new NavigationNotificationObserver(tab, this, reply_message, |
2169 number_of_navigations, false, false); | 2165 number_of_navigations, false, false); |
2170 browser->GoBack(CURRENT_TAB); | 2166 browser->GoBack(CURRENT_TAB); |
2171 return; | 2167 return; |
2172 } | 2168 } |
2173 } | 2169 } |
2174 | 2170 |
2175 AutomationMsg_GoBackBlockUntilNavigationsComplete::WriteReplyParams( | 2171 AutomationMsg_GoBackBlockUntilNavigationsComplete::WriteReplyParams( |
2176 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); | 2172 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); |
2177 Send(reply_message); | 2173 Send(reply_message); |
2178 } | 2174 } |
2179 | 2175 |
2180 void TestingAutomationProvider::GoForwardBlockUntilNavigationsComplete( | 2176 void TestingAutomationProvider::GoForwardBlockUntilNavigationsComplete( |
2181 int handle, int number_of_navigations, IPC::Message* reply_message) { | 2177 int handle, int number_of_navigations, IPC::Message* reply_message) { |
2182 if (tab_tracker_->ContainsHandle(handle)) { | 2178 if (tab_tracker_->ContainsHandle(handle)) { |
2183 content::NavigationController* tab = tab_tracker_->GetResource(handle); | 2179 NavigationController* tab = tab_tracker_->GetResource(handle); |
2184 Browser* browser = FindAndActivateTab(tab); | 2180 Browser* browser = FindAndActivateTab(tab); |
2185 if (browser && browser->command_updater()->IsCommandEnabled(IDC_FORWARD)) { | 2181 if (browser && browser->command_updater()->IsCommandEnabled(IDC_FORWARD)) { |
2186 new NavigationNotificationObserver(tab, this, reply_message, | 2182 new NavigationNotificationObserver(tab, this, reply_message, |
2187 number_of_navigations, false, false); | 2183 number_of_navigations, false, false); |
2188 browser->GoForward(CURRENT_TAB); | 2184 browser->GoForward(CURRENT_TAB); |
2189 return; | 2185 return; |
2190 } | 2186 } |
2191 } | 2187 } |
2192 | 2188 |
2193 AutomationMsg_GoForwardBlockUntilNavigationsComplete::WriteReplyParams( | 2189 AutomationMsg_GoForwardBlockUntilNavigationsComplete::WriteReplyParams( |
(...skipping 22 matching lines...) Expand all Loading... |
2216 else | 2212 else |
2217 browser->window()->GetDownloadShelf()->Close(); | 2213 browser->window()->GetDownloadShelf()->Close(); |
2218 #endif | 2214 #endif |
2219 } | 2215 } |
2220 } | 2216 } |
2221 } | 2217 } |
2222 | 2218 |
2223 void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) { | 2219 void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) { |
2224 *count = -1; // -1 is the error code | 2220 *count = -1; // -1 is the error code |
2225 if (tab_tracker_->ContainsHandle(handle)) { | 2221 if (tab_tracker_->ContainsHandle(handle)) { |
2226 content::NavigationController* nav_controller = | 2222 NavigationController* nav_controller = tab_tracker_->GetResource(handle); |
2227 tab_tracker_->GetResource(handle); | |
2228 TabContentsWrapper* tab_contents = | 2223 TabContentsWrapper* tab_contents = |
2229 TabContentsWrapper::GetCurrentWrapperForContents( | 2224 TabContentsWrapper::GetCurrentWrapperForContents( |
2230 nav_controller->GetWebContents()); | 2225 nav_controller->GetWebContents()); |
2231 if (tab_contents) { | 2226 if (tab_contents) { |
2232 BlockedContentTabHelper* blocked_content = | 2227 BlockedContentTabHelper* blocked_content = |
2233 tab_contents->blocked_content_tab_helper(); | 2228 tab_contents->blocked_content_tab_helper(); |
2234 *count = static_cast<int>(blocked_content->GetBlockedContentsCount()); | 2229 *count = static_cast<int>(blocked_content->GetBlockedContentsCount()); |
2235 } | 2230 } |
2236 } | 2231 } |
2237 } | 2232 } |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2972 IPC::Message* reply_message) { | 2967 IPC::Message* reply_message) { |
2973 AutomationJSONReply reply(this, reply_message); | 2968 AutomationJSONReply reply(this, reply_message); |
2974 int tab_index; | 2969 int tab_index; |
2975 TabContents* tab_contents = NULL; | 2970 TabContents* tab_contents = NULL; |
2976 if (!args->GetInteger("tab_index", &tab_index) || | 2971 if (!args->GetInteger("tab_index", &tab_index) || |
2977 !(tab_contents = browser->GetTabContentsAt(tab_index))) { | 2972 !(tab_contents = browser->GetTabContentsAt(tab_index))) { |
2978 reply.SendError("tab_index missing or invalid."); | 2973 reply.SendError("tab_index missing or invalid."); |
2979 return; | 2974 return; |
2980 } | 2975 } |
2981 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2976 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
2982 const content::NavigationController& controller = | 2977 const NavigationController& controller = tab_contents->GetController(); |
2983 tab_contents->GetController(); | |
2984 NavigationEntry* nav_entry = controller.GetActiveEntry(); | 2978 NavigationEntry* nav_entry = controller.GetActiveEntry(); |
2985 DCHECK(nav_entry); | 2979 DCHECK(nav_entry); |
2986 | 2980 |
2987 // Security info. | 2981 // Security info. |
2988 DictionaryValue* ssl = new DictionaryValue; | 2982 DictionaryValue* ssl = new DictionaryValue; |
2989 std::map<content::SecurityStyle, std::string> style_to_string; | 2983 std::map<content::SecurityStyle, std::string> style_to_string; |
2990 style_to_string[content::SECURITY_STYLE_UNKNOWN] = "SECURITY_STYLE_UNKNOWN"; | 2984 style_to_string[content::SECURITY_STYLE_UNKNOWN] = "SECURITY_STYLE_UNKNOWN"; |
2991 style_to_string[content::SECURITY_STYLE_UNAUTHENTICATED] = | 2985 style_to_string[content::SECURITY_STYLE_UNAUTHENTICATED] = |
2992 "SECURITY_STYLE_UNAUTHENTICATED"; | 2986 "SECURITY_STYLE_UNAUTHENTICATED"; |
2993 style_to_string[content::SECURITY_STYLE_AUTHENTICATION_BROKEN] = | 2987 style_to_string[content::SECURITY_STYLE_AUTHENTICATION_BROKEN] = |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3537 AutocompleteEditModel* model = loc_bar->location_entry()->model(); | 3531 AutocompleteEditModel* model = loc_bar->location_entry()->model(); |
3538 model->OnUpOrDownKeyPressed(count); | 3532 model->OnUpOrDownKeyPressed(count); |
3539 reply.SendSuccess(NULL); | 3533 reply.SendSuccess(NULL); |
3540 } | 3534 } |
3541 | 3535 |
3542 // Sample json input: { "command": "OmniboxAcceptInput" } | 3536 // Sample json input: { "command": "OmniboxAcceptInput" } |
3543 void TestingAutomationProvider::OmniboxAcceptInput( | 3537 void TestingAutomationProvider::OmniboxAcceptInput( |
3544 Browser* browser, | 3538 Browser* browser, |
3545 DictionaryValue* args, | 3539 DictionaryValue* args, |
3546 IPC::Message* reply_message) { | 3540 IPC::Message* reply_message) { |
3547 content::NavigationController& controller = | 3541 NavigationController& controller = |
3548 browser->GetSelectedWebContents()->GetController(); | 3542 browser->GetSelectedWebContents()->GetController(); |
3549 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); | 3543 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); |
3550 browser->window()->GetLocationBar()->AcceptInput(); | 3544 browser->window()->GetLocationBar()->AcceptInput(); |
3551 } | 3545 } |
3552 | 3546 |
3553 // Sample json input: { "command": "GetInstantInfo" } | 3547 // Sample json input: { "command": "GetInstantInfo" } |
3554 void TestingAutomationProvider::GetInstantInfo(Browser* browser, | 3548 void TestingAutomationProvider::GetInstantInfo(Browser* browser, |
3555 DictionaryValue* args, | 3549 DictionaryValue* args, |
3556 IPC::Message* reply_message) { | 3550 IPC::Message* reply_message) { |
3557 DictionaryValue* info = new DictionaryValue; | 3551 DictionaryValue* info = new DictionaryValue; |
(...skipping 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6187 IPC::Message* reply_message) { | 6181 IPC::Message* reply_message) { |
6188 if (SendErrorIfModalDialogActive(this, reply_message)) | 6182 if (SendErrorIfModalDialogActive(this, reply_message)) |
6189 return; | 6183 return; |
6190 | 6184 |
6191 TabContents* tab_contents; | 6185 TabContents* tab_contents; |
6192 std::string error; | 6186 std::string error; |
6193 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 6187 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
6194 AutomationJSONReply(this, reply_message).SendError(error); | 6188 AutomationJSONReply(this, reply_message).SendError(error); |
6195 return; | 6189 return; |
6196 } | 6190 } |
6197 content::NavigationController& controller = tab_contents->GetController(); | 6191 NavigationController& controller = tab_contents->GetController(); |
6198 if (!controller.CanGoForward()) { | 6192 if (!controller.CanGoForward()) { |
6199 DictionaryValue dict; | 6193 DictionaryValue dict; |
6200 dict.SetBoolean("did_go_forward", false); | 6194 dict.SetBoolean("did_go_forward", false); |
6201 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 6195 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
6202 return; | 6196 return; |
6203 } | 6197 } |
6204 new NavigationNotificationObserver(&controller, this, reply_message, | 6198 new NavigationNotificationObserver(&controller, this, reply_message, |
6205 1, false, true); | 6199 1, false, true); |
6206 controller.GoForward(); | 6200 controller.GoForward(); |
6207 } | 6201 } |
6208 | 6202 |
6209 void TestingAutomationProvider::GoBack( | 6203 void TestingAutomationProvider::GoBack( |
6210 DictionaryValue* args, | 6204 DictionaryValue* args, |
6211 IPC::Message* reply_message) { | 6205 IPC::Message* reply_message) { |
6212 if (SendErrorIfModalDialogActive(this, reply_message)) | 6206 if (SendErrorIfModalDialogActive(this, reply_message)) |
6213 return; | 6207 return; |
6214 | 6208 |
6215 TabContents* tab_contents; | 6209 TabContents* tab_contents; |
6216 std::string error; | 6210 std::string error; |
6217 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 6211 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
6218 AutomationJSONReply(this, reply_message).SendError(error); | 6212 AutomationJSONReply(this, reply_message).SendError(error); |
6219 return; | 6213 return; |
6220 } | 6214 } |
6221 content::NavigationController& controller = tab_contents->GetController(); | 6215 NavigationController& controller = tab_contents->GetController(); |
6222 if (!controller.CanGoBack()) { | 6216 if (!controller.CanGoBack()) { |
6223 DictionaryValue dict; | 6217 DictionaryValue dict; |
6224 dict.SetBoolean("did_go_back", false); | 6218 dict.SetBoolean("did_go_back", false); |
6225 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 6219 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
6226 return; | 6220 return; |
6227 } | 6221 } |
6228 new NavigationNotificationObserver(&controller, this, reply_message, | 6222 new NavigationNotificationObserver(&controller, this, reply_message, |
6229 1, false, true); | 6223 1, false, true); |
6230 controller.GoBack(); | 6224 controller.GoBack(); |
6231 } | 6225 } |
6232 | 6226 |
6233 void TestingAutomationProvider::ReloadJSON( | 6227 void TestingAutomationProvider::ReloadJSON( |
6234 DictionaryValue* args, | 6228 DictionaryValue* args, |
6235 IPC::Message* reply_message) { | 6229 IPC::Message* reply_message) { |
6236 if (SendErrorIfModalDialogActive(this, reply_message)) | 6230 if (SendErrorIfModalDialogActive(this, reply_message)) |
6237 return; | 6231 return; |
6238 | 6232 |
6239 TabContents* tab_contents; | 6233 TabContents* tab_contents; |
6240 std::string error; | 6234 std::string error; |
6241 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 6235 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
6242 AutomationJSONReply(this, reply_message).SendError(error); | 6236 AutomationJSONReply(this, reply_message).SendError(error); |
6243 return; | 6237 return; |
6244 } | 6238 } |
6245 content::NavigationController& controller = tab_contents->GetController(); | 6239 NavigationController& controller = tab_contents->GetController(); |
6246 new NavigationNotificationObserver(&controller, this, reply_message, | 6240 new NavigationNotificationObserver(&controller, this, reply_message, |
6247 1, false, true); | 6241 1, false, true); |
6248 controller.Reload(false); | 6242 controller.Reload(false); |
6249 } | 6243 } |
6250 | 6244 |
6251 void TestingAutomationProvider::CaptureEntirePageJSON( | 6245 void TestingAutomationProvider::CaptureEntirePageJSON( |
6252 DictionaryValue* args, | 6246 DictionaryValue* args, |
6253 IPC::Message* reply_message) { | 6247 IPC::Message* reply_message) { |
6254 if (SendErrorIfModalDialogActive(this, reply_message)) | 6248 if (SendErrorIfModalDialogActive(this, reply_message)) |
6255 return; | 6249 return; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6564 void TestingAutomationProvider::WaitForInfoBarCount( | 6558 void TestingAutomationProvider::WaitForInfoBarCount( |
6565 int tab_handle, | 6559 int tab_handle, |
6566 size_t target_count, | 6560 size_t target_count, |
6567 IPC::Message* reply_message) { | 6561 IPC::Message* reply_message) { |
6568 if (!tab_tracker_->ContainsHandle(tab_handle)) { | 6562 if (!tab_tracker_->ContainsHandle(tab_handle)) { |
6569 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_, false); | 6563 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_, false); |
6570 Send(reply_message_); | 6564 Send(reply_message_); |
6571 return; | 6565 return; |
6572 } | 6566 } |
6573 | 6567 |
6574 content::NavigationController* controller = | 6568 NavigationController* controller = tab_tracker_->GetResource(tab_handle); |
6575 tab_tracker_->GetResource(tab_handle); | |
6576 if (!controller) { | 6569 if (!controller) { |
6577 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_, false); | 6570 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_, false); |
6578 Send(reply_message_); | 6571 Send(reply_message_); |
6579 return; | 6572 return; |
6580 } | 6573 } |
6581 | 6574 |
6582 // The delegate will delete itself. | 6575 // The delegate will delete itself. |
6583 new InfoBarCountObserver(this, reply_message, | 6576 new InfoBarCountObserver(this, reply_message, |
6584 TabContentsWrapper::GetCurrentWrapperForContents( | 6577 TabContentsWrapper::GetCurrentWrapperForContents( |
6585 controller->GetWebContents()), target_count); | 6578 controller->GetWebContents()), target_count); |
6586 } | 6579 } |
6587 | 6580 |
6588 // Gets the current used encoding name of the page in the specified tab. | 6581 // Gets the current used encoding name of the page in the specified tab. |
6589 void TestingAutomationProvider::GetPageCurrentEncoding( | 6582 void TestingAutomationProvider::GetPageCurrentEncoding( |
6590 int tab_handle, std::string* current_encoding) { | 6583 int tab_handle, std::string* current_encoding) { |
6591 if (tab_tracker_->ContainsHandle(tab_handle)) { | 6584 if (tab_tracker_->ContainsHandle(tab_handle)) { |
6592 content::NavigationController* nav = tab_tracker_->GetResource(tab_handle); | 6585 NavigationController* nav = tab_tracker_->GetResource(tab_handle); |
6593 Browser* browser = FindAndActivateTab(nav); | 6586 Browser* browser = FindAndActivateTab(nav); |
6594 if (browser->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU)) | 6587 if (browser->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU)) |
6595 *current_encoding = nav->GetWebContents()->GetEncoding(); | 6588 *current_encoding = nav->GetWebContents()->GetEncoding(); |
6596 } | 6589 } |
6597 } | 6590 } |
6598 | 6591 |
6599 void TestingAutomationProvider::ShutdownSessionService(int handle, | 6592 void TestingAutomationProvider::ShutdownSessionService(int handle, |
6600 bool* result) { | 6593 bool* result) { |
6601 if (browser_tracker_->ContainsHandle(handle)) { | 6594 if (browser_tracker_->ContainsHandle(handle)) { |
6602 Browser* browser = browser_tracker_->GetResource(handle); | 6595 Browser* browser = browser_tracker_->GetResource(handle); |
(...skipping 25 matching lines...) Expand all Loading... |
6628 setting); | 6621 setting); |
6629 } | 6622 } |
6630 *success = true; | 6623 *success = true; |
6631 } | 6624 } |
6632 } | 6625 } |
6633 | 6626 |
6634 void TestingAutomationProvider::LoadBlockedPlugins(int tab_handle, | 6627 void TestingAutomationProvider::LoadBlockedPlugins(int tab_handle, |
6635 bool* success) { | 6628 bool* success) { |
6636 *success = false; | 6629 *success = false; |
6637 if (tab_tracker_->ContainsHandle(tab_handle)) { | 6630 if (tab_tracker_->ContainsHandle(tab_handle)) { |
6638 content::NavigationController* nav = tab_tracker_->GetResource(tab_handle); | 6631 NavigationController* nav = tab_tracker_->GetResource(tab_handle); |
6639 if (!nav) | 6632 if (!nav) |
6640 return; | 6633 return; |
6641 WebContents* contents = nav->GetWebContents(); | 6634 WebContents* contents = nav->GetWebContents(); |
6642 if (!contents) | 6635 if (!contents) |
6643 return; | 6636 return; |
6644 RenderViewHost* host = contents->GetRenderViewHost(); | 6637 RenderViewHost* host = contents->GetRenderViewHost(); |
6645 host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->routing_id())); | 6638 host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->routing_id())); |
6646 *success = true; | 6639 *success = true; |
6647 } | 6640 } |
6648 } | 6641 } |
6649 | 6642 |
6650 void TestingAutomationProvider::ResetToDefaultTheme() { | 6643 void TestingAutomationProvider::ResetToDefaultTheme() { |
6651 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); | 6644 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); |
6652 } | 6645 } |
6653 | 6646 |
6654 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( | 6647 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( |
6655 IPC::Message* reply_message) { | 6648 IPC::Message* reply_message) { |
6656 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); | 6649 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); |
6657 } | 6650 } |
6658 | 6651 |
6659 void TestingAutomationProvider::GetParentBrowserOfTab(int tab_handle, | 6652 void TestingAutomationProvider::GetParentBrowserOfTab(int tab_handle, |
6660 int* browser_handle, | 6653 int* browser_handle, |
6661 bool* success) { | 6654 bool* success) { |
6662 *success = false; | 6655 *success = false; |
6663 if (tab_tracker_->ContainsHandle(tab_handle)) { | 6656 if (tab_tracker_->ContainsHandle(tab_handle)) { |
6664 content::NavigationController* controller = | 6657 NavigationController* controller = tab_tracker_->GetResource(tab_handle); |
6665 tab_tracker_->GetResource(tab_handle); | |
6666 int index; | 6658 int index; |
6667 Browser* browser = Browser::GetBrowserForController(controller, &index); | 6659 Browser* browser = Browser::GetBrowserForController(controller, &index); |
6668 if (browser) { | 6660 if (browser) { |
6669 *browser_handle = browser_tracker_->Add(browser); | 6661 *browser_handle = browser_tracker_->Add(browser); |
6670 *success = true; | 6662 *success = true; |
6671 } | 6663 } |
6672 } | 6664 } |
6673 } | 6665 } |
6674 | 6666 |
6675 // TODO(brettw) change this to accept GURLs when history supports it | 6667 // TODO(brettw) change this to accept GURLs when history supports it |
(...skipping 16 matching lines...) Expand all Loading... |
6692 | 6684 |
6693 Send(reply_message_); | 6685 Send(reply_message_); |
6694 redirect_query_ = 0; | 6686 redirect_query_ = 0; |
6695 reply_message_ = NULL; | 6687 reply_message_ = NULL; |
6696 } | 6688 } |
6697 | 6689 |
6698 void TestingAutomationProvider::OnRemoveProvider() { | 6690 void TestingAutomationProvider::OnRemoveProvider() { |
6699 if (g_browser_process) | 6691 if (g_browser_process) |
6700 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6692 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6701 } | 6693 } |
OLD | NEW |