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 uuid | 5 import uuid |
6 | 6 |
7 | 7 |
8 class TabTracker(object): | 8 class TabTracker(object): |
9 """Uniquely track tabs within a window. | 9 """Uniquely track tabs within a window. |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 self._uuids.append(tab_uuid) | 53 self._uuids.append(tab_uuid) |
54 return tab_uuid | 54 return tab_uuid |
55 | 55 |
56 def ReleaseTab(self, tab_uuid): | 56 def ReleaseTab(self, tab_uuid): |
57 """Release and close a tab tracked by this TabTracker. | 57 """Release and close a tab tracked by this TabTracker. |
58 | 58 |
59 Args: | 59 Args: |
60 tab_uuid: the uuid of the tab to close | 60 tab_uuid: the uuid of the tab to close |
61 """ | 61 """ |
62 idx = self.GetTabIndex(tab_uuid) | 62 idx = self.GetTabIndex(tab_uuid) |
63 self._browser.GetBrowserWindow(self._window_idx).GetTab(idx).Close() | 63 self._browser.CloseTab(tab_index=idx, windex=self._window_idx) |
64 del self._uuids[idx] | 64 del self._uuids[idx] |
65 | 65 |
66 def GetTabIndex(self, tab_uuid): | 66 def GetTabIndex(self, tab_uuid): |
67 """Get the index of a tracked tab within this TabTracker's window. | 67 """Get the index of a tracked tab within this TabTracker's window. |
68 | 68 |
69 Args: | 69 Args: |
70 tab_uuid: the uuid of the tab to close | 70 tab_uuid: the uuid of the tab to close |
71 | 71 |
72 Returns: | 72 Returns: |
73 the index of the tab within this TabTracker's window | 73 the index of the tab within this TabTracker's window |
74 """ | 74 """ |
75 return self._uuids.index(tab_uuid) | 75 return self._uuids.index(tab_uuid) |
76 | 76 |
77 def GetWindowIndex(self): | 77 def GetWindowIndex(self): |
78 """Get the index of this TabTracker's window. | 78 """Get the index of this TabTracker's window. |
79 | 79 |
80 Returns: | 80 Returns: |
81 the index of this TabTracker's window | 81 the index of this TabTracker's window |
82 """ | 82 """ |
83 return self._window_idx | 83 return self._window_idx |
OLD | NEW |