| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """PyAuto: Python Interface to Chromium's Automation Proxy. | 7 """PyAuto: Python Interface to Chromium's Automation Proxy. |
| 8 | 8 |
| 9 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 9 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
| 10 For complete documentation on the functionality available, | 10 For complete documentation on the functionality available, |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 string or complex ones like list. | 1063 string or complex ones like list. |
| 1064 The user has to ensure that the right value is specified for the | 1064 The user has to ensure that the right value is specified for the |
| 1065 right key. It's useful to dump the preferences first to determine | 1065 right key. It's useful to dump the preferences first to determine |
| 1066 what type is expected for a particular preference path. | 1066 what type is expected for a particular preference path. |
| 1067 """ | 1067 """ |
| 1068 cmd_dict = { | 1068 cmd_dict = { |
| 1069 'command': 'SetLocalStatePrefs', | 1069 'command': 'SetLocalStatePrefs', |
| 1070 'path': path, | 1070 'path': path, |
| 1071 'value': value, | 1071 'value': value, |
| 1072 } | 1072 } |
| 1073 self._GetResultFromJSONRequest(cmd_dict) | 1073 self._GetResultFromJSONRequest(cmd_dict, windex=-1) |
| 1074 | 1074 |
| 1075 def GetPrefsInfo(self): | 1075 def GetPrefsInfo(self): |
| 1076 """Return info about preferences. | 1076 """Return info about preferences. |
| 1077 | 1077 |
| 1078 This represents a snapshot of the preferences. If you expect preferences | 1078 This represents a snapshot of the preferences. If you expect preferences |
| 1079 to have changed, you need to call this method again to get a fresh | 1079 to have changed, you need to call this method again to get a fresh |
| 1080 snapshot. | 1080 snapshot. |
| 1081 | 1081 |
| 1082 Returns: | 1082 Returns: |
| 1083 an instance of prefs_info.PrefsInfo | 1083 an instance of prefs_info.PrefsInfo |
| 1084 """ | 1084 """ |
| 1085 return prefs_info.PrefsInfo( | 1085 return prefs_info.PrefsInfo( |
| 1086 self._SendJSONRequest(0, json.dumps({'command': 'GetPrefsInfo'}), | 1086 self._SendJSONRequest(-1, json.dumps({'command': 'GetPrefsInfo'}), |
| 1087 self.action_max_timeout_ms())) | 1087 self.action_max_timeout_ms())) |
| 1088 | 1088 |
| 1089 def SetPrefs(self, path, value): | 1089 def SetPrefs(self, path, value): |
| 1090 """Set preference for the given path. | 1090 """Set preference for the given path. |
| 1091 | 1091 |
| 1092 Preferences are stored by Chromium as a hierarchical dictionary. | 1092 Preferences are stored by Chromium as a hierarchical dictionary. |
| 1093 dot-separated paths can be used to refer to a particular preference. | 1093 dot-separated paths can be used to refer to a particular preference. |
| 1094 example: "session.restore_on_startup" | 1094 example: "session.restore_on_startup" |
| 1095 | 1095 |
| 1096 Some preferences are managed, that is, they cannot be changed by the | 1096 Some preferences are managed, that is, they cannot be changed by the |
| (...skipping 3670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4767 successful = result.wasSuccessful() | 4767 successful = result.wasSuccessful() |
| 4768 if not successful: | 4768 if not successful: |
| 4769 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 4769 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
| 4770 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 4770 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
| 4771 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 4771 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
| 4772 sys.exit(not successful) | 4772 sys.exit(not successful) |
| 4773 | 4773 |
| 4774 | 4774 |
| 4775 if __name__ == '__main__': | 4775 if __name__ == '__main__': |
| 4776 Main() | 4776 Main() |
| OLD | NEW |