blob: f449885f136377a1edb5436d43cc2cc882d0b526 [file] [log] [blame]
// 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.
#include <string>
#include <vector>
#include "base/logging.h"
#include "chrome/common/media_router/media_route.h"
namespace media_router {
// Contains the information relevant to an issue.
struct IssueInfo {
// Possible actions for an issue.
enum class Action {
// 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.
// Denotes enum value boundary. New values should be added above.
// 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.
// |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& 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.
std::string route_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 {
using Id = int;
// ID is generated during construction.
explicit Issue(const IssueInfo& info);
Issue(const Issue& other) = default;
Issue& operator=(const Issue& other) = default;
const Id& id() const { return id_; }
const IssueInfo& info() const { return info_; }
Id id_;
IssueInfo info_;
} // namespace media_router