| 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 <string> | |
| 13 #include <vector> | 12 #include <vector> |
| 14 | 13 |
| 15 #include "base/callback.h" | 14 #include "base/callback.h" |
| 16 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 17 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 18 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 19 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
| 20 #include "chrome/browser/google/google_util.h" | 19 #include "chrome/browser/google/google_util.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 22 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 #include "webkit/glue/webkit_glue.h" | 42 #include "webkit/glue/webkit_glue.h" |
| 44 | 43 |
| 45 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 46 #include "base/win/win_util.h" | 45 #include "base/win/win_util.h" |
| 47 #include "chrome/browser/browser_process.h" | 46 #include "chrome/browser/browser_process.h" |
| 48 #include "chrome/browser/ui/views/restart_message_box.h" | 47 #include "chrome/browser/ui/views/restart_message_box.h" |
| 49 #include "chrome/installer/util/install_util.h" | 48 #include "chrome/installer/util/install_util.h" |
| 50 #endif // defined(OS_WIN) | 49 #endif // defined(OS_WIN) |
| 51 | 50 |
| 52 namespace { | 51 namespace { |
| 53 // The pixel width of the version text field. Ideally, we'd like to have the | |
| 54 // bounds set to the edge of the icon. However, the icon is not a view but a | |
| 55 // part of the background, so we have to hard code the width to make sure | |
| 56 // the version field doesn't overlap it. | |
| 57 const int kVersionFieldWidth = 195; | |
| 58 | |
| 59 // These are used as placeholder text around the links in the text in the about | 52 // These are used as placeholder text around the links in the text in the about |
| 60 // dialog. | 53 // dialog. |
| 61 const wchar_t* kBeginLink = L"BEGIN_LINK"; | 54 const wchar_t* kBeginLink = L"BEGIN_LINK"; |
| 62 const wchar_t* kEndLink = L"END_LINK"; | 55 const wchar_t* kEndLink = L"END_LINK"; |
| 63 const wchar_t* kBeginLinkChr = L"BEGIN_LINK_CHR"; | 56 const wchar_t* kBeginLinkChr = L"BEGIN_LINK_CHR"; |
| 64 const wchar_t* kBeginLinkOss = L"BEGIN_LINK_OSS"; | 57 const wchar_t* kBeginLinkOss = L"BEGIN_LINK_OSS"; |
| 65 const wchar_t* kEndLinkChr = L"END_LINK_CHR"; | 58 const wchar_t* kEndLinkChr = L"END_LINK_CHR"; |
| 66 const wchar_t* kEndLinkOss = L"END_LINK_OSS"; | 59 const wchar_t* kEndLinkOss = L"END_LINK_OSS"; |
| 67 | 60 |
| 68 // The background bitmap used to draw the background color for the About box | 61 // The background bitmap used to draw the background color for the About box |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 138 } |
| 146 | 139 |
| 147 current_version_ = version_info.Version(); | 140 current_version_ = version_info.Version(); |
| 148 | 141 |
| 149 // This code only runs as a result of the user opening the About box so | 142 // This code only runs as a result of the user opening the About box so |
| 150 // doing registry access to get the version string modifier should be fine. | 143 // doing registry access to get the version string modifier should be fine. |
| 151 base::ThreadRestrictions::ScopedAllowIO allow_io; | 144 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 152 std::string version_modifier = | 145 std::string version_modifier = |
| 153 chrome::VersionInfo::GetVersionStringModifier(); | 146 chrome::VersionInfo::GetVersionStringModifier(); |
| 154 if (!version_modifier.empty()) | 147 if (!version_modifier.empty()) |
| 155 version_details_ += " " + version_modifier; | 148 version_details_ += ASCIIToUTF16(" ") + ASCIIToUTF16(version_modifier); |
| 156 | 149 |
| 157 #if !defined(GOOGLE_CHROME_BUILD) | 150 #if !defined(GOOGLE_CHROME_BUILD) |
| 158 version_details_ += " ("; | 151 version_details_ += ASCIIToUTF16(" ("); |
| 159 version_details_ += l10n_util::GetStringUTF8( | 152 version_details_ += l10n_util::GetStringUTF16( |
| 160 version_info.IsOfficialBuild() ? | 153 version_info.IsOfficialBuild() ? |
| 161 IDS_ABOUT_VERSION_OFFICIAL : IDS_ABOUT_VERSION_UNOFFICIAL); | 154 IDS_ABOUT_VERSION_OFFICIAL : IDS_ABOUT_VERSION_UNOFFICIAL); |
| 162 version_details_ += " "; | 155 version_details_ += ASCIIToUTF16(" "); |
| 163 version_details_ += version_info.LastChange(); | 156 version_details_ += ASCIIToUTF16(version_info.LastChange()); |
| 164 version_details_ += ")"; | 157 version_details_ += ASCIIToUTF16(")"); |
| 165 #endif | 158 #endif |
| 166 | 159 |
| 167 // Views we will add to the *parent* of this dialog, since it will display | 160 // 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. | 161 // next to the buttons which we don't draw ourselves. |
| 169 throbber_.reset(new views::Throbber(50, true)); | 162 throbber_.reset(new views::Throbber(50, true)); |
| 170 throbber_->set_parent_owned(false); | 163 throbber_->set_parent_owned(false); |
| 171 throbber_->SetVisible(false); | 164 throbber_->SetVisible(false); |
| 172 | 165 |
| 173 SkBitmap* success_image = rb.GetBitmapNamed(IDR_UPDATE_UPTODATE); | 166 SkBitmap* success_image = rb.GetBitmapNamed(IDR_UPDATE_UPTODATE); |
| 174 success_indicator_.SetImage(*success_image); | 167 success_indicator_.SetImage(*success_image); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 199 // Add the dialog labels. | 192 // Add the dialog labels. |
| 200 about_title_label_ = new views::Label( | 193 about_title_label_ = new views::Label( |
| 201 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 194 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 202 about_title_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( | 195 about_title_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( |
| 203 ResourceBundle::BaseFont).DeriveFont(18)); | 196 ResourceBundle::BaseFont).DeriveFont(18)); |
| 204 about_title_label_->SetColor(SK_ColorBLACK); | 197 about_title_label_->SetColor(SK_ColorBLACK); |
| 205 AddChildView(about_title_label_); | 198 AddChildView(about_title_label_); |
| 206 | 199 |
| 207 // This is a text field so people can copy the version number from the dialog. | 200 // This is a text field so people can copy the version number from the dialog. |
| 208 version_label_ = new views::Textfield(); | 201 version_label_ = new views::Textfield(); |
| 209 version_label_->SetText(ASCIIToUTF16(current_version_ + version_details_)); | 202 version_label_->SetText(ASCIIToUTF16(current_version_) + version_details_); |
| 210 version_label_->SetReadOnly(true); | 203 version_label_->SetReadOnly(true); |
| 211 version_label_->RemoveBorder(); | 204 version_label_->RemoveBorder(); |
| 212 version_label_->SetTextColor(SK_ColorBLACK); | 205 version_label_->SetTextColor(SK_ColorBLACK); |
| 213 version_label_->SetBackgroundColor(SK_ColorWHITE); | 206 version_label_->SetBackgroundColor(SK_ColorWHITE); |
| 214 version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( | 207 version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( |
| 215 ResourceBundle::BaseFont)); | 208 ResourceBundle::BaseFont)); |
| 216 AddChildView(version_label_); | 209 AddChildView(version_label_); |
| 217 | 210 |
| 218 os_version_label_ = new views::Textfield(); | 211 os_version_label_ = new views::Textfield(); |
| 219 os_version_label_->SetText(UTF8ToUTF16(version_info.OSType())); | 212 os_version_label_->SetText(UTF8ToUTF16(version_info.OSType())); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 about_title_label_->SetBounds( | 335 about_title_label_->SetBounds( |
| 343 views::kPanelHorizMargin, views::kPanelVertMargin, | 336 views::kPanelHorizMargin, views::kPanelVertMargin, |
| 344 sz.width(), sz.height()); | 337 sz.width(), sz.height()); |
| 345 | 338 |
| 346 // Then we have the version number right below it. | 339 // Then we have the version number right below it. |
| 347 sz = version_label_->GetPreferredSize(); | 340 sz = version_label_->GetPreferredSize(); |
| 348 version_label_->SetBounds(views::kPanelHorizMargin, | 341 version_label_->SetBounds(views::kPanelHorizMargin, |
| 349 about_title_label_->y() + | 342 about_title_label_->y() + |
| 350 about_title_label_->height() + | 343 about_title_label_->height() + |
| 351 views::kRelatedControlVerticalSpacing, | 344 views::kRelatedControlVerticalSpacing, |
| 352 kVersionFieldWidth, | 345 panel_size.width() - |
| 346 about_dlg_background_logo_->width(), |
| 353 sz.height()); | 347 sz.height()); |
| 354 | 348 |
| 355 // Then we have the version number right below it. | 349 // Then we have the version number right below it. |
| 356 sz = os_version_label_->GetPreferredSize(); | 350 sz = os_version_label_->GetPreferredSize(); |
| 357 os_version_label_->SetBounds( | 351 os_version_label_->SetBounds( |
| 358 views::kPanelHorizMargin, | 352 views::kPanelHorizMargin, |
| 359 version_label_->y() + | 353 version_label_->y() + |
| 360 version_label_->height() + | 354 version_label_->height() + |
| 361 views::kRelatedControlVerticalSpacing, | 355 views::kRelatedControlVerticalSpacing, |
| 362 kVersionFieldWidth, | 356 panel_size.width() - |
| 357 about_dlg_background_logo_->width(), |
| 363 sz.height()); | 358 sz.height()); |
| 364 | 359 |
| 365 // For the width of the main text label we want to use up the whole panel | 360 // 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. | 361 // width and remaining height, minus a little margin on each side. |
| 367 int y_pos = background_image_height + views::kRelatedControlVerticalSpacing; | 362 int y_pos = background_image_height + views::kRelatedControlVerticalSpacing; |
| 368 sz.set_width(panel_size.width() - 2 * views::kPanelHorizMargin); | 363 sz.set_width(panel_size.width() - 2 * views::kPanelHorizMargin); |
| 369 | 364 |
| 370 // Draw the text right below the background image. | 365 // Draw the text right below the background image. |
| 371 copyright_label_->SetBounds(views::kPanelHorizMargin, | 366 copyright_label_->SetBounds(views::kPanelHorizMargin, |
| 372 y_pos, | 367 y_pos, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 sz = update_label_.GetPreferredSize(); | 407 sz = update_label_.GetPreferredSize(); |
| 413 int update_label_x = throbber_->x() + throbber_->width() + | 408 int update_label_x = throbber_->x() + throbber_->width() + |
| 414 views::kRelatedControlHorizontalSpacing; | 409 views::kRelatedControlHorizontalSpacing; |
| 415 update_label_.SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 410 update_label_.SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 416 update_label_.SetBounds(update_label_x, | 411 update_label_.SetBounds(update_label_x, |
| 417 throbber_topleft_y + 1, | 412 throbber_topleft_y + 1, |
| 418 parent_bounds.width() - update_label_x, | 413 parent_bounds.width() - update_label_x, |
| 419 sz.height()); | 414 sz.height()); |
| 420 } | 415 } |
| 421 | 416 |
| 422 | |
| 423 void AboutChromeView::OnPaint(gfx::Canvas* canvas) { | 417 void AboutChromeView::OnPaint(gfx::Canvas* canvas) { |
| 424 views::View::OnPaint(canvas); | 418 views::View::OnPaint(canvas); |
| 425 | 419 |
| 426 // Draw the background image color (and the separator) across the dialog. | 420 // Draw the background image color (and the separator) across the dialog. |
| 427 // This will become the background for the logo image at the top of the | 421 // This will become the background for the logo image at the top of the |
| 428 // dialog. | 422 // dialog. |
| 429 canvas->TileImageInt(*kBackgroundBmp, 0, 0, | 423 canvas->TileImageInt(*kBackgroundBmp, 0, 0, |
| 430 dialog_dimensions_.width(), kBackgroundBmp->height()); | 424 dialog_dimensions_.width(), kBackgroundBmp->height()); |
| 431 | 425 |
| 432 gfx::Font font = | 426 gfx::Font font = |
| (...skipping 347 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. | 774 // We have updated controls on the parent, so we need to update its layout. |
| 781 parent()->Layout(); | 775 parent()->Layout(); |
| 782 | 776 |
| 783 // Check button may have appeared/disappeared. We cannot call this during | 777 // Check button may have appeared/disappeared. We cannot call this during |
| 784 // ViewHierarchyChanged because the view hasn't been added to a Widget yet. | 778 // ViewHierarchyChanged because the view hasn't been added to a Widget yet. |
| 785 if (GetWidget()) | 779 if (GetWidget()) |
| 786 GetDialogClientView()->UpdateDialogButtons(); | 780 GetDialogClientView()->UpdateDialogButtons(); |
| 787 } | 781 } |
| 788 | 782 |
| 789 #endif | 783 #endif |
| OLD | NEW |