summaryrefslogtreecommitdiff
path: root/chromium/content/common/input/actions_parser.h
blob: 4894ac69584ddfec3d621a1eca7217d1ad082295 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_COMMON_INPUT_ACTIONS_PARSER_H_
#define CONTENT_COMMON_INPUT_ACTIONS_PARSER_H_

#include <cstddef>
#include <set>
#include <string>

#include "content/common/input/synthetic_pointer_action_list_params.h"

namespace base {
class Value;
}  // namespace base

namespace content {

// This class takes the argument of json format from
// GpuBenchmarking::PointerActionSequence, parses it and warps
// it into a SyntheticPointerActionListParams object.
class CONTENT_EXPORT ActionsParser {
 public:
  explicit ActionsParser(base::Value value);
  ~ActionsParser();
  bool ParsePointerActionSequence();
  const std::string& error_message() const { return error_message_; }
  const SyntheticPointerActionListParams& gesture_params() const {
    return gesture_params_;
  }

 private:
  bool ParsePointerActions(const base::Value& pointer_actions, int index);
  bool ParseActions(const base::Value& actions, int pointer_id);
  bool ParseAction(const base::Value& action,
                   SyntheticPointerActionListParams::ParamList& param_list,
                   int pointer_id);

  SyntheticPointerActionListParams gesture_params_;
  std::vector<SyntheticPointerActionListParams::ParamList>
      pointer_actions_list_;
  size_t longest_action_sequence_;
  std::string source_type_;
  std::string pointer_type_;
  std::string error_message_;

  base::Value pointer_actions_value_;
  int action_index_;
  std::set<int> pointer_id_set_;
  std::set<std::string> pointer_name_set_;
  bool use_testdriver_api_;

  DISALLOW_COPY_AND_ASSIGN(ActionsParser);
};

}  // namespace content

#endif  // CONTENT_COMMON_INPUT_ACTIONS_PARSER_H_