Chromium Code Reviews| Index: ash/content/display/screen_orientation_controller_chromeos.h |
| diff --git a/ash/content/display/screen_orientation_controller_chromeos.h b/ash/content/display/screen_orientation_controller_chromeos.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ac9ded045126a4dc9a582386f75dfe6f0d5d8fa6 |
| --- /dev/null |
| +++ b/ash/content/display/screen_orientation_controller_chromeos.h |
| @@ -0,0 +1,145 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ASH_CONTENT_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ |
| +#define ASH_CONTENT_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ |
| + |
| +#include "ash/accelerometer/accelerometer_observer.h" |
| +#include "ash/ash_export.h" |
| +#include "ash/display/display_controller.h" |
| +#include "ash/shell_observer.h" |
| +#include "base/macros.h" |
| +#include "base/observer_list.h" |
| +#include "content/public/browser/screen_orientation_delegate.h" |
| +#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" |
| +#include "ui/gfx/display.h" |
| + |
| +namespace aura { |
| +class Window; |
| +} |
| + |
| +namespace content { |
| +class WebContents; |
| +} |
| + |
| +namespace ash { |
| + |
| +// Implements ChromeOS specific functionality for ScreenOrientationProvider. |
| +class ASH_EXPORT ScreenOrientationController |
| + : public AccelerometerObserver, |
| + public content::ScreenOrientationDelegate, |
| + public DisplayController::Observer, |
| + public ShellObserver { |
| + public: |
| + // Observer that reports changes to the state of ScreenOrientationProvider's |
| + // rotation lock. |
| + class Observer { |
| + public: |
| + // Invoked when rotation is locked or unlocked. |
| + virtual void OnRotationLockChanged(bool rotation_locked) {} |
| + |
| + protected: |
| + virtual ~Observer() {} |
| + }; |
| + |
| + ScreenOrientationController(); |
| + virtual ~ScreenOrientationController(); |
| + |
| + // Add/Remove observers. |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| + bool ignore_display_configuration_updates() const { |
| + return ignore_display_configuration_updates_; |
| + } |
| + |
| + // True if |rotation_lock_| has been set and accelerometer updates should not |
| + // rotate the display. |
| + bool rotation_locked() { return rotation_locked_; } |
|
oshima
2014/12/11 23:51:28
nit: const
jonross
2014/12/12 18:30:04
Done.
|
| + |
| + // If |rotation_locked| future accelerometer updates should not change the |
| + // display rotation. |
| + void SetRotationLocked(bool rotation_locked); |
| + |
| + // Sets the display rotation and suppresses display notifications. |
| + void SetDisplayRotation(gfx::Display::Rotation rotation); |
| + |
| + // AccelerometerObserver: |
| + void OnAccelerometerUpdated(const ui::AccelerometerUpdate& update) override; |
| + |
| + // content::ScreenOrientationDelegate: |
| + bool FullScreenRequired(content::WebContents* web_contents) override; |
| + void Lock(content::WebContents* web_contents, |
| + blink::WebScreenOrientationLockType lock_orientation) override; |
| + bool ScreenOrientationProviderSupported() override; |
| + void Unlock(content::WebContents* web_contents) override; |
| + |
| + // DisplayController::Observer: |
| + void OnDisplayConfigurationChanged() override; |
| + |
| + // ShellObserver: |
| + void OnMaximizeModeStarted() override; |
| + void OnMaximizeModeEnded() override; |
| + |
| + private: |
| + // Sets the display rotation to |rotation|. Future accelerometer updates |
| + // should not be used to change the rotation. SetRotationLocked(false) removes |
| + // the rotation lock. |
| + void LockRotation(gfx::Display::Rotation rotation); |
| + |
| + // Locks rotation to the angle matching the primary orientation for |
| + // |lock_orientation|. |
| + void LockRotationToPrimaryOrientation( |
| + blink::WebScreenOrientationLockType lock_orientation); |
| + |
| + // Locks rotation to the angle matching the secondary orientation for |
| + // |lock_orientation|. |
| + void LockRotationToSecondaryOrientation( |
| + blink::WebScreenOrientationLockType lock_orientation); |
| + |
| + // For orientations that do not specify primary or secondary, locks to the |
| + // current rotation if it matches |lock_orientation|. Otherwise locks to a |
| + // matching rotation. |
| + void LockToRotationMatchingOrientation( |
| + blink::WebScreenOrientationLockType lock_orientation); |
| + |
| + // Detect screen rotation from |lid| accelerometer and automatically rotate |
| + // screen. |
| + void HandleScreenRotation(const gfx::Vector3dF& lid); |
| + |
| + // Checks DisplayManager for registered rotation lock, and rotation, |
| + // preferences. These are then applied. |
| + void LoadDisplayRotationProperties(); |
| + |
| + // The window that has applied the current lock. No other window can apply a |
| + // lock until the current window unlocks rotation. |
| + aura::Window* locking_window_; |
| + |
| + // The orientation of the display when at a rotation of 0. |
| + blink::WebScreenOrientationLockType natural_orientation_; |
| + |
| + // True when changes being applied cause OnDisplayConfigurationChanged() to be |
| + // called, and for which these changes should be ignored. |
| + bool ignore_display_configuration_updates_; |
| + |
| + // When true then accelerometer updates should not rotate the display. |
| + bool rotation_locked_; |
| + |
| + // The rotation of the display set by the user. This rotation will be |
| + // restored upon exiting maximize mode. |
| + gfx::Display::Rotation user_rotation_; |
| + |
| + // The current rotation set by ScreenOrientationController for the internal |
| + // display. |
| + gfx::Display::Rotation current_rotation_; |
| + |
| + // Rotation Lock observers. |
| + ObserverList<Observer> observers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScreenOrientationController); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_CONTENT_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ |