| Index: chrome/browser/ui/views/about_chrome_view.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/about_chrome_view.cc (revision 107092)
|
| +++ chrome/browser/ui/views/about_chrome_view.cc (working copy)
|
| @@ -50,6 +50,10 @@
|
| #include "chrome/installer/util/install_util.h"
|
| #endif // defined(OS_WIN)
|
|
|
| +// The amount of vertical space separating the error label at the bottom from
|
| +// the rest of the text.
|
| +static const int kErrorLabelVerticalSpacing = 15; // Pixels.
|
| +
|
| namespace {
|
| // These are used as placeholder text around the links in the text in the about
|
| // dialog.
|
| @@ -165,7 +169,12 @@
|
| // This is a text field so people can copy the version number from the dialog.
|
| version_label_ = new views::Textfield();
|
| chrome::VersionInfo version_info;
|
| - version_label_->SetText(UTF8ToUTF16(version_info.CreateVersionString()));
|
| + {
|
| + // TODO(finnur): Need to evaluate whether we should be doing IO here.
|
| + // See issue: http://crbug.com/101699.
|
| + base::ThreadRestrictions::ScopedAllowIO allow_io;
|
| + version_label_->SetText(UTF8ToUTF16(version_info.CreateVersionString()));
|
| + }
|
| version_label_->SetReadOnly(true);
|
| version_label_->RemoveBorder();
|
| version_label_->SetTextColor(SK_ColorBLACK);
|
| @@ -189,13 +198,13 @@
|
| text.find(kBeginLinkChr) < text.find(kBeginLinkOss);
|
|
|
| size_t link1 = text.find(kBeginLink);
|
| - DCHECK(link1 != std::wstring::npos);
|
| + DCHECK(link1 != string16::npos);
|
| size_t link1_end = text.find(kEndLink, link1);
|
| - DCHECK(link1_end != std::wstring::npos);
|
| + DCHECK(link1_end != string16::npos);
|
| size_t link2 = text.find(kBeginLink, link1_end);
|
| - DCHECK(link2 != std::wstring::npos);
|
| + DCHECK(link2 != string16::npos);
|
| size_t link2_end = text.find(kEndLink, link2);
|
| - DCHECK(link1_end != std::wstring::npos);
|
| + DCHECK(link1_end != string16::npos);
|
|
|
| main_label_chunk1_ = text.substr(0, link1);
|
| main_label_chunk2_ = StringSubRange(text, link1_end + kEndLinkOss.size(),
|
| @@ -267,6 +276,11 @@
|
| AddChildView(terms_of_service_url_);
|
| terms_of_service_url_->set_listener(this);
|
|
|
| + error_label_ = new views::Label();
|
| + error_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
|
| + error_label_->SetMultiLine(true);
|
| + AddChildView(error_label_);
|
| +
|
| // Add the Terms of Service line and some whitespace.
|
| height += font.GetHeight() + views::kRelatedControlVerticalSpacing;
|
| #endif
|
| @@ -327,6 +341,16 @@
|
| sz.width(),
|
| main_text_label_height_);
|
|
|
| + // And the error label at the bottom of the main content. This does not fit on
|
| + // screen until EnlargeWindowSizeIfNeeded has been called (which happens when
|
| + // an error is returned from Google Update).
|
| + sz.set_height(error_label_->GetHeightForWidth(sz.width()));
|
| + error_label_->SetBounds(main_text_label_->bounds().x(),
|
| + main_text_label_->bounds().y() +
|
| + main_text_label_->height() +
|
| + kErrorLabelVerticalSpacing,
|
| + sz.width(), sz.height());
|
| +
|
| // Get the y-coordinate of our parent so we can position the text left of the
|
| // buttons at the bottom.
|
| gfx::Rect parent_bounds = parent()->GetContentsBounds();
|
| @@ -484,7 +508,7 @@
|
| if (!(base::win::GetVersion() == base::win::VERSION_VISTA &&
|
| (base::win::OSInfo::GetInstance()->service_pack().major == 0) &&
|
| !base::win::UserAccountControlIsEnabled())) {
|
| - UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR);
|
| + UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR, string16());
|
| // CheckForUpdate(false, ...) means don't upgrade yet.
|
| google_updater_->CheckForUpdate(false, GetWidget());
|
| }
|
| @@ -593,6 +617,7 @@
|
|
|
| void AboutChromeView::OnReportResults(GoogleUpdateUpgradeResult result,
|
| GoogleUpdateErrorCode error_code,
|
| + const string16& error_message,
|
| const string16& version) {
|
| // Drop the last reference to the object so that it gets cleaned up here.
|
| google_updater_ = NULL;
|
| @@ -600,13 +625,14 @@
|
| // Make a note of which version Google Update is reporting is the latest
|
| // version.
|
| new_version_available_ = version;
|
| - UpdateStatus(result, error_code);
|
| + UpdateStatus(result, error_code, error_message);
|
| }
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // AboutChromeView, private:
|
|
|
| void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result,
|
| - GoogleUpdateErrorCode error_code) {
|
| + GoogleUpdateErrorCode error_code,
|
| + const string16& error_message) {
|
| #if !defined(GOOGLE_CHROME_BUILD)
|
| // For Chromium builds it would show an error message.
|
| // But it looks weird because in fact there is no error,
|
| @@ -638,7 +664,7 @@
|
| DCHECK(!google_updater_); // Should have been nulled out already.
|
| google_updater_ = new GoogleUpdate();
|
| google_updater_->set_status_listener(this);
|
| - UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR);
|
| + UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, string16());
|
| // CheckForUpdate(true,...) means perform upgrade if new version found.
|
| google_updater_->CheckForUpdate(true, GetWidget());
|
| // TODO(seanparent): Need to see if this code needs to change to
|
| @@ -668,7 +694,7 @@
|
| (installed_version->CompareTo(*running_version) <= 0)) {
|
| UserMetrics::RecordAction(
|
| UserMetricsAction("UpgradeCheck_AlreadyUpToDate"));
|
| - std::wstring update_label_text = l10n_util::GetStringFUTF16(
|
| + string16 update_label_text = l10n_util::GetStringFUTF16(
|
| IDS_UPGRADE_ALREADY_UP_TO_DATE,
|
| l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
|
| ASCIIToUTF16(version_info.Version()));
|
| @@ -689,7 +715,7 @@
|
| else
|
| UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Upgraded"));
|
| restart_button_visible_ = true;
|
| - const std::wstring& update_string =
|
| + const string16& update_string =
|
| UTF16ToWide(l10n_util::GetStringFUTF16(
|
| IDS_UPGRADE_SUCCESSFUL_RELAUNCH,
|
| l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
|
| @@ -697,8 +723,16 @@
|
| show_success_indicator = true;
|
| break;
|
| }
|
| - case UPGRADE_ERROR:
|
| + case UPGRADE_ERROR: {
|
| UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Error"));
|
| + if (!error_message.empty()) {
|
| + error_label_->SetText(
|
| + l10n_util::GetStringFUTF16(IDS_ABOUT_BOX_ERROR_DURING_UPDATE_CHECK,
|
| + error_message));
|
| + int added_height = EnlargeWindowSizeIfNeeded();
|
| + dialog_dimensions_.set_height(dialog_dimensions_.height() +
|
| + added_height);
|
| + }
|
| restart_button_visible_ = false;
|
| if (error_code != GOOGLE_UPDATE_DISABLED_BY_POLICY) {
|
| update_label_.SetText(
|
| @@ -709,6 +743,7 @@
|
| }
|
| show_timeout_indicator = true;
|
| break;
|
| + }
|
| default:
|
| NOTREACHED();
|
| }
|
| @@ -732,4 +767,20 @@
|
| GetDialogClientView()->UpdateDialogButtons();
|
| }
|
|
|
| +int AboutChromeView::EnlargeWindowSizeIfNeeded() {
|
| + if (error_label_->GetText().empty())
|
| + return 0;
|
| +
|
| + // This will enlarge the window each time the function is called, which is
|
| + // fine since we only receive status once from Google Update.
|
| + gfx::Rect window_rect = GetWidget()->GetWindowScreenBounds();
|
| + int height = error_label_->GetHeightForWidth(
|
| + dialog_dimensions_.width() - (2 * views::kPanelHorizMargin)) +
|
| + views::kRelatedControlVerticalSpacing;
|
| + window_rect.set_height(window_rect.height() + height);
|
| + GetWidget()->SetBounds(window_rect);
|
| +
|
| + return height;
|
| +}
|
| +
|
| #endif
|
|
|