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