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" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 int tab_index) { | 381 int tab_index) { |
382 // If we have a matching AppWindow with a controller, get the tab value | 382 // If we have a matching AppWindow with a controller, get the tab value |
383 // from its controller instead. | 383 // from its controller instead. |
384 WindowController* controller = GetAppWindowController(contents); | 384 WindowController* controller = GetAppWindowController(contents); |
385 if (controller) | 385 if (controller) |
386 return controller->CreateTabObject(nullptr, tab_index); | 386 return controller->CreateTabObject(nullptr, tab_index); |
387 | 387 |
388 if (!tab_strip) | 388 if (!tab_strip) |
389 ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index); | 389 ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index); |
390 bool is_loading = contents->IsLoading(); | 390 bool is_loading = contents->IsLoading(); |
391 std::unique_ptr<api::tabs::Tab> tab_object(new api::tabs::Tab); | 391 auto tab_object = base::MakeUnique<api::tabs::Tab>(); |
392 tab_object->id.reset(new int(GetTabIdForExtensions(contents))); | 392 tab_object->id = base::MakeUnique<int>(GetTabIdForExtensions(contents)); |
393 tab_object->index = tab_index; | 393 tab_object->index = tab_index; |
394 tab_object->window_id = GetWindowIdOfTab(contents); | 394 tab_object->window_id = GetWindowIdOfTab(contents); |
395 tab_object->status.reset(new std::string(GetTabStatusText(is_loading))); | 395 tab_object->status = |
| 396 base::MakeUnique<std::string>(GetTabStatusText(is_loading)); |
396 tab_object->active = tab_strip && tab_index == tab_strip->active_index(); | 397 tab_object->active = tab_strip && tab_index == tab_strip->active_index(); |
397 tab_object->selected = tab_strip && tab_index == tab_strip->active_index(); | 398 tab_object->selected = tab_strip && tab_index == tab_strip->active_index(); |
398 tab_object->highlighted = tab_strip && tab_strip->IsTabSelected(tab_index); | 399 tab_object->highlighted = tab_strip && tab_strip->IsTabSelected(tab_index); |
399 tab_object->pinned = tab_strip && tab_strip->IsTabPinned(tab_index); | 400 tab_object->pinned = tab_strip && tab_strip->IsTabPinned(tab_index); |
400 tab_object->audible.reset(new bool(contents->WasRecentlyAudible())); | 401 tab_object->audible = base::MakeUnique<bool>(contents->WasRecentlyAudible()); |
401 tab_object->discarded = | 402 tab_object->discarded = |
402 g_browser_process->GetTabManager()->IsTabDiscarded(contents); | 403 g_browser_process->GetTabManager()->IsTabDiscarded(contents); |
403 tab_object->auto_discardable = | 404 tab_object->auto_discardable = |
404 g_browser_process->GetTabManager()->IsTabAutoDiscardable(contents); | 405 g_browser_process->GetTabManager()->IsTabAutoDiscardable(contents); |
405 tab_object->muted_info = CreateMutedInfo(contents); | 406 tab_object->muted_info = CreateMutedInfo(contents); |
406 tab_object->incognito = contents->GetBrowserContext()->IsOffTheRecord(); | 407 tab_object->incognito = contents->GetBrowserContext()->IsOffTheRecord(); |
407 tab_object->width.reset( | 408 gfx::Size contents_size = contents->GetContainerBounds().size(); |
408 new int(contents->GetContainerBounds().size().width())); | 409 tab_object->width = base::MakeUnique<int>(contents_size.width()); |
409 tab_object->height.reset( | 410 tab_object->height = base::MakeUnique<int>(contents_size.height()); |
410 new int(contents->GetContainerBounds().size().height())); | |
411 | 411 |
412 tab_object->url.reset(new std::string(contents->GetURL().spec())); | 412 tab_object->url = base::MakeUnique<std::string>(contents->GetURL().spec()); |
413 tab_object->title.reset( | 413 tab_object->title = |
414 new std::string(base::UTF16ToUTF8(contents->GetTitle()))); | 414 base::MakeUnique<std::string>(base::UTF16ToUTF8(contents->GetTitle())); |
415 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); | 415 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); |
416 if (entry && entry->GetFavicon().valid) | 416 if (entry && entry->GetFavicon().valid) { |
417 tab_object->fav_icon_url.reset( | 417 tab_object->fav_icon_url = |
418 new std::string(entry->GetFavicon().url.spec())); | 418 base::MakeUnique<std::string>(entry->GetFavicon().url.spec()); |
| 419 } |
419 if (tab_strip) { | 420 if (tab_strip) { |
420 WebContents* opener = tab_strip->GetOpenerOfWebContentsAt(tab_index); | 421 WebContents* opener = tab_strip->GetOpenerOfWebContentsAt(tab_index); |
421 if (opener) | 422 if (opener) { |
422 tab_object->opener_tab_id.reset(new int(GetTabIdForExtensions(opener))); | 423 tab_object->opener_tab_id = |
| 424 base::MakeUnique<int>(GetTabIdForExtensions(opener)); |
| 425 } |
423 } | 426 } |
424 | 427 |
425 return tab_object; | 428 return tab_object; |
426 } | 429 } |
427 | 430 |
428 // static | 431 // static |
429 std::unique_ptr<api::tabs::MutedInfo> ExtensionTabUtil::CreateMutedInfo( | 432 std::unique_ptr<api::tabs::MutedInfo> ExtensionTabUtil::CreateMutedInfo( |
430 content::WebContents* contents) { | 433 content::WebContents* contents) { |
431 DCHECK(contents); | 434 DCHECK(contents); |
432 std::unique_ptr<api::tabs::MutedInfo> info(new api::tabs::MutedInfo); | 435 std::unique_ptr<api::tabs::MutedInfo> info(new api::tabs::MutedInfo); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 chrome::ShowSingletonTabOverwritingNTP(browser, params); | 715 chrome::ShowSingletonTabOverwritingNTP(browser, params); |
713 return true; | 716 return true; |
714 } | 717 } |
715 | 718 |
716 // static | 719 // static |
717 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { | 720 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { |
718 return browser && browser->tab_strip_model() && !browser->is_devtools(); | 721 return browser && browser->tab_strip_model() && !browser->is_devtools(); |
719 } | 722 } |
720 | 723 |
721 } // namespace extensions | 724 } // namespace extensions |
OLD | NEW |