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