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

Side by Side Diff: chrome/browser/ui/webui/help/version_updater_mac.mm

Issue 1769703002: Add viewing of error messages from Keystone upon self-update failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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
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/ui/webui/help/version_updater_mac.h" 5 #include "chrome/browser/ui/webui/help/version_updater_mac.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/lifetime/application_lifetime.h" 11 #include "chrome/browser/lifetime/application_lifetime.h"
10 #import "chrome/browser/mac/keystone_glue.h" 12 #import "chrome/browser/mac/keystone_glue.h"
11 #include "chrome/browser/obsolete_system/obsolete_system.h" 13 #include "chrome/browser/obsolete_system/obsolete_system.h"
12 #include "chrome/grit/chromium_strings.h" 14 #include "chrome/grit/chromium_strings.h"
13 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
15 17
16 // KeystoneObserver is a simple notification observer for Keystone status 18 // KeystoneObserver is a simple notification observer for Keystone status
17 // updates. It will be created and managed by VersionUpdaterMac. 19 // updates. It will be created and managed by VersionUpdaterMac.
18 @interface KeystoneObserver : NSObject { 20 @interface KeystoneObserver : NSObject {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 127 }
126 128
127 void VersionUpdaterMac::RelaunchBrowser() const { 129 void VersionUpdaterMac::RelaunchBrowser() const {
128 // Tell the Broweser to restart if possible. 130 // Tell the Broweser to restart if possible.
129 chrome::AttemptRestart(); 131 chrome::AttemptRestart();
130 } 132 }
131 133
132 void VersionUpdaterMac::UpdateStatus(NSDictionary* dictionary) { 134 void VersionUpdaterMac::UpdateStatus(NSDictionary* dictionary) {
133 AutoupdateStatus keystone_status = static_cast<AutoupdateStatus>( 135 AutoupdateStatus keystone_status = static_cast<AutoupdateStatus>(
134 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]); 136 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]);
137 const char* keystone_errors_utf8 =
138 [[dictionary objectForKey:kAutoupdateStatusErrorMessages] UTF8String];
135 139
136 bool enable_promote_button = true; 140 bool enable_promote_button = true;
137 base::string16 message; 141 base::string16 message;
138 142
139 Status status; 143 Status status;
140 switch (keystone_status) { 144 switch (keystone_status) {
141 case kAutoupdateRegistering: 145 case kAutoupdateRegistering:
142 case kAutoupdateChecking: 146 case kAutoupdateChecking:
143 status = CHECKING; 147 status = CHECKING;
144 enable_promote_button = false; 148 enable_promote_button = false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 208 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
205 message = l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, 209 message = l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT,
206 product_name); 210 product_name);
207 } 211 }
208 break; 212 break;
209 213
210 default: 214 default:
211 NOTREACHED(); 215 NOTREACHED();
212 return; 216 return;
213 } 217 }
218
219 // If there are any specific error messages being passed along by Keystone,
220 // include them in a <pre> block.
221 if (!message.empty() &&
222 keystone_errors_utf8 && strlen(keystone_errors_utf8)) {
223 // TODO: Should we localize the "Error details" string? If so, get the
224 // string translated and into GRD, then replace this StringPrintf call
225 // with a call to l10n_util::GetStringFUTF16(IDS_KEYSTONE_ERROR_DETAILS).
226 std::string formatted_errors =
227 base::StringPrintf("<br/><br/>Error details:<br/><pre>%s</pre>",
228 keystone_errors_utf8);
Boris Vidolov 2016/03/08 22:32:52 The code needs to sanitize the contents of keyston
229 message += base::UTF8ToUTF16(formatted_errors.c_str());
230 }
231
214 if (!status_callback_.is_null()) 232 if (!status_callback_.is_null())
215 status_callback_.Run(status, 0, message); 233 status_callback_.Run(status, 0, message);
216 234
217 if (!promote_callback_.is_null()) { 235 if (!promote_callback_.is_null()) {
218 PromotionState promotion_state = PROMOTE_HIDDEN; 236 PromotionState promotion_state = PROMOTE_HIDDEN;
219 if (show_promote_button_) 237 if (show_promote_button_)
220 promotion_state = enable_promote_button ? PROMOTE_ENABLED 238 promotion_state = enable_promote_button ? PROMOTE_ENABLED
221 : PROMOTE_DISABLED; 239 : PROMOTE_DISABLED;
222 promote_callback_.Run(promotion_state); 240 promote_callback_.Run(promotion_state);
223 } 241 }
(...skipping 16 matching lines...) Expand all
240 } else if (recent_status == kAutoupdatePromoting || 258 } else if (recent_status == kAutoupdatePromoting ||
241 recent_status == kAutoupdatePromoteFailed) { 259 recent_status == kAutoupdatePromoteFailed) {
242 // Show promotion UI because the user either just clicked that button or 260 // Show promotion UI because the user either just clicked that button or
243 // because the user should be able to click it again. 261 // because the user should be able to click it again.
244 show_promote_button_ = true; 262 show_promote_button_ = true;
245 } else { 263 } else {
246 // Show the promote button if promotion is a possibility. 264 // Show the promote button if promotion is a possibility.
247 show_promote_button_ = [keystone_glue wantsPromotion]; 265 show_promote_button_ = [keystone_glue wantsPromotion];
248 } 266 }
249 } 267 }
OLDNEW
« chrome/browser/mac/keystone_registration.mm ('K') | « chrome/browser/mac/keystone_registration.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698