Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/browser/automation/testing_automation_provider.h

Issue 10534163: First pass at refactoring pyautolib in preparation for removing proxy dependencies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied Nirnimesh's suggestions. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ 6 #define CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 class TestingAutomationProvider : public AutomationProvider, 57 class TestingAutomationProvider : public AutomationProvider,
58 public BrowserList::Observer, 58 public BrowserList::Observer,
59 public importer::ImporterListObserver, 59 public importer::ImporterListObserver,
60 public content::NotificationObserver { 60 public content::NotificationObserver {
61 public: 61 public:
62 explicit TestingAutomationProvider(Profile* profile); 62 explicit TestingAutomationProvider(Profile* profile);
63 63
64 virtual IPC::Channel::Mode GetChannelMode(bool use_named_interface); 64 virtual IPC::Channel::Mode GetChannelMode(bool use_named_interface);
65 65
66 // IPC::Channel::Listener: 66 // IPC::Channel::Listener:
67 //
kkania 2012/06/18 16:30:33 ?
craigdh 2012/06/19 00:19:35 Good question.
67 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 68 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
68 virtual void OnChannelError() OVERRIDE; 69 virtual void OnChannelError() OVERRIDE;
69 70
70 private: 71 private:
71 // Storage for ImportSettings() to resume operations after a callback. 72 // Storage for ImportSettings() to resume operations after a callback.
72 struct ImportSettingsData { 73 struct ImportSettingsData {
73 string16 browser_name; 74 string16 browser_name;
74 int import_items; 75 int import_items;
75 bool first_run; 76 bool first_run;
76 Browser* browser; 77 Browser* browser;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 IPC::Message* reply_message); 241 IPC::Message* reply_message);
241 242
242 void GoForwardBlockUntilNavigationsComplete(int handle, 243 void GoForwardBlockUntilNavigationsComplete(int handle,
243 int number_of_navigations, 244 int number_of_navigations,
244 IPC::Message* reply_message); 245 IPC::Message* reply_message);
245 246
246 void SetShelfVisibility(int handle, bool visible); 247 void SetShelfVisibility(int handle, bool visible);
247 248
248 // Generic pattern for pyautolib 249 // Generic pattern for pyautolib
249 // Uses the JSON interface for input/output. 250 // Uses the JSON interface for input/output.
250 void SendJSONRequest(int handle, 251 void SendJSONRequestWithBrowserHandle(int handle,
252 const std::string& json_request,
253 IPC::Message* reply_message);
254 void SendJSONRequestWithBrowserIndex(int index,
255 const std::string& json_request,
256 IPC::Message* reply_message);
257 void SendJSONRequest(Browser* browser,
251 const std::string& json_request, 258 const std::string& json_request,
252 IPC::Message* reply_message); 259 IPC::Message* reply_message);
253 260
254 // Method ptr for json handlers. 261 // Method ptr for json handlers.
255 // Uses the JSON interface for input/output. 262 // Uses the JSON interface for input/output.
256 typedef void (TestingAutomationProvider::*JsonHandler)(base::DictionaryValue*, 263 typedef void (TestingAutomationProvider::*JsonHandler)(base::DictionaryValue*,
257 IPC::Message*); 264 IPC::Message*);
258 265
259 // Method ptr for json handlers that take a browser argument. 266 // Method ptr for json handlers that take a browser argument.
260 // Uses the JSON interface for input/output. 267 // Uses the JSON interface for input/output.
261 typedef void (TestingAutomationProvider::*BrowserJsonHandler)( 268 typedef void (TestingAutomationProvider::*BrowserJsonHandler)(
262 Browser* browser, 269 Browser* browser,
263 base::DictionaryValue*, 270 base::DictionaryValue*,
264 IPC::Message*); 271 IPC::Message*);
265 272
273 // JSON interface helper functions.
274 static DictionaryValue* ParseJSONRequestCommand(
kkania 2012/06/18 16:30:33 i think static funcs are supposed to go above non-
craigdh 2012/06/19 00:19:35 I went and looked it up: the style guide only trea
275 const std::string& json_request,
276 std::string* command,
277 std::string* error);
278 void BuildJSONHandlerMaps();
279
266 // Set window dimensions. 280 // Set window dimensions.
267 // Uses the JSON interface for input/output. 281 // Uses the JSON interface for input/output.
268 void SetWindowDimensions(Browser* browser, 282 void SetWindowDimensions(Browser* browser,
269 base::DictionaryValue* args, 283 base::DictionaryValue* args,
270 IPC::Message* reply_message); 284 IPC::Message* reply_message);
271 285
272 // Get info about infobars in the given WebContents object. 286 // Get info about infobars in the given WebContents object.
273 // This includes info about the type of infobars, the message text, 287 // This includes info about the type of infobars, the message text,
274 // buttons, etc. 288 // buttons, etc.
275 // Caller owns the returned object. 289 // Caller owns the returned object.
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 1551
1538 // Selects the given |browser| and |tab| if not selected already. 1552 // Selects the given |browser| and |tab| if not selected already.
1539 void EnsureTabSelected(Browser* browser, content::WebContents* tab); 1553 void EnsureTabSelected(Browser* browser, content::WebContents* tab);
1540 1554
1541 #if defined(OS_CHROMEOS) 1555 #if defined(OS_CHROMEOS)
1542 // Avoid scoped ptr here to avoid having to define it completely in the 1556 // Avoid scoped ptr here to avoid having to define it completely in the
1543 // non-ChromeOS code. 1557 // non-ChromeOS code.
1544 PowerManagerClientObserverForTesting* power_manager_observer_; 1558 PowerManagerClientObserverForTesting* power_manager_observer_;
1545 #endif // defined(OS_CHROMEOS) 1559 #endif // defined(OS_CHROMEOS)
1546 1560
1561 std::map<std::string, JsonHandler> handler_map_;
1562 std::map<std::string, BrowserJsonHandler> browser_handler_map_;
1563
1547 // Used to wait on various browser sync events. 1564 // Used to wait on various browser sync events.
1548 scoped_ptr<ProfileSyncServiceHarness> sync_waiter_; 1565 scoped_ptr<ProfileSyncServiceHarness> sync_waiter_;
1549 1566
1550 content::NotificationRegistrar registrar_; 1567 content::NotificationRegistrar registrar_;
1551 1568
1552 // Used to enumerate browser profiles. 1569 // Used to enumerate browser profiles.
1553 scoped_refptr<ImporterList> importer_list_; 1570 scoped_refptr<ImporterList> importer_list_;
1554 1571
1555 // The stored data for the ImportSettings operation. 1572 // The stored data for the ImportSettings operation.
1556 ImportSettingsData import_settings_data_; 1573 ImportSettingsData import_settings_data_;
1557 1574
1558 // The automation event observer queue. It is lazily created when an observer 1575 // The automation event observer queue. It is lazily created when an observer
1559 // is added to avoid overhead when not needed. 1576 // is added to avoid overhead when not needed.
1560 scoped_ptr<AutomationEventQueue> automation_event_queue_; 1577 scoped_ptr<AutomationEventQueue> automation_event_queue_;
1561 1578
1562 DISALLOW_COPY_AND_ASSIGN(TestingAutomationProvider); 1579 DISALLOW_COPY_AND_ASSIGN(TestingAutomationProvider);
1563 }; 1580 };
1564 1581
1565 #endif // CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ 1582 #endif // CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698