OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This implements a browser-side endpoint for UI automation activity. | 5 // This implements a browser-side endpoint for UI automation activity. |
6 // The client-side endpoint is implemented by AutomationProxy. | 6 // The client-side endpoint is implemented by AutomationProxy. |
7 // The entire lifetime of this object should be contained within that of | 7 // The entire lifetime of this object should be contained within that of |
8 // the BrowserProcess, and in particular the NotificationService that's | 8 // the BrowserProcess, and in particular the NotificationService that's |
9 // hung off of it. | 9 // hung off of it. |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 class AutomationExtensionTracker; | 46 class AutomationExtensionTracker; |
47 class AutomationResourceMessageFilter; | 47 class AutomationResourceMessageFilter; |
48 class AutomationTabTracker; | 48 class AutomationTabTracker; |
49 class AutomationWindowTracker; | 49 class AutomationWindowTracker; |
50 class CreditCard; | 50 class CreditCard; |
51 class DictionaryValue; | 51 class DictionaryValue; |
52 class Extension; | 52 class Extension; |
53 class ExtensionPortContainer; | 53 class ExtensionPortContainer; |
54 class ExtensionTestResultNotificationObserver; | 54 class ExtensionTestResultNotificationObserver; |
55 class ExternalTabContainer; | 55 class ExternalTabContainer; |
| 56 class InitialLoadObserver; |
56 class LoginHandler; | 57 class LoginHandler; |
57 class MetricEventDurationObserver; | 58 class MetricEventDurationObserver; |
58 class InitialLoadObserver; | 59 class NavigationController; |
59 class NavigationControllerRestoredObserver; | 60 class NavigationControllerRestoredObserver; |
| 61 class Profile; |
60 struct AutocompleteMatchData; | 62 struct AutocompleteMatchData; |
61 | 63 |
62 namespace gfx { | 64 namespace gfx { |
63 class Point; | 65 class Point; |
64 } | 66 } |
65 | 67 |
66 class AutomationProvider : public base::RefCounted<AutomationProvider>, | 68 class AutomationProvider : public base::RefCounted<AutomationProvider>, |
67 public IPC::Channel::Listener, | 69 public IPC::Channel::Listener, |
68 public IPC::Message::Sender { | 70 public IPC::Message::Sender { |
69 public: | 71 public: |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 virtual ~AutomationProvider(); | 161 virtual ~AutomationProvider(); |
160 | 162 |
161 // Helper function to find the browser window that contains a given | 163 // Helper function to find the browser window that contains a given |
162 // NavigationController and activate that tab. | 164 // NavigationController and activate that tab. |
163 // Returns the Browser if found. | 165 // Returns the Browser if found. |
164 Browser* FindAndActivateTab(NavigationController* contents); | 166 Browser* FindAndActivateTab(NavigationController* contents); |
165 | 167 |
166 scoped_ptr<AutomationBrowserTracker> browser_tracker_; | 168 scoped_ptr<AutomationBrowserTracker> browser_tracker_; |
167 scoped_ptr<AutomationTabTracker> tab_tracker_; | 169 scoped_ptr<AutomationTabTracker> tab_tracker_; |
168 | 170 |
| 171 typedef std::map<NavigationController*, LoginHandler*> LoginHandlerMap; |
| 172 LoginHandlerMap login_handler_map_; |
| 173 |
| 174 Profile* profile_; |
| 175 |
| 176 // A pointer to reply message used when we do asynchronous processing in the |
| 177 // message handler. |
| 178 // TODO(phajdan.jr): Remove |reply_message_|, it is error-prone. |
| 179 IPC::Message* reply_message_; |
| 180 |
| 181 // Consumer for asynchronous history queries. |
| 182 CancelableRequestConsumer consumer_; |
| 183 |
169 private: | 184 private: |
170 // IPC Message callbacks. | 185 // IPC Message callbacks. |
171 void GetBrowserWindowCount(int* window_count); | |
172 void GetBrowserLocale(string16* locale); | 186 void GetBrowserLocale(string16* locale); |
173 void GetNormalBrowserWindowCount(int* window_count); | |
174 void GetShowingAppModalDialog(bool* showing_dialog, int* dialog_button); | 187 void GetShowingAppModalDialog(bool* showing_dialog, int* dialog_button); |
175 void ClickAppModalDialogButton(int button, bool* success); | 188 void ClickAppModalDialogButton(int button, bool* success); |
176 void ShutdownSessionService(int handle, bool* result); | 189 void ShutdownSessionService(int handle, bool* result); |
177 // Be aware that the browser window returned might be of non TYPE_NORMAL | 190 // Be aware that the browser window returned might be of non TYPE_NORMAL |
178 // or in incognito mode. | 191 // or in incognito mode. |
179 void GetBrowserWindow(int index, int* handle); | 192 void GetBrowserWindow(int index, int* handle); |
180 void FindNormalBrowserWindow(int* handle); | 193 void FindNormalBrowserWindow(int* handle); |
181 void GetLastActiveBrowserWindow(int* handle); | 194 void GetLastActiveBrowserWindow(int* handle); |
182 void GetActiveWindow(int* handle); | 195 void GetActiveWindow(int* handle); |
183 void ExecuteBrowserCommandAsync(int handle, int command, bool* success); | 196 void ExecuteBrowserCommandAsync(int handle, int command, bool* success); |
(...skipping 30 matching lines...) Expand all Loading... |
214 void GetTab(int win_handle, int tab_index, int* tab_handle); | 227 void GetTab(int win_handle, int tab_index, int* tab_handle); |
215 #if defined(OS_WIN) | 228 #if defined(OS_WIN) |
216 // TODO(port): Replace HWND. | 229 // TODO(port): Replace HWND. |
217 void GetTabHWND(int handle, HWND* tab_hwnd); | 230 void GetTabHWND(int handle, HWND* tab_hwnd); |
218 #endif // defined(OS_WIN) | 231 #endif // defined(OS_WIN) |
219 void GetTabProcessID(int handle, int* process_id); | 232 void GetTabProcessID(int handle, int* process_id); |
220 void GetTabTitle(int handle, int* title_string_size, std::wstring* title); | 233 void GetTabTitle(int handle, int* title_string_size, std::wstring* title); |
221 void GetTabIndex(int handle, int* tabstrip_index); | 234 void GetTabIndex(int handle, int* tabstrip_index); |
222 void GetTabURL(int handle, bool* success, GURL* url); | 235 void GetTabURL(int handle, bool* success, GURL* url); |
223 void HandleUnused(const IPC::Message& message, int handle); | 236 void HandleUnused(const IPC::Message& message, int handle); |
224 void NavigationAsync(int handle, const GURL& url, bool* status); | |
225 void NavigationAsyncWithDisposition(int handle, | |
226 const GURL& url, | |
227 WindowOpenDisposition disposition, | |
228 bool* status); | |
229 void GoBack(int handle, IPC::Message* reply_message); | |
230 void GoForward(int handle, IPC::Message* reply_message); | |
231 void Reload(int handle, IPC::Message* reply_message); | |
232 void SetAuth(int tab_handle, const std::wstring& username, | |
233 const std::wstring& password, IPC::Message* reply_message); | |
234 void CancelAuth(int tab_handle, IPC::Message* reply_message); | |
235 void NeedsAuth(int tab_handle, bool* needs_auth); | |
236 void GetRedirectsFrom(int tab_handle, | |
237 const GURL& source_url, | |
238 IPC::Message* reply_message); | |
239 void ExecuteJavascript(int handle, | 237 void ExecuteJavascript(int handle, |
240 const std::wstring& frame_xpath, | 238 const std::wstring& frame_xpath, |
241 const std::wstring& script, | 239 const std::wstring& script, |
242 IPC::Message* reply_message); | 240 IPC::Message* reply_message); |
243 void GetShelfVisibility(int handle, bool* visible); | 241 void GetShelfVisibility(int handle, bool* visible); |
244 void SetShelfVisibility(int handle, bool visible); | 242 void SetShelfVisibility(int handle, bool visible); |
245 void SetFilteredInet(const IPC::Message& message, bool enabled); | 243 void SetFilteredInet(const IPC::Message& message, bool enabled); |
246 void GetFilteredInetHitCount(int* hit_count); | 244 void GetFilteredInetHitCount(int* hit_count); |
247 void SetProxyConfig(const std::string& new_proxy_config); | 245 void SetProxyConfig(const std::string& new_proxy_config); |
248 void IsFullscreen(int handle, bool* is_fullscreen); | 246 void IsFullscreen(int handle, bool* is_fullscreen); |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 TabContents* GetTabContentsForHandle(int handle, NavigationController** tab); | 811 TabContents* GetTabContentsForHandle(int handle, NavigationController** tab); |
814 | 812 |
815 #if defined(OS_CHROMEOS) | 813 #if defined(OS_CHROMEOS) |
816 // Logs in through the Chrome OS Login Wizard with given |username| and | 814 // Logs in through the Chrome OS Login Wizard with given |username| and |
817 // password. Returns true via |reply_message| on success. | 815 // password. Returns true via |reply_message| on success. |
818 void LoginWithUserAndPass(const std::string& username, | 816 void LoginWithUserAndPass(const std::string& username, |
819 const std::string& password, | 817 const std::string& password, |
820 IPC::Message* reply_message); | 818 IPC::Message* reply_message); |
821 #endif | 819 #endif |
822 | 820 |
823 // Callback for history redirect queries. | |
824 virtual void OnRedirectQueryComplete( | |
825 HistoryService::Handle request_handle, | |
826 GURL from_url, | |
827 bool success, | |
828 history::RedirectList* redirects); | |
829 | |
830 // Returns the associated view for the tab handle passed in. | 821 // Returns the associated view for the tab handle passed in. |
831 // Returns NULL on failure. | 822 // Returns NULL on failure. |
832 RenderViewHost* GetViewForTab(int tab_handle); | 823 RenderViewHost* GetViewForTab(int tab_handle); |
833 | 824 |
834 // Returns the extension for the given handle. Returns NULL if there is | 825 // Returns the extension for the given handle. Returns NULL if there is |
835 // no extension for the handle. | 826 // no extension for the handle. |
836 Extension* GetExtension(int extension_handle); | 827 Extension* GetExtension(int extension_handle); |
837 | 828 |
838 // Returns the extension for the given handle, if the handle is valid and | 829 // Returns the extension for the given handle, if the handle is valid and |
839 // the associated extension is enabled. Returns NULL otherwise. | 830 // the associated extension is enabled. Returns NULL otherwise. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 | 901 |
911 void OnRunUnloadHandlers(int handle, gfx::NativeWindow notification_window, | 902 void OnRunUnloadHandlers(int handle, gfx::NativeWindow notification_window, |
912 int notification_message); | 903 int notification_message); |
913 | 904 |
914 void OnSetZoomLevel(int handle, int zoom_level); | 905 void OnSetZoomLevel(int handle, int zoom_level); |
915 | 906 |
916 ExternalTabContainer* GetExternalTabForHandle(int handle); | 907 ExternalTabContainer* GetExternalTabForHandle(int handle); |
917 #endif // defined(OS_WIN) | 908 #endif // defined(OS_WIN) |
918 | 909 |
919 typedef ObserverList<NotificationObserver> NotificationObserverList; | 910 typedef ObserverList<NotificationObserver> NotificationObserverList; |
920 typedef std::map<NavigationController*, LoginHandler*> LoginHandlerMap; | |
921 typedef std::map<int, ExtensionPortContainer*> PortContainerMap; | 911 typedef std::map<int, ExtensionPortContainer*> PortContainerMap; |
922 | 912 |
923 scoped_ptr<IPC::ChannelProxy> channel_; | 913 scoped_ptr<IPC::ChannelProxy> channel_; |
924 scoped_ptr<InitialLoadObserver> initial_load_observer_; | 914 scoped_ptr<InitialLoadObserver> initial_load_observer_; |
925 scoped_ptr<NotificationObserver> new_tab_ui_load_observer_; | 915 scoped_ptr<NotificationObserver> new_tab_ui_load_observer_; |
926 scoped_ptr<NotificationObserver> find_in_page_observer_; | 916 scoped_ptr<NotificationObserver> find_in_page_observer_; |
927 scoped_ptr<NotificationObserver> dom_operation_observer_; | 917 scoped_ptr<NotificationObserver> dom_operation_observer_; |
928 scoped_ptr<NotificationObserver> dom_inspector_observer_; | 918 scoped_ptr<NotificationObserver> dom_inspector_observer_; |
929 scoped_ptr<ExtensionTestResultNotificationObserver> | 919 scoped_ptr<ExtensionTestResultNotificationObserver> |
930 extension_test_result_observer_; | 920 extension_test_result_observer_; |
931 scoped_ptr<MetricEventDurationObserver> metric_event_duration_observer_; | 921 scoped_ptr<MetricEventDurationObserver> metric_event_duration_observer_; |
932 scoped_ptr<AutomationExtensionTracker> extension_tracker_; | 922 scoped_ptr<AutomationExtensionTracker> extension_tracker_; |
933 scoped_ptr<AutomationWindowTracker> window_tracker_; | 923 scoped_ptr<AutomationWindowTracker> window_tracker_; |
934 scoped_ptr<AutomationAutocompleteEditTracker> autocomplete_edit_tracker_; | 924 scoped_ptr<AutomationAutocompleteEditTracker> autocomplete_edit_tracker_; |
935 scoped_ptr<NavigationControllerRestoredObserver> restore_tracker_; | 925 scoped_ptr<NavigationControllerRestoredObserver> restore_tracker_; |
936 LoginHandlerMap login_handler_map_; | |
937 PortContainerMap port_containers_; | 926 PortContainerMap port_containers_; |
938 NotificationObserverList notification_observer_list_; | 927 NotificationObserverList notification_observer_list_; |
939 scoped_refptr<AutomationResourceMessageFilter> | 928 scoped_refptr<AutomationResourceMessageFilter> |
940 automation_resource_message_filter_; | 929 automation_resource_message_filter_; |
941 | 930 |
942 // Handle for an in-process redirect query. We expect only one redirect query | |
943 // at a time (we should have only one caller, and it will block while waiting | |
944 // for the results) so there is only one handle. When non-0, indicates a | |
945 // query in progress. | |
946 HistoryService::Handle redirect_query_; | |
947 | |
948 // Consumer for asynchronous history queries. | |
949 CancelableRequestConsumer consumer_; | |
950 | |
951 Profile* profile_; | |
952 | |
953 IPC::Message* reply_message_; | |
954 | |
955 // Keep track of whether a popup menu has been opened since the last time | 931 // Keep track of whether a popup menu has been opened since the last time |
956 // that StartTrackingPopupMenus has been called. | 932 // that StartTrackingPopupMenus has been called. |
957 bool popup_menu_opened_; | 933 bool popup_menu_opened_; |
958 | 934 |
959 // A temporary object that receives a notification when a popup menu opens. | 935 // A temporary object that receives a notification when a popup menu opens. |
960 PopupMenuWaiter* popup_menu_waiter_; | 936 PopupMenuWaiter* popup_menu_waiter_; |
961 | 937 |
962 DISALLOW_COPY_AND_ASSIGN(AutomationProvider); | 938 DISALLOW_COPY_AND_ASSIGN(AutomationProvider); |
963 }; | 939 }; |
964 | 940 |
965 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ | 941 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ |
OLD | NEW |