| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 json | 5 import json |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import platform | 8 import platform |
| 9 import shutil | 9 import shutil |
| 10 import socket | 10 import socket |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if self._extension_download_dir: | 147 if self._extension_download_dir: |
| 148 # Simple sanity check to lessen the impact of a stray rmtree(). | 148 # Simple sanity check to lessen the impact of a stray rmtree(). |
| 149 if len(self._extension_download_dir.split(os.sep)) < 3: | 149 if len(self._extension_download_dir.split(os.sep)) < 3: |
| 150 raise Exception("Path too shallow: %s" % self._extension_download_dir) | 150 raise Exception("Path too shallow: %s" % self._extension_download_dir) |
| 151 shutil.rmtree(self._extension_download_dir) | 151 shutil.rmtree(self._extension_download_dir) |
| 152 self._extension_download_dir = None | 152 self._extension_download_dir = None |
| 153 | 153 |
| 154 def CustomizeBrowserOptions(self, options): | 154 def CustomizeBrowserOptions(self, options): |
| 155 self._output_profile_path = options.output_profile_path | 155 self._output_profile_path = options.output_profile_path |
| 156 | 156 |
| 157 def WillRunTest(self, options): | 157 def WillRunTest(self): |
| 158 """Run before browser starts. | 158 """Run before browser starts. |
| 159 | 159 |
| 160 Download extensions and write installation files.""" | 160 Download extensions and write installation files.""" |
| 161 super(ExtensionsProfileCreator, self).WillRunTest(options) | 161 super(ExtensionsProfileCreator, self).WillRunTest() |
| 162 | 162 |
| 163 # Running this script on a corporate network or other managed environment | 163 # Running this script on a corporate network or other managed environment |
| 164 # could potentially alter the profile contents. | 164 # could potentially alter the profile contents. |
| 165 hostname = socket.gethostname() | 165 hostname = socket.gethostname() |
| 166 if hostname.endswith('corp.google.com'): | 166 if hostname.endswith('corp.google.com'): |
| 167 raise Exception("It appears you are connected to a corporate network " | 167 raise Exception("It appears you are connected to a corporate network " |
| 168 "(hostname=%s). This script needs to be run off the corp " | 168 "(hostname=%s). This script needs to be run off the corp " |
| 169 "network." % hostname) | 169 "network." % hostname) |
| 170 | 170 |
| 171 prompt = ("\n!!!This script must be run on a fresh OS installation, " | 171 prompt = ("\n!!!This script must be run on a fresh OS installation, " |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 if not self._extensions_installed: | 214 if not self._extensions_installed: |
| 215 sleep_seconds = 5 * 60 | 215 sleep_seconds = 5 * 60 |
| 216 logging.info("Sleeping for %d seconds." % sleep_seconds) | 216 logging.info("Sleeping for %d seconds." % sleep_seconds) |
| 217 time.sleep(sleep_seconds) | 217 time.sleep(sleep_seconds) |
| 218 self._extensions_installed = True | 218 self._extensions_installed = True |
| 219 else: | 219 else: |
| 220 # Phase 2: Wait for tab to finish loading. | 220 # Phase 2: Wait for tab to finish loading. |
| 221 for i in xrange(len(tab.browser.tabs)): | 221 for i in xrange(len(tab.browser.tabs)): |
| 222 t = tab.browser.tabs[i] | 222 t = tab.browser.tabs[i] |
| 223 t.WaitForDocumentReadyStateToBeComplete() | 223 t.WaitForDocumentReadyStateToBeComplete() |
| OLD | NEW |