OLD | NEW |
---|---|
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 struct InstallWarning { | 13 struct InstallWarning { |
14 enum Format { | 14 InstallWarning(const std::string& message); |
15 // IMPORTANT: Do not build HTML strings from user or developer-supplied | 15 InstallWarning(const std::string& key, |
Yoyo Zhou
2013/08/14 22:40:36
This is slightly unintuitive. Usually when you all
Devlin
2013/08/15 00:20:26
Done.
| |
16 // input. | 16 const std::string& message); |
17 FORMAT_TEXT, | 17 InstallWarning(const std::string& key, |
18 FORMAT_HTML, | 18 const std::string& specific, |
19 }; | 19 const std::string& message); |
20 static InstallWarning Text(const std::string& message) { | 20 ~InstallWarning(); |
21 return InstallWarning(FORMAT_TEXT, message); | 21 |
22 bool operator==(const InstallWarning& other) const { | |
23 return message == other.message; | |
Yoyo Zhou
2013/08/14 22:40:36
Maybe comment why this is appropriate and we can i
Devlin
2013/08/15 00:20:26
Done.
| |
22 } | 24 } |
23 InstallWarning(Format format, const std::string& message) | 25 |
24 : format(format), message(message) { | 26 // The manifest key to which this warning pertains (e.g., 'permissions'). |
Yoyo Zhou
2013/08/14 22:40:36
This is also optional, right?
Devlin
2013/08/15 00:20:26
Done.
| |
25 } | 27 std::string key; |
26 bool operator==(const InstallWarning& other) const { | 28 // Optional. The specific portion of the key which caused the warning. For |
27 return format == other.format && message == other.message; | 29 // instance, a single faulty permission in the 'permissions' key. |
28 } | 30 std::string specific; |
29 Format format; | 31 // The warning's message. |
30 std::string message; | 32 std::string message; |
31 }; | 33 }; |
32 | 34 |
33 // Let gtest print InstallWarnings. | 35 // Let gtest print InstallWarnings. |
34 void PrintTo(const InstallWarning&, ::std::ostream* os); | 36 void PrintTo(const InstallWarning&, ::std::ostream* os); |
35 | 37 |
36 } // namespace | 38 } // namespace |
37 | 39 |
38 #endif // EXTENSIONS_COMMON_INSTALL_WARNING_H_ | 40 #endif // EXTENSIONS_COMMON_INSTALL_WARNING_H_ |
OLD | NEW |