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