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

Side by Side Diff: chrome/browser/extensions/error_console/error_console.h

Issue 23311011: ErrorConsole Switch, Duplicate Error Detection, Dev Mode Check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 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 <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/prefs/pref_change_registrar.h"
14 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
15 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
16 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
18 #include "extensions/browser/extension_error.h" 19 #include "extensions/browser/extension_error.h"
19 20
20 namespace content { 21 namespace content {
21 class NotificationDetails; 22 class NotificationDetails;
22 class NotificationSource; 23 class NotificationSource;
23 class RenderViewHost; 24 class RenderViewHost;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // Add or remove observers of the ErrorConsole to be notified of any errors 65 // Add or remove observers of the ErrorConsole to be notified of any errors
65 // added. 66 // added.
66 void AddObserver(Observer* observer); 67 void AddObserver(Observer* observer);
67 void RemoveObserver(Observer* observer); 68 void RemoveObserver(Observer* observer);
68 69
69 const ErrorMap& errors() { return errors_; } 70 const ErrorMap& errors() { return errors_; }
70 71
71 private: 72 private:
72 FRIEND_TEST_ALL_PREFIXES(ErrorConsoleUnitTest, AddAndRemoveErrors); 73 FRIEND_TEST_ALL_PREFIXES(ErrorConsoleUnitTest, AddAndRemoveErrors);
73 74
75 // Enable the error console for error collection and retention.
76 void Enable();
77 // Disable the error console, removing the subscriptions to notifications and
78 // removing all current errors.
79 void Disable();
80
81 // Called when the Developer Mode preference is changed; this is important
82 // since we use this as a heuristic to determine if the console is enabled or
83 // not.
84 void OnPrefChanged();
85
74 // Remove all errors which happened while incognito; we have to do this once 86 // Remove all errors which happened while incognito; we have to do this once
75 // the incognito profile is destroyed. 87 // the incognito profile is destroyed.
76 void RemoveIncognitoErrors(); 88 void RemoveIncognitoErrors();
77 89
78 // Remove all errors relating to a particular |extension_id|. 90 // Remove all errors relating to a particular |extension_id|.
79 void RemoveErrorsForExtension(const std::string& extension_id); 91 void RemoveErrorsForExtension(const std::string& extension_id);
80 92
81 // Remove all errors for all extensions. 93 // Remove all errors for all extensions.
82 void RemoveAllErrors(); 94 void RemoveAllErrors();
83 95
84 // content::NotificationObserver implementation. 96 // content::NotificationObserver implementation.
85 virtual void Observe(int type, 97 virtual void Observe(int type,
86 const content::NotificationSource& source, 98 const content::NotificationSource& source,
87 const content::NotificationDetails& details) OVERRIDE; 99 const content::NotificationDetails& details) OVERRIDE;
88 100
101 // Whether or not the error console is enabled. Currently, this is set by
102 // whether or not the user has Developer Mode enabled.
103 bool enabled_;
104
89 // Needed because ObserverList is not thread-safe. 105 // Needed because ObserverList is not thread-safe.
90 base::ThreadChecker thread_checker_; 106 base::ThreadChecker thread_checker_;
91 107
92 // The list of all observers for the ErrorConsole. 108 // The list of all observers for the ErrorConsole.
93 ObserverList<Observer> observers_; 109 ObserverList<Observer> observers_;
94 110
95 // The errors which we have received so far. 111 // The errors which we have received so far.
96 ErrorMap errors_; 112 ErrorMap errors_;
97 113
98 // The profile with which the ErrorConsole is associated. Only collect errors 114 // The profile with which the ErrorConsole is associated. Only collect errors
99 // from extensions and RenderViews associated with this Profile (and it's 115 // from extensions and RenderViews associated with this Profile (and it's
100 // incognito fellow). 116 // incognito fellow).
101 Profile* profile_; 117 Profile* profile_;
102 118
103 content::NotificationRegistrar registrar_; 119 content::NotificationRegistrar notification_registrar_;
120 PrefChangeRegistrar pref_registrar_;
104 121
105 DISALLOW_COPY_AND_ASSIGN(ErrorConsole); 122 DISALLOW_COPY_AND_ASSIGN(ErrorConsole);
106 }; 123 };
107 124
108 } // namespace extensions 125 } // namespace extensions
109 126
110 #endif // CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_ 127 #endif // CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698