| 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 #include "base/observer_list.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 class MessageLoop; | 15 class MessageLoop; |
| 15 class FilePath; | 16 class FilePath; |
| 16 } | 17 } |
| 17 | 18 |
| 18 class Profile; | 19 class Profile; |
| 20 class ExtensionErrorReporterObserver; |
| 19 | 21 |
| 20 // Exposes an easy way for the various components of the extension system to | 22 // Exposes an easy way for the various components of the extension system to |
| 21 // report errors. This is a singleton that lives on the UI thread, with the | 23 // report errors. This is a singleton that lives on the UI thread, with the |
| 22 // exception of ReportError() which may be called from any thread. | 24 // exception of ReportError() which may be called from any thread. |
| 23 // TODO(aa): Hook this up to about:extensions, when we have about:extensions. | 25 // TODO(aa): Hook this up to about:extensions, when we have about:extensions. |
| 24 // TODO(aa): Consider exposing directly, or via a helper, to the renderer | 26 // TODO(aa): Consider exposing directly, or via a helper, to the renderer |
| 25 // process and plumbing the errors out to the browser. | 27 // process and plumbing the errors out to the browser. |
| 26 // TODO(aa): Add ReportError(extension_id, message, be_noisy), so that we can | 28 // TODO(aa): Add ReportError(extension_id, message, be_noisy), so that we can |
| 27 // report errors that are specific to a particular extension. | 29 // report errors that are specific to a particular extension. |
| 28 class ExtensionErrorReporter { | 30 class ExtensionErrorReporter { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 // Report an error. Errors always go to VLOG(1). Optionally, they can also | 49 // Report an error. Errors always go to VLOG(1). Optionally, they can also |
| 48 // cause a noisy alert box. | 50 // cause a noisy alert box. |
| 49 void ReportError(const base::string16& message, bool be_noisy); | 51 void ReportError(const base::string16& message, bool be_noisy); |
| 50 | 52 |
| 51 // Get the errors that have been reported so far. | 53 // Get the errors that have been reported so far. |
| 52 const std::vector<base::string16>* GetErrors(); | 54 const std::vector<base::string16>* GetErrors(); |
| 53 | 55 |
| 54 // Clear the list of errors reported so far. | 56 // Clear the list of errors reported so far. |
| 55 void ClearErrors(); | 57 void ClearErrors(); |
| 56 | 58 |
| 59 void AddObserver(ExtensionErrorReporterObserver* observer); |
| 60 void RemoveObserver(ExtensionErrorReporterObserver* observer); |
| 61 void TriggerOnLoadFailure(const base::FilePath& extension_path, |
| 62 const std::string& error); |
| 63 |
| 57 private: | 64 private: |
| 58 static ExtensionErrorReporter* instance_; | 65 static ExtensionErrorReporter* instance_; |
| 59 | 66 |
| 60 explicit ExtensionErrorReporter(bool enable_noisy_errors); | 67 explicit ExtensionErrorReporter(bool enable_noisy_errors); |
| 61 ~ExtensionErrorReporter(); | 68 ~ExtensionErrorReporter(); |
| 62 | 69 |
| 63 base::MessageLoop* ui_loop_; | 70 base::MessageLoop* ui_loop_; |
| 64 std::vector<base::string16> errors_; | 71 std::vector<base::string16> errors_; |
| 65 bool enable_noisy_errors_; | 72 bool enable_noisy_errors_; |
| 73 |
| 74 ObserverList<ExtensionErrorReporterObserver> observers_; |
| 66 }; | 75 }; |
| 67 | 76 |
| 68 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_ | 77 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_ |
| OLD | NEW |