| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Enable chrome testing interface on ChromeOS. | |
| 7 | |
| 8 Enables chrome automation over a named automation channel on ChromeOS. | |
| 9 Also, allows passing extra flags to chrome (--extra-chrome-flags). | |
| 10 The path to named testing interface automation socket is printed out. | |
| 11 | |
| 12 Needs to be run with superuser privileges. | |
| 13 | |
| 14 Usage: | |
| 15 sudo python enable_testing.py --extra-chrome-flags="--homepage=about:blank" | |
| 16 """ | |
| 17 | |
| 18 import dbus | |
| 19 import optparse | |
| 20 import os | |
| 21 import sys | |
| 22 | |
| 23 | |
| 24 class EnableChromeTestingOnChromeOS(object): | |
| 25 """Helper to enable chrome testing interface on ChromeOS. | |
| 26 | |
| 27 Also, can add additional flags to chrome to be used for testing. | |
| 28 """ | |
| 29 | |
| 30 SESSION_MANAGER_INTERFACE = 'org.chromium.SessionManagerInterface' | |
| 31 SESSION_MANAGER_PATH = '/org/chromium/SessionManager' | |
| 32 SESSION_MANAGER_SERVICE = 'org.chromium.SessionManager' | |
| 33 | |
| 34 def _ParseArgs(self): | |
| 35 parser = optparse.OptionParser() | |
| 36 parser.add_option( | |
| 37 '', '--extra-chrome-flags', action='append', default=[], | |
| 38 help='Pass extra flags to chrome.') | |
| 39 self._options, self._args = parser.parse_args() | |
| 40 | |
| 41 def Run(self): | |
| 42 self._ParseArgs() | |
| 43 assert os.geteuid() == 0, 'Needs superuser privileges.' | |
| 44 system_bus = dbus.SystemBus() | |
| 45 manager = dbus.Interface(system_bus.get_object(self.SESSION_MANAGER_SERVICE, | |
| 46 self.SESSION_MANAGER_PATH), | |
| 47 self.SESSION_MANAGER_INTERFACE) | |
| 48 print manager.EnableChromeTesting(True, self._options.extra_chrome_flags) | |
| 49 return 0 | |
| 50 | |
| 51 | |
| 52 if __name__ == '__main__': | |
| 53 sys.exit(EnableChromeTestingOnChromeOS().Run()) | |
| OLD | NEW |