Roll src/third_party/WebKit 06cb9e9:a978ee5 (svn 202558:202559)
[chromium-blink-merge.git] / ash / system / chromeos / rotation / tray_rotation_lock.h
blobaa4853ed49c4c91e3386ac8df96ffdc2a7699bbe
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
3 // found in the LICENSE file.
5 #ifndef ASH_SYSTEM_CHROMEOS_ROTATION_TRAY_ROTATION_LOCK_H_
6 #define ASH_SYSTEM_CHROMEOS_ROTATION_TRAY_ROTATION_LOCK_H_
8 #include "ash/content/display/screen_orientation_controller_chromeos.h"
9 #include "ash/shell_observer.h"
10 #include "ash/system/tray/tray_image_item.h"
12 namespace ash {
14 namespace tray {
15 class RotationLockDefaultView;
16 } // namespace tray
18 // TrayRotationLock is a provider of views for the SystemTray. Both a tray view
19 // and a default view are provided. Each view indicates the current state of
20 // the rotation lock for the display which it appears on. The default view can
21 // be interacted with, it toggles the state of the rotation lock.
22 // TrayRotationLock is only available on the primary display.
23 class ASH_EXPORT TrayRotationLock
24 : public TrayImageItem,
25 public ScreenOrientationController::Observer,
26 public ShellObserver {
27 public:
28 explicit TrayRotationLock(SystemTray* system_tray);
29 ~TrayRotationLock() override;
31 // ScreenOrientationController::Observer:
32 void OnRotationLockChanged(bool rotation_locked) override;
34 // SystemTrayItem:
35 views::View* CreateDefaultView(user::LoginStatus status) override;
37 // ShellObserver:
38 void OnMaximizeModeStarted() override;
39 void OnMaximizeModeEnded() override;
41 // TrayImageItem:
42 void DestroyTrayView() override;
44 protected:
45 // TrayImageItem:
46 bool GetInitialVisibility() override;
48 private:
49 friend class TrayRotationLockTest;
51 // True if |on_primary_display_|, maximize mode is enabled, and rotation is
52 // locked.
53 bool ShouldBeVisible();
55 // True if this is owned by a SystemTray on the primary display.
56 bool OnPrimaryDisplay() const;
58 // Removes TrayRotationLock as a ScreenOrientationController::Observer if
59 // currently observing.
60 void StopObservingRotation();
62 // Removes TrayRotationLock as a ShellObserver if currently observing.
63 void StopObservingShell();
65 // True while added as a ScreenOrientationController::Observer.
66 bool observing_rotation_;
68 // True while added as a ShellObserver.
69 bool observing_shell_;
71 DISALLOW_COPY_AND_ASSIGN(TrayRotationLock);
74 } // namespace ash
76 #endif // ASH_SYSTEM_CHROMEOS_ROTATION_TRAY_ROTATION_LOCK_H_