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

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 tablet_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 tablet_mode_ = true;
235 EnterMaximizeMode();
236 } else {
237 tablet_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;
Daniel Erat 2016/06/03 15:00:18 this doesn't seem right. this member feels like it
jonross 2016/06/03 16:27:24 Though the lid_open_past_180_ may actually be what
jcliang 2016/06/06 04:39:22 This is removed. I use another tablet_mode_swithc_
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // status as set by the touch-view-testing keyboard shortcut. 333 // status as set by the touch-view-testing keyboard shortcut.
317 return; 334 return;
318 } 335 }
319 336
320 if (IsMaximizeModeWindowManagerEnabled()) 337 if (IsMaximizeModeWindowManagerEnabled())
321 return; 338 return;
322 EnableMaximizeModeWindowManager(true); 339 EnableMaximizeModeWindowManager(true);
323 } 340 }
324 341
325 void MaximizeModeController::LeaveMaximizeMode() { 342 void MaximizeModeController::LeaveMaximizeMode() {
343 #if defined(OS_CHROMEOS)
344 if (tablet_mode_)
Daniel Erat 2016/06/03 15:00:18 i don't think i've looked at this code before, but
jonross 2016/06/03 16:27:24 The 'update state' method is HandleHingeRotation.
Daniel Erat 2016/06/03 16:59:51 what if the "decide what to do" code from HandleHi
jcliang 2016/06/06 04:39:22 This is removed. Everything is handled in HandleHi
345 return;
346 #endif
347
326 event_blocker_.reset(); 348 event_blocker_.reset();
327 349
328 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 350 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
329 switches::kAshEnableTouchViewTesting)) { 351 switches::kAshEnableTouchViewTesting)) {
330 // We don't let accelerometer updates interfere with the maximize mode 352 // We don't let accelerometer updates interfere with the maximize mode
331 // status as set by the touch-view-testing keyboard shortcut. 353 // status as set by the touch-view-testing keyboard shortcut.
332 return; 354 return;
333 } 355 }
334 356
335 if (!IsMaximizeModeWindowManagerEnabled()) 357 if (!IsMaximizeModeWindowManagerEnabled())
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds; 437 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds;
416 } 438 }
417 439
418 void MaximizeModeController::SetTickClockForTest( 440 void MaximizeModeController::SetTickClockForTest(
419 std::unique_ptr<base::TickClock> tick_clock) { 441 std::unique_ptr<base::TickClock> tick_clock) {
420 DCHECK(tick_clock_); 442 DCHECK(tick_clock_);
421 tick_clock_ = std::move(tick_clock); 443 tick_clock_ = std::move(tick_clock);
422 } 444 }
423 445
424 } // namespace ash 446 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698