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 #include "chrome/browser/extensions/extension_tab_util.h" | 5 #include "chrome/browser/extensions/extension_tab_util.h" |
6 | 6 |
| 7 #include "chrome/browser/extensions/extension_tab_helper.h" |
7 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 8 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
8 #include "chrome/browser/net/url_fixer_upper.h" | 9 #include "chrome/browser/net/url_fixer_upper.h" |
9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sessions/restore_tab_helper.h" | 11 #include "chrome/browser/sessions/restore_tab_helper.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
(...skipping 17 matching lines...) Expand all Loading... |
34 int ExtensionTabUtil::GetWindowIdOfTabStripModel( | 35 int ExtensionTabUtil::GetWindowIdOfTabStripModel( |
35 const TabStripModel* tab_strip_model) { | 36 const TabStripModel* tab_strip_model) { |
36 for (BrowserList::const_iterator it = BrowserList::begin(); | 37 for (BrowserList::const_iterator it = BrowserList::begin(); |
37 it != BrowserList::end(); ++it) { | 38 it != BrowserList::end(); ++it) { |
38 if ((*it)->tab_strip_model() == tab_strip_model) | 39 if ((*it)->tab_strip_model() == tab_strip_model) |
39 return GetWindowId(*it); | 40 return GetWindowId(*it); |
40 } | 41 } |
41 return -1; | 42 return -1; |
42 } | 43 } |
43 | 44 |
44 // TODO(sky): this function should really take a TabContentsWrapper. | |
45 int ExtensionTabUtil::GetTabId(const WebContents* web_contents) { | 45 int ExtensionTabUtil::GetTabId(const WebContents* web_contents) { |
46 const TabContentsWrapper* tab = | 46 const TabContentsWrapper* tab = |
47 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 47 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); |
48 return tab ? tab->restore_tab_helper()->session_id().id() : -1; | 48 return tab ? tab->extension_tab_helper()->GetTabId() : -1; |
49 } | 49 } |
50 | 50 |
51 std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) { | 51 std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) { |
52 return is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete; | 52 return is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete; |
53 } | 53 } |
54 | 54 |
55 // TODO(sky): this function should really take a TabContentsWrapper. | |
56 int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) { | 55 int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) { |
57 const TabContentsWrapper* tab = | 56 const TabContentsWrapper* tab = |
58 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 57 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); |
59 return tab ? tab->restore_tab_helper()->window_id().id() : -1; | 58 return tab ? tab->extension_tab_helper()->GetWindowId() : -1; |
60 } | 59 } |
61 | 60 |
62 DictionaryValue* ExtensionTabUtil::CreateTabValue(const WebContents* contents) { | 61 DictionaryValue* ExtensionTabUtil::CreateTabValue(const WebContents* contents) { |
63 // Find the tab strip and index of this guy. | 62 // Find the tab strip and index of this guy. |
64 TabStripModel* tab_strip = NULL; | 63 TabStripModel* tab_strip = NULL; |
65 int tab_index; | 64 int tab_index; |
66 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) | 65 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) |
67 return ExtensionTabUtil::CreateTabValue(contents, tab_strip, tab_index); | 66 return ExtensionTabUtil::CreateTabValue(contents, tab_strip, tab_index); |
68 | 67 |
69 // Couldn't find it. This can happen if the tab is being dragged. | 68 // Couldn't find it. This can happen if the tab is being dragged. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 215 } |
217 | 216 |
218 bool ExtensionTabUtil::IsCrashURL(const GURL& url) { | 217 bool ExtensionTabUtil::IsCrashURL(const GURL& url) { |
219 // Check a fixed-up URL, to normalize the scheme and parse hosts correctly. | 218 // Check a fixed-up URL, to normalize the scheme and parse hosts correctly. |
220 GURL fixed_url = | 219 GURL fixed_url = |
221 URLFixerUpper::FixupURL(url.possibly_invalid_spec(), std::string()); | 220 URLFixerUpper::FixupURL(url.possibly_invalid_spec(), std::string()); |
222 return (fixed_url.SchemeIs(chrome::kChromeUIScheme) && | 221 return (fixed_url.SchemeIs(chrome::kChromeUIScheme) && |
223 (fixed_url.host() == chrome::kChromeUIBrowserCrashHost || | 222 (fixed_url.host() == chrome::kChromeUIBrowserCrashHost || |
224 fixed_url.host() == chrome::kChromeUICrashHost)); | 223 fixed_url.host() == chrome::kChromeUICrashHost)); |
225 } | 224 } |
OLD | NEW |