summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorBartosz Fabianowski <bartfab@chromium.org>2015-04-16 12:27:51 +0200
committerBartosz Fabianowski <bartfab@chromium.org>2015-04-16 10:28:32 +0000
commit85a8238181175de195158bf1554f530cd0f6e3f1 (patch)
tree72b0b33ece151dc9cdb2e7af36e8d554ec64350e /ash
parent919dce4400651813d5ff6e8a85b944a5987adcb7 (diff)
downloadchromium_src-85a8238181175de195158bf1554f530cd0f6e3f1.zip
chromium_src-85a8238181175de195158bf1554f530cd0f6e3f1.tar.gz
chromium_src-85a8238181175de195158bf1554f530cd0f6e3f1.tar.bz2
Revert "Speculative revert by sheriff"
This reverts commit 919dce4400651813d5ff6e8a85b944a5987adcb7. BUG=None TBR=akuegel Review URL: https://codereview.chromium.org/1094553002 Cr-Commit-Position: refs/heads/master@{#325412}
Diffstat (limited to 'ash')
-rw-r--r--ash/content/display/screen_orientation_controller_chromeos.cc22
-rw-r--r--ash/content/display/screen_orientation_controller_chromeos_unittest.cc19
2 files changed, 31 insertions, 10 deletions
diff --git a/ash/content/display/screen_orientation_controller_chromeos.cc b/ash/content/display/screen_orientation_controller_chromeos.cc
index 07659d7c..dbd4465 100644
--- a/ash/content/display/screen_orientation_controller_chromeos.cc
+++ b/ash/content/display/screen_orientation_controller_chromeos.cc
@@ -196,10 +196,11 @@ void ScreenOrientationController::Unlock(content::WebContents* web_contents) {
void ScreenOrientationController::OnDisplayConfigurationChanged() {
if (ignore_display_configuration_updates_)
return;
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager();
+ if (!display_manager->HasInternalDisplay())
+ return;
gfx::Display::Rotation user_rotation =
- Shell::GetInstance()
- ->display_manager()
- ->GetDisplayInfo(gfx::Display::InternalDisplayId())
+ display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
.rotation();
if (user_rotation != current_rotation_) {
// A user may change other display configuration settings. When the user
@@ -212,11 +213,14 @@ void ScreenOrientationController::OnDisplayConfigurationChanged() {
void ScreenOrientationController::OnMaximizeModeStarted() {
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
- if (!display_manager->HasInternalDisplay())
- return;
- current_rotation_ = user_rotation_ =
- display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
- .rotation();
+ // Do not exit early, as the internal display can be determined after Maximize
+ // Mode has started. (chrome-os-partner:38796)
+ // Always start observing.
+ if (display_manager->HasInternalDisplay()) {
+ current_rotation_ = user_rotation_ =
+ display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
+ .rotation();
+ }
if (!rotation_locked_)
LoadDisplayRotationProperties();
chromeos::AccelerometerReader::GetInstance()->AddObserver(this);
@@ -224,8 +228,6 @@ void ScreenOrientationController::OnMaximizeModeStarted() {
}
void ScreenOrientationController::OnMaximizeModeEnded() {
- if (!Shell::GetInstance()->display_manager()->HasInternalDisplay())
- return;
chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this);
Shell::GetInstance()->display_controller()->RemoveObserver(this);
if (current_rotation_ != user_rotation_)
diff --git a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc
index ca02ca3..342e958 100644
--- a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc
+++ b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc
@@ -589,4 +589,23 @@ TEST_F(ScreenOrientationControllerTest, UserRotationLockDisallowsRotation) {
EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
}
+// Tests that when MaximizeMode is triggered before the internal display is
+// ready, that ScreenOrientationController still begins listening to events,
+// which require an internal display to be acted upon.
+TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) {
+ int64 internal_display_id = gfx::Display::InternalDisplayId();
+ gfx::Display::SetInternalDisplayId(gfx::Display::kInvalidDisplayID);
+
+ EnableMaximizeMode(true);
+
+ // Should not crash, even thought there is no internal display.
+ SetInternalDisplayRotation(gfx::Display::ROTATE_180);
+ EXPECT_FALSE(RotationLocked());
+
+ // With an internal display now available, functionality should resume.
+ gfx::Display::SetInternalDisplayId(internal_display_id);
+ SetInternalDisplayRotation(gfx::Display::ROTATE_90);
+ EXPECT_TRUE(RotationLocked());
+}
+
} // namespace ash