Index: ash/content/display/screen_orientation_delegate_chromeos.cc |
diff --git a/ash/content/display/screen_orientation_delegate_chromeos.cc b/ash/content/display/screen_orientation_delegate_chromeos.cc |
index 10d2b9bcf3ca662cda0831a3d7e073ea6074b870..a894b121036619ce11f917547ae0d3f022cde0ce 100644 |
--- a/ash/content/display/screen_orientation_delegate_chromeos.cc |
+++ b/ash/content/display/screen_orientation_delegate_chromeos.cc |
@@ -9,6 +9,7 @@ |
#include "ash/display/display_manager.h" |
#include "ash/shell.h" |
#include "ash/wm/maximize_mode/maximize_mode_controller.h" |
flackr
2014/11/27 15:39:15
Obsolete?
jonross
2014/12/10 17:57:30
Nope, used in ScreenOrientationDelegate::ScreenOri
|
+#include "base/auto_reset.h" |
#include "base/command_line.h" |
#include "content/public/browser/screen_orientation_provider.h" |
#include "content/public/browser/web_contents.h" |
@@ -49,7 +50,9 @@ namespace ash { |
ScreenOrientationDelegate::ScreenOrientationDelegate() |
: locking_window_(NULL), |
- natural_orientation_(GetDisplayNaturalOrientation()) { |
+ natural_orientation_(GetDisplayNaturalOrientation()), |
+ ignore_display_configuration_updates_(false), |
+ rotation_locked_(false) { |
content::ScreenOrientationProvider::SetDelegate(this); |
} |
@@ -57,6 +60,43 @@ ScreenOrientationDelegate::~ScreenOrientationDelegate() { |
content::ScreenOrientationProvider::SetDelegate(NULL); |
} |
+void ScreenOrientationDelegate::AddObserver(Observer* observer) { |
+ observers_.AddObserver(observer); |
+} |
+ |
+void ScreenOrientationDelegate::RemoveObserver(Observer* observer) { |
+ observers_.RemoveObserver(observer); |
+} |
+ |
+void ScreenOrientationDelegate::SetRotationLocked(bool rotation_locked) { |
+ if (rotation_locked_ == rotation_locked) |
+ return; |
+ base::AutoReset<bool> auto_ignore_display_configuration_updates( |
flackr
2014/11/27 15:39:15
Can you scope this to just the call which triggers
jonross
2014/12/10 17:57:30
Done.
|
+ &ignore_display_configuration_updates_, true); |
+ rotation_locked_ = rotation_locked; |
+ FOR_EACH_OBSERVER(Observer, observers_, |
+ OnRotationLockChanged(rotation_locked_)); |
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
+ if (!display_manager->HasInternalDisplay()) |
+ return; |
+ gfx::Display::Rotation current_rotation = |
+ display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
+ .rotation(); |
+ display_manager->RegisterDisplayRotationProperties(rotation_locked_, |
+ current_rotation); |
+} |
+ |
+void ScreenOrientationDelegate::SetDisplayRotation( |
+ gfx::Display::Rotation rotation) { |
+ base::AutoReset<bool> auto_ignore_display_configuration_updates( |
+ &ignore_display_configuration_updates_, true); |
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
+ if (!display_manager->HasInternalDisplay()) |
+ return; |
+ display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
+ rotation); |
+} |
+ |
bool ScreenOrientationDelegate::FullScreenRequired( |
content::WebContents* web_contents) { |
return true; |
@@ -66,13 +106,6 @@ void ScreenOrientationDelegate::Lock( |
content::WebContents* web_contents, |
blink::WebScreenOrientationLockType lock_orientation) { |
aura::Window* requesting_window = web_contents->GetNativeView(); |
- |
- // TODO(jonross): Make ScreenOrientationDelegate responsible for rotation |
- // lock. Have MaximizeModeController, and TrayRotationLock both use it |
- // instead. |
- MaximizeModeController* controller = |
- Shell::GetInstance()->maximize_mode_controller(); |
- |
// TODO(jonross): Track one rotation lock per window. When the active window |
// changes apply any corresponding rotation lock. |
if (!locking_window_) |
@@ -82,7 +115,7 @@ void ScreenOrientationDelegate::Lock( |
switch (lock_orientation) { |
case blink::WebScreenOrientationLockAny: |
- controller->SetRotationLocked(false); |
+ SetRotationLocked(false); |
locking_window_ = NULL; |
break; |
case blink::WebScreenOrientationLockDefault: |
@@ -108,7 +141,7 @@ void ScreenOrientationDelegate::Lock( |
blink::WebScreenOrientationLockLandscape); |
break; |
case blink::WebScreenOrientationLockNatural: |
- controller->LockRotation(gfx::Display::ROTATE_0); |
+ LockRotation(gfx::Display::ROTATE_0); |
break; |
default: |
NOTREACHED(); |
@@ -129,21 +162,26 @@ void ScreenOrientationDelegate::Unlock(content::WebContents* web_contents) { |
if (requesting_window != locking_window_) |
return; |
locking_window_ = NULL; |
- Shell::GetInstance()->maximize_mode_controller()->SetRotationLocked(false); |
+ SetRotationLocked(false); |
+} |
+ |
+void ScreenOrientationDelegate::LockRotation(gfx::Display::Rotation rotation) { |
+ SetRotationLocked(true); |
+ SetDisplayRotation(rotation); |
} |
void ScreenOrientationDelegate::LockRotationToPrimaryOrientation( |
blink::WebScreenOrientationLockType lock_orientation) { |
- Shell::GetInstance()->maximize_mode_controller()->LockRotation( |
- natural_orientation_ == lock_orientation ? gfx::Display::ROTATE_0 |
- : gfx::Display::ROTATE_90); |
+ LockRotation(natural_orientation_ == lock_orientation |
+ ? gfx::Display::ROTATE_0 |
+ : gfx::Display::ROTATE_90); |
} |
void ScreenOrientationDelegate::LockRotationToSecondaryOrientation( |
blink::WebScreenOrientationLockType lock_orientation) { |
- Shell::GetInstance()->maximize_mode_controller()->LockRotation( |
- natural_orientation_ == lock_orientation ? gfx::Display::ROTATE_180 |
- : gfx::Display::ROTATE_270); |
+ LockRotation(natural_orientation_ == lock_orientation |
+ ? gfx::Display::ROTATE_180 |
+ : gfx::Display::ROTATE_270); |
} |
void ScreenOrientationDelegate::LockToRotationMatchingOrientation( |
@@ -158,21 +196,19 @@ void ScreenOrientationDelegate::LockToRotationMatchingOrientation( |
gfx::Display::Rotation rotation = |
display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
.rotation(); |
- MaximizeModeController* controller = |
- Shell::GetInstance()->maximize_mode_controller(); |
if (natural_orientation_ == lock_orientation) { |
if (rotation == gfx::Display::ROTATE_0 || |
rotation == gfx::Display::ROTATE_180) { |
- controller->SetRotationLocked(true); |
+ SetRotationLocked(true); |
} else { |
- controller->LockRotation(gfx::Display::ROTATE_0); |
+ LockRotation(gfx::Display::ROTATE_0); |
} |
} else { |
if (rotation == gfx::Display::ROTATE_90 || |
rotation == gfx::Display::ROTATE_270) { |
- controller->SetRotationLocked(true); |
+ SetRotationLocked(true); |
} else { |
- controller->LockRotation(gfx::Display::ROTATE_90); |
+ LockRotation(gfx::Display::ROTATE_90); |
} |
} |
} |