Chromium Code Reviews| 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 import os | 4 import os |
| 5 | 5 |
| 6 from telemetry import browser_credentials | 6 from telemetry import browser_credentials |
| 7 from telemetry import extension_dict | |
| 7 from telemetry import tab_list | 8 from telemetry import tab_list |
| 8 from telemetry import temporary_http_server | 9 from telemetry import temporary_http_server |
| 9 from telemetry import wpr_modes | 10 from telemetry import wpr_modes |
| 10 from telemetry import wpr_server | 11 from telemetry import wpr_server |
| 11 | 12 |
| 12 | 13 |
| 13 class Browser(object): | 14 class Browser(object): |
| 14 """A running browser instance that can be controlled in a limited way. | 15 """A running browser instance that can be controlled in a limited way. |
| 15 | 16 |
| 16 To create a browser instance, use browser_finder.FindBrowser. | 17 To create a browser instance, use browser_finder.FindBrowser. |
| 17 | 18 |
| 18 Be sure to clean up after yourself by calling Close() when you are done with | 19 Be sure to clean up after yourself by calling Close() when you are done with |
| 19 the browser. Or better yet: | 20 the browser. Or better yet: |
| 20 browser_to_create = FindBrowser(options) | 21 browser_to_create = FindBrowser(options) |
| 21 with browser_to_create.Create() as browser: | 22 with browser_to_create.Create() as browser: |
| 22 ... do all your operations on browser here | 23 ... do all your operations on browser here |
| 23 """ | 24 """ |
| 24 def __init__(self, browser_backend, platform): | 25 def __init__(self, browser_backend, platform): |
| 25 self._browser_backend = browser_backend | 26 self._browser_backend = browser_backend |
| 26 self._http_server = None | 27 self._http_server = None |
| 27 self._wpr_server = None | 28 self._wpr_server = None |
| 28 self._platform = platform | 29 self._platform = platform |
| 29 self._tabs = tab_list.TabList(browser_backend.tab_list_backend) | 30 self._tabs = tab_list.TabList(browser_backend.tab_list_backend) |
| 31 self._extensions = None | |
| 32 if not browser_backend.is_content_shell: | |
|
nduca
2013/02/01 00:25:50
android isn't content shell.... treat these separa
achuithb
2013/02/06 00:23:03
Done.
| |
| 33 self._extensions = extension_dict.ExtensionDict( | |
| 34 browser_backend.extension_dict_backend) | |
| 30 self.credentials = browser_credentials.BrowserCredentials() | 35 self.credentials = browser_credentials.BrowserCredentials() |
| 31 | 36 |
| 32 def __enter__(self): | 37 def __enter__(self): |
| 33 return self | 38 return self |
| 34 | 39 |
| 35 def __exit__(self, *args): | 40 def __exit__(self, *args): |
| 36 self.Close() | 41 self.Close() |
| 37 | 42 |
| 38 @property | 43 @property |
| 39 def platform(self): | 44 def platform(self): |
| 40 return self._platform | 45 return self._platform |
| 41 | 46 |
| 42 @property | 47 @property |
| 43 def browser_type(self): | 48 def browser_type(self): |
| 44 return self._browser_backend.browser_type | 49 return self._browser_backend.browser_type |
| 45 | 50 |
| 46 @property | 51 @property |
| 47 def is_content_shell(self): | 52 def is_content_shell(self): |
| 48 """Returns whether this browser is a content shell, only.""" | 53 """Returns whether this browser is a content shell, only.""" |
| 49 return self._browser_backend.is_content_shell | 54 return self._browser_backend.is_content_shell |
| 50 | 55 |
| 51 @property | 56 @property |
| 52 def supports_tab_control(self): | 57 def supports_tab_control(self): |
| 53 return self._browser_backend.supports_tab_control | 58 return self._browser_backend.supports_tab_control |
| 54 | 59 |
| 55 @property | 60 @property |
| 56 def tabs(self): | 61 def tabs(self): |
| 57 return self._tabs | 62 return self._tabs |
| 58 | 63 |
| 59 @property | 64 @property |
|
nduca
2013/02/01 00:25:50
you dont have a supports_extensions property. you
achuithb
2013/02/06 00:23:03
Done.
| |
| 65 def extensions(self): | |
|
nduca
2013/02/01 00:25:50
doc tring should say that this may not be there
a
achuithb
2013/02/06 00:23:03
Done.
| |
| 66 return self._extensions | |
| 67 | |
| 68 @property | |
| 60 def supports_tracing(self): | 69 def supports_tracing(self): |
| 61 return self._browser_backend.supports_tracing | 70 return self._browser_backend.supports_tracing |
| 62 | 71 |
| 63 def StartTracing(self): | 72 def StartTracing(self): |
| 64 return self._browser_backend.StartTracing() | 73 return self._browser_backend.StartTracing() |
| 65 | 74 |
| 66 def StopTracing(self): | 75 def StopTracing(self): |
| 67 return self._browser_backend.StopTracing() | 76 return self._browser_backend.StopTracing() |
| 68 | 77 |
| 69 def GetTraceResultAndReset(self): | 78 def GetTraceResultAndReset(self): |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 archive_path, | 134 archive_path, |
| 126 use_record_mode, | 135 use_record_mode, |
| 127 self._browser_backend.WEBPAGEREPLAY_HOST, | 136 self._browser_backend.WEBPAGEREPLAY_HOST, |
| 128 self._browser_backend.webpagereplay_local_http_port, | 137 self._browser_backend.webpagereplay_local_http_port, |
| 129 self._browser_backend.webpagereplay_local_https_port, | 138 self._browser_backend.webpagereplay_local_https_port, |
| 130 self._browser_backend.webpagereplay_remote_http_port, | 139 self._browser_backend.webpagereplay_remote_http_port, |
| 131 self._browser_backend.webpagereplay_remote_https_port) | 140 self._browser_backend.webpagereplay_remote_https_port) |
| 132 | 141 |
| 133 def GetStandardOutput(self): | 142 def GetStandardOutput(self): |
| 134 return self._browser_backend.GetStandardOutput() | 143 return self._browser_backend.GetStandardOutput() |
| OLD | NEW |