OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/extension_error_reporter.h" | 5 #include "chrome/browser/extensions/extension_error_reporter.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 ExtensionErrorReporter::ExtensionErrorReporter(bool enable_noisy_errors) | 31 ExtensionErrorReporter::ExtensionErrorReporter(bool enable_noisy_errors) |
32 : ui_loop_(base::MessageLoop::current()), | 32 : ui_loop_(base::MessageLoop::current()), |
33 enable_noisy_errors_(enable_noisy_errors) { | 33 enable_noisy_errors_(enable_noisy_errors) { |
34 } | 34 } |
35 | 35 |
36 ExtensionErrorReporter::~ExtensionErrorReporter() {} | 36 ExtensionErrorReporter::~ExtensionErrorReporter() {} |
37 | 37 |
38 void ExtensionErrorReporter::ReportError(const base::string16& message, | 38 void ExtensionErrorReporter::ReportError(const base::string16& message, |
39 bool be_noisy, | 39 bool be_noisy) { |
40 bool* user_response) { | |
41 // NOTE: There won't be a ui_loop_ in the unit test environment. | 40 // NOTE: There won't be a ui_loop_ in the unit test environment. |
42 if (ui_loop_) { | 41 if (ui_loop_) { |
43 CHECK(base::MessageLoop::current() == ui_loop_) | 42 CHECK(base::MessageLoop::current() == ui_loop_) |
44 << "ReportError can only be called from the UI thread."; | 43 << "ReportError can only be called from the UI thread."; |
45 } | 44 } |
46 | 45 |
47 errors_.push_back(message); | 46 errors_.push_back(message); |
48 | 47 |
49 // TODO(aa): Print the error message out somewhere better. I think we are | 48 // TODO(aa): Print the error message out somewhere better. I think we are |
50 // going to need some sort of 'extension inspector'. | 49 // going to need some sort of 'extension inspector'. |
51 LOG(WARNING) << "Extension error: " << message; | 50 LOG(WARNING) << "Extension error: " << message; |
52 | 51 |
53 if (enable_noisy_errors_ && be_noisy) { | 52 if (enable_noisy_errors_ && be_noisy) { |
54 if (user_response) { | 53 chrome::ShowMessageBox(NULL, |
55 *user_response = | 54 base::ASCIIToUTF16("Extension error"), |
56 chrome::MESSAGE_BOX_RESULT_YES == | 55 message, |
57 chrome::ShowMessageBox(NULL, | 56 chrome::MESSAGE_BOX_TYPE_WARNING); |
58 base::ASCIIToUTF16("Extension error"), | |
59 message, | |
60 chrome::MESSAGE_BOX_TYPE_QUESTION); | |
61 } else { | |
62 chrome::ShowMessageBox(NULL, | |
63 base::ASCIIToUTF16("Extension error"), | |
64 message, | |
65 chrome::MESSAGE_BOX_TYPE_WARNING); | |
66 } | |
67 } | 57 } |
68 } | 58 } |
69 | 59 |
70 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() { | 60 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() { |
71 return &errors_; | 61 return &errors_; |
72 } | 62 } |
73 | 63 |
74 void ExtensionErrorReporter::ClearErrors() { | 64 void ExtensionErrorReporter::ClearErrors() { |
75 errors_.clear(); | 65 errors_.clear(); |
76 } | 66 } |
OLD | NEW |