| 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 std::unique_ptr<api::tabs::Tab> tab_object(new api::tabs::Tab); | 382 std::unique_ptr<api::tabs::Tab> tab_object(new api::tabs::Tab); |
| 381 tab_object->id.reset(new int(GetTabIdForExtensions(contents))); | 383 tab_object->id.reset(new int(GetTabIdForExtensions(contents))); |
| 382 tab_object->index = tab_index; | 384 tab_object->index = tab_index; |
| 383 tab_object->window_id = GetWindowIdOfTab(contents); | 385 tab_object->window_id = GetWindowIdOfTab(contents); |
| 384 tab_object->status.reset(new std::string(GetTabStatusText(is_loading))); | 386 tab_object->status.reset(new std::string(GetTabStatusText(is_loading))); |
| 385 tab_object->active = tab_strip && tab_index == tab_strip->active_index(); | 387 tab_object->active = tab_strip && tab_index == tab_strip->active_index(); |
| 386 tab_object->selected = tab_strip && tab_index == tab_strip->active_index(); | 388 tab_object->selected = tab_strip && tab_index == tab_strip->active_index(); |
| 387 tab_object->highlighted = tab_strip && tab_strip->IsTabSelected(tab_index); | 389 tab_object->highlighted = tab_strip && tab_strip->IsTabSelected(tab_index); |
| 388 tab_object->pinned = tab_strip && tab_strip->IsTabPinned(tab_index); | 390 tab_object->pinned = tab_strip && tab_strip->IsTabPinned(tab_index); |
| 389 tab_object->audible.reset(new bool(contents->WasRecentlyAudible())); | 391 tab_object->audible.reset(new bool(contents->WasRecentlyAudible())); |
| 392 |
| 393 memory::TabManager* tab_manager = g_browser_process->GetTabManager(); |
| 394 tab_object->discarded = tab_manager && tab_manager->IsTabDiscarded(contents); |
| 395 |
| 390 tab_object->muted_info = CreateMutedInfo(contents); | 396 tab_object->muted_info = CreateMutedInfo(contents); |
| 391 tab_object->incognito = contents->GetBrowserContext()->IsOffTheRecord(); | 397 tab_object->incognito = contents->GetBrowserContext()->IsOffTheRecord(); |
| 392 tab_object->width.reset( | 398 tab_object->width.reset( |
| 393 new int(contents->GetContainerBounds().size().width())); | 399 new int(contents->GetContainerBounds().size().width())); |
| 394 tab_object->height.reset( | 400 tab_object->height.reset( |
| 395 new int(contents->GetContainerBounds().size().height())); | 401 new int(contents->GetContainerBounds().size().height())); |
| 396 | 402 |
| 397 tab_object->url.reset(new std::string(contents->GetURL().spec())); | 403 tab_object->url.reset(new std::string(contents->GetURL().spec())); |
| 398 tab_object->title.reset( | 404 tab_object->title.reset( |
| 399 new std::string(base::UTF16ToUTF8(contents->GetTitle()))); | 405 new std::string(base::UTF16ToUTF8(contents->GetTitle()))); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 chrome::ShowSingletonTabOverwritingNTP(browser, params); | 669 chrome::ShowSingletonTabOverwritingNTP(browser, params); |
| 664 return true; | 670 return true; |
| 665 } | 671 } |
| 666 | 672 |
| 667 // static | 673 // static |
| 668 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { | 674 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { |
| 669 return browser && browser->tab_strip_model() && !browser->is_devtools(); | 675 return browser && browser->tab_strip_model() && !browser->is_devtools(); |
| 670 } | 676 } |
| 671 | 677 |
| 672 } // namespace extensions | 678 } // namespace extensions |
| OLD | NEW |