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 urllib2 | 4 import urllib2 |
5 import httplib | 5 import httplib |
6 import json | 6 import json |
7 | 7 |
8 from chrome_remote_control import inspector_backend | 8 from chrome_remote_control import inspector_backend |
9 from chrome_remote_control import tab | 9 from chrome_remote_control import tab |
10 from chrome_remote_control import util | 10 from chrome_remote_control import util |
(...skipping 27 matching lines...) Expand all Loading... |
38 except util.TimeoutException: | 38 except util.TimeoutException: |
39 raise BrowserGoneException() | 39 raise BrowserGoneException() |
40 | 40 |
41 def _ListTabs(self, timeout=None): | 41 def _ListTabs(self, timeout=None): |
42 if timeout: | 42 if timeout: |
43 req = urllib2.urlopen('http://localhost:%i/json' % self._port, | 43 req = urllib2.urlopen('http://localhost:%i/json' % self._port, |
44 timeout=timeout) | 44 timeout=timeout) |
45 else: | 45 else: |
46 req = urllib2.urlopen('http://localhost:%i/json' % self._port) | 46 req = urllib2.urlopen('http://localhost:%i/json' % self._port) |
47 data = req.read() | 47 data = req.read() |
48 return json.loads(data) | 48 all_contexts = json.loads(data) |
| 49 tabs = [ctx for ctx in all_contexts |
| 50 if not ctx['url'].startswith('chrome-extension://')] |
| 51 return tabs |
49 | 52 |
50 @property | 53 @property |
51 def num_tabs(self): | 54 def num_tabs(self): |
52 return len(self._ListTabs()) | 55 return len(self._ListTabs()) |
53 | 56 |
54 def GetNthTabUrl(self, index): | 57 def GetNthTabUrl(self, index): |
55 return self._ListTabs()[index]['url'] | 58 return self._ListTabs()[index]['url'] |
56 | 59 |
57 def ConnectToNthTab(self, browser, index): | 60 def ConnectToNthTab(self, browser, index): |
58 ib = inspector_backend.InspectorBackend(self, self._ListTabs()[index]) | 61 ib = inspector_backend.InspectorBackend(self, self._ListTabs()[index]) |
59 return tab.Tab(browser, ib) | 62 return tab.Tab(browser, ib) |
60 | 63 |
61 def CreateForwarder(self, host_port): | 64 def CreateForwarder(self, host_port): |
62 raise NotImplementedError() | 65 raise NotImplementedError() |
63 | 66 |
64 def IsBrowserRunning(self): | 67 def IsBrowserRunning(self): |
65 raise NotImplementedError() | 68 raise NotImplementedError() |
OLD | NEW |