| OLD | NEW |
| 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 import constants | 5 import constants |
| 6 import logging |
| 6 import traceback | 7 import traceback |
| 7 import warnings | 8 import warnings |
| 8 | 9 |
| 9 | 10 |
| 10 # Location where chrome reads command line flags from | 11 # Location where chrome reads command line flags from |
| 11 CHROME_COMMAND_FILE = '/data/local/chrome-command-line' | 12 CHROME_COMMAND_FILE = '/data/local/chrome-command-line' |
| 12 | 13 |
| 13 class FlagChanger(object): | 14 class FlagChanger(object): |
| 14 """Changes the flags Chrome runs with. | 15 """Changes the flags Chrome runs with. |
| 15 | 16 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 self._current_flags.remove(flag) | 80 self._current_flags.remove(flag) |
| 80 self._UpdateCommandLineFile() | 81 self._UpdateCommandLineFile() |
| 81 | 82 |
| 82 def Restore(self): | 83 def Restore(self): |
| 83 """Restores the flags to their original state.""" | 84 """Restores the flags to their original state.""" |
| 84 self._current_flags = self._TokenizeFlags(self._orig_line) | 85 self._current_flags = self._TokenizeFlags(self._orig_line) |
| 85 self._UpdateCommandLineFile() | 86 self._UpdateCommandLineFile() |
| 86 | 87 |
| 87 def _UpdateCommandLineFile(self): | 88 def _UpdateCommandLineFile(self): |
| 88 """Writes out the command line to the file, or removes it if empty.""" | 89 """Writes out the command line to the file, or removes it if empty.""" |
| 89 print "Current flags: ", self._current_flags | 90 logging.info('Current flags: %s', self._current_flags) |
| 90 | 91 |
| 91 if self._current_flags: | 92 if self._current_flags: |
| 92 self._android_cmd.SetProtectedFileContents(CHROME_COMMAND_FILE, | 93 self._android_cmd.SetProtectedFileContents(CHROME_COMMAND_FILE, |
| 93 'chrome ' + | 94 'chrome ' + |
| 94 ' '.join(self._current_flags)) | 95 ' '.join(self._current_flags)) |
| 95 else: | 96 else: |
| 96 self._android_cmd.RunShellCommand('su -c rm ' + CHROME_COMMAND_FILE) | 97 self._android_cmd.RunShellCommand('su -c rm ' + CHROME_COMMAND_FILE) |
| 97 | 98 |
| 98 def _TokenizeFlags(self, line): | 99 def _TokenizeFlags(self, line): |
| 99 """Changes the string containing the command line into a list of flags. | 100 """Changes the string containing the command line into a list of flags. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 136 |
| 136 # Tack on the last flag. | 137 # Tack on the last flag. |
| 137 if not current_flag: | 138 if not current_flag: |
| 138 if within_quotations: | 139 if within_quotations: |
| 139 warnings.warn("Unterminated quoted string: " + current_flag) | 140 warnings.warn("Unterminated quoted string: " + current_flag) |
| 140 else: | 141 else: |
| 141 tokenized_flags.append(current_flag) | 142 tokenized_flags.append(current_flag) |
| 142 | 143 |
| 143 # Return everything but the program name. | 144 # Return everything but the program name. |
| 144 return tokenized_flags[1:] | 145 return tokenized_flags[1:] |
| OLD | NEW |