| 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/api/tabs/tabs_constants.h" | 7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 8 #include "chrome/browser/extensions/tab_helper.h" | 8 #include "chrome/browser/extensions/tab_helper.h" |
| 9 #include "chrome/browser/extensions/window_controller.h" | 9 #include "chrome/browser/extensions/window_controller.h" |
| 10 #include "chrome/browser/net/url_fixer_upper.h" | 10 #include "chrome/browser/net/url_fixer_upper.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const TabStripModel* tab_strip_model) { | 42 const TabStripModel* tab_strip_model) { |
| 43 for (BrowserList::const_iterator it = BrowserList::begin(); | 43 for (BrowserList::const_iterator it = BrowserList::begin(); |
| 44 it != BrowserList::end(); ++it) { | 44 it != BrowserList::end(); ++it) { |
| 45 if ((*it)->tab_strip_model() == tab_strip_model) | 45 if ((*it)->tab_strip_model() == tab_strip_model) |
| 46 return GetWindowId(*it); | 46 return GetWindowId(*it); |
| 47 } | 47 } |
| 48 return -1; | 48 return -1; |
| 49 } | 49 } |
| 50 | 50 |
| 51 int ExtensionTabUtil::GetTabId(const WebContents* web_contents) { | 51 int ExtensionTabUtil::GetTabId(const WebContents* web_contents) { |
| 52 return SessionID::IdForTab(TabContents::FromWebContents(web_contents)); | 52 return SessionID::IdForTab(web_contents); |
| 53 } | 53 } |
| 54 | 54 |
| 55 std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) { | 55 std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) { |
| 56 return is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete; | 56 return is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete; |
| 57 } | 57 } |
| 58 | 58 |
| 59 int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) { | 59 int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) { |
| 60 return SessionID::IdForWindowContainingTab( | 60 return SessionID::IdForWindowContainingTab(web_contents); |
| 61 TabContents::FromWebContents(web_contents)); | |
| 62 } | 61 } |
| 63 | 62 |
| 64 DictionaryValue* ExtensionTabUtil::CreateTabValue( | 63 DictionaryValue* ExtensionTabUtil::CreateTabValue( |
| 65 const WebContents* contents, | 64 const WebContents* contents, |
| 66 const Extension* extension) { | 65 const Extension* extension) { |
| 67 // Find the tab strip and index of this guy. | 66 // Find the tab strip and index of this guy. |
| 68 TabStripModel* tab_strip = NULL; | 67 TabStripModel* tab_strip = NULL; |
| 69 int tab_index; | 68 int tab_index; |
| 70 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { | 69 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { |
| 71 return ExtensionTabUtil::CreateTabValue(contents, | 70 return ExtensionTabUtil::CreateTabValue(contents, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 include_incognito && profile->HasOffTheRecordProfile() ? | 211 include_incognito && profile->HasOffTheRecordProfile() ? |
| 213 profile->GetOffTheRecordProfile() : NULL; | 212 profile->GetOffTheRecordProfile() : NULL; |
| 214 for (BrowserList::const_iterator iter = BrowserList::begin(); | 213 for (BrowserList::const_iterator iter = BrowserList::begin(); |
| 215 iter != BrowserList::end(); ++iter) { | 214 iter != BrowserList::end(); ++iter) { |
| 216 Browser* target_browser = *iter; | 215 Browser* target_browser = *iter; |
| 217 if (target_browser->profile() == profile || | 216 if (target_browser->profile() == profile || |
| 218 target_browser->profile() == incognito_profile) { | 217 target_browser->profile() == incognito_profile) { |
| 219 TabStripModel* target_tab_strip = target_browser->tab_strip_model(); | 218 TabStripModel* target_tab_strip = target_browser->tab_strip_model(); |
| 220 for (int i = 0; i < target_tab_strip->count(); ++i) { | 219 for (int i = 0; i < target_tab_strip->count(); ++i) { |
| 221 TabContents* target_contents = target_tab_strip->GetTabContentsAt(i); | 220 TabContents* target_contents = target_tab_strip->GetTabContentsAt(i); |
| 222 if (SessionID::IdForTab(target_contents) == tab_id) { | 221 if (SessionID::IdForTab(target_contents->web_contents()) == tab_id) { |
| 223 if (browser) | 222 if (browser) |
| 224 *browser = target_browser; | 223 *browser = target_browser; |
| 225 if (tab_strip) | 224 if (tab_strip) |
| 226 *tab_strip = target_tab_strip; | 225 *tab_strip = target_tab_strip; |
| 227 if (contents) | 226 if (contents) |
| 228 *contents = target_contents; | 227 *contents = target_contents; |
| 229 if (tab_index) | 228 if (tab_index) |
| 230 *tab_index = i; | 229 *tab_index = i; |
| 231 return true; | 230 return true; |
| 232 } | 231 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 296 |
| 298 // static | 297 // static |
| 299 extensions::WindowController* ExtensionTabUtil::GetWindowControllerOfTab( | 298 extensions::WindowController* ExtensionTabUtil::GetWindowControllerOfTab( |
| 300 const WebContents* web_contents) { | 299 const WebContents* web_contents) { |
| 301 Browser* browser = browser::FindBrowserWithWebContents(web_contents); | 300 Browser* browser = browser::FindBrowserWithWebContents(web_contents); |
| 302 if (browser != NULL) | 301 if (browser != NULL) |
| 303 return browser->extension_window_controller(); | 302 return browser->extension_window_controller(); |
| 304 | 303 |
| 305 return NULL; | 304 return NULL; |
| 306 } | 305 } |
| OLD | NEW |