Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: ash/system/chromeos/rotation/tray_rotation_lock.cc

Issue 303723003: Lock Rotation on user settings changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
49 Shell::GetInstance()->AddShellObserver(this); 49 Shell::GetInstance()->AddShellObserver(this);
50 } 50 }
51 51
52 RotationLockDefaultView::~RotationLockDefaultView() { 52 RotationLockDefaultView::~RotationLockDefaultView() {
53 Shell::GetInstance()->RemoveShellObserver(this); 53 Shell::GetInstance()->RemoveShellObserver(this);
54 } 54 }
55 55
56 bool RotationLockDefaultView::PerformAction(const ui::Event& event) { 56 bool RotationLockDefaultView::PerformAction(const ui::Event& event) {
57 MaximizeModeController* maximize_mode_controller = Shell::GetInstance()-> 57 MaximizeModeController* maximize_mode_controller = Shell::GetInstance()->
58 maximize_mode_controller(); 58 maximize_mode_controller();
59 bool rotation_locked = !maximize_mode_controller->rotation_locked(); 59 maximize_mode_controller->SetRotationLocked(
60 maximize_mode_controller->set_rotation_locked(rotation_locked); 60 !maximize_mode_controller->rotation_locked());
61
62 UpdateImage(); 61 UpdateImage();
63
64 // RotationLockDefaultView can only be created by a TrayRotationLock. The
65 // owner needs to be told of the action so that it can update its visibility.
66 static_cast<TrayRotationLock*>(owner())->tray_view()->
67 SetVisible(rotation_locked);
68
69 return true; 62 return true;
70 } 63 }
71 64
72 void RotationLockDefaultView::OnMaximizeModeStarted() { 65 void RotationLockDefaultView::OnMaximizeModeStarted() {
73 UpdateImage(); 66 UpdateImage();
74 SetVisible(true); 67 SetVisible(true);
75 } 68 }
76 69
77 void RotationLockDefaultView::OnMaximizeModeEnded() { 70 void RotationLockDefaultView::OnMaximizeModeEnded() {
78 SetVisible(false); 71 SetVisible(false);
(...skipping 30 matching lines...) Expand all
109 102
110 if (on_primary_display_) 103 if (on_primary_display_)
111 Shell::GetInstance()->AddShellObserver(this); 104 Shell::GetInstance()->AddShellObserver(this);
112 } 105 }
113 106
114 TrayRotationLock::~TrayRotationLock() { 107 TrayRotationLock::~TrayRotationLock() {
115 if (on_primary_display_) 108 if (on_primary_display_)
116 Shell::GetInstance()->RemoveShellObserver(this); 109 Shell::GetInstance()->RemoveShellObserver(this);
117 } 110 }
118 111
112 void TrayRotationLock::OnRotationLockChanged(bool rotation_locked) {
113 tray_view()->SetVisible(ShouldBeVisible());
114 }
115
119 views::View* TrayRotationLock::CreateDefaultView(user::LoginStatus status) { 116 views::View* TrayRotationLock::CreateDefaultView(user::LoginStatus status) {
120 if (on_primary_display_) 117 if (on_primary_display_)
121 return new tray::RotationLockDefaultView(this); 118 return new tray::RotationLockDefaultView(this);
122 return NULL; 119 return NULL;
123 } 120 }
124 121
125 void TrayRotationLock::OnMaximizeModeStarted() { 122 void TrayRotationLock::OnMaximizeModeStarted() {
126 tray_view()->SetVisible( 123 tray_view()->SetVisible(
127 Shell::GetInstance()->maximize_mode_controller()->rotation_locked()); 124 Shell::GetInstance()->maximize_mode_controller()->rotation_locked());
125 Shell::GetInstance()->maximize_mode_controller()->AddObserver(this);
128 } 126 }
129 127
130 void TrayRotationLock::OnMaximizeModeEnded() { 128 void TrayRotationLock::OnMaximizeModeEnded() {
131 tray_view()->SetVisible(false); 129 tray_view()->SetVisible(false);
130 Shell::GetInstance()->maximize_mode_controller()->RemoveObserver(this);
132 } 131 }
133 132
134 bool TrayRotationLock::GetInitialVisibility() { 133 bool TrayRotationLock::GetInitialVisibility() {
134 return ShouldBeVisible();
135 }
136
137 bool TrayRotationLock::ShouldBeVisible() {
135 MaximizeModeController* controller = Shell::GetInstance()-> 138 MaximizeModeController* controller = Shell::GetInstance()->
136 maximize_mode_controller(); 139 maximize_mode_controller();
137 return on_primary_display_ && 140 return on_primary_display_ &&
138 controller->IsMaximizeModeWindowManagerEnabled() && 141 controller->IsMaximizeModeWindowManagerEnabled() &&
139 controller->rotation_locked(); 142 controller->rotation_locked();
140 } 143 }
141 144
142 } // namespace ash 145 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/rotation/tray_rotation_lock.h ('k') | ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698