OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/string16.h" |
| 13 |
12 class MessageLoop; | 14 class MessageLoop; |
13 | 15 |
14 // Exposes an easy way for the various components of the extension system to | 16 // Exposes an easy way for the various components of the extension system to |
15 // report errors. This is a singleton that lives on the UI thread, with the | 17 // report errors. This is a singleton that lives on the UI thread, with the |
16 // exception of ReportError() which may be called from any thread. | 18 // exception of ReportError() which may be called from any thread. |
17 // TODO(aa): Hook this up to about:extensions, when we have about:extensions. | 19 // TODO(aa): Hook this up to about:extensions, when we have about:extensions. |
18 // TODO(aa): Consider exposing directly, or via a helper, to the renderer | 20 // TODO(aa): Consider exposing directly, or via a helper, to the renderer |
19 // process and plumbing the errors out to the browser. | 21 // process and plumbing the errors out to the browser. |
20 // TODO(aa): Add ReportError(extension_id, message, be_noisy), so that we can | 22 // TODO(aa): Add ReportError(extension_id, message, be_noisy), so that we can |
21 // report errors that are specific to a particular extension. | 23 // report errors that are specific to a particular extension. |
22 class ExtensionErrorReporter { | 24 class ExtensionErrorReporter { |
23 public: | 25 public: |
24 // Initializes the error reporter. Must be called before any other methods | 26 // Initializes the error reporter. Must be called before any other methods |
25 // and on the UI thread. | 27 // and on the UI thread. |
26 static void Init(bool enable_noisy_errors); | 28 static void Init(bool enable_noisy_errors); |
27 | 29 |
28 // Get the singleton instance. | 30 // Get the singleton instance. |
29 static ExtensionErrorReporter* GetInstance(); | 31 static ExtensionErrorReporter* GetInstance(); |
30 | 32 |
31 // Report an error. Errors always go to VLOG(1). Optionally, they can also | 33 // Report an error. Errors always go to VLOG(1). Optionally, they can also |
32 // cause a noisy alert box. This method can be called from any thread. | 34 // cause a noisy alert box. This method can be called from any thread. |
33 void ReportError(const std::string& message, bool be_noisy); | 35 void ReportError(const string16& message, bool be_noisy); |
34 | 36 |
35 // Get the errors that have been reported so far. | 37 // Get the errors that have been reported so far. |
36 const std::vector<std::string>* GetErrors(); | 38 const std::vector<string16>* GetErrors(); |
37 | 39 |
38 // Clear the list of errors reported so far. | 40 // Clear the list of errors reported so far. |
39 void ClearErrors(); | 41 void ClearErrors(); |
40 | 42 |
41 private: | 43 private: |
42 static ExtensionErrorReporter* instance_; | 44 static ExtensionErrorReporter* instance_; |
43 | 45 |
44 explicit ExtensionErrorReporter(bool enable_noisy_errors); | 46 explicit ExtensionErrorReporter(bool enable_noisy_errors); |
45 ~ExtensionErrorReporter(); | 47 ~ExtensionErrorReporter(); |
46 | 48 |
47 MessageLoop* ui_loop_; | 49 MessageLoop* ui_loop_; |
48 std::vector<std::string> errors_; | 50 std::vector<string16> errors_; |
49 bool enable_noisy_errors_; | 51 bool enable_noisy_errors_; |
50 }; | 52 }; |
51 | 53 |
52 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_ | 54 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_ |
OLD | NEW |