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.
4
5#include "base/command_line.h"
6#include "base/logging.h"
7#include "ui/events/event_switches.h"
8#include "ui/events/gestures/unified_gesture_detector_enabled.h"
9
10namespace ui {
11
12bool IsUnifiedGestureDetectorEnabled() {
13  const bool kUseUnifiedGestureDetectorByDefault = true;
14
15  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
16  const std::string unified_gd_enabled_switch =
17      command_line.HasSwitch(switches::kUnifiedGestureDetector) ?
18      command_line.GetSwitchValueASCII(switches::kUnifiedGestureDetector) :
19      switches::kUnifiedGestureDetectorAuto;
20
21  if (unified_gd_enabled_switch.empty() ||
22      unified_gd_enabled_switch == switches::kUnifiedGestureDetectorEnabled) {
23    return true;
24  }
25
26  if (unified_gd_enabled_switch == switches::kUnifiedGestureDetectorDisabled)
27    return false;
28
29  if (unified_gd_enabled_switch == switches::kUnifiedGestureDetectorAuto)
30    return kUseUnifiedGestureDetectorByDefault;
31
32  LOG(ERROR) << "Invalid --unified-gesture-detector option: "
33             << unified_gd_enabled_switch;
34  return false;
35}
36
37}  // namespace ui
38