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

Unified Diff: chrome/browser/extensions/error_console/error_console.h

Issue 215623002: Enable Error Console for ADT and <= Dev Channel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/error_console/error_console.h
diff --git a/chrome/browser/extensions/error_console/error_console.h b/chrome/browser/extensions/error_console/error_console.h
index 06c375a9eee2108384264ae93c3cae202874496c..f509a9c4dcd9c7a0ca841b29c2dffee77da5f048 100644
--- a/chrome/browser/extensions/error_console/error_console.h
+++ b/chrome/browser/extensions/error_console/error_console.h
@@ -18,6 +18,7 @@
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/error_map.h"
#include "extensions/browser/extension_error.h"
+#include "extensions/browser/extension_registry_observer.h"
namespace content {
class NotificationDetails;
@@ -38,7 +39,8 @@ class Extension;
// errors can be viewed at chrome://extensions in developer mode.
// This class is owned by ExtensionSystem, making it, in effect, a
// BrowserContext-keyed service.
-class ErrorConsole : public content::NotificationObserver {
+class ErrorConsole : public content::NotificationObserver,
+ public ExtensionRegistryObserver {
public:
class Observer {
public:
@@ -78,7 +80,13 @@ class ErrorConsole : public content::NotificationObserver {
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
- bool enabled() const { return enabled_; }
+ // Returns whether or not the ErrorConsole is enabled for the
+ // chrome:extensions page or the Chrome Apps Developer Tools.
not at google - send to devlin 2014/03/31 18:52:43 nit: put a blank line here (with a //) to make it
Devlin 2014/03/31 21:18:24 Done.
+ // TODO(rdevlin.cronin): These have different answers - ErrorConsole is
+ // enabled by default in ADT, but only Dev Channel for chrome:extensions (or
+ // with the commandline switch). Once we do a full launch, clean all this up.
+ bool IsEnabledForChromeExtensionsPage() const;
+ bool IsEnabledForAppsDeveloperTools() const;
// Return the number of entries (extensions) in the error map.
size_t get_num_entries_for_test() const { return errors_.size(); }
@@ -94,6 +102,10 @@ class ErrorConsole : public content::NotificationObserver {
// is no entry in the map, it signals that the |default_mask_| should be used.
typedef std::map<std::string, int32> ErrorPreferenceMap;
+ // Checks whether or not the ErrorConsole should be enabled or disabled. If it
+ // is in the wrong state, enables or disables it appropriately.
+ void CheckEnabled();
+
// Enable the error console for error collection and retention. This involves
// subscribing to the appropriate notifications and fetching manifest errors.
void Enable(ExtensionService* extension_service);
@@ -107,6 +119,11 @@ class ErrorConsole : public content::NotificationObserver {
// not.
void OnPrefChanged();
+ // ExtensionRegistry implementation. If the Apps Developer Tools app is
+ // installed or uninstalled, we may need to turn the ErrorConsole on/off.
+ virtual void OnExtensionUnloaded(const Extension* extension) OVERRIDE;
+ virtual void OnExtensionLoaded(const Extension* extension) OVERRIDE;
+
// Add manifest errors from an extension's install warnings.
void AddManifestErrorsForExtension(const Extension* extension);
@@ -115,9 +132,11 @@ class ErrorConsole : public content::NotificationObserver {
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- // Whether or not the error console is enabled; it is enabled if the
- // FeatureSwitch (FeatureSwitch::error_console) is enabled and the user is
- // in Developer Mode.
+ // Whether or not the error console should record errors. This is true if
+ // the user is in developer mode, and at least one of the following is true:
+ // - The Chrome Apps Developer Tools are installed.
+ // - FeatureSwitch::error_console() is enabled.
+ // - This is a Dev Channel release.
bool enabled_;
// Needed because ObserverList is not thread-safe.

Powered by Google App Engine
This is Rietveld 408576698