| 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 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
| 20 #include "chrome/browser/google/google_util.h" | 20 #include "chrome/browser/google/google_util.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
| 22 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
| 23 #include "chrome/browser/ui/dialog_style.h" | 23 #include "chrome/browser/ui/dialog_style.h" |
| 24 #include "chrome/browser/ui/views/window.h" | 24 #include "chrome/browser/ui/views/window.h" |
| 25 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
| 26 #include "chrome/common/chrome_version_info.h" | 26 #include "chrome/common/chrome_version_info.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "chrome/installer/util/browser_distribution.h" | 28 #include "chrome/installer/util/browser_distribution.h" |
| 29 #include "content/browser/user_metrics.h" | 29 #include "content/public/browser/user_metrics.h" |
| 30 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
| 31 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 32 #include "grit/locale_settings.h" | 32 #include "grit/locale_settings.h" |
| 33 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
| 36 #include "ui/gfx/canvas.h" | 36 #include "ui/gfx/canvas.h" |
| 37 #include "ui/gfx/color_utils.h" | 37 #include "ui/gfx/color_utils.h" |
| 38 #include "ui/views/controls/button/text_button.h" | 38 #include "ui/views/controls/button/text_button.h" |
| 39 #include "ui/views/controls/link.h" | 39 #include "ui/views/controls/link.h" |
| 40 #include "ui/views/controls/textfield/textfield.h" | 40 #include "ui/views/controls/textfield/textfield.h" |
| 41 #include "ui/views/controls/throbber.h" | 41 #include "ui/views/controls/throbber.h" |
| 42 #include "ui/views/layout/layout_constants.h" | 42 #include "ui/views/layout/layout_constants.h" |
| 43 #include "ui/views/view_text_utils.h" | 43 #include "ui/views/view_text_utils.h" |
| 44 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
| 45 #include "webkit/glue/webkit_glue.h" | 45 #include "webkit/glue/webkit_glue.h" |
| 46 | 46 |
| 47 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 48 #include "base/win/win_util.h" | 48 #include "base/win/win_util.h" |
| 49 #include "chrome/browser/browser_process.h" | 49 #include "chrome/browser/browser_process.h" |
| 50 #include "chrome/browser/ui/views/restart_message_box.h" | 50 #include "chrome/browser/ui/views/restart_message_box.h" |
| 51 #include "chrome/installer/util/install_util.h" | 51 #include "chrome/installer/util/install_util.h" |
| 52 #endif // defined(OS_WIN) | 52 #endif // defined(OS_WIN) |
| 53 | 53 |
| 54 using content::UserMetricsAction; |
| 55 |
| 54 // The amount of vertical space separating the error label at the bottom from | 56 // The amount of vertical space separating the error label at the bottom from |
| 55 // the rest of the text. | 57 // the rest of the text. |
| 56 static const int kErrorLabelVerticalSpacing = 15; // Pixels. | 58 static const int kErrorLabelVerticalSpacing = 15; // Pixels. |
| 57 | 59 |
| 58 namespace { | 60 namespace { |
| 59 // These are used as placeholder text around the links in the text in the about | 61 // These are used as placeholder text around the links in the text in the about |
| 60 // dialog. | 62 // dialog. |
| 61 string16 kBeginLink() { | 63 string16 kBeginLink() { |
| 62 return ASCIIToUTF16("BEGIN_LINK"); | 64 return ASCIIToUTF16("BEGIN_LINK"); |
| 63 } | 65 } |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 return; | 658 return; |
| 657 #endif | 659 #endif |
| 658 bool show_success_indicator = false; | 660 bool show_success_indicator = false; |
| 659 bool show_update_available_indicator = false; | 661 bool show_update_available_indicator = false; |
| 660 bool show_timeout_indicator = false; | 662 bool show_timeout_indicator = false; |
| 661 bool show_throbber = false; | 663 bool show_throbber = false; |
| 662 bool show_update_label = true; // Always visible, except at start. | 664 bool show_update_label = true; // Always visible, except at start. |
| 663 | 665 |
| 664 switch (result) { | 666 switch (result) { |
| 665 case UPGRADE_STARTED: | 667 case UPGRADE_STARTED: |
| 666 UserMetrics::RecordAction(UserMetricsAction("Upgrade_Started")); | 668 content::RecordAction(UserMetricsAction("Upgrade_Started")); |
| 667 show_throbber = true; | 669 show_throbber = true; |
| 668 update_label_.SetText( | 670 update_label_.SetText( |
| 669 UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPGRADE_STARTED))); | 671 UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPGRADE_STARTED))); |
| 670 break; | 672 break; |
| 671 case UPGRADE_CHECK_STARTED: | 673 case UPGRADE_CHECK_STARTED: |
| 672 UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Started")); | 674 content::RecordAction(UserMetricsAction("UpgradeCheck_Started")); |
| 673 show_throbber = true; | 675 show_throbber = true; |
| 674 update_label_.SetText( | 676 update_label_.SetText( |
| 675 UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPGRADE_CHECK_STARTED))); | 677 UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPGRADE_CHECK_STARTED))); |
| 676 break; | 678 break; |
| 677 case UPGRADE_IS_AVAILABLE: | 679 case UPGRADE_IS_AVAILABLE: |
| 678 UserMetrics::RecordAction( | 680 content::RecordAction( |
| 679 UserMetricsAction("UpgradeCheck_UpgradeIsAvailable")); | 681 UserMetricsAction("UpgradeCheck_UpgradeIsAvailable")); |
| 680 DCHECK(!google_updater_); // Should have been nulled out already. | 682 DCHECK(!google_updater_); // Should have been nulled out already. |
| 681 google_updater_ = new GoogleUpdate(); | 683 google_updater_ = new GoogleUpdate(); |
| 682 google_updater_->set_status_listener(this); | 684 google_updater_->set_status_listener(this); |
| 683 UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, string16()); | 685 UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, string16()); |
| 684 // CheckForUpdate(true,...) means perform upgrade if new version found. | 686 // CheckForUpdate(true,...) means perform upgrade if new version found. |
| 685 google_updater_->CheckForUpdate(true, GetWidget()); | 687 google_updater_->CheckForUpdate(true, GetWidget()); |
| 686 // TODO(seanparent): Need to see if this code needs to change to | 688 // TODO(seanparent): Need to see if this code needs to change to |
| 687 // force a machine restart. | 689 // force a machine restart. |
| 688 return; | 690 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 701 scoped_ptr<Version> installed_version( | 703 scoped_ptr<Version> installed_version( |
| 702 InstallUtil::GetChromeVersion(dist, false)); | 704 InstallUtil::GetChromeVersion(dist, false)); |
| 703 if (!installed_version.get()) { | 705 if (!installed_version.get()) { |
| 704 // User-level Chrome is not installed, check system-level. | 706 // User-level Chrome is not installed, check system-level. |
| 705 installed_version.reset(InstallUtil::GetChromeVersion(dist, true)); | 707 installed_version.reset(InstallUtil::GetChromeVersion(dist, true)); |
| 706 } | 708 } |
| 707 scoped_ptr<Version> running_version( | 709 scoped_ptr<Version> running_version( |
| 708 Version::GetVersionFromString(version_info.Version())); | 710 Version::GetVersionFromString(version_info.Version())); |
| 709 if (!installed_version.get() || | 711 if (!installed_version.get() || |
| 710 (installed_version->CompareTo(*running_version) <= 0)) { | 712 (installed_version->CompareTo(*running_version) <= 0)) { |
| 711 UserMetrics::RecordAction( | 713 content::RecordAction( |
| 712 UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); | 714 UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); |
| 713 string16 update_label_text = l10n_util::GetStringFUTF16( | 715 string16 update_label_text = l10n_util::GetStringFUTF16( |
| 714 IDS_UPGRADE_ALREADY_UP_TO_DATE, | 716 IDS_UPGRADE_ALREADY_UP_TO_DATE, |
| 715 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 717 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
| 716 ASCIIToUTF16(version_info.Version())); | 718 ASCIIToUTF16(version_info.Version())); |
| 717 if (base::i18n::IsRTL()) { | 719 if (base::i18n::IsRTL()) { |
| 718 update_label_text.push_back( | 720 update_label_text.push_back( |
| 719 static_cast<wchar_t>(base::i18n::kLeftToRightMark)); | 721 static_cast<wchar_t>(base::i18n::kLeftToRightMark)); |
| 720 } | 722 } |
| 721 update_label_.SetText(update_label_text); | 723 update_label_.SetText(update_label_text); |
| 722 show_success_indicator = true; | 724 show_success_indicator = true; |
| 723 break; | 725 break; |
| 724 } | 726 } |
| 725 // No break here as we want to notify user about upgrade if there is one. | 727 // No break here as we want to notify user about upgrade if there is one. |
| 726 } | 728 } |
| 727 case UPGRADE_SUCCESSFUL: { | 729 case UPGRADE_SUCCESSFUL: { |
| 728 if (result == UPGRADE_ALREADY_UP_TO_DATE) | 730 if (result == UPGRADE_ALREADY_UP_TO_DATE) |
| 729 UserMetrics::RecordAction( | 731 content::RecordAction( |
| 730 UserMetricsAction("UpgradeCheck_AlreadyUpgraded")); | 732 UserMetricsAction("UpgradeCheck_AlreadyUpgraded")); |
| 731 else | 733 else |
| 732 UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Upgraded")); | 734 content::RecordAction(UserMetricsAction("UpgradeCheck_Upgraded")); |
| 733 restart_button_visible_ = true; | 735 restart_button_visible_ = true; |
| 734 const string16& update_string = | 736 const string16& update_string = |
| 735 UTF16ToWide(l10n_util::GetStringFUTF16( | 737 UTF16ToWide(l10n_util::GetStringFUTF16( |
| 736 IDS_UPGRADE_SUCCESSFUL_RELAUNCH, | 738 IDS_UPGRADE_SUCCESSFUL_RELAUNCH, |
| 737 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 739 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 738 update_label_.SetText(update_string); | 740 update_label_.SetText(update_string); |
| 739 show_success_indicator = true; | 741 show_success_indicator = true; |
| 740 break; | 742 break; |
| 741 } | 743 } |
| 742 case UPGRADE_ERROR: { | 744 case UPGRADE_ERROR: { |
| 743 UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Error")); | 745 content::RecordAction(UserMetricsAction("UpgradeCheck_Error")); |
| 744 if (!error_message.empty() && error_label_) { | 746 if (!error_message.empty() && error_label_) { |
| 745 error_label_->SetText( | 747 error_label_->SetText( |
| 746 l10n_util::GetStringFUTF16(IDS_ABOUT_BOX_ERROR_DURING_UPDATE_CHECK, | 748 l10n_util::GetStringFUTF16(IDS_ABOUT_BOX_ERROR_DURING_UPDATE_CHECK, |
| 747 error_message)); | 749 error_message)); |
| 748 int added_height = EnlargeWindowSizeIfNeeded(); | 750 int added_height = EnlargeWindowSizeIfNeeded(); |
| 749 dialog_dimensions_.set_height(dialog_dimensions_.height() + | 751 dialog_dimensions_.set_height(dialog_dimensions_.height() + |
| 750 added_height); | 752 added_height); |
| 751 } | 753 } |
| 752 restart_button_visible_ = false; | 754 restart_button_visible_ = false; |
| 753 if (error_code != GOOGLE_UPDATE_DISABLED_BY_POLICY) { | 755 if (error_code != GOOGLE_UPDATE_DISABLED_BY_POLICY) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 int height = error_label_->GetHeightForWidth( | 795 int height = error_label_->GetHeightForWidth( |
| 794 dialog_dimensions_.width() - (2 * views::kPanelHorizMargin)) + | 796 dialog_dimensions_.width() - (2 * views::kPanelHorizMargin)) + |
| 795 views::kRelatedControlVerticalSpacing; | 797 views::kRelatedControlVerticalSpacing; |
| 796 window_rect.set_height(window_rect.height() + height); | 798 window_rect.set_height(window_rect.height() + height); |
| 797 GetWidget()->SetBounds(window_rect); | 799 GetWidget()->SetBounds(window_rect); |
| 798 | 800 |
| 799 return height; | 801 return height; |
| 800 } | 802 } |
| 801 | 803 |
| 802 #endif | 804 #endif |
| OLD | NEW |