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/chromeos/rotation/tray_rotation_lock.h" | 5 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
| 9 #include "ash/system/tray/tray_item_more.h" | 9 #include "ash/system/tray/tray_item_more.h" |
| 10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 Shell::GetInstance()->AddShellObserver(this); | 48 Shell::GetInstance()->AddShellObserver(this); |
| 49 } | 49 } |
| 50 | 50 |
| 51 RotationLockDefaultView::~RotationLockDefaultView() { | 51 RotationLockDefaultView::~RotationLockDefaultView() { |
| 52 Shell::GetInstance()->RemoveShellObserver(this); | 52 Shell::GetInstance()->RemoveShellObserver(this); |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool RotationLockDefaultView::PerformAction(const ui::Event& event) { | 55 bool RotationLockDefaultView::PerformAction(const ui::Event& event) { |
| 56 MaximizeModeController* maximize_mode_controller = Shell::GetInstance()-> | 56 MaximizeModeController* maximize_mode_controller = Shell::GetInstance()-> |
| 57 maximize_mode_controller(); | 57 maximize_mode_controller(); |
| 58 bool rotation_locked = !maximize_mode_controller->rotation_locked(); | 58 bool rotation_locked = !maximize_mode_controller->rotation_locked(); |
|
flackr
2014/05/30 00:47:24
nit: No need to store value, as it's only used onc
jonross
2014/05/30 14:52:44
Done.
| |
| 59 maximize_mode_controller->set_rotation_locked(rotation_locked); | 59 maximize_mode_controller->SetRotationLocked(rotation_locked); |
| 60 | |
| 61 UpdateImage(); | 60 UpdateImage(); |
| 62 | |
| 63 // RotationLockDefaultView can only be created by a TrayRotationLock. The | |
| 64 // owner needs to be told of the action so that it can update its visibility. | |
| 65 static_cast<TrayRotationLock*>(owner())->tray_view()-> | |
| 66 SetVisible(rotation_locked); | |
| 67 | |
| 68 return true; | 61 return true; |
| 69 } | 62 } |
| 70 | 63 |
| 71 void RotationLockDefaultView::OnMaximizeModeStarted() { | 64 void RotationLockDefaultView::OnMaximizeModeStarted() { |
| 72 UpdateImage(); | 65 UpdateImage(); |
| 73 SetVisible(true); | 66 SetVisible(true); |
| 74 } | 67 } |
| 75 | 68 |
| 76 void RotationLockDefaultView::OnMaximizeModeEnded() { | 69 void RotationLockDefaultView::OnMaximizeModeEnded() { |
| 77 SetVisible(false); | 70 SetVisible(false); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 108 | 101 |
| 109 if (on_primary_display_) | 102 if (on_primary_display_) |
| 110 Shell::GetInstance()->AddShellObserver(this); | 103 Shell::GetInstance()->AddShellObserver(this); |
| 111 } | 104 } |
| 112 | 105 |
| 113 TrayRotationLock::~TrayRotationLock() { | 106 TrayRotationLock::~TrayRotationLock() { |
| 114 if (on_primary_display_) | 107 if (on_primary_display_) |
| 115 Shell::GetInstance()->RemoveShellObserver(this); | 108 Shell::GetInstance()->RemoveShellObserver(this); |
| 116 } | 109 } |
| 117 | 110 |
| 111 void TrayRotationLock::OnRotationLockChanged(bool rotation_locked) { | |
| 112 tray_view()->SetVisible(ShouldBeVisible()); | |
| 113 } | |
| 114 | |
| 118 views::View* TrayRotationLock::CreateDefaultView(user::LoginStatus status) { | 115 views::View* TrayRotationLock::CreateDefaultView(user::LoginStatus status) { |
| 119 if (on_primary_display_) | 116 if (on_primary_display_) |
| 120 return new tray::RotationLockDefaultView(this); | 117 return new tray::RotationLockDefaultView(this); |
| 121 return NULL; | 118 return NULL; |
| 122 } | 119 } |
| 123 | 120 |
| 124 void TrayRotationLock::OnMaximizeModeStarted() { | 121 void TrayRotationLock::OnMaximizeModeStarted() { |
| 125 tray_view()->SetVisible( | 122 tray_view()->SetVisible( |
| 126 Shell::GetInstance()->maximize_mode_controller()->rotation_locked()); | 123 Shell::GetInstance()->maximize_mode_controller()->rotation_locked()); |
| 124 Shell::GetInstance()->maximize_mode_controller()->AddObserver(this); | |
| 127 } | 125 } |
| 128 | 126 |
| 129 void TrayRotationLock::OnMaximizeModeEnded() { | 127 void TrayRotationLock::OnMaximizeModeEnded() { |
| 130 tray_view()->SetVisible(false); | 128 tray_view()->SetVisible(false); |
| 129 Shell::GetInstance()->maximize_mode_controller()->RemoveObserver(this); | |
| 131 } | 130 } |
| 132 | 131 |
| 133 bool TrayRotationLock::GetInitialVisibility() { | 132 bool TrayRotationLock::GetInitialVisibility() { |
| 133 return ShouldBeVisible(); | |
| 134 } | |
| 135 | |
| 136 bool TrayRotationLock::ShouldBeVisible() { | |
| 134 return on_primary_display_ && | 137 return on_primary_display_ && |
| 135 Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled() && | 138 Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled() && |
| 136 Shell::GetInstance()->maximize_mode_controller()->rotation_locked(); | 139 Shell::GetInstance()->maximize_mode_controller()->rotation_locked(); |
| 137 } | 140 } |
| 138 | 141 |
| 139 } // namespace ash | 142 } // namespace ash |
| OLD | NEW |