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 |
11 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ | 11 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ |
12 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ | 12 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ |
13 #pragma once | 13 #pragma once |
14 | 14 |
15 #include <map> | 15 #include <map> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
20 #include "base/compiler_specific.h" | |
21 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
22 #include "base/scoped_ptr.h" | 21 #include "base/scoped_ptr.h" |
23 #include "base/string16.h" | 22 #include "base/string16.h" |
24 #include "chrome/browser/autofill/field_types.h" | 23 #include "chrome/browser/autofill/field_types.h" |
25 #include "chrome/browser/cancelable_request.h" | 24 #include "chrome/browser/cancelable_request.h" |
26 #include "chrome/browser/tab_contents/navigation_entry.h" | 25 #include "chrome/browser/tab_contents/navigation_entry.h" |
27 #include "chrome/common/automation_constants.h" | 26 #include "chrome/common/automation_constants.h" |
28 #include "chrome/common/content_settings.h" | 27 #include "chrome/common/content_settings.h" |
29 #include "chrome/common/notification_observer.h" | 28 #include "chrome/common/notification_observer.h" |
30 #include "ipc/ipc_message.h" | 29 #include "ipc/ipc_message.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 75 } |
77 | 76 |
78 class AutomationProvider : public base::RefCounted<AutomationProvider>, | 77 class AutomationProvider : public base::RefCounted<AutomationProvider>, |
79 public IPC::Channel::Listener, | 78 public IPC::Channel::Listener, |
80 public IPC::Message::Sender { | 79 public IPC::Message::Sender { |
81 public: | 80 public: |
82 explicit AutomationProvider(Profile* profile); | 81 explicit AutomationProvider(Profile* profile); |
83 | 82 |
84 Profile* profile() const { return profile_; } | 83 Profile* profile() const { return profile_; } |
85 | 84 |
86 // Initializes a channel for a connection to an AutomationProxy. | 85 // Establishes a connection to an automation client, if present. |
87 // If channel_id starts with kNamedInterfacePrefix, it will act | 86 // An AutomationProxy should be established (probably in a different process) |
88 // as a server, create a named IPC socket with channel_id as its | 87 // before calling this. |
89 // path, and will listen on the socket for incoming connections. | 88 void ConnectToChannel(const std::string& channel_id); |
90 // If channel_id does not, it will act as a client and establish | |
91 // a connection on its primary IPC channel. See ipc/ipc_channel_posix.cc | |
92 // for more information about kPrimaryIPCChannel. | |
93 bool InitializeChannel(const std::string& channel_id) WARN_UNUSED_RESULT; | |
94 | 89 |
95 // Sets the number of tabs that we expect; when this number of tabs has | 90 // Sets the number of tabs that we expect; when this number of tabs has |
96 // loaded, an AutomationMsg_InitialLoadsComplete message is sent. | 91 // loaded, an AutomationMsg_InitialLoadsComplete message is sent. |
97 void SetExpectedTabCount(size_t expected_tabs); | 92 void SetExpectedTabCount(size_t expected_tabs); |
98 | 93 |
99 // Called when the inital set of tabs has finished loading. | |
100 // Call SetExpectedTabCount(0) to set this to true immediately. | |
101 void OnInitialLoadsComplete(); | |
102 | |
103 // Add a listener for navigation status notification. Currently only | 94 // Add a listener for navigation status notification. Currently only |
104 // navigation completion is observed; when the |number_of_navigations| | 95 // navigation completion is observed; when the |number_of_navigations| |
105 // complete, the completed_response object is sent; if the server requires | 96 // complete, the completed_response object is sent; if the server requires |
106 // authentication, we instead send the auth_needed_response object. A pointer | 97 // authentication, we instead send the auth_needed_response object. A pointer |
107 // to the added navigation observer is returned. This object should NOT be | 98 // to the added navigation observer is returned. This object should NOT be |
108 // deleted and should be released by calling the corresponding | 99 // deleted and should be released by calling the corresponding |
109 // RemoveNavigationStatusListener method. | 100 // RemoveNavigationStatusListener method. |
110 NotificationObserver* AddNavigationStatusListener( | 101 NotificationObserver* AddNavigationStatusListener( |
111 NavigationController* tab, IPC::Message* reply_message, | 102 NavigationController* tab, IPC::Message* reply_message, |
112 int number_of_navigations, bool include_current_navigation); | 103 int number_of_navigations, bool include_current_navigation); |
(...skipping 27 matching lines...) Expand all Loading... |
140 // Add an extension port container. | 131 // Add an extension port container. |
141 // Takes ownership of the container. | 132 // Takes ownership of the container. |
142 void AddPortContainer(ExtensionPortContainer* port); | 133 void AddPortContainer(ExtensionPortContainer* port); |
143 // Remove and delete the port container. | 134 // Remove and delete the port container. |
144 void RemovePortContainer(ExtensionPortContainer* port); | 135 void RemovePortContainer(ExtensionPortContainer* port); |
145 // Get the port container for the given port id. | 136 // Get the port container for the given port id. |
146 ExtensionPortContainer* GetPortContainer(int port_id) const; | 137 ExtensionPortContainer* GetPortContainer(int port_id) const; |
147 | 138 |
148 // IPC implementations | 139 // IPC implementations |
149 virtual bool Send(IPC::Message* msg); | 140 virtual bool Send(IPC::Message* msg); |
150 virtual void OnChannelConnected(int pid); | |
151 virtual void OnMessageReceived(const IPC::Message& msg); | 141 virtual void OnMessageReceived(const IPC::Message& msg); |
152 virtual void OnChannelError(); | 142 virtual void OnChannelError(); |
153 | 143 |
154 IPC::Message* reply_message_release() { | 144 IPC::Message* reply_message_release() { |
155 IPC::Message* reply_message = reply_message_; | 145 IPC::Message* reply_message = reply_message_; |
156 reply_message_ = NULL; | 146 reply_message_ = NULL; |
157 return reply_message; | 147 return reply_message; |
158 } | 148 } |
159 | 149 |
160 // Adds the extension passed in to the extension tracker, and returns | 150 // Adds the extension passed in to the extension tracker, and returns |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 scoped_ptr<IPC::ChannelProxy> channel_; | 394 scoped_ptr<IPC::ChannelProxy> channel_; |
405 scoped_ptr<NotificationObserver> new_tab_ui_load_observer_; | 395 scoped_ptr<NotificationObserver> new_tab_ui_load_observer_; |
406 scoped_ptr<NotificationObserver> find_in_page_observer_; | 396 scoped_ptr<NotificationObserver> find_in_page_observer_; |
407 scoped_ptr<NotificationObserver> dom_operation_observer_; | 397 scoped_ptr<NotificationObserver> dom_operation_observer_; |
408 scoped_ptr<NotificationObserver> dom_inspector_observer_; | 398 scoped_ptr<NotificationObserver> dom_inspector_observer_; |
409 scoped_ptr<ExtensionTestResultNotificationObserver> | 399 scoped_ptr<ExtensionTestResultNotificationObserver> |
410 extension_test_result_observer_; | 400 extension_test_result_observer_; |
411 scoped_ptr<AutomationExtensionTracker> extension_tracker_; | 401 scoped_ptr<AutomationExtensionTracker> extension_tracker_; |
412 PortContainerMap port_containers_; | 402 PortContainerMap port_containers_; |
413 | 403 |
414 // True iff connected to an AutomationProxy. | |
415 bool is_connected_; | |
416 | |
417 // True iff browser finished loading initial set of tabs. | |
418 bool initial_loads_complete_; | |
419 | |
420 DISALLOW_COPY_AND_ASSIGN(AutomationProvider); | 404 DISALLOW_COPY_AND_ASSIGN(AutomationProvider); |
421 }; | 405 }; |
422 | 406 |
423 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ | 407 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ |
OLD | NEW |