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/system/overview/overview_button_tray.h" | 5 #include "ash/system/overview/overview_button_tray.h" |
| 6 | 6 |
| 7 #include "ash/session/session_state_delegate.h" | |
| 7 #include "ash/shelf/shelf_types.h" | 8 #include "ash/shelf/shelf_types.h" |
| 8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 9 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
| 10 #include "ash/system/tray/tray_utils.h" | 11 #include "ash/system/tray/tray_utils.h" |
| 11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 12 #include "ash/wm/overview/window_selector_controller.h" | 13 #include "ash/wm/overview/window_selector_controller.h" |
| 13 #include "grit/ash_resources.h" | 14 #include "grit/ash_resources.h" |
| 14 #include "grit/ash_strings.h" | 15 #include "grit/ash_strings.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 35 SetContentsBackground(); | 36 SetContentsBackground(); |
| 36 | 37 |
| 37 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 38 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 38 icon_ = new views::ImageView(); | 39 icon_ = new views::ImageView(); |
| 39 icon_->SetImage( | 40 icon_->SetImage( |
| 40 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_OVERVIEW_MODE).ToImageSkia()); | 41 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_OVERVIEW_MODE).ToImageSkia()); |
| 41 SetIconBorderForShelfAlignment(); | 42 SetIconBorderForShelfAlignment(); |
| 42 tray_container()->AddChildView(icon_); | 43 tray_container()->AddChildView(icon_); |
| 43 | 44 |
| 44 Shell::GetInstance()->AddShellObserver(this); | 45 Shell::GetInstance()->AddShellObserver(this); |
| 46 Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver(this); | |
| 45 } | 47 } |
| 46 | 48 |
| 47 OverviewButtonTray::~OverviewButtonTray() { | 49 OverviewButtonTray::~OverviewButtonTray() { |
| 48 Shell::GetInstance()->RemoveShellObserver(this); | 50 Shell::GetInstance()->RemoveShellObserver(this); |
| 51 Shell::GetInstance()->session_state_delegate()->RemoveSessionStateObserver( | |
| 52 this); | |
| 49 } | 53 } |
| 50 | 54 |
| 51 void OverviewButtonTray::UpdateAfterLoginStatusChange( | 55 void OverviewButtonTray::UpdateAfterLoginStatusChange( |
| 52 user::LoginStatus status) { | 56 user::LoginStatus status) { |
| 53 UpdateIconVisibility(); | 57 UpdateIconVisibility(); |
| 54 } | 58 } |
| 55 | 59 |
| 56 bool OverviewButtonTray::PerformAction(const ui::Event& event) { | 60 bool OverviewButtonTray::PerformAction(const ui::Event& event) { |
| 57 WindowSelectorController* controller = | 61 WindowSelectorController* controller = |
| 58 Shell::GetInstance()->window_selector_controller(); | 62 Shell::GetInstance()->window_selector_controller(); |
| 59 controller->ToggleOverview(); | 63 controller->ToggleOverview(); |
| 60 SetDrawBackgroundAsActive(controller->IsSelecting()); | 64 SetDrawBackgroundAsActive(controller->IsSelecting()); |
| 61 Shell::GetInstance()->metrics()->RecordUserMetricsAction(UMA_TRAY_OVERVIEW); | 65 Shell::GetInstance()->metrics()->RecordUserMetricsAction(UMA_TRAY_OVERVIEW); |
| 62 return true; | 66 return true; |
| 63 } | 67 } |
| 64 | 68 |
| 69 void OverviewButtonTray::SessionStateChanged( | |
| 70 SessionStateDelegate::SessionState state) { | |
| 71 UpdateIconVisibility(); | |
|
flackr
2015/05/28 15:20:37
I think this is getting brittle, the logic / respo
jonross
2015/06/01 17:00:37
I've decided to decouple OverviewButton's visibili
| |
| 72 } | |
| 73 | |
| 65 void OverviewButtonTray::OnMaximizeModeStarted() { | 74 void OverviewButtonTray::OnMaximizeModeStarted() { |
| 66 UpdateIconVisibility(); | 75 UpdateIconVisibility(); |
| 67 } | 76 } |
| 68 | 77 |
| 69 void OverviewButtonTray::OnMaximizeModeEnded() { | 78 void OverviewButtonTray::OnMaximizeModeEnded() { |
| 70 UpdateIconVisibility(); | 79 UpdateIconVisibility(); |
| 71 } | 80 } |
| 72 | 81 |
| 73 void OverviewButtonTray::OnOverviewModeEnded() { | 82 void OverviewButtonTray::OnOverviewModeEnded() { |
| 74 SetDrawBackgroundAsActive(false); | 83 SetDrawBackgroundAsActive(false); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 } | 123 } |
| 115 } | 124 } |
| 116 | 125 |
| 117 void OverviewButtonTray::UpdateIconVisibility() { | 126 void OverviewButtonTray::UpdateIconVisibility() { |
| 118 SetVisible(Shell::GetInstance()->maximize_mode_controller()-> | 127 SetVisible(Shell::GetInstance()->maximize_mode_controller()-> |
| 119 IsMaximizeModeWindowManagerEnabled() && | 128 IsMaximizeModeWindowManagerEnabled() && |
| 120 Shell::GetInstance()->window_selector_controller()->CanSelect()); | 129 Shell::GetInstance()->window_selector_controller()->CanSelect()); |
| 121 } | 130 } |
| 122 | 131 |
| 123 } // namespace ash | 132 } // namespace ash |
| OLD | NEW |