| 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/display/screen_orientation_controller_chromeos.h" | 7 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "ash/system/tray/tray_item_more.h" | 10 #include "ash/system/tray/tray_item_more.h" |
| 11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 12 #include "grit/ash_resources.h" | 12 #include "grit/ash_resources.h" |
| 13 #include "grit/ash_strings.h" | 13 #include "grit/ash_strings.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/display.h" | 16 #include "ui/display/display.h" |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 | 19 |
| 20 namespace tray { | 20 namespace tray { |
| 21 | 21 |
| 22 // Extends TrayItemMore, however does not make use of the chevron, nor of the | 22 // Extends TrayItemMore, however does not make use of the chevron, nor of the |
| 23 // DetailedView. This was chosen over ActionableView in order to reuse the | 23 // DetailedView. This was chosen over ActionableView in order to reuse the |
| 24 // layout and styling of labels and images. This allows RotationLockDefaultView | 24 // layout and styling of labels and images. This allows RotationLockDefaultView |
| 25 // to maintain the look of other system tray items without code duplication. | 25 // to maintain the look of other system tray items without code duplication. |
| 26 class RotationLockDefaultView : public TrayItemMore, | 26 class RotationLockDefaultView : public TrayItemMore, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 Shell::GetInstance() | 142 Shell::GetInstance() |
| 143 ->maximize_mode_controller() | 143 ->maximize_mode_controller() |
| 144 ->IsMaximizeModeWindowManagerEnabled() && | 144 ->IsMaximizeModeWindowManagerEnabled() && |
| 145 Shell::GetInstance() | 145 Shell::GetInstance() |
| 146 ->screen_orientation_controller() | 146 ->screen_orientation_controller() |
| 147 ->rotation_locked(); | 147 ->rotation_locked(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool TrayRotationLock::OnPrimaryDisplay() const { | 150 bool TrayRotationLock::OnPrimaryDisplay() const { |
| 151 gfx::NativeView native_view = system_tray()->GetWidget()->GetNativeView(); | 151 gfx::NativeView native_view = system_tray()->GetWidget()->GetNativeView(); |
| 152 gfx::Display parent_display = | 152 display::Display parent_display = |
| 153 gfx::Screen::GetScreen()->GetDisplayNearestWindow(native_view); | 153 display::Screen::GetScreen()->GetDisplayNearestWindow(native_view); |
| 154 return parent_display.IsInternal(); | 154 return parent_display.IsInternal(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void TrayRotationLock::StopObservingRotation() { | 157 void TrayRotationLock::StopObservingRotation() { |
| 158 if (!observing_rotation_) | 158 if (!observing_rotation_) |
| 159 return; | 159 return; |
| 160 ScreenOrientationController* controller = | 160 ScreenOrientationController* controller = |
| 161 Shell::GetInstance()->screen_orientation_controller(); | 161 Shell::GetInstance()->screen_orientation_controller(); |
| 162 if (controller) | 162 if (controller) |
| 163 controller->RemoveObserver(this); | 163 controller->RemoveObserver(this); |
| 164 observing_rotation_ = false; | 164 observing_rotation_ = false; |
| 165 } | 165 } |
| 166 | 166 |
| 167 void TrayRotationLock::StopObservingShell() { | 167 void TrayRotationLock::StopObservingShell() { |
| 168 if (!observing_shell_) | 168 if (!observing_shell_) |
| 169 return; | 169 return; |
| 170 Shell::GetInstance()->RemoveShellObserver(this); | 170 Shell::GetInstance()->RemoveShellObserver(this); |
| 171 observing_shell_ = false; | 171 observing_shell_ = false; |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace ash | 174 } // namespace ash |
| OLD | NEW |