OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_SET_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_SET_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_SET_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_SET_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 // TODO(battre) Remove the Extension prefix. | 14 // TODO(battre) Remove the Extension prefix. |
15 | 15 |
| 16 namespace base { |
| 17 class FilePath; |
| 18 } |
| 19 |
16 class ExtensionSet; | 20 class ExtensionSet; |
17 | 21 |
18 namespace extensions { | 22 namespace extensions { |
19 | 23 |
20 // This class is used by the ExtensionWarningService to represent warnings if | 24 // This class is used by the ExtensionWarningService to represent warnings if |
21 // extensions misbehave. Note that the ExtensionWarningService deals only with | 25 // extensions misbehave. Note that the ExtensionWarningService deals only with |
22 // specific warnings that should trigger a badge on the Chrome menu button. | 26 // specific warnings that should trigger a badge on the Chrome menu button. |
23 class ExtensionWarning { | 27 class ExtensionWarning { |
24 public: | 28 public: |
25 enum WarningType { | 29 enum WarningType { |
26 // Don't use this, it is only intended for the default constructor and | 30 // Don't use this, it is only intended for the default constructor and |
27 // does not have localized warning messages for the UI. | 31 // does not have localized warning messages for the UI. |
28 kInvalid = 0, | 32 kInvalid = 0, |
29 // An extension caused excessive network delays. | 33 // An extension caused excessive network delays. |
30 kNetworkDelay, | 34 kNetworkDelay, |
31 // This extension failed to modify a network request because the | 35 // This extension failed to modify a network request because the |
32 // modification conflicted with a modification of another extension. | 36 // modification conflicted with a modification of another extension. |
33 kNetworkConflict, | 37 kNetworkConflict, |
34 // This extension failed to redirect a network request because another | 38 // This extension failed to redirect a network request because another |
35 // extension with higher precedence redirected to a different target. | 39 // extension with higher precedence redirected to a different target. |
36 kRedirectConflict, | 40 kRedirectConflict, |
37 // The extension repeatedly flushed WebKit's in-memory cache, which slows | 41 // The extension repeatedly flushed WebKit's in-memory cache, which slows |
38 // down the overall performance. | 42 // down the overall performance. |
39 kRepeatedCacheFlushes, | 43 kRepeatedCacheFlushes, |
| 44 // The extension failed to determine the filename of a download because |
| 45 // another extension with higher precedence determined a different filename. |
| 46 kDownloadFilenameConflict, |
40 kMaxWarningType | 47 kMaxWarningType |
41 }; | 48 }; |
42 | 49 |
43 // We allow copy&assign for passing containers of ExtensionWarnings between | 50 // We allow copy&assign for passing containers of ExtensionWarnings between |
44 // threads. | 51 // threads. |
45 ExtensionWarning(const ExtensionWarning& other); | 52 ExtensionWarning(const ExtensionWarning& other); |
46 ~ExtensionWarning(); | 53 ~ExtensionWarning(); |
47 ExtensionWarning& operator=(const ExtensionWarning& other); | 54 ExtensionWarning& operator=(const ExtensionWarning& other); |
48 | 55 |
49 // Factory methods for various warning types. | 56 // Factory methods for various warning types. |
(...skipping 12 matching lines...) Expand all Loading... |
62 const std::string& conflicting_header); | 69 const std::string& conflicting_header); |
63 static ExtensionWarning CreateResponseHeaderConflictWarning( | 70 static ExtensionWarning CreateResponseHeaderConflictWarning( |
64 const std::string& extension_id, | 71 const std::string& extension_id, |
65 const std::string& winning_extension_id, | 72 const std::string& winning_extension_id, |
66 const std::string& conflicting_header); | 73 const std::string& conflicting_header); |
67 static ExtensionWarning CreateCredentialsConflictWarning( | 74 static ExtensionWarning CreateCredentialsConflictWarning( |
68 const std::string& extension_id, | 75 const std::string& extension_id, |
69 const std::string& winning_extension_id); | 76 const std::string& winning_extension_id); |
70 static ExtensionWarning CreateRepeatedCacheFlushesWarning( | 77 static ExtensionWarning CreateRepeatedCacheFlushesWarning( |
71 const std::string& extension_id); | 78 const std::string& extension_id); |
| 79 static ExtensionWarning CreateDownloadFilenameConflictWarning( |
| 80 const std::string& losing_extension_id, |
| 81 const std::string& winning_extension_id, |
| 82 const base::FilePath& losing_filename, |
| 83 const base::FilePath& winning_filename); |
72 | 84 |
73 // Returns the specific warning type. | 85 // Returns the specific warning type. |
74 WarningType warning_type() const { return type_; } | 86 WarningType warning_type() const { return type_; } |
75 | 87 |
76 // Returns the id of the extension for which this warning is valid. | 88 // Returns the id of the extension for which this warning is valid. |
77 const std::string& extension_id() const { return extension_id_; } | 89 const std::string& extension_id() const { return extension_id_; } |
78 | 90 |
79 // Returns a localized warning message. | 91 // Returns a localized warning message. |
80 std::string GetLocalizedMessage(const ExtensionSet* extensions) const; | 92 std::string GetLocalizedMessage(const ExtensionSet* extensions) const; |
81 | 93 |
(...skipping 18 matching lines...) Expand all Loading... |
100 // Compare ExtensionWarnings based on the tuple of (extension_id, type). | 112 // Compare ExtensionWarnings based on the tuple of (extension_id, type). |
101 // The message associated with ExtensionWarnings is purely informational | 113 // The message associated with ExtensionWarnings is purely informational |
102 // and does not contribute to distinguishing extensions. | 114 // and does not contribute to distinguishing extensions. |
103 bool operator<(const ExtensionWarning& a, const ExtensionWarning& b); | 115 bool operator<(const ExtensionWarning& a, const ExtensionWarning& b); |
104 | 116 |
105 typedef std::set<ExtensionWarning> ExtensionWarningSet; | 117 typedef std::set<ExtensionWarning> ExtensionWarningSet; |
106 | 118 |
107 } // namespace extensions | 119 } // namespace extensions |
108 | 120 |
109 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_SET_H_ | 121 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_SET_H_ |
OLD | NEW |