| 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/chromeos/rotation/tray_rotation_lock.h" | 5 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" |
| 6 | 6 |
| 7 #include "ash/common/system/tray/tray_item_more.h" | 7 #include "ash/common/system/tray/tray_item_more.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "ash/display/screen_orientation_controller_chromeos.h" | 9 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
| 12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 13 #include "grit/ash_resources.h" | 13 #include "grit/ash_resources.h" |
| 14 #include "grit/ash_strings.h" | 14 #include "grit/ash_strings.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/display/display.h" | 17 #include "ui/display/display.h" |
| 18 | 18 |
| 19 namespace ash { | 19 namespace ash { |
| 20 | 20 |
| 21 namespace tray { | 21 namespace tray { |
| 22 | 22 |
| 23 // Extends TrayItemMore, however does not make use of the chevron, nor of the | 23 // Extends TrayItemMore, however does not make use of the chevron, nor of the |
| 24 // DetailedView. This was chosen over ActionableView in order to reuse the | 24 // DetailedView. This was chosen over ActionableView in order to reuse the |
| 25 // layout and styling of labels and images. This allows RotationLockDefaultView | 25 // layout and styling of labels and images. This allows RotationLockDefaultView |
| 26 // to maintain the look of other system tray items without code duplication. | 26 // to maintain the look of other system tray items without code duplication. |
| 27 class RotationLockDefaultView : public TrayItemMore, | 27 class RotationLockDefaultView : public TrayItemMore, public ShellObserver { |
| 28 public ShellObserver { | |
| 29 public: | 28 public: |
| 30 explicit RotationLockDefaultView(SystemTrayItem* owner); | 29 explicit RotationLockDefaultView(SystemTrayItem* owner); |
| 31 ~RotationLockDefaultView() override; | 30 ~RotationLockDefaultView() override; |
| 32 | 31 |
| 33 // ActionableView: | 32 // ActionableView: |
| 34 bool PerformAction(const ui::Event& event) override; | 33 bool PerformAction(const ui::Event& event) override; |
| 35 | 34 |
| 36 // ShellObserver: | 35 // ShellObserver: |
| 37 void OnMaximizeModeStarted() override; | 36 void OnMaximizeModeStarted() override; |
| 38 void OnMaximizeModeEnded() override; | 37 void OnMaximizeModeEnded() override; |
| 39 | 38 |
| 40 private: | 39 private: |
| 41 void UpdateImage(); | 40 void UpdateImage(); |
| 42 | 41 |
| 43 DISALLOW_COPY_AND_ASSIGN(RotationLockDefaultView); | 42 DISALLOW_COPY_AND_ASSIGN(RotationLockDefaultView); |
| 44 }; | 43 }; |
| 45 | 44 |
| 46 RotationLockDefaultView::RotationLockDefaultView(SystemTrayItem* owner) | 45 RotationLockDefaultView::RotationLockDefaultView(SystemTrayItem* owner) |
| 47 : TrayItemMore(owner, false) { | 46 : TrayItemMore(owner, false) { |
| 48 UpdateImage(); | 47 UpdateImage(); |
| 49 SetVisible(Shell::GetInstance()->maximize_mode_controller()-> | 48 SetVisible(Shell::GetInstance() |
| 50 IsMaximizeModeWindowManagerEnabled()); | 49 ->maximize_mode_controller() |
| 50 ->IsMaximizeModeWindowManagerEnabled()); |
| 51 WmShell::Get()->AddShellObserver(this); | 51 WmShell::Get()->AddShellObserver(this); |
| 52 } | 52 } |
| 53 | 53 |
| 54 RotationLockDefaultView::~RotationLockDefaultView() { | 54 RotationLockDefaultView::~RotationLockDefaultView() { |
| 55 WmShell::Get()->RemoveShellObserver(this); | 55 WmShell::Get()->RemoveShellObserver(this); |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool RotationLockDefaultView::PerformAction(const ui::Event& event) { | 58 bool RotationLockDefaultView::PerformAction(const ui::Event& event) { |
| 59 ScreenOrientationController* screen_orientation_controller = | 59 ScreenOrientationController* screen_orientation_controller = |
| 60 Shell::GetInstance()->screen_orientation_controller(); | 60 Shell::GetInstance()->screen_orientation_controller(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 72 void RotationLockDefaultView::OnMaximizeModeEnded() { | 72 void RotationLockDefaultView::OnMaximizeModeEnded() { |
| 73 SetVisible(false); | 73 SetVisible(false); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void RotationLockDefaultView::UpdateImage() { | 76 void RotationLockDefaultView::UpdateImage() { |
| 77 base::string16 label; | 77 base::string16 label; |
| 78 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 78 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 79 if (Shell::GetInstance() | 79 if (Shell::GetInstance() |
| 80 ->screen_orientation_controller() | 80 ->screen_orientation_controller() |
| 81 ->rotation_locked()) { | 81 ->rotation_locked()) { |
| 82 SetImage(bundle.GetImageNamed( | 82 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED_DARK) |
| 83 IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED_DARK).ToImageSkia()); | 83 .ToImageSkia()); |
| 84 label = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ROTATION_LOCK_LOCKED); | 84 label = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ROTATION_LOCK_LOCKED); |
| 85 SetLabel(label); | 85 SetLabel(label); |
| 86 SetAccessibleName(label); | 86 SetAccessibleName(label); |
| 87 } else { | 87 } else { |
| 88 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_AUTO_ROTATION_DARK). | 88 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_AUTO_ROTATION_DARK) |
| 89 ToImageSkia()); | 89 .ToImageSkia()); |
| 90 label = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ROTATION_LOCK_AUTO); | 90 label = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ROTATION_LOCK_AUTO); |
| 91 SetLabel(label); | 91 SetLabel(label); |
| 92 SetAccessibleName(label); | 92 SetAccessibleName(label); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace tray | 96 } // namespace tray |
| 97 | 97 |
| 98 TrayRotationLock::TrayRotationLock(SystemTray* system_tray) | 98 TrayRotationLock::TrayRotationLock(SystemTray* system_tray) |
| 99 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED), | 99 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 166 } |
| 167 | 167 |
| 168 void TrayRotationLock::StopObservingShell() { | 168 void TrayRotationLock::StopObservingShell() { |
| 169 if (!observing_shell_) | 169 if (!observing_shell_) |
| 170 return; | 170 return; |
| 171 WmShell::Get()->RemoveShellObserver(this); | 171 WmShell::Get()->RemoveShellObserver(this); |
| 172 observing_shell_ = false; | 172 observing_shell_ = false; |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace ash | 175 } // namespace ash |
| OLD | NEW |