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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } // namespace browser | 87 } // namespace browser |
88 | 88 |
89 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
90 // AboutChromeView, public: | 90 // AboutChromeView, public: |
91 | 91 |
92 AboutChromeView::AboutChromeView(Profile* profile) | 92 AboutChromeView::AboutChromeView(Profile* profile) |
93 : profile_(profile), | 93 : profile_(profile), |
94 about_dlg_background_logo_(NULL), | 94 about_dlg_background_logo_(NULL), |
95 about_title_label_(NULL), | 95 about_title_label_(NULL), |
96 version_label_(NULL), | 96 version_label_(NULL), |
97 os_version_label_(NULL), | |
98 copyright_label_(NULL), | 97 copyright_label_(NULL), |
99 main_text_label_(NULL), | 98 main_text_label_(NULL), |
100 main_text_label_height_(0), | 99 main_text_label_height_(0), |
101 chromium_url_(NULL), | 100 chromium_url_(NULL), |
102 open_source_url_(NULL), | 101 open_source_url_(NULL), |
103 terms_of_service_url_(NULL), | 102 terms_of_service_url_(NULL), |
104 restart_button_visible_(false), | 103 restart_button_visible_(false), |
105 chromium_url_appears_first_(true), | 104 chromium_url_appears_first_(true), |
106 text_direction_is_rtl_(false) { | 105 text_direction_is_rtl_(false) { |
107 DCHECK(profile); | 106 DCHECK(profile); |
(...skipping 17 matching lines...) Expand all Loading... |
125 // need to let it know that we will no longer be listening. | 124 // need to let it know that we will no longer be listening. |
126 if (google_updater_) | 125 if (google_updater_) |
127 google_updater_->set_status_listener(NULL); | 126 google_updater_->set_status_listener(NULL); |
128 #endif | 127 #endif |
129 } | 128 } |
130 | 129 |
131 void AboutChromeView::Init() { | 130 void AboutChromeView::Init() { |
132 text_direction_is_rtl_ = base::i18n::IsRTL(); | 131 text_direction_is_rtl_ = base::i18n::IsRTL(); |
133 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 132 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
134 | 133 |
135 chrome::VersionInfo version_info; | |
136 if (!version_info.is_valid()) { | |
137 NOTREACHED() << L"Failed to initialize about window"; | |
138 return; | |
139 } | |
140 | |
141 current_version_ = version_info.Version(); | |
142 | |
143 // This code only runs as a result of the user opening the About box so | |
144 // doing registry access to get the version string modifier should be fine. | |
145 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
146 std::string version_modifier = | |
147 chrome::VersionInfo::GetVersionStringModifier(); | |
148 if (!version_modifier.empty()) | |
149 version_details_ += ASCIIToUTF16(" ") + ASCIIToUTF16(version_modifier); | |
150 | |
151 #if !defined(GOOGLE_CHROME_BUILD) | |
152 version_details_ += ASCIIToUTF16(" ("); | |
153 version_details_ += l10n_util::GetStringUTF16( | |
154 version_info.IsOfficialBuild() ? | |
155 IDS_ABOUT_VERSION_OFFICIAL : IDS_ABOUT_VERSION_UNOFFICIAL); | |
156 version_details_ += ASCIIToUTF16(" "); | |
157 version_details_ += ASCIIToUTF16(version_info.LastChange()); | |
158 version_details_ += ASCIIToUTF16(")"); | |
159 #endif | |
160 | |
161 // Views we will add to the *parent* of this dialog, since it will display | 134 // Views we will add to the *parent* of this dialog, since it will display |
162 // next to the buttons which we don't draw ourselves. | 135 // next to the buttons which we don't draw ourselves. |
163 throbber_.reset(new views::Throbber(50, true)); | 136 throbber_.reset(new views::Throbber(50, true)); |
164 throbber_->set_parent_owned(false); | 137 throbber_->set_parent_owned(false); |
165 throbber_->SetVisible(false); | 138 throbber_->SetVisible(false); |
166 | 139 |
167 SkBitmap* success_image = rb.GetBitmapNamed(IDR_UPDATE_UPTODATE); | 140 SkBitmap* success_image = rb.GetBitmapNamed(IDR_UPDATE_UPTODATE); |
168 success_indicator_.SetImage(*success_image); | 141 success_indicator_.SetImage(*success_image); |
169 success_indicator_.set_parent_owned(false); | 142 success_indicator_.set_parent_owned(false); |
170 | 143 |
(...skipping 22 matching lines...) Expand all Loading... |
193 // Add the dialog labels. | 166 // Add the dialog labels. |
194 about_title_label_ = new views::Label( | 167 about_title_label_ = new views::Label( |
195 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 168 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
196 about_title_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( | 169 about_title_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( |
197 ResourceBundle::BaseFont).DeriveFont(18)); | 170 ResourceBundle::BaseFont).DeriveFont(18)); |
198 about_title_label_->SetColor(SK_ColorBLACK); | 171 about_title_label_->SetColor(SK_ColorBLACK); |
199 AddChildView(about_title_label_); | 172 AddChildView(about_title_label_); |
200 | 173 |
201 // This is a text field so people can copy the version number from the dialog. | 174 // This is a text field so people can copy the version number from the dialog. |
202 version_label_ = new views::Textfield(); | 175 version_label_ = new views::Textfield(); |
203 version_label_->SetText(ASCIIToUTF16(current_version_) + version_details_); | 176 chrome::VersionInfo version_info; |
| 177 version_label_->SetText(UTF8ToUTF16(version_info.CreateVersionString())); |
204 version_label_->SetReadOnly(true); | 178 version_label_->SetReadOnly(true); |
205 version_label_->RemoveBorder(); | 179 version_label_->RemoveBorder(); |
206 version_label_->SetTextColor(SK_ColorBLACK); | 180 version_label_->SetTextColor(SK_ColorBLACK); |
207 version_label_->SetBackgroundColor(SK_ColorWHITE); | 181 version_label_->SetBackgroundColor(SK_ColorWHITE); |
208 version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( | 182 version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( |
209 ResourceBundle::BaseFont)); | 183 ResourceBundle::BaseFont)); |
210 AddChildView(version_label_); | 184 AddChildView(version_label_); |
211 | 185 |
212 os_version_label_ = new views::Textfield(); | |
213 os_version_label_->SetText(UTF8ToUTF16(version_info.OSType())); | |
214 os_version_label_->SetReadOnly(true); | |
215 os_version_label_->RemoveBorder(); | |
216 os_version_label_->SetTextColor(SK_ColorBLACK); | |
217 os_version_label_->SetBackgroundColor(SK_ColorWHITE); | |
218 os_version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( | |
219 ResourceBundle::BaseFont)); | |
220 AddChildView(os_version_label_); | |
221 | |
222 // The copyright URL portion of the main label. | 186 // The copyright URL portion of the main label. |
223 copyright_label_ = new views::Label( | 187 copyright_label_ = new views::Label( |
224 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT))); | 188 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT))); |
225 copyright_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 189 copyright_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
226 AddChildView(copyright_label_); | 190 AddChildView(copyright_label_); |
227 | 191 |
228 main_text_label_ = new views::Label(L""); | 192 main_text_label_ = new views::Label(L""); |
229 | 193 |
230 // 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. |
231 std::wstring text = | 195 std::wstring text = |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // Then we have the version number right below it. | 304 // Then we have the version number right below it. |
341 sz = version_label_->GetPreferredSize(); | 305 sz = version_label_->GetPreferredSize(); |
342 version_label_->SetBounds(views::kPanelHorizMargin, | 306 version_label_->SetBounds(views::kPanelHorizMargin, |
343 about_title_label_->y() + | 307 about_title_label_->y() + |
344 about_title_label_->height() + | 308 about_title_label_->height() + |
345 views::kRelatedControlVerticalSpacing, | 309 views::kRelatedControlVerticalSpacing, |
346 panel_size.width() - | 310 panel_size.width() - |
347 about_dlg_background_logo_->width(), | 311 about_dlg_background_logo_->width(), |
348 sz.height()); | 312 sz.height()); |
349 | 313 |
350 // Then we have the version number right below it. | |
351 sz = os_version_label_->GetPreferredSize(); | |
352 os_version_label_->SetBounds( | |
353 views::kPanelHorizMargin, | |
354 version_label_->y() + | |
355 version_label_->height() + | |
356 views::kRelatedControlVerticalSpacing, | |
357 panel_size.width() - | |
358 about_dlg_background_logo_->width(), | |
359 sz.height()); | |
360 | |
361 // For the width of the main text label we want to use up the whole panel | 314 // For the width of the main text label we want to use up the whole panel |
362 // width and remaining height, minus a little margin on each side. | 315 // width and remaining height, minus a little margin on each side. |
363 int y_pos = background_image_height + views::kRelatedControlVerticalSpacing; | 316 int y_pos = background_image_height + views::kRelatedControlVerticalSpacing; |
364 sz.set_width(panel_size.width() - 2 * views::kPanelHorizMargin); | 317 sz.set_width(panel_size.width() - 2 * views::kPanelHorizMargin); |
365 | 318 |
366 // Draw the text right below the background image. | 319 // Draw the text right below the background image. |
367 copyright_label_->SetBounds(views::kPanelHorizMargin, | 320 copyright_label_->SetBounds(views::kPanelHorizMargin, |
368 y_pos, | 321 y_pos, |
369 sz.width(), | 322 sz.width(), |
370 sz.height()); | 323 sz.height()); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 // The extra version check is necessary on Windows because the application | 655 // The extra version check is necessary on Windows because the application |
703 // may be already up to date on disk though the running app is still | 656 // may be already up to date on disk though the running app is still |
704 // out of date. Chrome OS doesn't quite have this issue since the | 657 // out of date. Chrome OS doesn't quite have this issue since the |
705 // OS/App are updated together. If a newer version of the OS has been | 658 // OS/App are updated together. If a newer version of the OS has been |
706 // staged then UPGRADE_SUCESSFUL will be returned. | 659 // staged then UPGRADE_SUCESSFUL will be returned. |
707 // Google Update reported that Chrome is up-to-date. Now make sure that we | 660 // Google Update reported that Chrome is up-to-date. Now make sure that we |
708 // are running the latest version and if not, notify the user by falling | 661 // are running the latest version and if not, notify the user by falling |
709 // into the next case of UPGRADE_SUCCESSFUL. | 662 // into the next case of UPGRADE_SUCCESSFUL. |
710 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 663 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
711 base::ThreadRestrictions::ScopedAllowIO allow_io; | 664 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 665 chrome::VersionInfo version_info; |
712 scoped_ptr<Version> installed_version( | 666 scoped_ptr<Version> installed_version( |
713 InstallUtil::GetChromeVersion(dist, false)); | 667 InstallUtil::GetChromeVersion(dist, false)); |
714 if (!installed_version.get()) { | 668 if (!installed_version.get()) { |
715 // User-level Chrome is not installed, check system-level. | 669 // User-level Chrome is not installed, check system-level. |
716 installed_version.reset(InstallUtil::GetChromeVersion(dist, true)); | 670 installed_version.reset(InstallUtil::GetChromeVersion(dist, true)); |
717 } | 671 } |
718 scoped_ptr<Version> running_version( | 672 scoped_ptr<Version> running_version( |
719 Version::GetVersionFromString(current_version_)); | 673 Version::GetVersionFromString(version_info.Version())); |
720 if (!installed_version.get() || | 674 if (!installed_version.get() || |
721 (installed_version->CompareTo(*running_version) <= 0)) { | 675 (installed_version->CompareTo(*running_version) <= 0)) { |
722 UserMetrics::RecordAction( | 676 UserMetrics::RecordAction( |
723 UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); | 677 UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); |
724 std::wstring update_label_text = l10n_util::GetStringFUTF16( | 678 std::wstring update_label_text = l10n_util::GetStringFUTF16( |
725 IDS_UPGRADE_ALREADY_UP_TO_DATE, | 679 IDS_UPGRADE_ALREADY_UP_TO_DATE, |
726 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 680 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
727 ASCIIToUTF16(current_version_)); | 681 ASCIIToUTF16(version_info.Version())); |
728 if (base::i18n::IsRTL()) { | 682 if (base::i18n::IsRTL()) { |
729 update_label_text.push_back( | 683 update_label_text.push_back( |
730 static_cast<wchar_t>(base::i18n::kLeftToRightMark)); | 684 static_cast<wchar_t>(base::i18n::kLeftToRightMark)); |
731 } | 685 } |
732 update_label_.SetText(update_label_text); | 686 update_label_.SetText(update_label_text); |
733 show_success_indicator = true; | 687 show_success_indicator = true; |
734 break; | 688 break; |
735 } | 689 } |
736 // No break here as we want to notify user about upgrade if there is one. | 690 // No break here as we want to notify user about upgrade if there is one. |
737 } | 691 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 // We have updated controls on the parent, so we need to update its layout. | 733 // We have updated controls on the parent, so we need to update its layout. |
780 parent()->Layout(); | 734 parent()->Layout(); |
781 | 735 |
782 // Check button may have appeared/disappeared. We cannot call this during | 736 // Check button may have appeared/disappeared. We cannot call this during |
783 // ViewHierarchyChanged because the view hasn't been added to a Widget yet. | 737 // ViewHierarchyChanged because the view hasn't been added to a Widget yet. |
784 if (GetWidget()) | 738 if (GetWidget()) |
785 GetDialogClientView()->UpdateDialogButtons(); | 739 GetDialogClientView()->UpdateDialogButtons(); |
786 } | 740 } |
787 | 741 |
788 #endif | 742 #endif |
OLD | NEW |