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

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

Issue 2020553003: Hook up TABLET_MODE switch to maximize_mode_controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 <utility> 7 #include <utility>
8 8
9 #include "ash/accelerators/accelerator_controller.h" 9 #include "ash/accelerators/accelerator_controller.h"
10 #include "ash/accelerators/accelerator_table.h" 10 #include "ash/accelerators/accelerator_table.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 #endif // OS_CHROMEOS 97 #endif // OS_CHROMEOS
98 98
99 } // namespace 99 } // namespace
100 100
101 MaximizeModeController::MaximizeModeController() 101 MaximizeModeController::MaximizeModeController()
102 : have_seen_accelerometer_data_(false), 102 : have_seen_accelerometer_data_(false),
103 lid_open_past_180_(false), 103 lid_open_past_180_(false),
104 touchview_usage_interval_start_time_(base::Time::Now()), 104 touchview_usage_interval_start_time_(base::Time::Now()),
105 tick_clock_(new base::DefaultTickClock()), 105 tick_clock_(new base::DefaultTickClock()),
106 #if defined(OS_CHROMEOS)
107 force_maximize_mode_(false),
108 #endif
106 lid_is_closed_(false) { 109 lid_is_closed_(false) {
107 Shell* shell = Shell::GetInstance(); 110 Shell* shell = Shell::GetInstance();
108 shell->AddShellObserver(this); 111 shell->AddShellObserver(this);
109 shell->metrics()->RecordUserMetricsAction( 112 shell->metrics()->RecordUserMetricsAction(
110 ash::UMA_MAXIMIZE_MODE_INITIALLY_DISABLED); 113 ash::UMA_MAXIMIZE_MODE_INITIALLY_DISABLED);
111 114
112 #if defined(OS_CHROMEOS) 115 #if defined(OS_CHROMEOS)
113 // TODO(jonross): Do not create MaximizeModeController if the flag is 116 // TODO(jonross): Do not create MaximizeModeController if the flag is
114 // unavailable. This will require refactoring 117 // unavailable. This will require refactoring
115 // IsMaximizeModeWindowManagerEnabled to check for the existance of the 118 // IsMaximizeModeWindowManagerEnabled to check for the existance of the
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 220 }
218 221
219 void MaximizeModeController::LidEventReceived(bool open, 222 void MaximizeModeController::LidEventReceived(bool open,
220 const base::TimeTicks& time) { 223 const base::TimeTicks& time) {
221 if (open) 224 if (open)
222 last_lid_open_time_ = time; 225 last_lid_open_time_ = time;
223 lid_is_closed_ = !open; 226 lid_is_closed_ = !open;
224 LeaveMaximizeMode(); 227 LeaveMaximizeMode();
225 } 228 }
226 229
230 void MaximizeModeController::TabletModeEventReceived(
231 bool on,
232 const base::TimeTicks& time) {
233 if (on) {
234 force_maximize_mode_ = true;
235 EnterMaximizeMode();
236 } else {
237 force_maximize_mode_ = false;
238 // Set lid_open_past_180_ so that we get a chance to decide whether to
239 // leave maximize mode.
240 lid_open_past_180_ = true;
jonross 2016/06/03 03:27:19 I think that this should be set when the tablet mo
jcliang 2016/06/03 05:28:49 If lid_open_past_180_ is set when the tablet mode
241 }
242 }
243
227 void MaximizeModeController::SuspendImminent() { 244 void MaximizeModeController::SuspendImminent() {
228 // The system is about to suspend, so record TouchView usage interval metrics 245 // The system is about to suspend, so record TouchView usage interval metrics
229 // based on whether TouchView mode is currently active. 246 // based on whether TouchView mode is currently active.
230 RecordTouchViewUsageInterval(CurrentTouchViewIntervalType()); 247 RecordTouchViewUsageInterval(CurrentTouchViewIntervalType());
231 } 248 }
232 249
233 void MaximizeModeController::SuspendDone( 250 void MaximizeModeController::SuspendDone(
234 const base::TimeDelta& sleep_duration) { 251 const base::TimeDelta& sleep_duration) {
235 // We do not want TouchView usage metrics to include time spent in suspend. 252 // We do not want TouchView usage metrics to include time spent in suspend.
236 touchview_usage_interval_start_time_ = base::Time::Now(); 253 touchview_usage_interval_start_time_ = base::Time::Now();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 void MaximizeModeController::LeaveMaximizeMode() { 342 void MaximizeModeController::LeaveMaximizeMode() {
326 event_blocker_.reset(); 343 event_blocker_.reset();
327 344
328 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 345 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
329 switches::kAshEnableTouchViewTesting)) { 346 switches::kAshEnableTouchViewTesting)) {
330 // We don't let accelerometer updates interfere with the maximize mode 347 // We don't let accelerometer updates interfere with the maximize mode
331 // status as set by the touch-view-testing keyboard shortcut. 348 // status as set by the touch-view-testing keyboard shortcut.
332 return; 349 return;
333 } 350 }
334 351
352 #if defined(OS_CHROMEOS)
353 if (force_maximize_mode_)
354 return;
jonross 2016/06/03 03:27:19 With this here it is possible for the tablet mode
jcliang 2016/06/03 05:28:49 Done.
355 #endif
335 if (!IsMaximizeModeWindowManagerEnabled()) 356 if (!IsMaximizeModeWindowManagerEnabled())
336 return; 357 return;
337 EnableMaximizeModeWindowManager(false); 358 EnableMaximizeModeWindowManager(false);
338 } 359 }
339 360
340 // Called after maximize mode has started, windows might still animate though. 361 // Called after maximize mode has started, windows might still animate though.
341 void MaximizeModeController::OnMaximizeModeStarted() { 362 void MaximizeModeController::OnMaximizeModeStarted() {
342 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_INACTIVE); 363 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_INACTIVE);
343 } 364 }
344 365
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds; 436 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds;
416 } 437 }
417 438
418 void MaximizeModeController::SetTickClockForTest( 439 void MaximizeModeController::SetTickClockForTest(
419 std::unique_ptr<base::TickClock> tick_clock) { 440 std::unique_ptr<base::TickClock> tick_clock) {
420 DCHECK(tick_clock_); 441 DCHECK(tick_clock_);
421 tick_clock_ = std::move(tick_clock); 442 tick_clock_ = std::move(tick_clock);
422 } 443 }
423 444
424 } // namespace ash 445 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698