summaryrefslogtreecommitdiff
path: root/chromium/chrome/common/media_router/issue.h
blob: 840c37476455981ee84a577008c14385fc6dfcbc (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright 2015 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 CHROME_COMMON_MEDIA_ROUTER_ISSUE_H_
#define CHROME_COMMON_MEDIA_ROUTER_ISSUE_H_

#include <string>
#include <vector>

#include "chrome/common/media_router/media_route.h"
#include "chrome/common/media_router/media_sink.h"

namespace media_router {

// Contains the information relevant to an issue.
struct IssueInfo {
 public:
  // Possible actions for an issue.
  enum class Action {
    DISMISS,
    // NOTE: If LEARN_MORE is set as a possible action for an issue, then its
    // |help_page_id_| must also be set to a valid value.
    LEARN_MORE,

    // Denotes enum value boundary. New values should be added above.
    NUM_VALUES = LEARN_MORE
  };

  // Severity type of an issue. A FATAL issue is considered blocking. Although
  // issues of other severity levels may also be blocking.
  enum class Severity { FATAL, WARNING, NOTIFICATION };

  static const int kUnknownHelpPageId = 0;

  // Used by Mojo and testing only.
  IssueInfo();

  // |title|: The title for the issue.
  // |default_action|: Default action user can take to resolve the issue.
  // |severity|: The severity of the issue. If FATAL, then |is_blocking| is set
  // to |true|.
  IssueInfo(const std::string& title, Action default_action, Severity severity);
  IssueInfo(const IssueInfo& other);
  ~IssueInfo();

  IssueInfo& operator=(const IssueInfo& other);
  bool operator==(const IssueInfo& other) const;

  // Fields set with values provided to the constructor.
  std::string title;
  Action default_action;
  Severity severity;

  // Description message for the issue.
  std::string message;

  // Options the user can take to resolve the issue in addition to the
  // default action. Can be empty. If non-empty, currently only one secondary
  // action is supported.
  std::vector<Action> secondary_actions;

  // ID of route associated with the Issue, or empty if no route is associated
  // with it.
  MediaRoute::Id route_id;

  // ID of the sink associated with this issue, or empty if no sink is
  // associated with it.
  MediaSink::Id sink_id;

  // |true| if the issue needs to be resolved before continuing. Note that a
  // Issue of severity FATAL is considered blocking by default.
  bool is_blocking;

  // ID of help page to link to, if one of the actions is LEARN_MORE.
  // Defaults to |kUnknownHelpPageId|.
  int help_page_id;
};

// An issue that is associated with a globally unique ID. Created by
// IssueManager when an IssueInfo is added to it.
class Issue {
 public:
  using Id = int;
  // ID is generated during construction.
  explicit Issue(const IssueInfo& info);
  Issue(const Issue& other) = default;
  Issue& operator=(const Issue& other) = default;
  ~Issue();

  const Id& id() const { return id_; }
  const IssueInfo& info() const { return info_; }

 private:
  Id id_;
  IssueInfo info_;
};

}  // namespace media_router

#endif  // CHROME_COMMON_MEDIA_ROUTER_ISSUE_H_