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