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

Side by Side Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 1827083004: UI: Rename MediaState to AlertState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-tab-indicator
Patch Set: Keep gypi ordered Created 4 years, 8 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
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.h ('k') | chrome/browser/ui/views/tabs/tab_renderer_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/views/tabs/tab.h" 5 #include "chrome/browser/ui/views/tabs/tab.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/alias.h" 12 #include "base/debug/alias.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/profiler/scoped_tracker.h" 14 #include "base/profiler/scoped_tracker.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/browser/themes/theme_properties.h" 17 #include "chrome/browser/themes/theme_properties.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/layout_constants.h" 19 #include "chrome/browser/ui/layout_constants.h"
20 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 20 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
21 #include "chrome/browser/ui/tabs/tab_utils.h" 21 #include "chrome/browser/ui/tabs/tab_utils.h"
22 #include "chrome/browser/ui/view_ids.h" 22 #include "chrome/browser/ui/view_ids.h"
23 #include "chrome/browser/ui/views/tabs/media_indicator_button.h" 23 #include "chrome/browser/ui/views/tabs/alert_indicator_button.h"
24 #include "chrome/browser/ui/views/tabs/tab_controller.h" 24 #include "chrome/browser/ui/views/tabs/tab_controller.h"
25 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" 25 #include "chrome/browser/ui/views/touch_uma/touch_uma.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
28 #include "content/public/browser/user_metrics.h" 28 #include "content/public/browser/user_metrics.h"
29 #include "grit/components_scaled_resources.h" 29 #include "grit/components_scaled_resources.h"
30 #include "grit/components_strings.h" 30 #include "grit/components_strings.h"
31 #include "grit/theme_resources.h" 31 #include "grit/theme_resources.h"
32 #include "third_party/skia/include/effects/SkGradientShader.h" 32 #include "third_party/skia/include/effects/SkGradientShader.h"
33 #include "third_party/skia/include/pathops/SkPathOps.h" 33 #include "third_party/skia/include/pathops/SkPathOps.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 closing_(false), 487 closing_(false),
488 dragging_(false), 488 dragging_(false),
489 detached_(false), 489 detached_(false),
490 favicon_hiding_offset_(0), 490 favicon_hiding_offset_(0),
491 immersive_loading_step_(0), 491 immersive_loading_step_(0),
492 should_display_crashed_favicon_(false), 492 should_display_crashed_favicon_(false),
493 pulse_animation_(new gfx::ThrobAnimation(this)), 493 pulse_animation_(new gfx::ThrobAnimation(this)),
494 crash_icon_animation_(new FaviconCrashAnimation(this)), 494 crash_icon_animation_(new FaviconCrashAnimation(this)),
495 animation_container_(container), 495 animation_container_(container),
496 throbber_(nullptr), 496 throbber_(nullptr),
497 media_indicator_button_(nullptr), 497 alert_indicator_button_(nullptr),
498 close_button_(nullptr), 498 close_button_(nullptr),
499 title_(new views::Label()), 499 title_(new views::Label()),
500 tab_activated_with_last_tap_down_(false), 500 tab_activated_with_last_tap_down_(false),
501 hover_controller_(this), 501 hover_controller_(this),
502 showing_icon_(false), 502 showing_icon_(false),
503 showing_media_indicator_(false), 503 showing_alert_indicator_(false),
504 showing_close_button_(false), 504 showing_close_button_(false),
505 button_color_(SK_ColorTRANSPARENT) { 505 button_color_(SK_ColorTRANSPARENT) {
506 DCHECK(controller); 506 DCHECK(controller);
507 InitTabResources(); 507 InitTabResources();
508 508
509 // So we get don't get enter/exit on children and don't prematurely stop the 509 // So we get don't get enter/exit on children and don't prematurely stop the
510 // hover. 510 // hover.
511 set_notify_enter_exit_on_child(true); 511 set_notify_enter_exit_on_child(true);
512 512
513 set_id(VIEW_ID_TAB); 513 set_id(VIEW_ID_TAB);
514 514
515 SetBorder(views::Border::CreateEmptyBorder(GetLayoutInsets(TAB))); 515 SetBorder(views::Border::CreateEmptyBorder(GetLayoutInsets(TAB)));
516 516
517 title_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); 517 title_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD);
518 title_->SetElideBehavior(gfx::FADE_TAIL); 518 title_->SetElideBehavior(gfx::FADE_TAIL);
519 title_->SetHandlesTooltips(false); 519 title_->SetHandlesTooltips(false);
520 title_->SetAutoColorReadabilityEnabled(false); 520 title_->SetAutoColorReadabilityEnabled(false);
521 title_->SetText(CoreTabHelper::GetDefaultTitle()); 521 title_->SetText(CoreTabHelper::GetDefaultTitle());
522 AddChildView(title_); 522 AddChildView(title_);
523 523
524 SetEventTargeter( 524 SetEventTargeter(
525 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); 525 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
526 526
527 throbber_ = new ThrobberView(this); 527 throbber_ = new ThrobberView(this);
528 throbber_->SetVisible(false); 528 throbber_->SetVisible(false);
529 AddChildView(throbber_); 529 AddChildView(throbber_);
530 530
531 media_indicator_button_ = new MediaIndicatorButton(this); 531 alert_indicator_button_ = new AlertIndicatorButton(this);
532 AddChildView(media_indicator_button_); 532 AddChildView(alert_indicator_button_);
533 533
534 close_button_ = new TabCloseButton(this); 534 close_button_ = new TabCloseButton(this);
535 close_button_->SetAccessibleName( 535 close_button_->SetAccessibleName(
536 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); 536 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
537 // The normal image is set by OnButtonColorMaybeChanged() because it depends 537 // The normal image is set by OnButtonColorMaybeChanged() because it depends
538 // on the current theme and active state. The hovered and pressed images 538 // on the current theme and active state. The hovered and pressed images
539 // don't depend on the these, so we can set them here. 539 // don't depend on the these, so we can set them here.
540 const gfx::ImageSkia& hovered = gfx::CreateVectorIcon( 540 const gfx::ImageSkia& hovered = gfx::CreateVectorIcon(
541 gfx::VectorIconId::TAB_CLOSE_HOVERED_PRESSED, kTabCloseButtonSize, 541 gfx::VectorIconId::TAB_CLOSE_HOVERED_PRESSED, kTabCloseButtonSize,
542 SkColorSetRGB(0xDB, 0x44, 0x37)); 542 SkColorSetRGB(0xDB, 0x44, 0x37));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 590
591 Tab::~Tab() { 591 Tab::~Tab() {
592 } 592 }
593 593
594 bool Tab::IsActive() const { 594 bool Tab::IsActive() const {
595 return controller_->IsActiveTab(this); 595 return controller_->IsActiveTab(this);
596 } 596 }
597 597
598 void Tab::ActiveStateChanged() { 598 void Tab::ActiveStateChanged() {
599 OnButtonColorMaybeChanged(); 599 OnButtonColorMaybeChanged();
600 media_indicator_button_->UpdateEnabledForMuteToggle(); 600 alert_indicator_button_->UpdateEnabledForMuteToggle();
601 Layout(); 601 Layout();
602 } 602 }
603 603
604 void Tab::MediaStateChanged() { 604 void Tab::AlertStateChanged() {
605 Layout(); 605 Layout();
606 } 606 }
607 607
608 bool Tab::IsSelected() const { 608 bool Tab::IsSelected() const {
609 return controller_->IsTabSelected(this); 609 return controller_->IsTabSelected(this);
610 } 610 }
611 611
612 void Tab::SetData(const TabRendererData& data) { 612 void Tab::SetData(const TabRendererData& data) {
613 DCHECK(GetWidget()); 613 DCHECK(GetWidget());
614 614
(...skipping 13 matching lines...) Expand all
628 Browser::FormatTitleForDisplay(&title); 628 Browser::FormatTitleForDisplay(&title);
629 } 629 }
630 title_->SetText(title); 630 title_->SetText(title);
631 631
632 if (!data_.IsCrashed()) { 632 if (!data_.IsCrashed()) {
633 crash_icon_animation_->Stop(); 633 crash_icon_animation_->Stop();
634 should_display_crashed_favicon_ = false; 634 should_display_crashed_favicon_ = false;
635 favicon_hiding_offset_ = 0; 635 favicon_hiding_offset_ = 0;
636 } else if (!should_display_crashed_favicon_ && 636 } else if (!should_display_crashed_favicon_ &&
637 !crash_icon_animation_->is_animating()) { 637 !crash_icon_animation_->is_animating()) {
638 data_.media_state = TAB_MEDIA_STATE_NONE; 638 data_.alert_state = TabAlertState::NONE;
639 crash_icon_animation_->Start(); 639 crash_icon_animation_->Start();
640 } 640 }
641 641
642 if (data_.media_state != old.media_state) 642 if (data_.alert_state != old.alert_state)
643 media_indicator_button_->TransitionToMediaState(data_.media_state); 643 alert_indicator_button_->TransitionToAlertState(data_.alert_state);
644 644
645 if (old.pinned != data_.pinned) 645 if (old.pinned != data_.pinned)
646 StopPinnedTabTitleAnimation(); 646 StopPinnedTabTitleAnimation();
647 647
648 DataChanged(old); 648 DataChanged(old);
649 649
650 Layout(); 650 Layout();
651 SchedulePaint(); 651 SchedulePaint();
652 } 652 }
653 653
(...skipping 20 matching lines...) Expand all
674 void Tab::StartPinnedTabTitleAnimation() { 674 void Tab::StartPinnedTabTitleAnimation() {
675 if (data().pinned) 675 if (data().pinned)
676 pinned_title_change_animation_->Start(); 676 pinned_title_change_animation_->Start();
677 } 677 }
678 678
679 void Tab::StopPinnedTabTitleAnimation() { 679 void Tab::StopPinnedTabTitleAnimation() {
680 pinned_title_change_animation_->Stop(); 680 pinned_title_change_animation_->Stop();
681 } 681 }
682 682
683 int Tab::GetWidthOfLargestSelectableRegion() const { 683 int Tab::GetWidthOfLargestSelectableRegion() const {
684 // Assume the entire region to the left of the media indicator and/or close 684 // Assume the entire region to the left of the alert indicator and/or close
685 // buttons is available for click-to-select. If neither are visible, the 685 // buttons is available for click-to-select. If neither are visible, the
686 // entire tab region is available. 686 // entire tab region is available.
687 const int indicator_left = showing_media_indicator_ ? 687 const int indicator_left =
688 media_indicator_button_->x() : width(); 688 showing_alert_indicator_ ? alert_indicator_button_->x() : width();
689 const int close_button_left = showing_close_button_ ? 689 const int close_button_left = showing_close_button_ ?
690 close_button_->x() : width(); 690 close_button_->x() : width();
691 return std::min(indicator_left, close_button_left); 691 return std::min(indicator_left, close_button_left);
692 } 692 }
693 693
694 // static 694 // static
695 gfx::Size Tab::GetMinimumInactiveSize() { 695 gfx::Size Tab::GetMinimumInactiveSize() {
696 return gfx::Size(GetLayoutInsets(TAB).width(), GetLayoutConstant(TAB_HEIGHT)); 696 return gfx::Size(GetLayoutInsets(TAB).width(), GetLayoutConstant(TAB_HEIGHT));
697 } 697 }
698 698
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 } 768 }
769 769
770 void Tab::AnimationEnded(const gfx::Animation* animation) { 770 void Tab::AnimationEnded(const gfx::Animation* animation) {
771 SchedulePaint(); 771 SchedulePaint();
772 } 772 }
773 773
774 //////////////////////////////////////////////////////////////////////////////// 774 ////////////////////////////////////////////////////////////////////////////////
775 // Tab, views::ButtonListener overrides: 775 // Tab, views::ButtonListener overrides:
776 776
777 void Tab::ButtonPressed(views::Button* sender, const ui::Event& event) { 777 void Tab::ButtonPressed(views::Button* sender, const ui::Event& event) {
778 if (!media_indicator_button_ || !media_indicator_button_->visible()) 778 if (!alert_indicator_button_ || !alert_indicator_button_->visible())
779 content::RecordAction(UserMetricsAction("CloseTab_NoMediaIndicator")); 779 content::RecordAction(UserMetricsAction("CloseTab_NoAlertIndicator"));
780 else if (media_indicator_button_->enabled()) 780 else if (alert_indicator_button_->enabled())
781 content::RecordAction(UserMetricsAction("CloseTab_MuteToggleAvailable")); 781 content::RecordAction(UserMetricsAction("CloseTab_MuteToggleAvailable"));
782 else if (data_.media_state == TAB_MEDIA_STATE_AUDIO_PLAYING) 782 else if (data_.alert_state == TabAlertState::AUDIO_PLAYING)
783 content::RecordAction(UserMetricsAction("CloseTab_AudioIndicator")); 783 content::RecordAction(UserMetricsAction("CloseTab_AudioIndicator"));
784 else 784 else
785 content::RecordAction(UserMetricsAction("CloseTab_RecordingIndicator")); 785 content::RecordAction(UserMetricsAction("CloseTab_RecordingIndicator"));
786 786
787 const CloseTabSource source = 787 const CloseTabSource source =
788 (event.type() == ui::ET_MOUSE_RELEASED && 788 (event.type() == ui::ET_MOUSE_RELEASED &&
789 !(event.flags() & ui::EF_FROM_TOUCH)) ? CLOSE_TAB_FROM_MOUSE 789 !(event.flags() & ui::EF_FROM_TOUCH)) ? CLOSE_TAB_FROM_MOUSE
790 : CLOSE_TAB_FROM_TOUCH; 790 : CLOSE_TAB_FROM_TOUCH;
791 DCHECK_EQ(close_button_, sender); 791 DCHECK_EQ(close_button_, sender);
792 controller_->CloseTab(this, source); 792 controller_->CloseTab(this, source);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 close_button_->SetPosition( 954 close_button_->SetPosition(
955 gfx::Point(close_button_end - close_button_size.width() - left, 0)); 955 gfx::Point(close_button_end - close_button_size.width() - left, 0));
956 const int bottom = height() - close_button_size.height() - top; 956 const int bottom = height() - close_button_size.height() - top;
957 const int right = width() - close_button_end; 957 const int right = width() - close_button_end;
958 close_button_->SetBorder( 958 close_button_->SetBorder(
959 views::Border::CreateEmptyBorder(top, left, bottom, right)); 959 views::Border::CreateEmptyBorder(top, left, bottom, right));
960 close_button_->SizeToPreferredSize(); 960 close_button_->SizeToPreferredSize();
961 } 961 }
962 close_button_->SetVisible(showing_close_button_); 962 close_button_->SetVisible(showing_close_button_);
963 963
964 showing_media_indicator_ = ShouldShowMediaIndicator(); 964 showing_alert_indicator_ = ShouldShowAlertIndicator();
965 if (showing_media_indicator_) { 965 if (showing_alert_indicator_) {
966 const gfx::Size image_size(media_indicator_button_->GetPreferredSize()); 966 const gfx::Size image_size(alert_indicator_button_->GetPreferredSize());
967 const int right = showing_close_button_ ? 967 const int right = showing_close_button_ ?
968 close_button_->x() + close_button_->GetInsets().left() : lb.right(); 968 close_button_->x() + close_button_->GetInsets().left() : lb.right();
969 gfx::Rect bounds( 969 gfx::Rect bounds(
970 std::max(lb.x(), right - image_size.width()), 970 std::max(lb.x(), right - image_size.width()),
971 lb.y() + (lb.height() - image_size.height() + 1) / 2, 971 lb.y() + (lb.height() - image_size.height() + 1) / 2,
972 image_size.width(), 972 image_size.width(),
973 image_size.height()); 973 image_size.height());
974 MaybeAdjustLeftForPinnedTab(&bounds); 974 MaybeAdjustLeftForPinnedTab(&bounds);
975 media_indicator_button_->SetBoundsRect(bounds); 975 alert_indicator_button_->SetBoundsRect(bounds);
976 } 976 }
977 media_indicator_button_->SetVisible(showing_media_indicator_); 977 alert_indicator_button_->SetVisible(showing_alert_indicator_);
978 978
979 // Size the title to fill the remaining width and use all available height. 979 // Size the title to fill the remaining width and use all available height.
980 const bool show_title = ShouldRenderAsNormalTab(); 980 const bool show_title = ShouldRenderAsNormalTab();
981 if (show_title) { 981 if (show_title) {
982 const int title_spacing = GetLayoutConstant(TAB_FAVICON_TITLE_SPACING); 982 const int title_spacing = GetLayoutConstant(TAB_FAVICON_TITLE_SPACING);
983 int title_left = showing_icon_ ? 983 int title_left = showing_icon_ ?
984 (favicon_bounds_.right() + title_spacing) : start; 984 (favicon_bounds_.right() + title_spacing) : start;
985 int title_width = lb.right() - title_left; 985 int title_width = lb.right() - title_left;
986 if (showing_media_indicator_) { 986 if (showing_alert_indicator_) {
987 title_width = 987 title_width =
988 media_indicator_button_->x() - kAfterTitleSpacing - title_left; 988 alert_indicator_button_->x() - kAfterTitleSpacing - title_left;
989 } else if (close_button_->visible()) { 989 } else if (close_button_->visible()) {
990 // Allow the title to overlay the close button's empty border padding. 990 // Allow the title to overlay the close button's empty border padding.
991 title_width = close_button_->x() + close_button_->GetInsets().left() - 991 title_width = close_button_->x() + close_button_->GetInsets().left() -
992 kAfterTitleSpacing - title_left; 992 kAfterTitleSpacing - title_left;
993 } 993 }
994 // The Label will automatically center the font's cap height within the 994 // The Label will automatically center the font's cap height within the
995 // provided vertical space. 995 // provided vertical space.
996 title_->SetBoundsRect( 996 title_->SetBoundsRect(
997 gfx::Rect(title_left, lb.y(), std::max(title_width, 0), lb.height())); 997 gfx::Rect(title_left, lb.y(), std::max(title_width, 0), lb.height()));
998 } 998 }
999 title_->SetVisible(show_title); 999 title_->SetVisible(show_title);
1000 } 1000 }
1001 1001
1002 void Tab::OnThemeChanged() { 1002 void Tab::OnThemeChanged() {
1003 LoadTabImages(); 1003 LoadTabImages();
1004 OnButtonColorMaybeChanged(); 1004 OnButtonColorMaybeChanged();
1005 } 1005 }
1006 1006
1007 const char* Tab::GetClassName() const { 1007 const char* Tab::GetClassName() const {
1008 return kViewClassName; 1008 return kViewClassName;
1009 } 1009 }
1010 1010
1011 bool Tab::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const { 1011 bool Tab::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const {
1012 // Note: Anything that affects the tooltip text should be accounted for when 1012 // Note: Anything that affects the tooltip text should be accounted for when
1013 // calling TooltipTextChanged() from Tab::DataChanged(). 1013 // calling TooltipTextChanged() from Tab::DataChanged().
1014 *tooltip = chrome::AssembleTabTooltipText(data_.title, data_.media_state); 1014 *tooltip = chrome::AssembleTabTooltipText(data_.title, data_.alert_state);
1015 return !tooltip->empty(); 1015 return !tooltip->empty();
1016 } 1016 }
1017 1017
1018 bool Tab::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin) const { 1018 bool Tab::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin) const {
1019 origin->set_x(title_->x() + 10); 1019 origin->set_x(title_->x() + 10);
1020 origin->set_y(-4); 1020 origin->set_y(-4);
1021 return true; 1021 return true;
1022 } 1022 }
1023 1023
1024 bool Tab::OnMousePressed(const ui::MouseEvent& event) { 1024 bool Tab::OnMousePressed(const ui::MouseEvent& event) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 if (closest_tab) 1091 if (closest_tab)
1092 controller_->CloseTab(closest_tab, CLOSE_TAB_FROM_MOUSE); 1092 controller_->CloseTab(closest_tab, CLOSE_TAB_FROM_MOUSE);
1093 } 1093 }
1094 } else if (event.IsOnlyLeftMouseButton() && !event.IsShiftDown() && 1094 } else if (event.IsOnlyLeftMouseButton() && !event.IsShiftDown() &&
1095 !event.IsControlDown()) { 1095 !event.IsControlDown()) {
1096 // If the tab was already selected mouse pressed doesn't change the 1096 // If the tab was already selected mouse pressed doesn't change the
1097 // selection. Reset it now to handle the case where multiple tabs were 1097 // selection. Reset it now to handle the case where multiple tabs were
1098 // selected. 1098 // selected.
1099 controller_->SelectTab(this); 1099 controller_->SelectTab(this);
1100 1100
1101 if (media_indicator_button_ && media_indicator_button_->visible() && 1101 if (alert_indicator_button_ && alert_indicator_button_->visible() &&
1102 media_indicator_button_->bounds().Contains(event.location())) { 1102 alert_indicator_button_->bounds().Contains(event.location())) {
1103 content::RecordAction(UserMetricsAction("TabMediaIndicator_Clicked")); 1103 content::RecordAction(UserMetricsAction("TabAlertIndicator_Clicked"));
1104 } 1104 }
1105 } 1105 }
1106 } 1106 }
1107 1107
1108 void Tab::OnMouseCaptureLost() { 1108 void Tab::OnMouseCaptureLost() {
1109 controller_->EndDrag(END_DRAG_CAPTURE_LOST); 1109 controller_->EndDrag(END_DRAG_CAPTURE_LOST);
1110 } 1110 }
1111 1111
1112 void Tab::OnMouseEntered(const ui::MouseEvent& event) { 1112 void Tab::OnMouseEntered(const ui::MouseEvent& event) {
1113 hover_controller_.Show(views::GlowHoverController::SUBTLE); 1113 hover_controller_.Show(views::GlowHoverController::SUBTLE);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 const int ideal_delta = width() - GetPinnedWidth(); 1177 const int ideal_delta = width() - GetPinnedWidth();
1178 const int ideal_x = (GetPinnedWidth() - bounds->width()) / 2; 1178 const int ideal_x = (GetPinnedWidth() - bounds->width()) / 2;
1179 bounds->set_x( 1179 bounds->set_x(
1180 bounds->x() + static_cast<int>( 1180 bounds->x() + static_cast<int>(
1181 (1 - static_cast<float>(ideal_delta) / 1181 (1 - static_cast<float>(ideal_delta) /
1182 static_cast<float>(kPinnedTabExtraWidthToRenderAsNormal)) * 1182 static_cast<float>(kPinnedTabExtraWidthToRenderAsNormal)) *
1183 (ideal_x - bounds->x()))); 1183 (ideal_x - bounds->x())));
1184 } 1184 }
1185 1185
1186 void Tab::DataChanged(const TabRendererData& old) { 1186 void Tab::DataChanged(const TabRendererData& old) {
1187 if (data().media_state != old.media_state || data().title != old.title) 1187 if (data().alert_state != old.alert_state || data().title != old.title)
1188 TooltipTextChanged(); 1188 TooltipTextChanged();
1189 1189
1190 if (data().blocked == old.blocked) 1190 if (data().blocked == old.blocked)
1191 return; 1191 return;
1192 1192
1193 if (data().blocked) 1193 if (data().blocked)
1194 StartPulse(); 1194 StartPulse();
1195 else 1195 else
1196 StopPulse(); 1196 StopPulse();
1197 } 1197 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 if (visible_icons < 3) 1569 if (visible_icons < 3)
1570 return visible_icons; 1570 return visible_icons;
1571 const int padding = controller_->ShouldHideCloseButtonForInactiveTabs() ? 1571 const int padding = controller_->ShouldHideCloseButtonForInactiveTabs() ?
1572 0 : kExtraLeftPaddingToBalanceCloseButtonPadding; 1572 0 : kExtraLeftPaddingToBalanceCloseButtonPadding;
1573 return (available_width - padding) / icon_width; 1573 return (available_width - padding) / icon_width;
1574 } 1574 }
1575 1575
1576 bool Tab::ShouldShowIcon() const { 1576 bool Tab::ShouldShowIcon() const {
1577 return chrome::ShouldTabShowFavicon( 1577 return chrome::ShouldTabShowFavicon(
1578 IconCapacity(), data().pinned, IsActive(), data().show_icon, 1578 IconCapacity(), data().pinned, IsActive(), data().show_icon,
1579 media_indicator_button_ ? media_indicator_button_->showing_media_state() : 1579 alert_indicator_button_ ? alert_indicator_button_->showing_alert_state()
1580 data_.media_state); 1580 : data_.alert_state);
1581 } 1581 }
1582 1582
1583 bool Tab::ShouldShowMediaIndicator() const { 1583 bool Tab::ShouldShowAlertIndicator() const {
1584 return chrome::ShouldTabShowMediaIndicator( 1584 return chrome::ShouldTabShowAlertIndicator(
1585 IconCapacity(), data().pinned, IsActive(), data().show_icon, 1585 IconCapacity(), data().pinned, IsActive(), data().show_icon,
1586 media_indicator_button_ ? media_indicator_button_->showing_media_state() : 1586 alert_indicator_button_ ? alert_indicator_button_->showing_alert_state()
1587 data_.media_state); 1587 : data_.alert_state);
1588 } 1588 }
1589 1589
1590 bool Tab::ShouldShowCloseBox() const { 1590 bool Tab::ShouldShowCloseBox() const {
1591 if (!IsActive() && controller_->ShouldHideCloseButtonForInactiveTabs()) 1591 if (!IsActive() && controller_->ShouldHideCloseButtonForInactiveTabs())
1592 return false; 1592 return false;
1593 1593
1594 return chrome::ShouldTabShowCloseButton( 1594 return chrome::ShouldTabShowCloseButton(
1595 IconCapacity(), data().pinned, IsActive()); 1595 IconCapacity(), data().pinned, IsActive());
1596 } 1596 }
1597 1597
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 if (!theme_provider) 1629 if (!theme_provider)
1630 return; 1630 return;
1631 1631
1632 const SkColor title_color = theme_provider->GetColor(IsActive() ? 1632 const SkColor title_color = theme_provider->GetColor(IsActive() ?
1633 ThemeProperties::COLOR_TAB_TEXT : 1633 ThemeProperties::COLOR_TAB_TEXT :
1634 ThemeProperties::COLOR_BACKGROUND_TAB_TEXT); 1634 ThemeProperties::COLOR_BACKGROUND_TAB_TEXT);
1635 const SkColor new_button_color = SkColorSetA(title_color, 0xA0); 1635 const SkColor new_button_color = SkColorSetA(title_color, 0xA0);
1636 if (button_color_ != new_button_color) { 1636 if (button_color_ != new_button_color) {
1637 button_color_ = new_button_color; 1637 button_color_ = new_button_color;
1638 title_->SetEnabledColor(title_color); 1638 title_->SetEnabledColor(title_color);
1639 media_indicator_button_->OnParentTabButtonColorChanged(); 1639 alert_indicator_button_->OnParentTabButtonColorChanged();
1640 const gfx::ImageSkia& close_button_normal_image = gfx::CreateVectorIcon( 1640 const gfx::ImageSkia& close_button_normal_image = gfx::CreateVectorIcon(
1641 gfx::VectorIconId::TAB_CLOSE_NORMAL, kTabCloseButtonSize, 1641 gfx::VectorIconId::TAB_CLOSE_NORMAL, kTabCloseButtonSize,
1642 button_color_); 1642 button_color_);
1643 close_button_->SetImage(views::CustomButton::STATE_NORMAL, 1643 close_button_->SetImage(views::CustomButton::STATE_NORMAL,
1644 &close_button_normal_image); 1644 &close_button_normal_image);
1645 } 1645 }
1646 } 1646 }
1647 1647
1648 void Tab::ScheduleIconPaint() { 1648 void Tab::ScheduleIconPaint() {
1649 gfx::Rect bounds = favicon_bounds_; 1649 gfx::Rect bounds = favicon_bounds_;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 inactive_images_.image_c = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_CENTER); 1763 inactive_images_.image_c = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_CENTER);
1764 inactive_images_.image_r = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_RIGHT); 1764 inactive_images_.image_r = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_RIGHT);
1765 inactive_images_.l_width = inactive_images_.image_l->width(); 1765 inactive_images_.l_width = inactive_images_.image_l->width();
1766 inactive_images_.r_width = inactive_images_.image_r->width(); 1766 inactive_images_.r_width = inactive_images_.image_r->width();
1767 1767
1768 mask_images_.image_l = rb.GetImageSkiaNamed(IDR_TAB_ALPHA_LEFT); 1768 mask_images_.image_l = rb.GetImageSkiaNamed(IDR_TAB_ALPHA_LEFT);
1769 mask_images_.image_r = rb.GetImageSkiaNamed(IDR_TAB_ALPHA_RIGHT); 1769 mask_images_.image_r = rb.GetImageSkiaNamed(IDR_TAB_ALPHA_RIGHT);
1770 mask_images_.l_width = mask_images_.image_l->width(); 1770 mask_images_.l_width = mask_images_.image_l->width();
1771 mask_images_.r_width = mask_images_.image_r->width(); 1771 mask_images_.r_width = mask_images_.image_r->width();
1772 } 1772 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.h ('k') | chrome/browser/ui/views/tabs/tab_renderer_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698