Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: extensions/common/install_warning.h

Issue 22470007: Add a "key" entry to InstallWarnings, remove InstallWarning::Format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dc_ec_infrastructure
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_COMMON_INSTALL_WARNING_H_ 5 #ifndef EXTENSIONS_COMMON_INSTALL_WARNING_H_
6 #define EXTENSIONS_COMMON_INSTALL_WARNING_H_ 6 #define EXTENSIONS_COMMON_INSTALL_WARNING_H_
7 7
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 10
11 namespace extensions { 11 namespace extensions {
12 12
13 // A struct to describe a non-fatal issue discovered in the installation of an
14 // extension.
13 struct InstallWarning { 15 struct InstallWarning {
14 enum Format { 16 InstallWarning(const std::string& message);
15 // IMPORTANT: Do not build HTML strings from user or developer-supplied 17 InstallWarning(const std::string& message,
16 // input. 18 const std::string& key);
17 FORMAT_TEXT, 19 InstallWarning(const std::string& message,
18 FORMAT_HTML, 20 const std::string& key,
19 }; 21 const std::string& specific);
20 static InstallWarning Text(const std::string& message) { 22 ~InstallWarning();
21 return InstallWarning(FORMAT_TEXT, message); 23
24 bool operator==(const InstallWarning& other) const {
25 // We don't have to look at |key| or |specific| here, because they are each
26 // used in the the message itself.
27 // For example, a full message would be "Permission 'foo' is unknown or URL
28 // pattern is malformed." |key| here is "permissions", and |specific| is
29 // "foo", but these are redundant with the message.
30 return message == other.message;
22 } 31 }
23 InstallWarning(Format format, const std::string& message) 32
24 : format(format), message(message) { 33 // The warning's message (human-friendly).
25 }
26 bool operator==(const InstallWarning& other) const {
27 return format == other.format && message == other.message;
28 }
29 Format format;
30 std::string message; 34 std::string message;
35 // Optional - for specifying the incorrect key in the manifest (e.g.,
36 // "permissions").
37 std::string key;
38 // Optional - for specifying the incorrect portion of a key in the manifest
39 // (e.g., an unrecognized permission "foo" in "permissions").
40 std::string specific;
31 }; 41 };
32 42
33 // Let gtest print InstallWarnings. 43 // Let gtest print InstallWarnings.
34 void PrintTo(const InstallWarning&, ::std::ostream* os); 44 void PrintTo(const InstallWarning&, ::std::ostream* os);
35 45
36 } // namespace 46 } // namespace
37 47
38 #endif // EXTENSIONS_COMMON_INSTALL_WARNING_H_ 48 #endif // EXTENSIONS_COMMON_INSTALL_WARNING_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/permissions_data.cc ('k') | extensions/common/install_warning.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698