Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_controller.cc

Issue 895993002: Correcly Report CanEnterMaximizeMode on devices without accelerometers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/wm/maximize_mode/maximize_mode_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/wm/maximize_mode/maximize_mode_controller.h" 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 void MaximizeModeController::AddWindow(aura::Window* window) { 127 void MaximizeModeController::AddWindow(aura::Window* window) {
128 if (IsMaximizeModeWindowManagerEnabled()) 128 if (IsMaximizeModeWindowManagerEnabled())
129 maximize_mode_window_manager_->AddWindow(window); 129 maximize_mode_window_manager_->AddWindow(window);
130 } 130 }
131 131
132 #if defined(OS_CHROMEOS) 132 #if defined(OS_CHROMEOS)
133 void MaximizeModeController::OnAccelerometerUpdated( 133 void MaximizeModeController::OnAccelerometerUpdated(
134 const ui::AccelerometerUpdate& update) { 134 const ui::AccelerometerUpdate& update) {
135 if (!update.has(ui::ACCELEROMETER_SOURCE_SCREEN))
136 return;
137
135 bool first_accelerometer_update = !have_seen_accelerometer_data_; 138 bool first_accelerometer_update = !have_seen_accelerometer_data_;
136 have_seen_accelerometer_data_ = true; 139 have_seen_accelerometer_data_ = true;
137 140
138 if (!update.has(ui::ACCELEROMETER_SOURCE_SCREEN))
139 return;
140
141 // Whether or not we enter maximize mode affects whether we handle screen 141 // Whether or not we enter maximize mode affects whether we handle screen
142 // rotation, so determine whether to enter maximize mode first. 142 // rotation, so determine whether to enter maximize mode first.
143 if (!update.has(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD)) { 143 if (!update.has(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD)) {
144 if (first_accelerometer_update) 144 if (first_accelerometer_update)
145 EnterMaximizeMode(); 145 EnterMaximizeMode();
flackr 2015/02/03 22:32:11 Seems like this path (entering maximize mode when
jonross 2015/02/04 18:31:23 Done.
146 } else if (chromeos::AccelerometerReader::IsReadingStable( 146 } else if (chromeos::AccelerometerReader::IsReadingStable(
147 update, ui::ACCELEROMETER_SOURCE_SCREEN) && 147 update, ui::ACCELEROMETER_SOURCE_SCREEN) &&
148 chromeos::AccelerometerReader::IsReadingStable( 148 chromeos::AccelerometerReader::IsReadingStable(
149 update, ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) && 149 update, ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) &&
150 std::abs(update.get(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) 150 std::abs(update.get(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD)
151 .Length() - 151 .Length() -
152 update.get(ui::ACCELEROMETER_SOURCE_SCREEN).Length()) <= 152 update.get(ui::ACCELEROMETER_SOURCE_SCREEN).Length()) <=
153 kNoisyMagnitudeDeviation) { 153 kNoisyMagnitudeDeviation) {
154 // update.has(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) 154 // update.has(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD)
155 // Ignore the reading if it appears unstable. The reading is considered 155 // Ignore the reading if it appears unstable. The reading is considered
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return elapsed_time <= kLidRecentlyOpenedDuration; 302 return elapsed_time <= kLidRecentlyOpenedDuration;
303 } 303 }
304 304
305 void MaximizeModeController::SetTickClockForTest( 305 void MaximizeModeController::SetTickClockForTest(
306 scoped_ptr<base::TickClock> tick_clock) { 306 scoped_ptr<base::TickClock> tick_clock) {
307 DCHECK(tick_clock_); 307 DCHECK(tick_clock_);
308 tick_clock_ = tick_clock.Pass(); 308 tick_clock_ = tick_clock.Pass();
309 } 309 }
310 310
311 } // namespace ash 311 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/maximize_mode/maximize_mode_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698