OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ERROR_REPORTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class MessageLoop; | 14 class MessageLoop; |
| 15 class FilePath; |
15 } | 16 } |
16 | 17 |
| 18 class Profile; |
| 19 |
17 // Exposes an easy way for the various components of the extension system to | 20 // Exposes an easy way for the various components of the extension system to |
18 // report errors. This is a singleton that lives on the UI thread, with the | 21 // report errors. This is a singleton that lives on the UI thread, with the |
19 // exception of ReportError() which may be called from any thread. | 22 // exception of ReportError() which may be called from any thread. |
20 // TODO(aa): Hook this up to about:extensions, when we have about:extensions. | 23 // TODO(aa): Hook this up to about:extensions, when we have about:extensions. |
21 // TODO(aa): Consider exposing directly, or via a helper, to the renderer | 24 // TODO(aa): Consider exposing directly, or via a helper, to the renderer |
22 // process and plumbing the errors out to the browser. | 25 // process and plumbing the errors out to the browser. |
23 // TODO(aa): Add ReportError(extension_id, message, be_noisy), so that we can | 26 // TODO(aa): Add ReportError(extension_id, message, be_noisy), so that we can |
24 // report errors that are specific to a particular extension. | 27 // report errors that are specific to a particular extension. |
25 class ExtensionErrorReporter { | 28 class ExtensionErrorReporter { |
26 public: | 29 public: |
27 // Initializes the error reporter. Must be called before any other methods | 30 // Initializes the error reporter. Must be called before any other methods |
28 // and on the UI thread. | 31 // and on the UI thread. |
29 static void Init(bool enable_noisy_errors); | 32 static void Init(bool enable_noisy_errors); |
30 | 33 |
31 // Get the singleton instance. | 34 // Get the singleton instance. |
32 static ExtensionErrorReporter* GetInstance(); | 35 static ExtensionErrorReporter* GetInstance(); |
33 | 36 |
| 37 // Report an extension load error. This forwards to ReportError() after |
| 38 // sending an EXTENSION_LOAD_ERROR notification. |
| 39 // TODO(rdevlin.cronin): There's a lot wrong with this. But some of our |
| 40 // systems rely on the notification. Investigate what it will take to remove |
| 41 // the notification and this method. |
| 42 void ReportLoadError(const base::FilePath& extension_path, |
| 43 const std::string& error, |
| 44 Profile* profile, |
| 45 bool be_noisy); |
| 46 |
34 // Report an error. Errors always go to VLOG(1). Optionally, they can also | 47 // Report an error. Errors always go to VLOG(1). Optionally, they can also |
35 // cause a noisy alert box. | 48 // cause a noisy alert box. |
36 void ReportError(const base::string16& message, bool be_noisy); | 49 void ReportError(const base::string16& message, bool be_noisy); |
37 | 50 |
38 // Get the errors that have been reported so far. | 51 // Get the errors that have been reported so far. |
39 const std::vector<base::string16>* GetErrors(); | 52 const std::vector<base::string16>* GetErrors(); |
40 | 53 |
41 // Clear the list of errors reported so far. | 54 // Clear the list of errors reported so far. |
42 void ClearErrors(); | 55 void ClearErrors(); |
43 | 56 |
44 private: | 57 private: |
45 static ExtensionErrorReporter* instance_; | 58 static ExtensionErrorReporter* instance_; |
46 | 59 |
47 explicit ExtensionErrorReporter(bool enable_noisy_errors); | 60 explicit ExtensionErrorReporter(bool enable_noisy_errors); |
48 ~ExtensionErrorReporter(); | 61 ~ExtensionErrorReporter(); |
49 | 62 |
50 base::MessageLoop* ui_loop_; | 63 base::MessageLoop* ui_loop_; |
51 std::vector<base::string16> errors_; | 64 std::vector<base::string16> errors_; |
52 bool enable_noisy_errors_; | 65 bool enable_noisy_errors_; |
53 }; | 66 }; |
54 | 67 |
55 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_ | 68 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_ |
OLD | NEW |