Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: chrome/browser/extensions/extension_tab_util.cc

Issue 10443105: Take 2 at implementing activeTab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: empty -> is_empty Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/api/tabs/tabs_constants.h" 7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
8 #include "chrome/browser/extensions/extension_tab_helper.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.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents.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"
17 #include "chrome/common/extensions/extension_manifest_constants.h" 18 #include "chrome/common/extensions/extension_manifest_constants.h"
(...skipping 16 matching lines...) Expand all
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 TabContents.
45 int ExtensionTabUtil::GetTabId(const WebContents* web_contents) { 45 int ExtensionTabUtil::GetTabId(const WebContents* web_contents) {
46 const TabContents* tab = TabContents::FromWebContents(web_contents); 46 const TabContents* tab = TabContents::FromWebContents(web_contents);
47 return tab ? tab->restore_tab_helper()->session_id().id() : -1; 47 return tab ? tab->extension_tab_helper()->tab_id() : -1;
48 } 48 }
49 49
50 std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) { 50 std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) {
51 return is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete; 51 return is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete;
52 } 52 }
53 53
54 // TODO(sky): this function should really take a TabContents.
55 int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) { 54 int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) {
56 const TabContents* tab = TabContents::FromWebContents(web_contents); 55 const TabContents* tab = TabContents::FromWebContents(web_contents);
57 return tab ? tab->restore_tab_helper()->window_id().id() : -1; 56 return tab ? tab->extension_tab_helper()->window_id() : -1;
58 } 57 }
59 58
60 DictionaryValue* ExtensionTabUtil::CreateTabValue(const WebContents* contents) { 59 DictionaryValue* ExtensionTabUtil::CreateTabValue(const WebContents* contents) {
61 // Find the tab strip and index of this guy. 60 // Find the tab strip and index of this guy.
62 TabStripModel* tab_strip = NULL; 61 TabStripModel* tab_strip = NULL;
63 int tab_index; 62 int tab_index;
64 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) 63 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index))
65 return ExtensionTabUtil::CreateTabValue(contents, tab_strip, tab_index); 64 return ExtensionTabUtil::CreateTabValue(contents, tab_strip, tab_index);
66 65
67 // Couldn't find it. This can happen if the tab is being dragged. 66 // Couldn't find it. This can happen if the tab is being dragged.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 212 }
214 213
215 bool ExtensionTabUtil::IsCrashURL(const GURL& url) { 214 bool ExtensionTabUtil::IsCrashURL(const GURL& url) {
216 // Check a fixed-up URL, to normalize the scheme and parse hosts correctly. 215 // Check a fixed-up URL, to normalize the scheme and parse hosts correctly.
217 GURL fixed_url = 216 GURL fixed_url =
218 URLFixerUpper::FixupURL(url.possibly_invalid_spec(), std::string()); 217 URLFixerUpper::FixupURL(url.possibly_invalid_spec(), std::string());
219 return (fixed_url.SchemeIs(chrome::kChromeUIScheme) && 218 return (fixed_url.SchemeIs(chrome::kChromeUIScheme) &&
220 (fixed_url.host() == chrome::kChromeUIBrowserCrashHost || 219 (fixed_url.host() == chrome::kChromeUIBrowserCrashHost ||
221 fixed_url.host() == chrome::kChromeUICrashHost)); 220 fixed_url.host() == chrome::kChromeUICrashHost));
222 } 221 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_helper.cc ('k') | chrome/browser/extensions/extension_toolbar_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698