OLD | NEW |
---|---|
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 "base/file_version_info.h" | 7 #include "base/file_version_info.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_GoForward, GoForward) | 895 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_GoForward, GoForward) |
896 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) | 896 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) |
897 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SetAuth, SetAuth) | 897 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SetAuth, SetAuth) |
898 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CancelAuth, | 898 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CancelAuth, |
899 CancelAuth) | 899 CancelAuth) |
900 IPC_MESSAGE_HANDLER(AutomationMsg_NeedsAuth, NeedsAuth) | 900 IPC_MESSAGE_HANDLER(AutomationMsg_NeedsAuth, NeedsAuth) |
901 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RedirectsFrom, | 901 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RedirectsFrom, |
902 GetRedirectsFrom) | 902 GetRedirectsFrom) |
903 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, | 903 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, |
904 GetBrowserWindowCount) | 904 GetBrowserWindowCount) |
905 IPC_MESSAGE_HANDLER(AutomationMsg_NormalBrowserWindowCount, | |
906 GetNormalBrowserWindowCount) | |
905 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) | 907 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) |
906 IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow, | 908 IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow, |
907 GetLastActiveBrowserWindow) | 909 GetLastActiveBrowserWindow) |
908 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) | 910 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) |
911 IPC_MESSAGE_HANDLER(AutomationMsg_FindNormalBrowserWindow, | |
912 FindNormalBrowserWindow) | |
909 IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) | 913 IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) |
910 IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow); | 914 IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow); |
911 #if defined(OS_WIN) | 915 #if defined(OS_WIN) |
912 IPC_MESSAGE_HANDLER(AutomationMsg_WindowHWND, GetWindowHWND) | 916 IPC_MESSAGE_HANDLER(AutomationMsg_WindowHWND, GetWindowHWND) |
913 #endif // defined(OS_WIN) | 917 #endif // defined(OS_WIN) |
914 IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, | 918 IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, |
915 ExecuteBrowserCommandAsync) | 919 ExecuteBrowserCommandAsync) |
916 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, | 920 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, |
917 ExecuteBrowserCommand) | 921 ExecuteBrowserCommand) |
918 IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, | 922 IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1297 if (browser_tracker_->ContainsHandle(handle)) { | 1301 if (browser_tracker_->ContainsHandle(handle)) { |
1298 Browser* browser = browser_tracker_->GetResource(handle); | 1302 Browser* browser = browser_tracker_->GetResource(handle); |
1299 *active_tab_index = browser->selected_index(); | 1303 *active_tab_index = browser->selected_index(); |
1300 } | 1304 } |
1301 } | 1305 } |
1302 | 1306 |
1303 void AutomationProvider::GetBrowserWindowCount(int* window_count) { | 1307 void AutomationProvider::GetBrowserWindowCount(int* window_count) { |
1304 *window_count = static_cast<int>(BrowserList::size()); | 1308 *window_count = static_cast<int>(BrowserList::size()); |
1305 } | 1309 } |
1306 | 1310 |
1311 void AutomationProvider::GetNormalBrowserWindowCount(int* window_count) { | |
1312 *window_count = static_cast<int>( | |
1313 BrowserList::GetBrowserCountForType(profile_, Browser::TYPE_NORMAL)); | |
1314 } | |
1315 | |
1307 void AutomationProvider::GetShowingAppModalDialog(bool* showing_dialog, | 1316 void AutomationProvider::GetShowingAppModalDialog(bool* showing_dialog, |
1308 int* dialog_button) { | 1317 int* dialog_button) { |
1309 AppModalDialog* dialog_delegate = AppModalDialogQueue::active_dialog(); | 1318 AppModalDialog* dialog_delegate = AppModalDialogQueue::active_dialog(); |
1310 *showing_dialog = (dialog_delegate != NULL); | 1319 *showing_dialog = (dialog_delegate != NULL); |
1311 if (*showing_dialog) | 1320 if (*showing_dialog) |
1312 *dialog_button = dialog_delegate->GetDialogButtons(); | 1321 *dialog_button = dialog_delegate->GetDialogButtons(); |
1313 else | 1322 else |
1314 *dialog_button = MessageBoxFlags::DIALOGBUTTON_NONE; | 1323 *dialog_button = MessageBoxFlags::DIALOGBUTTON_NONE; |
1315 } | 1324 } |
1316 | 1325 |
(...skipping 14 matching lines...) Expand all Loading... | |
1331 dialog_delegate->CancelWindow(); | 1340 dialog_delegate->CancelWindow(); |
1332 *success = true; | 1341 *success = true; |
1333 } | 1342 } |
1334 } | 1343 } |
1335 } | 1344 } |
1336 | 1345 |
1337 void AutomationProvider::GetBrowserWindow(int index, int* handle) { | 1346 void AutomationProvider::GetBrowserWindow(int index, int* handle) { |
1338 *handle = 0; | 1347 *handle = 0; |
1339 if (index >= 0) { | 1348 if (index >= 0) { |
1340 BrowserList::const_iterator iter = BrowserList::begin(); | 1349 BrowserList::const_iterator iter = BrowserList::begin(); |
1341 | 1350 for (; (iter != BrowserList::end()) && (index > 0); ++iter, --index); |
1342 for (; (iter != BrowserList::end()) && (index > 0); ++iter, --index); | |
1343 if (iter != BrowserList::end()) { | 1351 if (iter != BrowserList::end()) { |
1344 *handle = browser_tracker_->Add(*iter); | 1352 *handle = browser_tracker_->Add(*iter); |
1345 } | 1353 } |
1346 } | 1354 } |
1347 } | 1355 } |
1348 | 1356 |
1357 void AutomationProvider::FindNormalBrowserWindow(int* handle) { | |
1358 *handle = 0; | |
1359 Browser* browser = BrowserList::FindBrowserWithType(profile_, | |
1360 Browser::TYPE_NORMAL); | |
1361 if (browser) | |
1362 *handle = browser_tracker_->Add(browser); | |
Finnur
2009/05/01 04:05:49
Don't you want to NULL handle if no browser was fo
| |
1363 } | |
1364 | |
1349 void AutomationProvider::GetLastActiveBrowserWindow(int* handle) { | 1365 void AutomationProvider::GetLastActiveBrowserWindow(int* handle) { |
1350 *handle = 0; | 1366 *handle = 0; |
1351 Browser* browser = BrowserList::GetLastActive(); | 1367 Browser* browser = BrowserList::GetLastActive(); |
1352 if (browser) | 1368 if (browser) |
1353 *handle = browser_tracker_->Add(browser); | 1369 *handle = browser_tracker_->Add(browser); |
1354 } | 1370 } |
1355 | 1371 |
1356 #if defined(OS_WIN) | 1372 #if defined(OS_WIN) |
1357 // TODO(port): Remove windowsisms. | 1373 // TODO(port): Remove windowsisms. |
1358 BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM l_param) { | 1374 BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM l_param) { |
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2882 DLOG(WARNING) << "SetParent failed. Error 0x%x" << GetLastError(); | 2898 DLOG(WARNING) << "SetParent failed. Error 0x%x" << GetLastError(); |
2883 } | 2899 } |
2884 } | 2900 } |
2885 } | 2901 } |
2886 #endif | 2902 #endif |
2887 | 2903 |
2888 void AutomationProvider::GetWindowTitle(int handle, string16* text) { | 2904 void AutomationProvider::GetWindowTitle(int handle, string16* text) { |
2889 gfx::NativeWindow window = window_tracker_->GetResource(handle); | 2905 gfx::NativeWindow window = window_tracker_->GetResource(handle); |
2890 text->assign(platform_util::GetWindowTitle(window)); | 2906 text->assign(platform_util::GetWindowTitle(window)); |
2891 } | 2907 } |
OLD | NEW |