platformKeys: Add per-extension sign permissions.
[chromium-blink-merge.git] / ash / wm / workspace / two_step_edge_cycler.cc
blob45bedebe3c947d16e7a9ea96526c036b2ec16fef
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
3 // found in the LICENSE file.
5 #include "ash/wm/workspace/two_step_edge_cycler.h"
7 #include <cstdlib>
9 namespace ash {
10 namespace {
12 // We cycle to the second mode if any of the following happens while the mouse
13 // is on the edge of the workspace:
14 // . The user stops moving the mouse for |kMaxDelay| and then moves the mouse
15 // again.
16 // . The mouse moves |kMaxPixels| horizontal pixels.
17 // . The mouse is moved |kMaxMoves| times.
18 const int kMaxDelay = 500;
19 const int kMaxPixels = 100;
20 const int kMaxMoves = 25;
22 } // namespace
24 TwoStepEdgeCycler::TwoStepEdgeCycler(const gfx::Point& start)
25 : second_mode_(false),
26 time_last_move_(base::TimeTicks::Now()),
27 num_moves_(0),
28 start_x_(start.x()) {
31 TwoStepEdgeCycler::~TwoStepEdgeCycler() {
34 void TwoStepEdgeCycler::OnMove(const gfx::Point& location) {
35 if (second_mode_)
36 return;
38 ++num_moves_;
39 second_mode_ =
40 (base::TimeTicks::Now() - time_last_move_).InMilliseconds() >
41 kMaxDelay ||
42 std::abs(location.x() - start_x_) >= kMaxPixels ||
43 num_moves_ >= kMaxMoves;
44 time_last_move_ = base::TimeTicks::Now();
47 } // namespace ash