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

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

Issue 1239643004: extensions: tabs: set tab id to -1 for app/devtools windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Support no tab id and NONE tab id Created 5 years, 5 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
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 "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
10 #include "chrome/browser/extensions/chrome_extension_function.h" 10 #include "chrome/browser/extensions/chrome_extension_function.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 int ExtensionTabUtil::GetWindowIdOfTabStripModel( 308 int ExtensionTabUtil::GetWindowIdOfTabStripModel(
309 const TabStripModel* tab_strip_model) { 309 const TabStripModel* tab_strip_model) {
310 for (chrome::BrowserIterator it; !it.done(); it.Next()) { 310 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
311 if (it->tab_strip_model() == tab_strip_model) 311 if (it->tab_strip_model() == tab_strip_model)
312 return GetWindowId(*it); 312 return GetWindowId(*it);
313 } 313 }
314 return -1; 314 return -1;
315 } 315 }
316 316
317 int ExtensionTabUtil::GetTabId(const WebContents* web_contents) { 317 int ExtensionTabUtil::GetTabId(const WebContents* web_contents) {
318 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
319 if (browser && browser->is_devtools())
not at google - send to devlin 2015/07/17 16:44:58 ExtensionTabUtil::BrowserSupportsTabs(browser)
320 return -1;
318 return SessionTabHelper::IdForTab(web_contents); 321 return SessionTabHelper::IdForTab(web_contents);
319 } 322 }
320 323
321 std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) { 324 std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) {
322 return is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete; 325 return is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete;
323 } 326 }
324 327
325 int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) { 328 int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) {
326 return SessionTabHelper::IdForWindowContainingTab(web_contents); 329 return SessionTabHelper::IdForWindowContainingTab(web_contents);
327 } 330 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 return false; 485 return false;
483 } 486 }
484 487
485 bool ExtensionTabUtil::GetTabById(int tab_id, 488 bool ExtensionTabUtil::GetTabById(int tab_id,
486 content::BrowserContext* browser_context, 489 content::BrowserContext* browser_context,
487 bool include_incognito, 490 bool include_incognito,
488 Browser** browser, 491 Browser** browser,
489 TabStripModel** tab_strip, 492 TabStripModel** tab_strip,
490 WebContents** contents, 493 WebContents** contents,
491 int* tab_index) { 494 int* tab_index) {
495 if (tab_id == api::tabs::TAB_ID_NONE)
496 return false;
492 Profile* profile = Profile::FromBrowserContext(browser_context); 497 Profile* profile = Profile::FromBrowserContext(browser_context);
493 Profile* incognito_profile = 498 Profile* incognito_profile =
494 include_incognito && profile->HasOffTheRecordProfile() ? 499 include_incognito && profile->HasOffTheRecordProfile() ?
495 profile->GetOffTheRecordProfile() : NULL; 500 profile->GetOffTheRecordProfile() : NULL;
496 for (chrome::BrowserIterator it; !it.done(); it.Next()) { 501 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
497 Browser* target_browser = *it; 502 Browser* target_browser = *it;
498 if (target_browser->profile() == profile || 503 if (target_browser->profile() == profile ||
499 target_browser->profile() == incognito_profile) { 504 target_browser->profile() == incognito_profile) {
500 TabStripModel* target_tab_strip = target_browser->tab_strip_model(); 505 TabStripModel* target_tab_strip = target_browser->tab_strip_model();
501 for (int i = 0; i < target_tab_strip->count(); ++i) { 506 for (int i = 0; i < target_tab_strip->count(); ++i) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 637
633 chrome::NavigateParams params( 638 chrome::NavigateParams params(
634 chrome::GetSingletonTabNavigateParams(browser, url_to_navigate)); 639 chrome::GetSingletonTabNavigateParams(browser, url_to_navigate));
635 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 640 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
636 params.url = url_to_navigate; 641 params.url = url_to_navigate;
637 chrome::ShowSingletonTabOverwritingNTP(browser, params); 642 chrome::ShowSingletonTabOverwritingNTP(browser, params);
638 return true; 643 return true;
639 } 644 }
640 645
641 } // namespace extensions 646 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698