Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" | |
| 13 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 14 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 14 #include "chrome/browser/extensions/chrome_extension_function.h" | 15 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 15 #include "chrome/browser/extensions/chrome_extension_function_details.h" | 16 #include "chrome/browser/extensions/chrome_extension_function_details.h" |
| 16 #include "chrome/browser/extensions/tab_helper.h" | 17 #include "chrome/browser/extensions/tab_helper.h" |
| 17 #include "chrome/browser/extensions/window_controller.h" | 18 #include "chrome/browser/extensions/window_controller.h" |
| 18 #include "chrome/browser/extensions/window_controller_list.h" | 19 #include "chrome/browser/extensions/window_controller_list.h" |
| 20 #include "chrome/browser/memory/tab_manager.h" | |
| 19 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/sessions/session_tab_helper.h" | 22 #include "chrome/browser/sessions/session_tab_helper.h" |
| 21 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_finder.h" | 24 #include "chrome/browser/ui/browser_finder.h" |
| 23 #include "chrome/browser/ui/browser_navigator_params.h" | 25 #include "chrome/browser/ui/browser_navigator_params.h" |
| 24 #include "chrome/browser/ui/browser_window.h" | 26 #include "chrome/browser/ui/browser_window.h" |
| 25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 26 #include "chrome/browser/ui/singleton_tabs.h" | 28 #include "chrome/browser/ui/singleton_tabs.h" |
| 27 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 29 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 std::unique_ptr<api::tabs::Tab> tab_object(new api::tabs::Tab); | 383 std::unique_ptr<api::tabs::Tab> tab_object(new api::tabs::Tab); |
| 382 tab_object->id.reset(new int(GetTabIdForExtensions(contents))); | 384 tab_object->id.reset(new int(GetTabIdForExtensions(contents))); |
| 383 tab_object->index = tab_index; | 385 tab_object->index = tab_index; |
| 384 tab_object->window_id = GetWindowIdOfTab(contents); | 386 tab_object->window_id = GetWindowIdOfTab(contents); |
| 385 tab_object->status.reset(new std::string(GetTabStatusText(is_loading))); | 387 tab_object->status.reset(new std::string(GetTabStatusText(is_loading))); |
| 386 tab_object->active = tab_strip && tab_index == tab_strip->active_index(); | 388 tab_object->active = tab_strip && tab_index == tab_strip->active_index(); |
| 387 tab_object->selected = tab_strip && tab_index == tab_strip->active_index(); | 389 tab_object->selected = tab_strip && tab_index == tab_strip->active_index(); |
| 388 tab_object->highlighted = tab_strip && tab_strip->IsTabSelected(tab_index); | 390 tab_object->highlighted = tab_strip && tab_strip->IsTabSelected(tab_index); |
| 389 tab_object->pinned = tab_strip && tab_strip->IsTabPinned(tab_index); | 391 tab_object->pinned = tab_strip && tab_strip->IsTabPinned(tab_index); |
| 390 tab_object->audible.reset(new bool(contents->WasRecentlyAudible())); | 392 tab_object->audible.reset(new bool(contents->WasRecentlyAudible())); |
| 393 | |
| 394 memory::TabManager* tab_manager = | |
| 395 g_browser_process ? g_browser_process->GetTabManager() : nullptr; | |
|
chrisha
2016/06/15 15:56:12
Can g_browser_process every not exist in this cont
Georges Khalil
2016/06/15 17:25:42
Looking at similar code, we can even forgo the DCH
Anderson Silva
2016/06/16 14:04:51
Acknowledged.
| |
| 396 tab_object->discarded = tab_manager && tab_manager->IsTabDiscarded(contents); | |
| 397 | |
| 391 tab_object->muted_info = CreateMutedInfo(contents); | 398 tab_object->muted_info = CreateMutedInfo(contents); |
| 392 tab_object->incognito = contents->GetBrowserContext()->IsOffTheRecord(); | 399 tab_object->incognito = contents->GetBrowserContext()->IsOffTheRecord(); |
| 393 tab_object->width.reset( | 400 tab_object->width.reset( |
| 394 new int(contents->GetContainerBounds().size().width())); | 401 new int(contents->GetContainerBounds().size().width())); |
| 395 tab_object->height.reset( | 402 tab_object->height.reset( |
| 396 new int(contents->GetContainerBounds().size().height())); | 403 new int(contents->GetContainerBounds().size().height())); |
| 397 | 404 |
| 398 tab_object->url.reset(new std::string(contents->GetURL().spec())); | 405 tab_object->url.reset(new std::string(contents->GetURL().spec())); |
| 399 tab_object->title.reset( | 406 tab_object->title.reset( |
| 400 new std::string(base::UTF16ToUTF8(contents->GetTitle()))); | 407 new std::string(base::UTF16ToUTF8(contents->GetTitle()))); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 chrome::ShowSingletonTabOverwritingNTP(browser, params); | 671 chrome::ShowSingletonTabOverwritingNTP(browser, params); |
| 665 return true; | 672 return true; |
| 666 } | 673 } |
| 667 | 674 |
| 668 // static | 675 // static |
| 669 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { | 676 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { |
| 670 return browser && browser->tab_strip_model() && !browser->is_devtools(); | 677 return browser && browser->tab_strip_model() && !browser->is_devtools(); |
| 671 } | 678 } |
| 672 | 679 |
| 673 } // namespace extensions | 680 } // namespace extensions |
| OLD | NEW |