| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 content::Source<Profile>(Profile::FromBrowserContext(browser_context)), | 53 content::Source<Profile>(Profile::FromBrowserContext(browser_context)), |
| 54 content::Details<const std::string>(&error)); | 54 content::Details<const std::string>(&error)); |
| 55 | 55 |
| 56 std::string path_str = base::UTF16ToUTF8(extension_path.LossyDisplayName()); | 56 std::string path_str = base::UTF16ToUTF8(extension_path.LossyDisplayName()); |
| 57 base::string16 message = base::UTF8ToUTF16(base::StringPrintf( | 57 base::string16 message = base::UTF8ToUTF16(base::StringPrintf( |
| 58 "%s %s. %s", | 58 "%s %s. %s", |
| 59 l10n_util::GetStringUTF8(IDS_EXTENSIONS_LOAD_ERROR_MESSAGE).c_str(), | 59 l10n_util::GetStringUTF8(IDS_EXTENSIONS_LOAD_ERROR_MESSAGE).c_str(), |
| 60 path_str.c_str(), | 60 path_str.c_str(), |
| 61 error.c_str())); | 61 error.c_str())); |
| 62 ReportError(message, be_noisy); | 62 ReportError(message, be_noisy); |
| 63 FOR_EACH_OBSERVER(Observer, | 63 for (auto& observer : observers_) |
| 64 observers_, | 64 observer.OnLoadFailure(browser_context, extension_path, error); |
| 65 OnLoadFailure(browser_context, extension_path, error)); | |
| 66 } | 65 } |
| 67 | 66 |
| 68 void ExtensionErrorReporter::ReportError(const base::string16& message, | 67 void ExtensionErrorReporter::ReportError(const base::string16& message, |
| 69 bool be_noisy) { | 68 bool be_noisy) { |
| 70 // NOTE: There won't be a |ui_task_runner_| in the unit test environment. | 69 // NOTE: There won't be a |ui_task_runner_| in the unit test environment. |
| 71 CHECK(!ui_task_runner_ || ui_task_runner_->BelongsToCurrentThread()) | 70 CHECK(!ui_task_runner_ || ui_task_runner_->BelongsToCurrentThread()) |
| 72 << "ReportError can only be called from the UI thread."; | 71 << "ReportError can only be called from the UI thread."; |
| 73 | 72 |
| 74 errors_.push_back(message); | 73 errors_.push_back(message); |
| 75 | 74 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 92 errors_.clear(); | 91 errors_.clear(); |
| 93 } | 92 } |
| 94 | 93 |
| 95 void ExtensionErrorReporter::AddObserver(Observer* observer) { | 94 void ExtensionErrorReporter::AddObserver(Observer* observer) { |
| 96 observers_.AddObserver(observer); | 95 observers_.AddObserver(observer); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void ExtensionErrorReporter::RemoveObserver(Observer* observer) { | 98 void ExtensionErrorReporter::RemoveObserver(Observer* observer) { |
| 100 observers_.RemoveObserver(observer); | 99 observers_.RemoveObserver(observer); |
| 101 } | 100 } |
| OLD | NEW |