1// Copyright (c) 2013 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#ifndef EXTENSIONS_COMMON_INSTALL_WARNING_H_
6#define EXTENSIONS_COMMON_INSTALL_WARNING_H_
7
8#include "base/macros.h"
9
10#include <ostream>
11#include <string>
12
13namespace extensions {
14
15// A struct to describe a non-fatal issue discovered in the installation of an
16// extension.
17struct InstallWarning {
18 explicit InstallWarning(const std::string& message);
19 InstallWarning(const std::string& message,
20 const std::string& key);
21 InstallWarning(const std::string& message,
22 const std::string& key,
23 const std::string& specific);
24 InstallWarning(InstallWarning&& other);
25 InstallWarning& operator=(InstallWarning&& other);
26 ~InstallWarning();
27
28 bool operator==(const InstallWarning& other) const {
29 // We don't have to look at |key| or |specific| here, because they are each
30 // used in the the message itself.
31 // For example, a full message would be "Permission 'foo' is unknown or URL
32 // pattern is malformed." |key| here is "permissions", and |specific| is
33 // "foo", but these are redundant with the message.
34 return message == other.message;
35 }
36
37 // The warning's message (human-friendly).
38 std::string message;
39 // Optional - for specifying the incorrect key in the manifest (e.g.,
40 // "permissions").
41 std::string key;
42 // Optional - for specifying the incorrect portion of a key in the manifest
43 // (e.g., an unrecognized permission "foo" in "permissions").
44 std::string specific;
45
46 DISALLOW_COPY(InstallWarning);
47};
48
49// Let gtest print InstallWarnings.
50void PrintTo(const InstallWarning&, ::std::ostream* os);
51
52} // namespace extensions
53
54#endif // EXTENSIONS_COMMON_INSTALL_WARNING_H_
55