| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/system/overview/overview_button_tray.h" | 5 #include "ash/system/overview/overview_button_tray.h" |
| 6 | 6 |
| 7 #include "ash/resources/vector_icons/vector_icons.h" | 7 #include "ash/resources/vector_icons/vector_icons.h" |
| 8 #include "ash/session/session_controller.h" | 8 #include "ash/session/session_controller.h" |
| 9 #include "ash/shelf/shelf_constants.h" | 9 #include "ash/shelf/shelf_constants.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/shell_port.h" | 11 #include "ash/shell_port.h" |
| 12 #include "ash/strings/grit/ash_strings.h" | 12 #include "ash/strings/grit/ash_strings.h" |
| 13 #include "ash/system/tray/system_tray_delegate.h" | 13 #include "ash/system/tray/system_tray_delegate.h" |
| 14 #include "ash/system/tray/tray_constants.h" | 14 #include "ash/system/tray/tray_constants.h" |
| 15 #include "ash/system/tray/tray_container.h" |
| 15 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 16 #include "ash/wm/overview/window_selector_controller.h" | 17 #include "ash/wm/overview/window_selector_controller.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/gfx/paint_vector_icon.h" | 19 #include "ui/gfx/paint_vector_icon.h" |
| 19 #include "ui/views/border.h" | 20 #include "ui/views/border.h" |
| 20 #include "ui/views/controls/image_view.h" | 21 #include "ui/views/controls/image_view.h" |
| 21 | 22 |
| 22 namespace ash { | 23 namespace ash { |
| 23 | 24 |
| 24 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) | 25 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) |
| 25 : TrayBackgroundView(wm_shelf, true), | 26 : TrayBackgroundView(wm_shelf), |
| 26 icon_(new views::ImageView()), | 27 icon_(new views::ImageView()), |
| 27 scoped_session_observer_(this) { | 28 scoped_session_observer_(this) { |
| 28 SetInkDropMode(InkDropMode::ON); | 29 SetInkDropMode(InkDropMode::ON); |
| 29 | 30 |
| 30 icon_->SetImage(CreateVectorIcon(kShelfOverviewIcon, kShelfIconColor)); | 31 gfx::ImageSkia image = |
| 31 SetIconBorderForShelfAlignment(); | 32 gfx::CreateVectorIcon(kShelfOverviewIcon, kShelfIconColor); |
| 33 icon_->SetImage(image); |
| 34 const int vertical_padding = (kTrayItemSize - image.height()) / 2; |
| 35 const int horizontal_padding = (kTrayItemSize - image.width()) / 2; |
| 36 icon_->SetBorder(views::CreateEmptyBorder( |
| 37 gfx::Insets(vertical_padding, horizontal_padding))); |
| 32 tray_container()->AddChildView(icon_); | 38 tray_container()->AddChildView(icon_); |
| 33 | 39 |
| 34 // Since OverviewButtonTray is located on the rightmost position of a | 40 // Since OverviewButtonTray is located on the rightmost position of a |
| 35 // horizontal shelf, no separator is required. | 41 // horizontal shelf, no separator is required. |
| 36 set_separator_visibility(false); | 42 set_separator_visibility(false); |
| 37 | 43 |
| 38 Shell::Get()->AddShellObserver(this); | 44 Shell::Get()->AddShellObserver(this); |
| 39 } | 45 } |
| 40 | 46 |
| 41 OverviewButtonTray::~OverviewButtonTray() { | 47 OverviewButtonTray::~OverviewButtonTray() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 86 |
| 81 base::string16 OverviewButtonTray::GetAccessibleNameForTray() { | 87 base::string16 OverviewButtonTray::GetAccessibleNameForTray() { |
| 82 return l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_BUTTON_ACCESSIBLE_NAME); | 88 return l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_BUTTON_ACCESSIBLE_NAME); |
| 83 } | 89 } |
| 84 | 90 |
| 85 void OverviewButtonTray::HideBubbleWithView( | 91 void OverviewButtonTray::HideBubbleWithView( |
| 86 const views::TrayBubbleView* bubble_view) { | 92 const views::TrayBubbleView* bubble_view) { |
| 87 // This class has no bubbles to hide. | 93 // This class has no bubbles to hide. |
| 88 } | 94 } |
| 89 | 95 |
| 90 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) { | |
| 91 if (alignment == shelf_alignment()) | |
| 92 return; | |
| 93 | |
| 94 TrayBackgroundView::SetShelfAlignment(alignment); | |
| 95 SetIconBorderForShelfAlignment(); | |
| 96 } | |
| 97 | |
| 98 void OverviewButtonTray::SetIconBorderForShelfAlignment() { | |
| 99 // Pad button size to align with other controls in the system tray. | |
| 100 const gfx::ImageSkia& image = icon_->GetImage(); | |
| 101 const int vertical_padding = (kTrayItemSize - image.height()) / 2; | |
| 102 const int horizontal_padding = (kTrayItemSize - image.width()) / 2; | |
| 103 icon_->SetBorder(views::CreateEmptyBorder( | |
| 104 gfx::Insets(vertical_padding, horizontal_padding))); | |
| 105 } | |
| 106 | |
| 107 void OverviewButtonTray::UpdateIconVisibility() { | 96 void OverviewButtonTray::UpdateIconVisibility() { |
| 108 // The visibility of the OverviewButtonTray has diverged from | 97 // The visibility of the OverviewButtonTray has diverged from |
| 109 // WindowSelectorController::CanSelect. The visibility of the button should | 98 // WindowSelectorController::CanSelect. The visibility of the button should |
| 110 // not change during transient times in which CanSelect is false. Such as when | 99 // not change during transient times in which CanSelect is false. Such as when |
| 111 // a modal dialog is present. | 100 // a modal dialog is present. |
| 112 SessionController* session_controller = Shell::Get()->session_controller(); | 101 SessionController* session_controller = Shell::Get()->session_controller(); |
| 113 | 102 |
| 114 Shell* shell = Shell::Get(); | 103 Shell* shell = Shell::Get(); |
| 115 SetVisible( | 104 SetVisible( |
| 116 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && | 105 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && |
| 117 session_controller->IsActiveUserSessionStarted() && | 106 session_controller->IsActiveUserSessionStarted() && |
| 118 !session_controller->IsScreenLocked() && | 107 !session_controller->IsScreenLocked() && |
| 119 session_controller->GetSessionState() == | 108 session_controller->GetSessionState() == |
| 120 session_manager::SessionState::ACTIVE && | 109 session_manager::SessionState::ACTIVE && |
| 121 shell->system_tray_delegate()->GetUserLoginStatus() != | 110 shell->system_tray_delegate()->GetUserLoginStatus() != |
| 122 LoginStatus::KIOSK_APP && | 111 LoginStatus::KIOSK_APP && |
| 123 shell->system_tray_delegate()->GetUserLoginStatus() != | 112 shell->system_tray_delegate()->GetUserLoginStatus() != |
| 124 LoginStatus::ARC_KIOSK_APP); | 113 LoginStatus::ARC_KIOSK_APP); |
| 125 } | 114 } |
| 126 | 115 |
| 127 } // namespace ash | 116 } // namespace ash |
| OLD | NEW |