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) |
322 IPC_MESSAGE_HANDLER(AutomationMsg_ApplyAccelerator, ApplyAccelerator) | 323 IPC_MESSAGE_HANDLER(AutomationMsg_ApplyAccelerator, ApplyAccelerator) |
323 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, | 324 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, |
324 ExecuteJavascript) | 325 ExecuteJavascript) |
325 IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowCount, | 326 IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowCount, |
326 GetConstrainedWindowCount) | 327 GetConstrainedWindowCount) |
327 IPC_MESSAGE_HANDLER(AutomationMsg_FindInPage, HandleFindInPageRequest) | 328 IPC_MESSAGE_HANDLER(AutomationMsg_FindInPage, HandleFindInPageRequest) |
328 IPC_MESSAGE_HANDLER(AutomationMsg_GetFocusedViewID, GetFocusedViewID) | 329 IPC_MESSAGE_HANDLER(AutomationMsg_GetFocusedViewID, GetFocusedViewID) |
329 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InspectElement, | 330 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InspectElement, |
330 HandleInspectElementRequest) | 331 HandleInspectElementRequest) |
331 IPC_MESSAGE_HANDLER(AutomationMsg_DownloadDirectory, GetDownloadDirectory) | 332 IPC_MESSAGE_HANDLER(AutomationMsg_DownloadDirectory, GetDownloadDirectory) |
332 IPC_MESSAGE_HANDLER(AutomationMsg_SetProxyConfig, SetProxyConfig); | 333 IPC_MESSAGE_HANDLER(AutomationMsg_SetProxyConfig, SetProxyConfig); |
333 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindow, | 334 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindow, |
334 OpenNewBrowserWindow) | 335 OpenNewBrowserWindow) |
| 336 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType, |
| 337 OpenNewBrowserWindowOfType) |
335 IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) | 338 IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) |
336 IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditForBrowser, | 339 IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditForBrowser, |
337 GetAutocompleteEditForBrowser) | 340 GetAutocompleteEditForBrowser) |
338 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserForWindow, GetBrowserForWindow) | 341 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserForWindow, GetBrowserForWindow) |
339 #if defined(OS_WIN) | 342 #if defined(OS_WIN) |
340 IPC_MESSAGE_HANDLER(AutomationMsg_CreateExternalTab, CreateExternalTab) | 343 IPC_MESSAGE_HANDLER(AutomationMsg_CreateExternalTab, CreateExternalTab) |
341 #endif | 344 #endif |
342 IPC_MESSAGE_HANDLER(AutomationMsg_NavigateInExternalTab, | 345 IPC_MESSAGE_HANDLER(AutomationMsg_NavigateInExternalTab, |
343 NavigateInExternalTab) | 346 NavigateInExternalTab) |
344 IPC_MESSAGE_HANDLER(AutomationMsg_NavigateExternalTabAtIndex, | 347 IPC_MESSAGE_HANDLER(AutomationMsg_NavigateExternalTabAtIndex, |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 | 877 |
875 void AutomationProvider::GetTabCount(int handle, int* tab_count) { | 878 void AutomationProvider::GetTabCount(int handle, int* tab_count) { |
876 *tab_count = -1; // -1 is the error code | 879 *tab_count = -1; // -1 is the error code |
877 | 880 |
878 if (browser_tracker_->ContainsHandle(handle)) { | 881 if (browser_tracker_->ContainsHandle(handle)) { |
879 Browser* browser = browser_tracker_->GetResource(handle); | 882 Browser* browser = browser_tracker_->GetResource(handle); |
880 *tab_count = browser->tab_count(); | 883 *tab_count = browser->tab_count(); |
881 } | 884 } |
882 } | 885 } |
883 | 886 |
| 887 void AutomationProvider::GetType(int handle, int* type_as_int) { |
| 888 *type_as_int = -1; // -1 is the error code |
| 889 |
| 890 if (browser_tracker_->ContainsHandle(handle)) { |
| 891 Browser* browser = browser_tracker_->GetResource(handle); |
| 892 *type_as_int = static_cast<int>(browser->type()); |
| 893 } |
| 894 } |
| 895 |
884 void AutomationProvider::GetTab(int win_handle, int tab_index, | 896 void AutomationProvider::GetTab(int win_handle, int tab_index, |
885 int* tab_handle) { | 897 int* tab_handle) { |
886 *tab_handle = 0; | 898 *tab_handle = 0; |
887 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { | 899 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { |
888 Browser* browser = browser_tracker_->GetResource(win_handle); | 900 Browser* browser = browser_tracker_->GetResource(win_handle); |
889 if (tab_index < browser->tab_count()) { | 901 if (tab_index < browser->tab_count()) { |
890 TabContents* tab_contents = | 902 TabContents* tab_contents = |
891 browser->GetTabContentsAt(tab_index); | 903 browser->GetTabContentsAt(tab_index); |
892 *tab_handle = tab_tracker_->Add(&tab_contents->controller()); | 904 *tab_handle = tab_tracker_->Add(&tab_contents->controller()); |
893 } | 905 } |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 if (tab_tracker_->ContainsHandle(handle)) { | 1284 if (tab_tracker_->ContainsHandle(handle)) { |
1273 NavigationController* tab = tab_tracker_->GetResource(handle); | 1285 NavigationController* tab = tab_tracker_->GetResource(handle); |
1274 DownloadManager* dlm = tab->profile()->GetDownloadManager(); | 1286 DownloadManager* dlm = tab->profile()->GetDownloadManager(); |
1275 DCHECK(dlm); | 1287 DCHECK(dlm); |
1276 *download_directory = dlm->download_path(); | 1288 *download_directory = dlm->download_path(); |
1277 } | 1289 } |
1278 } | 1290 } |
1279 | 1291 |
1280 void AutomationProvider::OpenNewBrowserWindow(bool show, | 1292 void AutomationProvider::OpenNewBrowserWindow(bool show, |
1281 IPC::Message* reply_message) { | 1293 IPC::Message* reply_message) { |
| 1294 OpenNewBrowserWindowOfType(static_cast<int>(Browser::TYPE_NORMAL), show, |
| 1295 reply_message); |
| 1296 } |
| 1297 |
| 1298 void AutomationProvider::OpenNewBrowserWindowOfType( |
| 1299 int type, bool show, IPC::Message* reply_message) { |
1282 new BrowserOpenedNotificationObserver(this, reply_message); | 1300 new BrowserOpenedNotificationObserver(this, reply_message); |
1283 // We may have no current browser windows open so don't rely on | 1301 // We may have no current browser windows open so don't rely on |
1284 // asking an existing browser to execute the IDC_NEWWINDOW command | 1302 // asking an existing browser to execute the IDC_NEWWINDOW command |
1285 Browser* browser = Browser::Create(profile_); | 1303 Browser* browser = new Browser(static_cast<Browser::Type>(type), profile_); |
| 1304 browser->CreateBrowserWindow(); |
1286 browser->AddBlankTab(true); | 1305 browser->AddBlankTab(true); |
1287 if (show) | 1306 if (show) |
1288 browser->window()->Show(); | 1307 browser->window()->Show(); |
1289 } | 1308 } |
1290 | 1309 |
1291 void AutomationProvider::GetWindowForBrowser(int browser_handle, | 1310 void AutomationProvider::GetWindowForBrowser(int browser_handle, |
1292 bool* success, | 1311 bool* success, |
1293 int* handle) { | 1312 int* handle) { |
1294 *success = false; | 1313 *success = false; |
1295 *handle = 0; | 1314 *handle = 0; |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2159 reply_message); | 2178 reply_message); |
2160 | 2179 |
2161 profile_->GetExtensionsService()->LoadExtension(extension_dir); | 2180 profile_->GetExtensionsService()->LoadExtension(extension_dir); |
2162 profile_->GetUserScriptMaster()->AddWatchedPath(extension_dir); | 2181 profile_->GetUserScriptMaster()->AddWatchedPath(extension_dir); |
2163 } else { | 2182 } else { |
2164 AutomationMsg_LoadExpandedExtension::WriteReplyParams( | 2183 AutomationMsg_LoadExpandedExtension::WriteReplyParams( |
2165 reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); | 2184 reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); |
2166 Send(reply_message); | 2185 Send(reply_message); |
2167 } | 2186 } |
2168 } | 2187 } |
OLD | NEW |