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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 *handle = browser_tracker_->Add(browser); | 730 *handle = browser_tracker_->Add(browser); |
731 } | 731 } |
732 | 732 |
733 void AutomationProvider::GetLastActiveBrowserWindow(int* handle) { | 733 void AutomationProvider::GetLastActiveBrowserWindow(int* handle) { |
734 *handle = 0; | 734 *handle = 0; |
735 Browser* browser = BrowserList::GetLastActive(); | 735 Browser* browser = BrowserList::GetLastActive(); |
736 if (browser) | 736 if (browser) |
737 *handle = browser_tracker_->Add(browser); | 737 *handle = browser_tracker_->Add(browser); |
738 } | 738 } |
739 | 739 |
740 #if defined(OS_LINUX) | 740 #if defined(USE_X11) |
741 // TODO(estade): use this implementation for all platforms? | 741 // TODO(estade): use this implementation for all platforms? |
742 void AutomationProvider::GetActiveWindow(int* handle) { | 742 void AutomationProvider::GetActiveWindow(int* handle) { |
743 gfx::NativeWindow window = | 743 gfx::NativeWindow window = |
744 BrowserList::GetLastActive()->window()->GetNativeHandle(); | 744 BrowserList::GetLastActive()->window()->GetNativeHandle(); |
745 *handle = window_tracker_->Add(window); | 745 *handle = window_tracker_->Add(window); |
746 } | 746 } |
747 #endif | 747 #endif |
748 | 748 |
749 void AutomationProvider::ExecuteBrowserCommandAsync(int handle, int command, | 749 void AutomationProvider::ExecuteBrowserCommandAsync(int handle, int command, |
750 bool* success) { | 750 bool* success) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 } | 815 } |
816 | 816 |
817 private: | 817 private: |
818 AutomationProvider* provider_; | 818 AutomationProvider* provider_; |
819 IPC::Message* reply_message_; | 819 IPC::Message* reply_message_; |
820 | 820 |
821 DISALLOW_COPY_AND_ASSIGN(WindowDragResponseTask); | 821 DISALLOW_COPY_AND_ASSIGN(WindowDragResponseTask); |
822 }; | 822 }; |
823 #endif // defined(OS_WIN) | 823 #endif // defined(OS_WIN) |
824 | 824 |
825 #if defined(OS_WIN) || defined(OS_LINUX) | 825 #if defined(OS_WIN) || defined(USE_X11) |
826 void AutomationProvider::WindowSimulateClick(const IPC::Message& message, | 826 void AutomationProvider::WindowSimulateClick(const IPC::Message& message, |
827 int handle, | 827 int handle, |
828 const gfx::Point& click, | 828 const gfx::Point& click, |
829 int flags) { | 829 int flags) { |
830 if (window_tracker_->ContainsHandle(handle)) { | 830 if (window_tracker_->ContainsHandle(handle)) { |
831 ui_controls::SendMouseMoveNotifyWhenDone(click.x(), click.y(), | 831 ui_controls::SendMouseMoveNotifyWhenDone(click.x(), click.y(), |
832 new ClickTask(flags)); | 832 new ClickTask(flags)); |
833 } | 833 } |
834 } | 834 } |
835 | 835 |
836 void AutomationProvider::WindowSimulateKeyPress(const IPC::Message& message, | 836 void AutomationProvider::WindowSimulateKeyPress(const IPC::Message& message, |
837 int handle, | 837 int handle, |
838 wchar_t key, | 838 wchar_t key, |
839 int flags) { | 839 int flags) { |
840 if (!window_tracker_->ContainsHandle(handle)) | 840 if (!window_tracker_->ContainsHandle(handle)) |
841 return; | 841 return; |
842 | 842 |
843 gfx::NativeWindow window = window_tracker_->GetResource(handle); | 843 gfx::NativeWindow window = window_tracker_->GetResource(handle); |
844 // The key event is sent to whatever window is active. | 844 // The key event is sent to whatever window is active. |
845 ui_controls::SendKeyPress(window, key, | 845 ui_controls::SendKeyPress(window, key, |
846 ((flags & views::Event::EF_CONTROL_DOWN) == | 846 ((flags & views::Event::EF_CONTROL_DOWN) == |
847 views::Event::EF_CONTROL_DOWN), | 847 views::Event::EF_CONTROL_DOWN), |
848 ((flags & views::Event::EF_SHIFT_DOWN) == | 848 ((flags & views::Event::EF_SHIFT_DOWN) == |
849 views::Event::EF_SHIFT_DOWN), | 849 views::Event::EF_SHIFT_DOWN), |
850 ((flags & views::Event::EF_ALT_DOWN) == | 850 ((flags & views::Event::EF_ALT_DOWN) == |
851 views::Event::EF_ALT_DOWN)); | 851 views::Event::EF_ALT_DOWN)); |
852 } | 852 } |
853 #endif // defined(OS_WIN) || defined(OS_LINUX) | 853 #endif // defined(OS_WIN) || defined(USE_X11) |
854 | 854 |
855 void AutomationProvider::IsWindowActive(int handle, bool* success, | 855 void AutomationProvider::IsWindowActive(int handle, bool* success, |
856 bool* is_active) { | 856 bool* is_active) { |
857 if (window_tracker_->ContainsHandle(handle)) { | 857 if (window_tracker_->ContainsHandle(handle)) { |
858 *is_active = | 858 *is_active = |
859 platform_util::IsWindowActive(window_tracker_->GetResource(handle)); | 859 platform_util::IsWindowActive(window_tracker_->GetResource(handle)); |
860 *success = true; | 860 *success = true; |
861 } else { | 861 } else { |
862 *success = false; | 862 *success = false; |
863 *is_active = false; | 863 *is_active = false; |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 for (;iter != BrowserList::end(); ++iter) { | 2061 for (;iter != BrowserList::end(); ++iter) { |
2062 gfx::NativeWindow this_window = (*iter)->window()->GetNativeHandle(); | 2062 gfx::NativeWindow this_window = (*iter)->window()->GetNativeHandle(); |
2063 if (window == this_window) { | 2063 if (window == this_window) { |
2064 // Add() returns the existing handle for the resource if any. | 2064 // Add() returns the existing handle for the resource if any. |
2065 *browser_handle = browser_tracker_->Add(*iter); | 2065 *browser_handle = browser_tracker_->Add(*iter); |
2066 *success = true; | 2066 *success = true; |
2067 return; | 2067 return; |
2068 } | 2068 } |
2069 } | 2069 } |
2070 } | 2070 } |
OLD | NEW |