Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: chrome/browser/extensions/extension_error_reporter.cc

Issue 684153002: Fix not localized strings in extension_error_reporter.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Localization in unit test Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/simple_message_box.h" 17 #include "chrome/browser/ui/simple_message_box.h"
18 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 #include "extensions/browser/notification_types.h" 19 #include "extensions/browser/notification_types.h"
20 #include "grit/generated_resources.h"
21 #include "ui/base/l10n/l10n_util.h"
20 22
21 ExtensionErrorReporter* ExtensionErrorReporter::instance_ = NULL; 23 ExtensionErrorReporter* ExtensionErrorReporter::instance_ = NULL;
22 24
23 // static 25 // static
24 void ExtensionErrorReporter::Init(bool enable_noisy_errors) { 26 void ExtensionErrorReporter::Init(bool enable_noisy_errors) {
25 if (!instance_) { 27 if (!instance_) {
26 instance_ = new ExtensionErrorReporter(enable_noisy_errors); 28 instance_ = new ExtensionErrorReporter(enable_noisy_errors);
27 } 29 }
28 } 30 }
29 31
(...skipping 14 matching lines...) Expand all
44 const base::FilePath& extension_path, 46 const base::FilePath& extension_path,
45 const std::string& error, 47 const std::string& error,
46 content::BrowserContext* browser_context, 48 content::BrowserContext* browser_context,
47 bool be_noisy) { 49 bool be_noisy) {
48 content::NotificationService::current()->Notify( 50 content::NotificationService::current()->Notify(
49 extensions::NOTIFICATION_EXTENSION_LOAD_ERROR, 51 extensions::NOTIFICATION_EXTENSION_LOAD_ERROR,
50 content::Source<Profile>(Profile::FromBrowserContext(browser_context)), 52 content::Source<Profile>(Profile::FromBrowserContext(browser_context)),
51 content::Details<const std::string>(&error)); 53 content::Details<const std::string>(&error));
52 54
53 std::string path_str = base::UTF16ToUTF8(extension_path.LossyDisplayName()); 55 std::string path_str = base::UTF16ToUTF8(extension_path.LossyDisplayName());
54 base::string16 message = base::UTF8ToUTF16( 56 base::string16 message = base::UTF8ToUTF16(base::StringPrintf(
55 base::StringPrintf("Could not load extension from '%s'. %s", 57 "%s %s. %s",
56 path_str.c_str(), 58 l10n_util::GetStringUTF8(IDS_EXTENSIONS_LOAD_ERROR_MESSAGE).c_str(),
57 error.c_str())); 59 path_str.c_str(),
60 error.c_str()));
58 ReportError(message, be_noisy); 61 ReportError(message, be_noisy);
59 FOR_EACH_OBSERVER(Observer, 62 FOR_EACH_OBSERVER(Observer,
60 observers_, 63 observers_,
61 OnLoadFailure(browser_context, extension_path, error)); 64 OnLoadFailure(browser_context, extension_path, error));
62 } 65 }
63 66
64 void ExtensionErrorReporter::ReportError(const base::string16& message, 67 void ExtensionErrorReporter::ReportError(const base::string16& message,
65 bool be_noisy) { 68 bool be_noisy) {
66 // NOTE: There won't be a ui_loop_ in the unit test environment. 69 // NOTE: There won't be a ui_loop_ in the unit test environment.
67 if (ui_loop_) { 70 if (ui_loop_) {
68 CHECK(base::MessageLoop::current() == ui_loop_) 71 CHECK(base::MessageLoop::current() == ui_loop_)
69 << "ReportError can only be called from the UI thread."; 72 << "ReportError can only be called from the UI thread.";
70 } 73 }
71 74
72 errors_.push_back(message); 75 errors_.push_back(message);
73 76
74 // TODO(aa): Print the error message out somewhere better. I think we are 77 // TODO(aa): Print the error message out somewhere better. I think we are
75 // going to need some sort of 'extension inspector'. 78 // going to need some sort of 'extension inspector'.
76 LOG(WARNING) << "Extension error: " << message; 79 LOG(WARNING) << "Extension error: " << message;
77 80
78 if (enable_noisy_errors_ && be_noisy) { 81 if (enable_noisy_errors_ && be_noisy) {
79 chrome::ShowMessageBox(NULL, 82 chrome::ShowMessageBox(
80 base::ASCIIToUTF16("Extension error"), 83 NULL,
81 message, 84 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_ERROR_HEADING),
82 chrome::MESSAGE_BOX_TYPE_WARNING); 85 message,
86 chrome::MESSAGE_BOX_TYPE_WARNING);
83 } 87 }
84 } 88 }
85 89
86 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() { 90 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() {
87 return &errors_; 91 return &errors_;
88 } 92 }
89 93
90 void ExtensionErrorReporter::ClearErrors() { 94 void ExtensionErrorReporter::ClearErrors() {
91 errors_.clear(); 95 errors_.clear();
92 } 96 }
93 97
94 void ExtensionErrorReporter::AddObserver(Observer* observer) { 98 void ExtensionErrorReporter::AddObserver(Observer* observer) {
95 observers_.AddObserver(observer); 99 observers_.AddObserver(observer);
96 } 100 }
97 101
98 void ExtensionErrorReporter::RemoveObserver(Observer* observer) { 102 void ExtensionErrorReporter::RemoveObserver(Observer* observer) {
99 observers_.RemoveObserver(observer); 103 observers_.RemoveObserver(observer);
100 } 104 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698