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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(); |
| 59 maximize_mode_controller->set_rotation_locked(rotation_locked); | 59 maximize_mode_controller->SetRotationLocked(rotation_locked); |
| 60 | 60 |
| 61 UpdateImage(); | 61 UpdateImage(); |
| 62 | 62 |
|
flackr
2014/05/28 14:48:04
nit: I don't think the empty lines are necessary t
jonross
2014/05/28 19:13:33
Well at one point in the past it was a fat method.
| |
| 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); | |
|
flackr
2014/05/28 14:48:04
Nice to be able to remove this! :-)
| |
| 67 | |
| 68 return true; | 63 return true; |
| 69 } | 64 } |
| 70 | 65 |
| 71 void RotationLockDefaultView::OnMaximizeModeStarted() { | 66 void RotationLockDefaultView::OnMaximizeModeStarted() { |
| 72 UpdateImage(); | 67 UpdateImage(); |
| 73 SetVisible(true); | 68 SetVisible(true); |
| 74 } | 69 } |
| 75 | 70 |
| 76 void RotationLockDefaultView::OnMaximizeModeEnded() { | 71 void RotationLockDefaultView::OnMaximizeModeEnded() { |
| 77 SetVisible(false); | 72 SetVisible(false); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 108 | 103 |
| 109 if (on_primary_display_) | 104 if (on_primary_display_) |
| 110 Shell::GetInstance()->AddShellObserver(this); | 105 Shell::GetInstance()->AddShellObserver(this); |
| 111 } | 106 } |
| 112 | 107 |
| 113 TrayRotationLock::~TrayRotationLock() { | 108 TrayRotationLock::~TrayRotationLock() { |
| 114 if (on_primary_display_) | 109 if (on_primary_display_) |
| 115 Shell::GetInstance()->RemoveShellObserver(this); | 110 Shell::GetInstance()->RemoveShellObserver(this); |
| 116 } | 111 } |
| 117 | 112 |
| 113 void TrayRotationLock::OnRotationLockChanged() { | |
| 114 tray_view()->SetVisible(GetInitialVisibility()); | |
|
flackr
2014/05/28 14:48:04
Can you move the logic in GetInitialVisibility to
jonross
2014/05/28 19:13:33
Done.
| |
| 115 } | |
| 116 | |
| 118 views::View* TrayRotationLock::CreateDefaultView(user::LoginStatus status) { | 117 views::View* TrayRotationLock::CreateDefaultView(user::LoginStatus status) { |
| 119 if (on_primary_display_) | 118 if (on_primary_display_) |
| 120 return new tray::RotationLockDefaultView(this); | 119 return new tray::RotationLockDefaultView(this); |
| 121 return NULL; | 120 return NULL; |
| 122 } | 121 } |
| 123 | 122 |
| 124 void TrayRotationLock::OnMaximizeModeStarted() { | 123 void TrayRotationLock::OnMaximizeModeStarted() { |
| 125 tray_view()->SetVisible( | 124 tray_view()->SetVisible( |
| 126 Shell::GetInstance()->maximize_mode_controller()->rotation_locked()); | 125 Shell::GetInstance()->maximize_mode_controller()->rotation_locked()); |
| 126 Shell::GetInstance()->maximize_mode_controller()->AddObserver(this); | |
| 127 } | 127 } |
| 128 | 128 |
| 129 void TrayRotationLock::OnMaximizeModeEnded() { | 129 void TrayRotationLock::OnMaximizeModeEnded() { |
| 130 tray_view()->SetVisible(false); | 130 tray_view()->SetVisible(false); |
| 131 MaximizeModeController* controller = Shell::GetInstance()-> | |
| 132 maximize_mode_controller(); | |
| 133 // Upon system shutdown the controller could already be cleaned up. | |
|
flackr
2014/05/28 14:48:04
Isn't the controller at least around when OnMaximi
jonross
2014/05/28 19:13:33
Done.
| |
| 134 if (controller) | |
| 135 controller->RemoveObserver(this); | |
| 131 } | 136 } |
| 132 | 137 |
| 133 bool TrayRotationLock::GetInitialVisibility() { | 138 bool TrayRotationLock::GetInitialVisibility() { |
| 134 return on_primary_display_ && | 139 return on_primary_display_ && |
| 135 Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled() && | 140 Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled() && |
| 136 Shell::GetInstance()->maximize_mode_controller()->rotation_locked(); | 141 Shell::GetInstance()->maximize_mode_controller()->rotation_locked(); |
| 137 } | 142 } |
| 138 | 143 |
| 139 } // namespace ash | 144 } // namespace ash |
| OLD | NEW |