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