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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 #include "chrome/browser/themes/theme_service.h" | 91 #include "chrome/browser/themes/theme_service.h" |
92 #include "chrome/browser/themes/theme_service_factory.h" | 92 #include "chrome/browser/themes/theme_service_factory.h" |
93 #include "chrome/browser/translate/translate_infobar_delegate.h" | 93 #include "chrome/browser/translate/translate_infobar_delegate.h" |
94 #include "chrome/browser/translate/translate_tab_helper.h" | 94 #include "chrome/browser/translate/translate_tab_helper.h" |
95 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 95 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
96 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 96 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
97 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 97 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
98 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 98 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
99 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 99 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
100 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" | 100 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
| 101 #include "chrome/browser/ui/browser_finder.h" |
| 102 #include "chrome/browser/ui/browser_list.h" |
101 #include "chrome/browser/ui/browser_window.h" | 103 #include "chrome/browser/ui/browser_window.h" |
102 #include "chrome/browser/ui/find_bar/find_bar.h" | 104 #include "chrome/browser/ui/find_bar/find_bar.h" |
103 #include "chrome/browser/ui/fullscreen_controller.h" | 105 #include "chrome/browser/ui/fullscreen_controller.h" |
104 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" | 106 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" |
105 #include "chrome/browser/ui/login/login_prompt.h" | 107 #include "chrome/browser/ui/login/login_prompt.h" |
106 #include "chrome/browser/ui/media_stream_infobar_delegate.h" | 108 #include "chrome/browser/ui/media_stream_infobar_delegate.h" |
107 #include "chrome/browser/ui/omnibox/location_bar.h" | 109 #include "chrome/browser/ui/omnibox/location_bar.h" |
108 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 110 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
109 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" | 111 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
110 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 112 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 *active_tab_index = browser->active_index(); | 638 *active_tab_index = browser->active_index(); |
637 } | 639 } |
638 } | 640 } |
639 | 641 |
640 void TestingAutomationProvider::CloseTab(int tab_handle, | 642 void TestingAutomationProvider::CloseTab(int tab_handle, |
641 bool wait_until_closed, | 643 bool wait_until_closed, |
642 IPC::Message* reply_message) { | 644 IPC::Message* reply_message) { |
643 if (tab_tracker_->ContainsHandle(tab_handle)) { | 645 if (tab_tracker_->ContainsHandle(tab_handle)) { |
644 NavigationController* controller = tab_tracker_->GetResource(tab_handle); | 646 NavigationController* controller = tab_tracker_->GetResource(tab_handle); |
645 int index; | 647 int index; |
646 Browser* browser = Browser::GetBrowserForController(controller, &index); | 648 Browser* browser = browser::FindBrowserForController(controller, &index); |
647 DCHECK(browser); | 649 DCHECK(browser); |
648 new TabClosedNotificationObserver(this, wait_until_closed, reply_message); | 650 new TabClosedNotificationObserver(this, wait_until_closed, reply_message); |
649 browser->CloseTabContents(controller->GetWebContents()); | 651 browser->CloseTabContents(controller->GetWebContents()); |
650 return; | 652 return; |
651 } | 653 } |
652 | 654 |
653 AutomationMsg_CloseTab::WriteReplyParams(reply_message, false); | 655 AutomationMsg_CloseTab::WriteReplyParams(reply_message, false); |
654 Send(reply_message); | 656 Send(reply_message); |
655 } | 657 } |
656 | 658 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 AutomationMsg_Reload::WriteReplyParams( | 755 AutomationMsg_Reload::WriteReplyParams( |
754 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); | 756 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); |
755 Send(reply_message); | 757 Send(reply_message); |
756 } | 758 } |
757 | 759 |
758 void TestingAutomationProvider::GetBrowserWindowCount(int* window_count) { | 760 void TestingAutomationProvider::GetBrowserWindowCount(int* window_count) { |
759 *window_count = static_cast<int>(BrowserList::size()); | 761 *window_count = static_cast<int>(BrowserList::size()); |
760 } | 762 } |
761 | 763 |
762 void TestingAutomationProvider::GetNormalBrowserWindowCount(int* window_count) { | 764 void TestingAutomationProvider::GetNormalBrowserWindowCount(int* window_count) { |
763 *window_count = static_cast<int>( | 765 *window_count = static_cast<int>(browser::GetTabbedBrowserCount(profile_)); |
764 BrowserList::GetBrowserCountForType(profile_, true)); | |
765 } | 766 } |
766 | 767 |
767 void TestingAutomationProvider::GetBrowserWindow(int index, int* handle) { | 768 void TestingAutomationProvider::GetBrowserWindow(int index, int* handle) { |
768 *handle = 0; | 769 *handle = 0; |
769 Browser* browser = automation_util::GetBrowserAt(index); | 770 Browser* browser = automation_util::GetBrowserAt(index); |
770 if (browser) | 771 if (browser) |
771 *handle = browser_tracker_->Add(browser); | 772 *handle = browser_tracker_->Add(browser); |
772 } | 773 } |
773 | 774 |
774 void TestingAutomationProvider::FindTabbedBrowserWindow(int* handle) { | 775 void TestingAutomationProvider::FindTabbedBrowserWindow(int* handle) { |
775 *handle = 0; | 776 *handle = 0; |
776 Browser* browser = BrowserList::FindTabbedBrowser(profile_, false); | 777 Browser* browser = browser::FindTabbedBrowser(profile_, false); |
777 if (browser) | 778 if (browser) |
778 *handle = browser_tracker_->Add(browser); | 779 *handle = browser_tracker_->Add(browser); |
779 } | 780 } |
780 | 781 |
781 void TestingAutomationProvider::GetLastActiveBrowserWindow(int* handle) { | 782 void TestingAutomationProvider::GetLastActiveBrowserWindow(int* handle) { |
782 *handle = 0; | 783 *handle = 0; |
783 Browser* browser = BrowserList::GetLastActive(); | 784 Browser* browser = BrowserList::GetLastActive(); |
784 if (browser) | 785 if (browser) |
785 *handle = browser_tracker_->Add(browser); | 786 *handle = browser_tracker_->Add(browser); |
786 } | 787 } |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 } | 1259 } |
1259 *title_string_size = static_cast<int>(title->size()); | 1260 *title_string_size = static_cast<int>(title->size()); |
1260 } | 1261 } |
1261 } | 1262 } |
1262 | 1263 |
1263 void TestingAutomationProvider::GetTabIndex(int handle, int* tabstrip_index) { | 1264 void TestingAutomationProvider::GetTabIndex(int handle, int* tabstrip_index) { |
1264 *tabstrip_index = -1; // -1 is the error code | 1265 *tabstrip_index = -1; // -1 is the error code |
1265 | 1266 |
1266 if (tab_tracker_->ContainsHandle(handle)) { | 1267 if (tab_tracker_->ContainsHandle(handle)) { |
1267 NavigationController* tab = tab_tracker_->GetResource(handle); | 1268 NavigationController* tab = tab_tracker_->GetResource(handle); |
1268 Browser* browser = Browser::GetBrowserForController(tab, NULL); | 1269 Browser* browser = browser::FindBrowserForController(tab, NULL); |
1269 *tabstrip_index = browser->GetIndexOfController(tab); | 1270 *tabstrip_index = browser->GetIndexOfController(tab); |
1270 } | 1271 } |
1271 } | 1272 } |
1272 | 1273 |
1273 void TestingAutomationProvider::GetTabURL(int handle, | 1274 void TestingAutomationProvider::GetTabURL(int handle, |
1274 bool* success, | 1275 bool* success, |
1275 GURL* url) { | 1276 GURL* url) { |
1276 *success = false; | 1277 *success = false; |
1277 if (tab_tracker_->ContainsHandle(handle)) { | 1278 if (tab_tracker_->ContainsHandle(handle)) { |
1278 NavigationController* tab = tab_tracker_->GetResource(handle); | 1279 NavigationController* tab = tab_tracker_->GetResource(handle); |
(...skipping 5835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7114 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); | 7115 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); |
7115 } | 7116 } |
7116 | 7117 |
7117 void TestingAutomationProvider::GetParentBrowserOfTab(int tab_handle, | 7118 void TestingAutomationProvider::GetParentBrowserOfTab(int tab_handle, |
7118 int* browser_handle, | 7119 int* browser_handle, |
7119 bool* success) { | 7120 bool* success) { |
7120 *success = false; | 7121 *success = false; |
7121 if (tab_tracker_->ContainsHandle(tab_handle)) { | 7122 if (tab_tracker_->ContainsHandle(tab_handle)) { |
7122 NavigationController* controller = tab_tracker_->GetResource(tab_handle); | 7123 NavigationController* controller = tab_tracker_->GetResource(tab_handle); |
7123 int index; | 7124 int index; |
7124 Browser* browser = Browser::GetBrowserForController(controller, &index); | 7125 Browser* browser = browser::FindBrowserForController(controller, &index); |
7125 if (browser) { | 7126 if (browser) { |
7126 *browser_handle = browser_tracker_->Add(browser); | 7127 *browser_handle = browser_tracker_->Add(browser); |
7127 *success = true; | 7128 *success = true; |
7128 } | 7129 } |
7129 } | 7130 } |
7130 } | 7131 } |
7131 | 7132 |
7132 void TestingAutomationProvider::OnRemoveProvider() { | 7133 void TestingAutomationProvider::OnRemoveProvider() { |
7133 if (g_browser_process) | 7134 if (g_browser_process) |
7134 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 7135 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
7135 } | 7136 } |
OLD | NEW |