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

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

Issue 2642853006: Remove the ash-enable-touch-view-testing flag (Closed)
Patch Set: Fix tests Created 3 years, 11 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/common/wm/maximize_mode/maximize_mode_controller.h" 5 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/ash_switches.h" 9 #include "ash/common/ash_switches.h"
10 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" 10 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 bool IsEnabled() { 81 bool IsEnabled() {
82 return base::CommandLine::ForCurrentProcess()->HasSwitch( 82 return base::CommandLine::ForCurrentProcess()->HasSwitch(
83 switches::kAshEnableTouchView); 83 switches::kAshEnableTouchView);
84 } 84 }
85 85
86 } // namespace 86 } // namespace
87 87
88 MaximizeModeController::MaximizeModeController() 88 MaximizeModeController::MaximizeModeController()
89 : have_seen_accelerometer_data_(false), 89 : have_seen_accelerometer_data_(false),
90 force_can_enter_maximize_mode_for_tests_(false),
90 touchview_usage_interval_start_time_(base::Time::Now()), 91 touchview_usage_interval_start_time_(base::Time::Now()),
91 tick_clock_(new base::DefaultTickClock()), 92 tick_clock_(new base::DefaultTickClock()),
92 tablet_mode_switch_is_on_(false), 93 tablet_mode_switch_is_on_(false),
93 lid_is_closed_(false) { 94 lid_is_closed_(false) {
94 WmShell::Get()->AddShellObserver(this); 95 WmShell::Get()->AddShellObserver(this);
95 WmShell::Get()->RecordUserMetricsAction(UMA_MAXIMIZE_MODE_INITIALLY_DISABLED); 96 WmShell::Get()->RecordUserMetricsAction(UMA_MAXIMIZE_MODE_INITIALLY_DISABLED);
96 97
97 // TODO(jonross): Do not create MaximizeModeController if the flag is 98 // TODO(jonross): Do not create MaximizeModeController if the flag is
98 // unavailable. This will require refactoring 99 // unavailable. This will require refactoring
99 // IsMaximizeModeWindowManagerEnabled to check for the existance of the 100 // IsMaximizeModeWindowManagerEnabled to check for the existance of the
100 // controller. 101 // controller.
101 const bool is_enabled = IsEnabled(); 102 if (IsEnabled()) {
102 if (is_enabled)
103 WmShell::Get()->AddDisplayObserver(this); 103 WmShell::Get()->AddDisplayObserver(this);
104
105 if (is_enabled)
106 chromeos::AccelerometerReader::GetInstance()->AddObserver(this); 104 chromeos::AccelerometerReader::GetInstance()->AddObserver(this);
105 }
107 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( 106 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
108 this); 107 this);
109 } 108 }
110 109
111 MaximizeModeController::~MaximizeModeController() { 110 MaximizeModeController::~MaximizeModeController() {
112 WmShell::Get()->RemoveShellObserver(this); 111 WmShell::Get()->RemoveShellObserver(this);
113 const bool is_enabled = IsEnabled(); 112
114 if (is_enabled) 113 if (IsEnabled()) {
115 WmShell::Get()->RemoveDisplayObserver(this); 114 WmShell::Get()->RemoveDisplayObserver(this);
116
117 if (is_enabled)
118 chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); 115 chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this);
116 }
119 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( 117 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(
120 this); 118 this);
121 } 119 }
122 120
123 bool MaximizeModeController::CanEnterMaximizeMode() { 121 bool MaximizeModeController::CanEnterMaximizeMode() {
124 // If we have ever seen accelerometer data, then HandleHingeRotation may 122 // If we have ever seen accelerometer data, then HandleHingeRotation may
125 // trigger maximize mode at some point in the future. 123 // trigger maximize mode at some point in the future.
126 // The --enable-touch-view-testing switch can also mean that we may enter
127 // maximize mode.
128 // TODO(mgiuca): This can result in false positives, as it returns true for 124 // TODO(mgiuca): This can result in false positives, as it returns true for
129 // any device with an accelerometer. Have TouchView-enabled devices explicitly 125 // any device with an accelerometer. Have TouchView-enabled devices explicitly
130 // set a flag, and change this implementation to simply return true iff the 126 // set a flag, and change this implementation to simply return true iff the
131 // flag is present (http://crbug.com/457445). 127 // flag is present (http://crbug.com/457445).
132 return have_seen_accelerometer_data_ || 128 return have_seen_accelerometer_data_ ||
Daniel Erat 2017/01/19 22:33:29 the comment makes me think that this should possib
afakhry 2017/01/24 03:00:09 That's a reasonable alternative, though from mgiuc
Daniel Erat 2017/01/24 04:30:06 would you mind updating/deleting the comment as pa
afakhry 2017/01/24 17:24:08 Done.
133 base::CommandLine::ForCurrentProcess()->HasSwitch( 129 force_can_enter_maximize_mode_for_tests_;
134 switches::kAshEnableTouchViewTesting);
135 } 130 }
136 131
137 // TODO(jcliang): Hide or remove EnableMaximizeModeWindowManager 132 // TODO(jcliang): Hide or remove EnableMaximizeModeWindowManager
138 // (http://crbug.com/620241). 133 // (http://crbug.com/620241).
139 void MaximizeModeController::EnableMaximizeModeWindowManager( 134 void MaximizeModeController::EnableMaximizeModeWindowManager(
140 bool should_enable) { 135 bool should_enable) {
141 bool is_enabled = !!maximize_mode_window_manager_.get(); 136 bool is_enabled = !!maximize_mode_window_manager_.get();
142 if (should_enable == is_enabled) 137 if (should_enable == is_enabled)
143 return; 138 return;
144 139
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 EnterMaximizeMode(); 304 EnterMaximizeMode();
310 } 305 }
311 } 306 }
312 307
313 void MaximizeModeController::EnterMaximizeMode() { 308 void MaximizeModeController::EnterMaximizeMode() {
314 // Always reset first to avoid creation before destruction of a previous 309 // Always reset first to avoid creation before destruction of a previous
315 // object. 310 // object.
316 event_blocker_ = 311 event_blocker_ =
317 WmShell::Get()->CreateScopedDisableInternalMouseAndKeyboard(); 312 WmShell::Get()->CreateScopedDisableInternalMouseAndKeyboard();
318 313
319 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
320 switches::kAshEnableTouchViewTesting)) {
321 // We don't let accelerometer updates interfere with the maximize mode
322 // status as set by the touch-view-testing keyboard shortcut.
323 return;
324 }
325
326 if (IsMaximizeModeWindowManagerEnabled()) 314 if (IsMaximizeModeWindowManagerEnabled())
327 return; 315 return;
328 EnableMaximizeModeWindowManager(true); 316 EnableMaximizeModeWindowManager(true);
329 } 317 }
330 318
331 void MaximizeModeController::LeaveMaximizeMode() { 319 void MaximizeModeController::LeaveMaximizeMode() {
332 event_blocker_.reset(); 320 event_blocker_.reset();
333 321
334 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
335 switches::kAshEnableTouchViewTesting)) {
336 // We don't let accelerometer updates interfere with the maximize mode
337 // status as set by the touch-view-testing keyboard shortcut.
338 return;
339 }
340
341 if (!IsMaximizeModeWindowManagerEnabled()) 322 if (!IsMaximizeModeWindowManagerEnabled())
342 return; 323 return;
343 EnableMaximizeModeWindowManager(false); 324 EnableMaximizeModeWindowManager(false);
344 } 325 }
345 326
346 // Called after maximize mode has started, windows might still animate though. 327 // Called after maximize mode has started, windows might still animate though.
347 void MaximizeModeController::OnMaximizeModeStarted() { 328 void MaximizeModeController::OnMaximizeModeStarted() {
348 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_INACTIVE); 329 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_INACTIVE);
349 } 330 }
350 331
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds; 408 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds;
428 } 409 }
429 410
430 void MaximizeModeController::SetTickClockForTest( 411 void MaximizeModeController::SetTickClockForTest(
431 std::unique_ptr<base::TickClock> tick_clock) { 412 std::unique_ptr<base::TickClock> tick_clock) {
432 DCHECK(tick_clock_); 413 DCHECK(tick_clock_);
433 tick_clock_ = std::move(tick_clock); 414 tick_clock_ = std::move(tick_clock);
434 } 415 }
435 416
436 } // namespace ash 417 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698