OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/message_box_flags.h" | 10 #include "app/message_box_flags.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible) | 302 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible) |
303 #if !defined(OS_MACOSX) | 303 #if !defined(OS_MACOSX) |
304 IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) | 304 IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) |
305 IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) | 305 IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) |
306 #endif // !defined(OS_MACOSX) | 306 #endif // !defined(OS_MACOSX) |
307 #if defined(OS_WIN) || defined(OS_LINUX) | 307 #if defined(OS_WIN) || defined(OS_LINUX) |
308 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag, | 308 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag, |
309 WindowSimulateDrag) | 309 WindowSimulateDrag) |
310 #endif // defined(OS_WIN) || defined(OS_LINUX) | 310 #endif // defined(OS_WIN) || defined(OS_LINUX) |
311 IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) | 311 IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) |
| 312 IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) |
312 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) | 313 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) |
313 #if defined(OS_WIN) | 314 #if defined(OS_WIN) |
314 IPC_MESSAGE_HANDLER(AutomationMsg_TabHWND, GetTabHWND) | 315 IPC_MESSAGE_HANDLER(AutomationMsg_TabHWND, GetTabHWND) |
315 #endif // defined(OS_WIN) | 316 #endif // defined(OS_WIN) |
316 IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessID, GetTabProcessID) | 317 IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessID, GetTabProcessID) |
317 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) | 318 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) |
318 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) | 319 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) |
319 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) | 320 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) |
320 IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) | 321 IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) |
321 IPC_MESSAGE_HANDLER(AutomationMsg_HandleUnused, HandleUnused) | 322 IPC_MESSAGE_HANDLER(AutomationMsg_HandleUnused, HandleUnused) |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 | 875 |
875 void AutomationProvider::GetTabCount(int handle, int* tab_count) { | 876 void AutomationProvider::GetTabCount(int handle, int* tab_count) { |
876 *tab_count = -1; // -1 is the error code | 877 *tab_count = -1; // -1 is the error code |
877 | 878 |
878 if (browser_tracker_->ContainsHandle(handle)) { | 879 if (browser_tracker_->ContainsHandle(handle)) { |
879 Browser* browser = browser_tracker_->GetResource(handle); | 880 Browser* browser = browser_tracker_->GetResource(handle); |
880 *tab_count = browser->tab_count(); | 881 *tab_count = browser->tab_count(); |
881 } | 882 } |
882 } | 883 } |
883 | 884 |
| 885 void AutomationProvider::GetType(int handle, int* type_as_int) { |
| 886 *type_as_int = -1; // -1 is the error code |
| 887 |
| 888 if (browser_tracker_->ContainsHandle(handle)) { |
| 889 Browser* browser = browser_tracker_->GetResource(handle); |
| 890 *type_as_int = static_cast<int>(browser->type()); |
| 891 } |
| 892 } |
| 893 |
884 void AutomationProvider::GetTab(int win_handle, int tab_index, | 894 void AutomationProvider::GetTab(int win_handle, int tab_index, |
885 int* tab_handle) { | 895 int* tab_handle) { |
886 *tab_handle = 0; | 896 *tab_handle = 0; |
887 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { | 897 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { |
888 Browser* browser = browser_tracker_->GetResource(win_handle); | 898 Browser* browser = browser_tracker_->GetResource(win_handle); |
889 if (tab_index < browser->tab_count()) { | 899 if (tab_index < browser->tab_count()) { |
890 TabContents* tab_contents = | 900 TabContents* tab_contents = |
891 browser->GetTabContentsAt(tab_index); | 901 browser->GetTabContentsAt(tab_index); |
892 *tab_handle = tab_tracker_->Add(&tab_contents->controller()); | 902 *tab_handle = tab_tracker_->Add(&tab_contents->controller()); |
893 } | 903 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 int handle, FilePath* download_directory) { | 1280 int handle, FilePath* download_directory) { |
1271 DLOG(INFO) << "Handling download directory request"; | 1281 DLOG(INFO) << "Handling download directory request"; |
1272 if (tab_tracker_->ContainsHandle(handle)) { | 1282 if (tab_tracker_->ContainsHandle(handle)) { |
1273 NavigationController* tab = tab_tracker_->GetResource(handle); | 1283 NavigationController* tab = tab_tracker_->GetResource(handle); |
1274 DownloadManager* dlm = tab->profile()->GetDownloadManager(); | 1284 DownloadManager* dlm = tab->profile()->GetDownloadManager(); |
1275 DCHECK(dlm); | 1285 DCHECK(dlm); |
1276 *download_directory = dlm->download_path(); | 1286 *download_directory = dlm->download_path(); |
1277 } | 1287 } |
1278 } | 1288 } |
1279 | 1289 |
1280 void AutomationProvider::OpenNewBrowserWindow(bool show, | 1290 void AutomationProvider::OpenNewBrowserWindow(int type, |
| 1291 bool show, |
1281 IPC::Message* reply_message) { | 1292 IPC::Message* reply_message) { |
1282 new BrowserOpenedNotificationObserver(this, reply_message); | 1293 new BrowserOpenedNotificationObserver(this, reply_message); |
1283 // We may have no current browser windows open so don't rely on | 1294 // We may have no current browser windows open so don't rely on |
1284 // asking an existing browser to execute the IDC_NEWWINDOW command | 1295 // asking an existing browser to execute the IDC_NEWWINDOW command |
1285 Browser* browser = Browser::Create(profile_); | 1296 Browser* browser = new Browser(static_cast<Browser::Type>(type), profile_); |
| 1297 browser->CreateBrowserWindow(); |
1286 browser->AddBlankTab(true); | 1298 browser->AddBlankTab(true); |
1287 if (show) | 1299 if (show) |
1288 browser->window()->Show(); | 1300 browser->window()->Show(); |
1289 } | 1301 } |
1290 | 1302 |
1291 void AutomationProvider::GetWindowForBrowser(int browser_handle, | 1303 void AutomationProvider::GetWindowForBrowser(int browser_handle, |
1292 bool* success, | 1304 bool* success, |
1293 int* handle) { | 1305 int* handle) { |
1294 *success = false; | 1306 *success = false; |
1295 *handle = 0; | 1307 *handle = 0; |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2159 reply_message); | 2171 reply_message); |
2160 | 2172 |
2161 profile_->GetExtensionsService()->LoadExtension(extension_dir); | 2173 profile_->GetExtensionsService()->LoadExtension(extension_dir); |
2162 profile_->GetUserScriptMaster()->AddWatchedPath(extension_dir); | 2174 profile_->GetUserScriptMaster()->AddWatchedPath(extension_dir); |
2163 } else { | 2175 } else { |
2164 AutomationMsg_LoadExpandedExtension::WriteReplyParams( | 2176 AutomationMsg_LoadExpandedExtension::WriteReplyParams( |
2165 reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); | 2177 reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); |
2166 Send(reply_message); | 2178 Send(reply_message); |
2167 } | 2179 } |
2168 } | 2180 } |
OLD | NEW |