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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, | 48 chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, |
49 content::Source<Profile>(profile), | 49 content::Source<Profile>(profile), |
50 content::Details<const std::string>(&error)); | 50 content::Details<const std::string>(&error)); |
51 | 51 |
52 std::string path_str = base::UTF16ToUTF8(extension_path.LossyDisplayName()); | 52 std::string path_str = base::UTF16ToUTF8(extension_path.LossyDisplayName()); |
53 base::string16 message = base::UTF8ToUTF16( | 53 base::string16 message = base::UTF8ToUTF16( |
54 base::StringPrintf("Could not load extension from '%s'. %s", | 54 base::StringPrintf("Could not load extension from '%s'. %s", |
55 path_str.c_str(), | 55 path_str.c_str(), |
56 error.c_str())); | 56 error.c_str())); |
57 ReportError(message, be_noisy); | 57 ReportError(message, be_noisy); |
| 58 FOR_EACH_OBSERVER(Observer, |
| 59 observers_, |
| 60 OnLoadFailure(extension_path, error)); |
58 } | 61 } |
59 | 62 |
60 void ExtensionErrorReporter::ReportError(const base::string16& message, | 63 void ExtensionErrorReporter::ReportError(const base::string16& message, |
61 bool be_noisy) { | 64 bool be_noisy) { |
62 // NOTE: There won't be a ui_loop_ in the unit test environment. | 65 // NOTE: There won't be a ui_loop_ in the unit test environment. |
63 if (ui_loop_) { | 66 if (ui_loop_) { |
64 CHECK(base::MessageLoop::current() == ui_loop_) | 67 CHECK(base::MessageLoop::current() == ui_loop_) |
65 << "ReportError can only be called from the UI thread."; | 68 << "ReportError can only be called from the UI thread."; |
66 } | 69 } |
67 | 70 |
(...skipping 11 matching lines...) Expand all Loading... |
79 } | 82 } |
80 } | 83 } |
81 | 84 |
82 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() { | 85 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() { |
83 return &errors_; | 86 return &errors_; |
84 } | 87 } |
85 | 88 |
86 void ExtensionErrorReporter::ClearErrors() { | 89 void ExtensionErrorReporter::ClearErrors() { |
87 errors_.clear(); | 90 errors_.clear(); |
88 } | 91 } |
| 92 |
| 93 void ExtensionErrorReporter::AddObserver( |
| 94 Observer* observer) { |
| 95 observers_.AddObserver(observer); |
| 96 } |
| 97 |
| 98 void ExtensionErrorReporter::RemoveObserver( |
| 99 Observer* observer) { |
| 100 observers_.RemoveObserver(observer); |
| 101 } |
OLD | NEW |