OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/about_chrome_view.h" | 5 #include "chrome/browser/ui/views/about_chrome_view.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <commdlg.h> | 8 #include <commdlg.h> |
9 #endif // defined(OS_WIN) | 9 #endif // defined(OS_WIN) |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "views/widget/widget.h" | 43 #include "views/widget/widget.h" |
44 #include "webkit/glue/webkit_glue.h" | 44 #include "webkit/glue/webkit_glue.h" |
45 | 45 |
46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
47 #include "base/win/win_util.h" | 47 #include "base/win/win_util.h" |
48 #include "chrome/browser/browser_process.h" | 48 #include "chrome/browser/browser_process.h" |
49 #include "chrome/browser/ui/views/restart_message_box.h" | 49 #include "chrome/browser/ui/views/restart_message_box.h" |
50 #include "chrome/installer/util/install_util.h" | 50 #include "chrome/installer/util/install_util.h" |
51 #endif // defined(OS_WIN) | 51 #endif // defined(OS_WIN) |
52 | 52 |
| 53 // The amount of vertical space separating the error label at the bottom from |
| 54 // the rest of the text. |
| 55 static const int kErrorLabelVerticalSpacing = 15; // Pixels. |
| 56 |
53 namespace { | 57 namespace { |
54 // These are used as placeholder text around the links in the text in the about | 58 // These are used as placeholder text around the links in the text in the about |
55 // dialog. | 59 // dialog. |
56 const string16 kBeginLink(ASCIIToUTF16("BEGIN_LINK")); | 60 const string16 kBeginLink(ASCIIToUTF16("BEGIN_LINK")); |
57 const string16 kEndLink(ASCIIToUTF16("END_LINK")); | 61 const string16 kEndLink(ASCIIToUTF16("END_LINK")); |
58 const string16 kBeginLinkChr(ASCIIToUTF16("BEGIN_LINK_CHR")); | 62 const string16 kBeginLinkChr(ASCIIToUTF16("BEGIN_LINK_CHR")); |
59 const string16 kBeginLinkOss(ASCIIToUTF16("BEGIN_LINK_OSS")); | 63 const string16 kBeginLinkOss(ASCIIToUTF16("BEGIN_LINK_OSS")); |
60 const string16 kEndLinkChr(ASCIIToUTF16("END_LINK_CHR")); | 64 const string16 kEndLinkChr(ASCIIToUTF16("END_LINK_CHR")); |
61 const string16 kEndLinkOss(ASCIIToUTF16("END_LINK_OSS")); | 65 const string16 kEndLinkOss(ASCIIToUTF16("END_LINK_OSS")); |
62 | 66 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 162 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
159 about_title_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( | 163 about_title_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( |
160 ResourceBundle::BaseFont).DeriveFont(18)); | 164 ResourceBundle::BaseFont).DeriveFont(18)); |
161 about_title_label_->SetBackgroundColor(SK_ColorWHITE); | 165 about_title_label_->SetBackgroundColor(SK_ColorWHITE); |
162 about_title_label_->SetEnabledColor(SK_ColorBLACK); | 166 about_title_label_->SetEnabledColor(SK_ColorBLACK); |
163 AddChildView(about_title_label_); | 167 AddChildView(about_title_label_); |
164 | 168 |
165 // This is a text field so people can copy the version number from the dialog. | 169 // This is a text field so people can copy the version number from the dialog. |
166 version_label_ = new views::Textfield(); | 170 version_label_ = new views::Textfield(); |
167 chrome::VersionInfo version_info; | 171 chrome::VersionInfo version_info; |
168 version_label_->SetText(UTF8ToUTF16(version_info.CreateVersionString())); | 172 { |
| 173 // TODO(finnur): Need to evaluate whether we should be doing IO here. |
| 174 // See issue: http://crbug.com/101699. |
| 175 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 176 version_label_->SetText(UTF8ToUTF16(version_info.CreateVersionString())); |
| 177 } |
169 version_label_->SetReadOnly(true); | 178 version_label_->SetReadOnly(true); |
170 version_label_->RemoveBorder(); | 179 version_label_->RemoveBorder(); |
171 version_label_->SetTextColor(SK_ColorBLACK); | 180 version_label_->SetTextColor(SK_ColorBLACK); |
172 version_label_->SetBackgroundColor(SK_ColorWHITE); | 181 version_label_->SetBackgroundColor(SK_ColorWHITE); |
173 version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( | 182 version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( |
174 ResourceBundle::BaseFont)); | 183 ResourceBundle::BaseFont)); |
175 AddChildView(version_label_); | 184 AddChildView(version_label_); |
176 | 185 |
177 // The copyright URL portion of the main label. | 186 // The copyright URL portion of the main label. |
178 copyright_label_ = new views::Label( | 187 copyright_label_ = new views::Label( |
179 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT)); | 188 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT)); |
180 copyright_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 189 copyright_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
181 AddChildView(copyright_label_); | 190 AddChildView(copyright_label_); |
182 | 191 |
183 main_text_label_ = new views::Label(string16()); | 192 main_text_label_ = new views::Label(string16()); |
184 | 193 |
185 // Figure out what to write in the main label of the About box. | 194 // Figure out what to write in the main label of the About box. |
186 string16 text = l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_LICENSE); | 195 string16 text = l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_LICENSE); |
187 | 196 |
188 chromium_url_appears_first_ = | 197 chromium_url_appears_first_ = |
189 text.find(kBeginLinkChr) < text.find(kBeginLinkOss); | 198 text.find(kBeginLinkChr) < text.find(kBeginLinkOss); |
190 | 199 |
191 size_t link1 = text.find(kBeginLink); | 200 size_t link1 = text.find(kBeginLink); |
192 DCHECK(link1 != std::wstring::npos); | 201 DCHECK(link1 != string16::npos); |
193 size_t link1_end = text.find(kEndLink, link1); | 202 size_t link1_end = text.find(kEndLink, link1); |
194 DCHECK(link1_end != std::wstring::npos); | 203 DCHECK(link1_end != string16::npos); |
195 size_t link2 = text.find(kBeginLink, link1_end); | 204 size_t link2 = text.find(kBeginLink, link1_end); |
196 DCHECK(link2 != std::wstring::npos); | 205 DCHECK(link2 != string16::npos); |
197 size_t link2_end = text.find(kEndLink, link2); | 206 size_t link2_end = text.find(kEndLink, link2); |
198 DCHECK(link1_end != std::wstring::npos); | 207 DCHECK(link1_end != string16::npos); |
199 | 208 |
200 main_label_chunk1_ = text.substr(0, link1); | 209 main_label_chunk1_ = text.substr(0, link1); |
201 main_label_chunk2_ = StringSubRange(text, link1_end + kEndLinkOss.size(), | 210 main_label_chunk2_ = StringSubRange(text, link1_end + kEndLinkOss.size(), |
202 link2); | 211 link2); |
203 main_label_chunk3_ = text.substr(link2_end + kEndLinkOss.size()); | 212 main_label_chunk3_ = text.substr(link2_end + kEndLinkOss.size()); |
204 | 213 |
205 // The Chromium link within the main text of the dialog. | 214 // The Chromium link within the main text of the dialog. |
206 chromium_url_ = new views::Link( | 215 chromium_url_ = new views::Link( |
207 StringSubRange(text, text.find(kBeginLinkChr) + kBeginLinkChr.size(), | 216 StringSubRange(text, text.find(kBeginLinkChr) + kBeginLinkChr.size(), |
208 text.find(kEndLinkChr))); | 217 text.find(kEndLinkChr))); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 269 |
261 main_label_chunk4_ = text.substr(0, url_offsets[0]); | 270 main_label_chunk4_ = text.substr(0, url_offsets[0]); |
262 main_label_chunk5_ = text.substr(url_offsets[0]); | 271 main_label_chunk5_ = text.substr(url_offsets[0]); |
263 | 272 |
264 // The Terms of Service URL at the bottom. | 273 // The Terms of Service URL at the bottom. |
265 terms_of_service_url_ = new views::Link( | 274 terms_of_service_url_ = new views::Link( |
266 l10n_util::GetStringUTF16(IDS_TERMS_OF_SERVICE)); | 275 l10n_util::GetStringUTF16(IDS_TERMS_OF_SERVICE)); |
267 AddChildView(terms_of_service_url_); | 276 AddChildView(terms_of_service_url_); |
268 terms_of_service_url_->set_listener(this); | 277 terms_of_service_url_->set_listener(this); |
269 | 278 |
| 279 error_label_ = new views::Label(); |
| 280 error_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 281 error_label_->SetMultiLine(true); |
| 282 AddChildView(error_label_); |
| 283 |
270 // Add the Terms of Service line and some whitespace. | 284 // Add the Terms of Service line and some whitespace. |
271 height += font.GetHeight() + views::kRelatedControlVerticalSpacing; | 285 height += font.GetHeight() + views::kRelatedControlVerticalSpacing; |
272 #endif | 286 #endif |
273 | 287 |
274 // Use whichever is greater (the calculated height or the specified minimum | 288 // Use whichever is greater (the calculated height or the specified minimum |
275 // height). | 289 // height). |
276 dialog_dimensions_.set_height(std::max(height, dialog_dimensions_.height())); | 290 dialog_dimensions_.set_height(std::max(height, dialog_dimensions_.height())); |
277 } | 291 } |
278 | 292 |
279 //////////////////////////////////////////////////////////////////////////////// | 293 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 sz.width(), | 334 sz.width(), |
321 sz.height()); | 335 sz.height()); |
322 | 336 |
323 // Then the main_text_label. | 337 // Then the main_text_label. |
324 main_text_label_->SetBounds(views::kPanelHorizMargin, | 338 main_text_label_->SetBounds(views::kPanelHorizMargin, |
325 copyright_label_->y() + | 339 copyright_label_->y() + |
326 copyright_label_->height(), | 340 copyright_label_->height(), |
327 sz.width(), | 341 sz.width(), |
328 main_text_label_height_); | 342 main_text_label_height_); |
329 | 343 |
| 344 // And the error label at the bottom of the main content. This does not fit on |
| 345 // screen until EnlargeWindowSizeIfNeeded has been called (which happens when |
| 346 // an error is returned from Google Update). |
| 347 sz.set_height(error_label_->GetHeightForWidth(sz.width())); |
| 348 error_label_->SetBounds(main_text_label_->bounds().x(), |
| 349 main_text_label_->bounds().y() + |
| 350 main_text_label_->height() + |
| 351 kErrorLabelVerticalSpacing, |
| 352 sz.width(), sz.height()); |
| 353 |
330 // Get the y-coordinate of our parent so we can position the text left of the | 354 // Get the y-coordinate of our parent so we can position the text left of the |
331 // buttons at the bottom. | 355 // buttons at the bottom. |
332 gfx::Rect parent_bounds = parent()->GetContentsBounds(); | 356 gfx::Rect parent_bounds = parent()->GetContentsBounds(); |
333 | 357 |
334 sz = throbber_->GetPreferredSize(); | 358 sz = throbber_->GetPreferredSize(); |
335 int throbber_topleft_x = views::kPanelHorizMargin; | 359 int throbber_topleft_x = views::kPanelHorizMargin; |
336 int throbber_topleft_y = | 360 int throbber_topleft_y = |
337 parent_bounds.bottom() - sz.height() - views::kButtonVEdgeMargin - 3; | 361 parent_bounds.bottom() - sz.height() - views::kButtonVEdgeMargin - 3; |
338 throbber_->SetBounds(throbber_topleft_x, throbber_topleft_y, | 362 throbber_->SetBounds(throbber_topleft_x, throbber_topleft_y, |
339 sz.width(), sz.height()); | 363 sz.width(), sz.height()); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 501 |
478 #if defined(OS_WIN) && !defined(USE_AURA) | 502 #if defined(OS_WIN) && !defined(USE_AURA) |
479 // On-demand updates for Chrome don't work in Vista RTM when UAC is turned | 503 // On-demand updates for Chrome don't work in Vista RTM when UAC is turned |
480 // off. So, in this case we just want the About box to not mention | 504 // off. So, in this case we just want the About box to not mention |
481 // on-demand updates. Silent updates (in the background) should still | 505 // on-demand updates. Silent updates (in the background) should still |
482 // work as before - enabling UAC or installing the latest service pack | 506 // work as before - enabling UAC or installing the latest service pack |
483 // for Vista is another option. | 507 // for Vista is another option. |
484 if (!(base::win::GetVersion() == base::win::VERSION_VISTA && | 508 if (!(base::win::GetVersion() == base::win::VERSION_VISTA && |
485 (base::win::OSInfo::GetInstance()->service_pack().major == 0) && | 509 (base::win::OSInfo::GetInstance()->service_pack().major == 0) && |
486 !base::win::UserAccountControlIsEnabled())) { | 510 !base::win::UserAccountControlIsEnabled())) { |
487 UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR); | 511 UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR, string16()); |
488 // CheckForUpdate(false, ...) means don't upgrade yet. | 512 // CheckForUpdate(false, ...) means don't upgrade yet. |
489 google_updater_->CheckForUpdate(false, GetWidget()); | 513 google_updater_->CheckForUpdate(false, GetWidget()); |
490 } | 514 } |
491 #endif | 515 #endif |
492 } else { | 516 } else { |
493 parent->RemoveChildView(&update_label_); | 517 parent->RemoveChildView(&update_label_); |
494 parent->RemoveChildView(throbber_.get()); | 518 parent->RemoveChildView(throbber_.get()); |
495 parent->RemoveChildView(&success_indicator_); | 519 parent->RemoveChildView(&success_indicator_); |
496 parent->RemoveChildView(&update_available_indicator_); | 520 parent->RemoveChildView(&update_available_indicator_); |
497 parent->RemoveChildView(&timeout_indicator_); | 521 parent->RemoveChildView(&timeout_indicator_); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 610 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
587 browser->OpenURL(url, GURL(), NEW_WINDOW, content::PAGE_TRANSITION_LINK); | 611 browser->OpenURL(url, GURL(), NEW_WINDOW, content::PAGE_TRANSITION_LINK); |
588 } | 612 } |
589 | 613 |
590 #if defined(OS_WIN) && !defined(USE_AURA) | 614 #if defined(OS_WIN) && !defined(USE_AURA) |
591 //////////////////////////////////////////////////////////////////////////////// | 615 //////////////////////////////////////////////////////////////////////////////// |
592 // AboutChromeView, GoogleUpdateStatusListener implementation: | 616 // AboutChromeView, GoogleUpdateStatusListener implementation: |
593 | 617 |
594 void AboutChromeView::OnReportResults(GoogleUpdateUpgradeResult result, | 618 void AboutChromeView::OnReportResults(GoogleUpdateUpgradeResult result, |
595 GoogleUpdateErrorCode error_code, | 619 GoogleUpdateErrorCode error_code, |
| 620 const string16& error_message, |
596 const string16& version) { | 621 const string16& version) { |
597 // Drop the last reference to the object so that it gets cleaned up here. | 622 // Drop the last reference to the object so that it gets cleaned up here. |
598 google_updater_ = NULL; | 623 google_updater_ = NULL; |
599 | 624 |
600 // Make a note of which version Google Update is reporting is the latest | 625 // Make a note of which version Google Update is reporting is the latest |
601 // version. | 626 // version. |
602 new_version_available_ = version; | 627 new_version_available_ = version; |
603 UpdateStatus(result, error_code); | 628 UpdateStatus(result, error_code, error_message); |
604 } | 629 } |
605 //////////////////////////////////////////////////////////////////////////////// | 630 //////////////////////////////////////////////////////////////////////////////// |
606 // AboutChromeView, private: | 631 // AboutChromeView, private: |
607 | 632 |
608 void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, | 633 void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, |
609 GoogleUpdateErrorCode error_code) { | 634 GoogleUpdateErrorCode error_code, |
| 635 const string16& error_message) { |
610 #if !defined(GOOGLE_CHROME_BUILD) | 636 #if !defined(GOOGLE_CHROME_BUILD) |
611 // For Chromium builds it would show an error message. | 637 // For Chromium builds it would show an error message. |
612 // But it looks weird because in fact there is no error, | 638 // But it looks weird because in fact there is no error, |
613 // just the update server is not available for non-official builds. | 639 // just the update server is not available for non-official builds. |
614 return; | 640 return; |
615 #endif | 641 #endif |
616 bool show_success_indicator = false; | 642 bool show_success_indicator = false; |
617 bool show_update_available_indicator = false; | 643 bool show_update_available_indicator = false; |
618 bool show_timeout_indicator = false; | 644 bool show_timeout_indicator = false; |
619 bool show_throbber = false; | 645 bool show_throbber = false; |
(...skipping 11 matching lines...) Expand all Loading... |
631 show_throbber = true; | 657 show_throbber = true; |
632 update_label_.SetText( | 658 update_label_.SetText( |
633 UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPGRADE_CHECK_STARTED))); | 659 UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPGRADE_CHECK_STARTED))); |
634 break; | 660 break; |
635 case UPGRADE_IS_AVAILABLE: | 661 case UPGRADE_IS_AVAILABLE: |
636 UserMetrics::RecordAction( | 662 UserMetrics::RecordAction( |
637 UserMetricsAction("UpgradeCheck_UpgradeIsAvailable")); | 663 UserMetricsAction("UpgradeCheck_UpgradeIsAvailable")); |
638 DCHECK(!google_updater_); // Should have been nulled out already. | 664 DCHECK(!google_updater_); // Should have been nulled out already. |
639 google_updater_ = new GoogleUpdate(); | 665 google_updater_ = new GoogleUpdate(); |
640 google_updater_->set_status_listener(this); | 666 google_updater_->set_status_listener(this); |
641 UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR); | 667 UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, string16()); |
642 // CheckForUpdate(true,...) means perform upgrade if new version found. | 668 // CheckForUpdate(true,...) means perform upgrade if new version found. |
643 google_updater_->CheckForUpdate(true, GetWidget()); | 669 google_updater_->CheckForUpdate(true, GetWidget()); |
644 // TODO(seanparent): Need to see if this code needs to change to | 670 // TODO(seanparent): Need to see if this code needs to change to |
645 // force a machine restart. | 671 // force a machine restart. |
646 return; | 672 return; |
647 case UPGRADE_ALREADY_UP_TO_DATE: { | 673 case UPGRADE_ALREADY_UP_TO_DATE: { |
648 // The extra version check is necessary on Windows because the application | 674 // The extra version check is necessary on Windows because the application |
649 // may be already up to date on disk though the running app is still | 675 // may be already up to date on disk though the running app is still |
650 // out of date. Chrome OS doesn't quite have this issue since the | 676 // out of date. Chrome OS doesn't quite have this issue since the |
651 // OS/App are updated together. If a newer version of the OS has been | 677 // OS/App are updated together. If a newer version of the OS has been |
652 // staged then UPGRADE_SUCESSFUL will be returned. | 678 // staged then UPGRADE_SUCESSFUL will be returned. |
653 // Google Update reported that Chrome is up-to-date. Now make sure that we | 679 // Google Update reported that Chrome is up-to-date. Now make sure that we |
654 // are running the latest version and if not, notify the user by falling | 680 // are running the latest version and if not, notify the user by falling |
655 // into the next case of UPGRADE_SUCCESSFUL. | 681 // into the next case of UPGRADE_SUCCESSFUL. |
656 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 682 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
657 base::ThreadRestrictions::ScopedAllowIO allow_io; | 683 base::ThreadRestrictions::ScopedAllowIO allow_io; |
658 chrome::VersionInfo version_info; | 684 chrome::VersionInfo version_info; |
659 scoped_ptr<Version> installed_version( | 685 scoped_ptr<Version> installed_version( |
660 InstallUtil::GetChromeVersion(dist, false)); | 686 InstallUtil::GetChromeVersion(dist, false)); |
661 if (!installed_version.get()) { | 687 if (!installed_version.get()) { |
662 // User-level Chrome is not installed, check system-level. | 688 // User-level Chrome is not installed, check system-level. |
663 installed_version.reset(InstallUtil::GetChromeVersion(dist, true)); | 689 installed_version.reset(InstallUtil::GetChromeVersion(dist, true)); |
664 } | 690 } |
665 scoped_ptr<Version> running_version( | 691 scoped_ptr<Version> running_version( |
666 Version::GetVersionFromString(version_info.Version())); | 692 Version::GetVersionFromString(version_info.Version())); |
667 if (!installed_version.get() || | 693 if (!installed_version.get() || |
668 (installed_version->CompareTo(*running_version) <= 0)) { | 694 (installed_version->CompareTo(*running_version) <= 0)) { |
669 UserMetrics::RecordAction( | 695 UserMetrics::RecordAction( |
670 UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); | 696 UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); |
671 std::wstring update_label_text = l10n_util::GetStringFUTF16( | 697 string16 update_label_text = l10n_util::GetStringFUTF16( |
672 IDS_UPGRADE_ALREADY_UP_TO_DATE, | 698 IDS_UPGRADE_ALREADY_UP_TO_DATE, |
673 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 699 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
674 ASCIIToUTF16(version_info.Version())); | 700 ASCIIToUTF16(version_info.Version())); |
675 if (base::i18n::IsRTL()) { | 701 if (base::i18n::IsRTL()) { |
676 update_label_text.push_back( | 702 update_label_text.push_back( |
677 static_cast<wchar_t>(base::i18n::kLeftToRightMark)); | 703 static_cast<wchar_t>(base::i18n::kLeftToRightMark)); |
678 } | 704 } |
679 update_label_.SetText(update_label_text); | 705 update_label_.SetText(update_label_text); |
680 show_success_indicator = true; | 706 show_success_indicator = true; |
681 break; | 707 break; |
682 } | 708 } |
683 // No break here as we want to notify user about upgrade if there is one. | 709 // No break here as we want to notify user about upgrade if there is one. |
684 } | 710 } |
685 case UPGRADE_SUCCESSFUL: { | 711 case UPGRADE_SUCCESSFUL: { |
686 if (result == UPGRADE_ALREADY_UP_TO_DATE) | 712 if (result == UPGRADE_ALREADY_UP_TO_DATE) |
687 UserMetrics::RecordAction( | 713 UserMetrics::RecordAction( |
688 UserMetricsAction("UpgradeCheck_AlreadyUpgraded")); | 714 UserMetricsAction("UpgradeCheck_AlreadyUpgraded")); |
689 else | 715 else |
690 UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Upgraded")); | 716 UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Upgraded")); |
691 restart_button_visible_ = true; | 717 restart_button_visible_ = true; |
692 const std::wstring& update_string = | 718 const string16& update_string = |
693 UTF16ToWide(l10n_util::GetStringFUTF16( | 719 UTF16ToWide(l10n_util::GetStringFUTF16( |
694 IDS_UPGRADE_SUCCESSFUL_RELAUNCH, | 720 IDS_UPGRADE_SUCCESSFUL_RELAUNCH, |
695 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 721 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
696 update_label_.SetText(update_string); | 722 update_label_.SetText(update_string); |
697 show_success_indicator = true; | 723 show_success_indicator = true; |
698 break; | 724 break; |
699 } | 725 } |
700 case UPGRADE_ERROR: | 726 case UPGRADE_ERROR: { |
701 UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Error")); | 727 UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Error")); |
| 728 if (!error_message.empty()) { |
| 729 error_label_->SetText( |
| 730 l10n_util::GetStringFUTF16(IDS_ABOUT_BOX_ERROR_DURING_UPDATE_CHECK, |
| 731 error_message)); |
| 732 int added_height = EnlargeWindowSizeIfNeeded(); |
| 733 dialog_dimensions_.set_height(dialog_dimensions_.height() + |
| 734 added_height); |
| 735 } |
702 restart_button_visible_ = false; | 736 restart_button_visible_ = false; |
703 if (error_code != GOOGLE_UPDATE_DISABLED_BY_POLICY) { | 737 if (error_code != GOOGLE_UPDATE_DISABLED_BY_POLICY) { |
704 update_label_.SetText( | 738 update_label_.SetText( |
705 l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, error_code)); | 739 l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, error_code)); |
706 } else { | 740 } else { |
707 update_label_.SetText( | 741 update_label_.SetText( |
708 l10n_util::GetStringUTF16(IDS_UPGRADE_DISABLED_BY_POLICY)); | 742 l10n_util::GetStringUTF16(IDS_UPGRADE_DISABLED_BY_POLICY)); |
709 } | 743 } |
710 show_timeout_indicator = true; | 744 show_timeout_indicator = true; |
711 break; | 745 break; |
| 746 } |
712 default: | 747 default: |
713 NOTREACHED(); | 748 NOTREACHED(); |
714 } | 749 } |
715 | 750 |
716 success_indicator_.SetVisible(show_success_indicator); | 751 success_indicator_.SetVisible(show_success_indicator); |
717 update_available_indicator_.SetVisible(show_update_available_indicator); | 752 update_available_indicator_.SetVisible(show_update_available_indicator); |
718 timeout_indicator_.SetVisible(show_timeout_indicator); | 753 timeout_indicator_.SetVisible(show_timeout_indicator); |
719 update_label_.SetVisible(show_update_label); | 754 update_label_.SetVisible(show_update_label); |
720 throbber_->SetVisible(show_throbber); | 755 throbber_->SetVisible(show_throbber); |
721 if (show_throbber) | 756 if (show_throbber) |
722 throbber_->Start(); | 757 throbber_->Start(); |
723 else | 758 else |
724 throbber_->Stop(); | 759 throbber_->Stop(); |
725 | 760 |
726 // We have updated controls on the parent, so we need to update its layout. | 761 // We have updated controls on the parent, so we need to update its layout. |
727 parent()->Layout(); | 762 parent()->Layout(); |
728 | 763 |
729 // Check button may have appeared/disappeared. We cannot call this during | 764 // Check button may have appeared/disappeared. We cannot call this during |
730 // ViewHierarchyChanged because the view hasn't been added to a Widget yet. | 765 // ViewHierarchyChanged because the view hasn't been added to a Widget yet. |
731 if (GetWidget()) | 766 if (GetWidget()) |
732 GetDialogClientView()->UpdateDialogButtons(); | 767 GetDialogClientView()->UpdateDialogButtons(); |
733 } | 768 } |
734 | 769 |
| 770 int AboutChromeView::EnlargeWindowSizeIfNeeded() { |
| 771 if (error_label_->GetText().empty()) |
| 772 return 0; |
| 773 |
| 774 // This will enlarge the window each time the function is called, which is |
| 775 // fine since we only receive status once from Google Update. |
| 776 gfx::Rect window_rect = GetWidget()->GetWindowScreenBounds(); |
| 777 int height = error_label_->GetHeightForWidth( |
| 778 dialog_dimensions_.width() - (2 * views::kPanelHorizMargin)) + |
| 779 views::kRelatedControlVerticalSpacing; |
| 780 window_rect.set_height(window_rect.height() + height); |
| 781 GetWidget()->SetBounds(window_rect); |
| 782 |
| 783 return height; |
| 784 } |
| 785 |
735 #endif | 786 #endif |
OLD | NEW |