| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 public: | 42 public: |
| 43 // Sent when a new error is reported to the error console. | 43 // Sent when a new error is reported to the error console. |
| 44 virtual void OnErrorAdded(const ExtensionError* error) = 0; | 44 virtual void OnErrorAdded(const ExtensionError* error) = 0; |
| 45 | 45 |
| 46 // Sent upon destruction to allow any observers to invalidate any references | 46 // Sent upon destruction to allow any observers to invalidate any references |
| 47 // they have to the error console. | 47 // they have to the error console. |
| 48 virtual void OnErrorConsoleDestroyed(); | 48 virtual void OnErrorConsoleDestroyed(); |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 explicit ErrorConsole(Profile* profile); | 51 explicit ErrorConsole(Profile* profile); |
| 52 virtual ~ErrorConsole(); | 52 ~ErrorConsole() override; |
| 53 | 53 |
| 54 // Convenience method to return the ErrorConsole for a given profile. | 54 // Convenience method to return the ErrorConsole for a given profile. |
| 55 static ErrorConsole* Get(Profile* profile); | 55 static ErrorConsole* Get(Profile* profile); |
| 56 | 56 |
| 57 // Set whether or not errors of the specified |type| are stored for the | 57 // Set whether or not errors of the specified |type| are stored for the |
| 58 // extension with the given |extension_id|. This will be stored in the | 58 // extension with the given |extension_id|. This will be stored in the |
| 59 // preferences. | 59 // preferences. |
| 60 void SetReportingForExtension(const std::string& extension_id, | 60 void SetReportingForExtension(const std::string& extension_id, |
| 61 ExtensionError::Type type, | 61 ExtensionError::Type type, |
| 62 bool enabled); | 62 bool enabled); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // removing all current errors. | 119 // removing all current errors. |
| 120 void Disable(); | 120 void Disable(); |
| 121 | 121 |
| 122 // Called when the Developer Mode preference is changed; this is important | 122 // Called when the Developer Mode preference is changed; this is important |
| 123 // since we use this as a heuristic to determine if the console is enabled or | 123 // since we use this as a heuristic to determine if the console is enabled or |
| 124 // not. | 124 // not. |
| 125 void OnPrefChanged(); | 125 void OnPrefChanged(); |
| 126 | 126 |
| 127 // ExtensionRegistry implementation. If the Apps Developer Tools app is | 127 // ExtensionRegistry implementation. If the Apps Developer Tools app is |
| 128 // installed or uninstalled, we may need to turn the ErrorConsole on/off. | 128 // installed or uninstalled, we may need to turn the ErrorConsole on/off. |
| 129 virtual void OnExtensionUnloaded( | 129 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 130 content::BrowserContext* browser_context, | 130 const Extension* extension, |
| 131 const Extension* extension, | 131 UnloadedExtensionInfo::Reason reason) override; |
| 132 UnloadedExtensionInfo::Reason reason) override; | 132 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 133 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 133 const Extension* extension) override; |
| 134 const Extension* extension) override; | 134 void OnExtensionInstalled(content::BrowserContext* browser_context, |
| 135 virtual void OnExtensionInstalled(content::BrowserContext* browser_context, | 135 const Extension* extension, |
| 136 const Extension* extension, | 136 bool is_update) override; |
| 137 bool is_update) override; | 137 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 138 virtual void OnExtensionUninstalled( | 138 const Extension* extension, |
| 139 content::BrowserContext* browser_context, | 139 extensions::UninstallReason reason) override; |
| 140 const Extension* extension, | |
| 141 extensions::UninstallReason reason) override; | |
| 142 | 140 |
| 143 // Add manifest errors from an extension's install warnings. | 141 // Add manifest errors from an extension's install warnings. |
| 144 void AddManifestErrorsForExtension(const Extension* extension); | 142 void AddManifestErrorsForExtension(const Extension* extension); |
| 145 | 143 |
| 146 // content::NotificationObserver implementation. | 144 // content::NotificationObserver implementation. |
| 147 virtual void Observe(int type, | 145 void Observe(int type, |
| 148 const content::NotificationSource& source, | 146 const content::NotificationSource& source, |
| 149 const content::NotificationDetails& details) override; | 147 const content::NotificationDetails& details) override; |
| 150 | 148 |
| 151 // Returns the applicable bit mask of reporting preferences for the extension. | 149 // Returns the applicable bit mask of reporting preferences for the extension. |
| 152 int GetMaskForExtension(const std::string& extension_id) const; | 150 int GetMaskForExtension(const std::string& extension_id) const; |
| 153 | 151 |
| 154 // Whether or not the error console should record errors. This is true if | 152 // Whether or not the error console should record errors. This is true if |
| 155 // the user is in developer mode, and at least one of the following is true: | 153 // the user is in developer mode, and at least one of the following is true: |
| 156 // - The Chrome Apps Developer Tools are installed. | 154 // - The Chrome Apps Developer Tools are installed. |
| 157 // - FeatureSwitch::error_console() is enabled. | 155 // - FeatureSwitch::error_console() is enabled. |
| 158 // - This is a Dev Channel release. | 156 // - This is a Dev Channel release. |
| 159 bool enabled_; | 157 bool enabled_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 185 | 183 |
| 186 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 184 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 187 registry_observer_; | 185 registry_observer_; |
| 188 | 186 |
| 189 DISALLOW_COPY_AND_ASSIGN(ErrorConsole); | 187 DISALLOW_COPY_AND_ASSIGN(ErrorConsole); |
| 190 }; | 188 }; |
| 191 | 189 |
| 192 } // namespace extensions | 190 } // namespace extensions |
| 193 | 191 |
| 194 #endif // CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_ | 192 #endif // CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_ |
| OLD | NEW |