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

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

Issue 2505403003: TouchView Mojom (Closed)
Patch Set: Minor param rename Created 4 years 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 | « ash/common/wm/maximize_mode/maximize_mode_controller.h ('k') | ash/mus/manifest.json » ('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/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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return; 156 return;
157 157
158 WmShell* shell = WmShell::Get(); 158 WmShell* shell = WmShell::Get();
159 159
160 if (should_enable) { 160 if (should_enable) {
161 maximize_mode_window_manager_.reset(new MaximizeModeWindowManager()); 161 maximize_mode_window_manager_.reset(new MaximizeModeWindowManager());
162 // TODO(jonross): Move the maximize mode notifications from ShellObserver 162 // TODO(jonross): Move the maximize mode notifications from ShellObserver
163 // to MaximizeModeController::Observer 163 // to MaximizeModeController::Observer
164 shell->RecordUserMetricsAction(UMA_MAXIMIZE_MODE_ENABLED); 164 shell->RecordUserMetricsAction(UMA_MAXIMIZE_MODE_ENABLED);
165 shell->OnMaximizeModeStarted(); 165 shell->OnMaximizeModeStarted();
166
167 observers_.ForAllPtrs([](mojom::TouchViewObserver* observer) {
168 observer->OnTouchViewToggled(true);
169 });
170
166 } else { 171 } else {
167 maximize_mode_window_manager_.reset(); 172 maximize_mode_window_manager_.reset();
168 shell->RecordUserMetricsAction(UMA_MAXIMIZE_MODE_DISABLED); 173 shell->RecordUserMetricsAction(UMA_MAXIMIZE_MODE_DISABLED);
169 shell->OnMaximizeModeEnded(); 174 shell->OnMaximizeModeEnded();
175
176 observers_.ForAllPtrs([](mojom::TouchViewObserver* observer) {
177 observer->OnTouchViewToggled(false);
178 });
170 } 179 }
171 } 180 }
172 181
173 bool MaximizeModeController::IsMaximizeModeWindowManagerEnabled() const { 182 bool MaximizeModeController::IsMaximizeModeWindowManagerEnabled() const {
174 return maximize_mode_window_manager_.get() != NULL; 183 return maximize_mode_window_manager_.get() != NULL;
175 } 184 }
176 185
177 void MaximizeModeController::AddWindow(WmWindow* window) { 186 void MaximizeModeController::AddWindow(WmWindow* window) {
178 if (IsMaximizeModeWindowManagerEnabled()) 187 if (IsMaximizeModeWindowManagerEnabled())
179 maximize_mode_window_manager_->AddWindow(window); 188 maximize_mode_window_manager_->AddWindow(window);
180 } 189 }
181 190
191 void MaximizeModeController::BindRequest(
192 mojom::TouchViewManagerRequest request) {
193 bindings_.AddBinding(this, std::move(request));
194 }
195
182 #if defined(OS_CHROMEOS) 196 #if defined(OS_CHROMEOS)
183 void MaximizeModeController::OnAccelerometerUpdated( 197 void MaximizeModeController::OnAccelerometerUpdated(
184 scoped_refptr<const chromeos::AccelerometerUpdate> update) { 198 scoped_refptr<const chromeos::AccelerometerUpdate> update) {
185 bool first_accelerometer_update = !have_seen_accelerometer_data_; 199 bool first_accelerometer_update = !have_seen_accelerometer_data_;
186 have_seen_accelerometer_data_ = true; 200 have_seen_accelerometer_data_ = true;
187 201
188 if (!update->has(chromeos::ACCELEROMETER_SOURCE_SCREEN)) 202 if (!update->has(chromeos::ACCELEROMETER_SOURCE_SCREEN))
189 return; 203 return;
190 204
191 if (!display::Display::HasInternalDisplay()) 205 if (!display::Display::HasInternalDisplay())
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 touchview_usage_interval_start_time_ = current_time; 398 touchview_usage_interval_start_time_ = current_time;
385 } 399 }
386 400
387 MaximizeModeController::TouchViewIntervalType 401 MaximizeModeController::TouchViewIntervalType
388 MaximizeModeController::CurrentTouchViewIntervalType() { 402 MaximizeModeController::CurrentTouchViewIntervalType() {
389 if (IsMaximizeModeWindowManagerEnabled()) 403 if (IsMaximizeModeWindowManagerEnabled())
390 return TOUCH_VIEW_INTERVAL_ACTIVE; 404 return TOUCH_VIEW_INTERVAL_ACTIVE;
391 return TOUCH_VIEW_INTERVAL_INACTIVE; 405 return TOUCH_VIEW_INTERVAL_INACTIVE;
392 } 406 }
393 407
408 void MaximizeModeController::AddObserver(mojom::TouchViewObserverPtr observer) {
409 observer->OnTouchViewToggled(IsMaximizeModeWindowManagerEnabled());
410 observers_.AddPtr(std::move(observer));
411 }
412
394 void MaximizeModeController::OnAppTerminating() { 413 void MaximizeModeController::OnAppTerminating() {
395 // The system is about to shut down, so record TouchView usage interval 414 // The system is about to shut down, so record TouchView usage interval
396 // metrics based on whether TouchView mode is currently active. 415 // metrics based on whether TouchView mode is currently active.
397 RecordTouchViewUsageInterval(CurrentTouchViewIntervalType()); 416 RecordTouchViewUsageInterval(CurrentTouchViewIntervalType());
398 417
399 if (CanEnterMaximizeMode()) { 418 if (CanEnterMaximizeMode()) {
400 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewActiveTotal", 419 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewActiveTotal",
401 total_touchview_time_.InMinutes(), 1, 420 total_touchview_time_.InMinutes(), 1,
402 base::TimeDelta::FromDays(7).InMinutes(), 50); 421 base::TimeDelta::FromDays(7).InMinutes(), 50);
403 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewInactiveTotal", 422 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchView.TouchViewInactiveTotal",
(...skipping 19 matching lines...) Expand all
423 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds; 442 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds;
424 } 443 }
425 444
426 void MaximizeModeController::SetTickClockForTest( 445 void MaximizeModeController::SetTickClockForTest(
427 std::unique_ptr<base::TickClock> tick_clock) { 446 std::unique_ptr<base::TickClock> tick_clock) {
428 DCHECK(tick_clock_); 447 DCHECK(tick_clock_);
429 tick_clock_ = std::move(tick_clock); 448 tick_clock_ = std::move(tick_clock);
430 } 449 }
431 450
432 } // namespace ash 451 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/maximize_mode/maximize_mode_controller.h ('k') | ash/mus/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698