OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import shutil |
| 6 |
| 7 from profile_creators import extension_profile_extender |
| 8 from profile_creators import profile_generator |
| 9 from telemetry.page import shared_page_state |
| 10 |
| 11 |
| 12 class ExtensionProfileSharedState(shared_page_state.SharedPageState): |
| 13 """Shared state tied with extension profile. |
| 14 |
| 15 Generates extension profile on initialization. |
| 16 """ |
| 17 |
| 18 def __init__(self, test, finder_options, story_set): |
| 19 super(ExtensionProfileSharedState, self).__init__( |
| 20 test, finder_options, story_set) |
| 21 generator = profile_generator.ProfileGenerator( |
| 22 extension_profile_extender.ExtensionProfileExtender, |
| 23 'extension_profile') |
| 24 self._out_dir = generator.Run(finder_options) |
| 25 if self._out_dir: |
| 26 finder_options.browser_options.profile_dir = self._out_dir |
| 27 else: |
| 28 finder_options.browser_options.dont_override_profile = True |
| 29 |
| 30 def TearDownState(self): |
| 31 """Clean up generated profile directory.""" |
| 32 super(ExtensionProfileSharedState, self).TearDownState() |
| 33 if self._out_dir: |
| 34 shutil.rmtree(self._out_dir) |
OLD | NEW |