Chromium Code Reviews| 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/common/system/overview/overview_button_tray.h" | 5 #include "ash/common/system/overview/overview_button_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shelf/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
| 10 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 const int kHorizontalShelfVerticalPadding = 4; | 32 const int kHorizontalShelfVerticalPadding = 4; |
| 33 const int kVerticalShelfHorizontalPadding = 2; | 33 const int kVerticalShelfHorizontalPadding = 2; |
| 34 const int kVerticalShelfVerticalPadding = 5; | 34 const int kVerticalShelfVerticalPadding = 5; |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 namespace ash { | 38 namespace ash { |
| 39 | 39 |
| 40 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) | 40 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) |
| 41 : TrayBackgroundView(wm_shelf), icon_(nullptr) { | 41 : TrayBackgroundView(wm_shelf), icon_(nullptr) { |
| 42 SetContentsBackground(); | |
| 43 | |
| 44 icon_ = new views::ImageView(); | 42 icon_ = new views::ImageView(); |
| 45 if (MaterialDesignController::IsShelfMaterial()) { | 43 if (MaterialDesignController::IsShelfMaterial()) { |
| 44 SetInkDropMode(InkDropMode::ON); | |
| 45 SetContentsBackground(false); | |
| 46 gfx::ImageSkia image_md = | 46 gfx::ImageSkia image_md = |
| 47 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERVIEW, kShelfIconColor); | 47 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERVIEW, kShelfIconColor); |
| 48 icon_->SetImage(image_md); | 48 icon_->SetImage(image_md); |
| 49 } else { | 49 } else { |
| 50 SetContentsBackground(true); | |
| 50 gfx::ImageSkia* image_non_md = | 51 gfx::ImageSkia* image_non_md = |
| 51 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 52 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 52 IDR_AURA_UBER_TRAY_OVERVIEW_MODE); | 53 IDR_AURA_UBER_TRAY_OVERVIEW_MODE); |
| 53 icon_->SetImage(image_non_md); | 54 icon_->SetImage(image_non_md); |
| 54 } | 55 } |
| 55 SetIconBorderForShelfAlignment(); | 56 SetIconBorderForShelfAlignment(); |
| 56 tray_container()->AddChildView(icon_); | 57 tray_container()->AddChildView(icon_); |
| 57 | 58 |
| 58 WmShell::Get()->AddShellObserver(this); | 59 WmShell::Get()->AddShellObserver(this); |
| 59 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); | 60 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); |
| 60 } | 61 } |
| 61 | 62 |
| 62 OverviewButtonTray::~OverviewButtonTray() { | 63 OverviewButtonTray::~OverviewButtonTray() { |
| 63 WmShell::Get()->RemoveShellObserver(this); | 64 WmShell::Get()->RemoveShellObserver(this); |
| 64 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this); | 65 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void OverviewButtonTray::UpdateAfterLoginStatusChange(LoginStatus status) { | 68 void OverviewButtonTray::UpdateAfterLoginStatusChange(LoginStatus status) { |
| 68 UpdateIconVisibility(); | 69 UpdateIconVisibility(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 bool OverviewButtonTray::PerformAction(const ui::Event& event) { | 72 bool OverviewButtonTray::PerformAction(const ui::Event& event) { |
| 72 WindowSelectorController* controller = | 73 WindowSelectorController* controller = |
| 73 WmShell::Get()->window_selector_controller(); | 74 WmShell::Get()->window_selector_controller(); |
| 75 bool was_selecting = controller->IsSelecting(); | |
| 74 controller->ToggleOverview(); | 76 controller->ToggleOverview(); |
|
bruthig
2016/11/11 17:30:40
nit: Consider changing ToggleOverview() to return
mohsen
2016/11/11 22:37:24
Done.
| |
| 75 SetDrawBackgroundAsActive(controller->IsSelecting()); | |
| 76 WmShell::Get()->RecordUserMetricsAction(UMA_TRAY_OVERVIEW); | 77 WmShell::Get()->RecordUserMetricsAction(UMA_TRAY_OVERVIEW); |
| 77 return true; | 78 return was_selecting != controller->IsSelecting(); |
|
bruthig
2016/11/11 17:30:40
nit: it would be useful to have a comment here as
mohsen
2016/11/11 22:37:24
Done.
| |
| 78 } | 79 } |
| 79 | 80 |
| 80 void OverviewButtonTray::SessionStateChanged( | 81 void OverviewButtonTray::SessionStateChanged( |
| 81 session_manager::SessionState state) { | 82 session_manager::SessionState state) { |
| 82 UpdateIconVisibility(); | 83 UpdateIconVisibility(); |
| 83 } | 84 } |
| 84 | 85 |
| 85 void OverviewButtonTray::OnMaximizeModeStarted() { | 86 void OverviewButtonTray::OnMaximizeModeStarted() { |
| 86 UpdateIconVisibility(); | 87 UpdateIconVisibility(); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void OverviewButtonTray::OnMaximizeModeEnded() { | 90 void OverviewButtonTray::OnMaximizeModeEnded() { |
| 90 UpdateIconVisibility(); | 91 UpdateIconVisibility(); |
| 91 } | 92 } |
| 92 | 93 |
| 94 void OverviewButtonTray::OnOverviewModeStarting() { | |
| 95 SetIsActive(true); | |
| 96 } | |
| 97 | |
| 93 void OverviewButtonTray::OnOverviewModeEnded() { | 98 void OverviewButtonTray::OnOverviewModeEnded() { |
| 94 SetDrawBackgroundAsActive(false); | 99 SetIsActive(false); |
| 95 } | 100 } |
| 96 | 101 |
| 97 void OverviewButtonTray::ClickedOutsideBubble() {} | 102 void OverviewButtonTray::ClickedOutsideBubble() {} |
| 98 | 103 |
| 99 base::string16 OverviewButtonTray::GetAccessibleNameForTray() { | 104 base::string16 OverviewButtonTray::GetAccessibleNameForTray() { |
| 100 return l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_BUTTON_ACCESSIBLE_NAME); | 105 return l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_BUTTON_ACCESSIBLE_NAME); |
| 101 } | 106 } |
| 102 | 107 |
| 103 void OverviewButtonTray::HideBubbleWithView( | 108 void OverviewButtonTray::HideBubbleWithView( |
| 104 const views::TrayBubbleView* bubble_view) { | 109 const views::TrayBubbleView* bubble_view) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && | 149 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && |
| 145 session_state_delegate->IsActiveUserSessionStarted() && | 150 session_state_delegate->IsActiveUserSessionStarted() && |
| 146 !session_state_delegate->IsScreenLocked() && | 151 !session_state_delegate->IsScreenLocked() && |
| 147 session_state_delegate->GetSessionState() == | 152 session_state_delegate->GetSessionState() == |
| 148 session_manager::SessionState::ACTIVE && | 153 session_manager::SessionState::ACTIVE && |
| 149 shell->system_tray_delegate()->GetUserLoginStatus() != | 154 shell->system_tray_delegate()->GetUserLoginStatus() != |
| 150 LoginStatus::KIOSK_APP); | 155 LoginStatus::KIOSK_APP); |
| 151 } | 156 } |
| 152 | 157 |
| 153 } // namespace ash | 158 } // namespace ash |
| OLD | NEW |