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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) | 368 IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) |
369 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 369 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
370 AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, | 370 AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, |
371 NavigateToURLBlockUntilNavigationsComplete) | 371 NavigateToURLBlockUntilNavigationsComplete) |
372 IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsync, NavigationAsync) | 372 IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsync, NavigationAsync) |
373 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) | 373 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) |
374 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, GetBrowserWindowCount) | 374 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, GetBrowserWindowCount) |
375 IPC_MESSAGE_HANDLER(AutomationMsg_NormalBrowserWindowCount, | 375 IPC_MESSAGE_HANDLER(AutomationMsg_NormalBrowserWindowCount, |
376 GetNormalBrowserWindowCount) | 376 GetNormalBrowserWindowCount) |
377 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) | 377 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) |
378 IPC_MESSAGE_HANDLER(AutomationMsg_FindTabbedBrowserWindow, | |
379 FindTabbedBrowserWindow) | |
380 IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, | 378 IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, |
381 ExecuteBrowserCommandAsync) | 379 ExecuteBrowserCommandAsync) |
382 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, | 380 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, |
383 ExecuteBrowserCommand) | 381 ExecuteBrowserCommand) |
384 IPC_MESSAGE_HANDLER(AutomationMsg_TerminateSession, TerminateSession) | 382 IPC_MESSAGE_HANDLER(AutomationMsg_TerminateSession, TerminateSession) |
385 IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) | 383 IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) |
386 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) | 384 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) |
387 IPC_MESSAGE_HANDLER(AutomationMsg_WindowMouseMove, WindowSimulateMouseMove) | 385 IPC_MESSAGE_HANDLER(AutomationMsg_WindowMouseMove, WindowSimulateMouseMove) |
388 IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) | 386 IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) |
389 IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) | 387 IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 *window_count = static_cast<int>(browser::GetTabbedBrowserCount(profile_)); | 658 *window_count = static_cast<int>(browser::GetTabbedBrowserCount(profile_)); |
661 } | 659 } |
662 | 660 |
663 void TestingAutomationProvider::GetBrowserWindow(int index, int* handle) { | 661 void TestingAutomationProvider::GetBrowserWindow(int index, int* handle) { |
664 *handle = 0; | 662 *handle = 0; |
665 Browser* browser = automation_util::GetBrowserAt(index); | 663 Browser* browser = automation_util::GetBrowserAt(index); |
666 if (browser) | 664 if (browser) |
667 *handle = browser_tracker_->Add(browser); | 665 *handle = browser_tracker_->Add(browser); |
668 } | 666 } |
669 | 667 |
670 void TestingAutomationProvider::FindTabbedBrowserWindow(int* handle) { | |
671 *handle = 0; | |
672 Browser* browser = browser::FindTabbedBrowser(profile_, false); | |
673 if (browser) | |
674 *handle = browser_tracker_->Add(browser); | |
675 } | |
676 | |
677 void TestingAutomationProvider::ExecuteBrowserCommandAsync(int handle, | 668 void TestingAutomationProvider::ExecuteBrowserCommandAsync(int handle, |
678 int command, | 669 int command, |
679 bool* success) { | 670 bool* success) { |
680 *success = false; | 671 *success = false; |
681 if (!browser_tracker_->ContainsHandle(handle)) { | 672 if (!browser_tracker_->ContainsHandle(handle)) { |
682 LOG(WARNING) << "Browser tracker does not contain handle: " << handle; | 673 LOG(WARNING) << "Browser tracker does not contain handle: " << handle; |
683 return; | 674 return; |
684 } | 675 } |
685 Browser* browser = browser_tracker_->GetResource(handle); | 676 Browser* browser = browser_tracker_->GetResource(handle); |
686 if (!chrome::SupportsCommand(browser, command)) { | 677 if (!chrome::SupportsCommand(browser, command)) { |
(...skipping 6081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6768 void TestingAutomationProvider::OnRemoveProvider() { | 6759 void TestingAutomationProvider::OnRemoveProvider() { |
6769 if (g_browser_process) | 6760 if (g_browser_process) |
6770 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6761 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6771 } | 6762 } |
6772 | 6763 |
6773 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6764 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
6774 WebContents* tab) { | 6765 WebContents* tab) { |
6775 if (chrome::GetActiveWebContents(browser) != tab) | 6766 if (chrome::GetActiveWebContents(browser) != tab) |
6776 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 6767 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
6777 } | 6768 } |
OLD | NEW |