Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/browser/views/about_chrome_view.cc

Issue 440008: Show chromium os version in about panel (Closed)
Patch Set: Fix newline Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/views/about_chrome_view.h" 5 #include "chrome/browser/views/about_chrome_view.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/color_utils.h" 8 #include "app/gfx/color_utils.h"
9 #include "base/i18n/word_iterator.h" 9 #include "base/i18n/word_iterator.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } // namespace browser 76 } // namespace browser
77 77
78 //////////////////////////////////////////////////////////////////////////////// 78 ////////////////////////////////////////////////////////////////////////////////
79 // AboutChromeView, public: 79 // AboutChromeView, public:
80 80
81 AboutChromeView::AboutChromeView(Profile* profile) 81 AboutChromeView::AboutChromeView(Profile* profile)
82 : profile_(profile), 82 : profile_(profile),
83 about_dlg_background_logo_(NULL), 83 about_dlg_background_logo_(NULL),
84 about_title_label_(NULL), 84 about_title_label_(NULL),
85 version_label_(NULL), 85 version_label_(NULL),
86 #if defined(OS_CHROMEOS)
87 os_version_label_(NULL),
88 #endif
86 copyright_label_(NULL), 89 copyright_label_(NULL),
87 main_text_label_(NULL), 90 main_text_label_(NULL),
88 main_text_label_height_(0), 91 main_text_label_height_(0),
89 chromium_url_(NULL), 92 chromium_url_(NULL),
90 open_source_url_(NULL), 93 open_source_url_(NULL),
91 terms_of_service_url_(NULL), 94 terms_of_service_url_(NULL),
92 check_button_status_(CHECKBUTTON_HIDDEN), 95 check_button_status_(CHECKBUTTON_HIDDEN),
93 chromium_url_appears_first_(true), 96 chromium_url_appears_first_(true),
94 text_direction_is_rtl_(false) { 97 text_direction_is_rtl_(false) {
95 DCHECK(profile); 98 DCHECK(profile);
99 #if defined(OS_CHROMEOS)
100 loader_.GetVersion(&consumer_,
101 NewCallback(this, &AboutChromeView::OnOSVersion));
102 #endif
96 Init(); 103 Init();
97 104
98 #if defined(OS_WIN) 105 #if defined(OS_WIN)
99 google_updater_ = new GoogleUpdate(); 106 google_updater_ = new GoogleUpdate();
100 google_updater_->AddStatusChangeListener(this); 107 google_updater_->AddStatusChangeListener(this);
101 #endif 108 #endif
102 109
103 if (kBackgroundBmp == NULL) { 110 if (kBackgroundBmp == NULL) {
104 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 111 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
105 kBackgroundBmp = rb.GetBitmapNamed(IDR_ABOUT_BACKGROUND_COLOR); 112 kBackgroundBmp = rb.GetBitmapNamed(IDR_ABOUT_BACKGROUND_COLOR);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 version_label_ = new views::Textfield(); 188 version_label_ = new views::Textfield();
182 version_label_->SetText(WideToUTF16Hack(current_version_)); 189 version_label_->SetText(WideToUTF16Hack(current_version_));
183 version_label_->SetReadOnly(true); 190 version_label_->SetReadOnly(true);
184 version_label_->RemoveBorder(); 191 version_label_->RemoveBorder();
185 version_label_->SetTextColor(SK_ColorBLACK); 192 version_label_->SetTextColor(SK_ColorBLACK);
186 version_label_->SetBackgroundColor(SK_ColorWHITE); 193 version_label_->SetBackgroundColor(SK_ColorWHITE);
187 version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont( 194 version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont(
188 ResourceBundle::BaseFont)); 195 ResourceBundle::BaseFont));
189 AddChildView(version_label_); 196 AddChildView(version_label_);
190 197
198 #if defined(OS_CHROMEOS)
199 os_version_label_ = new views::Textfield();
200 os_version_label_->SetReadOnly(true);
201 os_version_label_->RemoveBorder();
202 os_version_label_->SetTextColor(SK_ColorBLACK);
203 os_version_label_->SetBackgroundColor(SK_ColorWHITE);
204 os_version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont(
205 ResourceBundle::BaseFont));
206 AddChildView(os_version_label_);
207 #endif
208
191 // The copyright URL portion of the main label. 209 // The copyright URL portion of the main label.
192 copyright_label_ = new views::Label( 210 copyright_label_ = new views::Label(
193 l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT)); 211 l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT));
194 copyright_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 212 copyright_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
195 AddChildView(copyright_label_); 213 AddChildView(copyright_label_);
196 214
197 main_text_label_ = new views::Label(L""); 215 main_text_label_ = new views::Label(L"");
198 216
199 // Figure out what to write in the main label of the About box. 217 // Figure out what to write in the main label of the About box.
200 std::wstring text = l10n_util::GetString(IDS_ABOUT_VERSION_LICENSE); 218 std::wstring text = l10n_util::GetString(IDS_ABOUT_VERSION_LICENSE);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 324
307 // Then we have the version number right below it. 325 // Then we have the version number right below it.
308 sz = version_label_->GetPreferredSize(); 326 sz = version_label_->GetPreferredSize();
309 version_label_->SetBounds(kPanelHorizMargin, 327 version_label_->SetBounds(kPanelHorizMargin,
310 about_title_label_->y() + 328 about_title_label_->y() +
311 about_title_label_->height() + 329 about_title_label_->height() +
312 kRelatedControlVerticalSpacing, 330 kRelatedControlVerticalSpacing,
313 kVersionFieldWidth, 331 kVersionFieldWidth,
314 sz.height()); 332 sz.height());
315 333
334 #if defined(OS_CHROMEOS)
335 // Then we have the version number right below it.
336 sz = os_version_label_->GetPreferredSize();
337 os_version_label_->SetBounds(
338 kPanelHorizMargin,
339 version_label_->y() +
340 version_label_->height() +
341 kRelatedControlVerticalSpacing,
342 kVersionFieldWidth,
343 sz.height());
344 #endif
345
316 // For the width of the main text label we want to use up the whole panel 346 // For the width of the main text label we want to use up the whole panel
317 // width and remaining height, minus a little margin on each side. 347 // width and remaining height, minus a little margin on each side.
318 int y_pos = background_image_height + kRelatedControlVerticalSpacing; 348 int y_pos = background_image_height + kRelatedControlVerticalSpacing;
319 sz.set_width(panel_size.width() - 2 * kPanelHorizMargin); 349 sz.set_width(panel_size.width() - 2 * kPanelHorizMargin);
320 350
321 // Draw the text right below the background image. 351 // Draw the text right below the background image.
322 copyright_label_->SetBounds(kPanelHorizMargin, 352 copyright_label_->SetBounds(kPanelHorizMargin,
323 y_pos, 353 y_pos,
324 sz.width(), 354 sz.width(),
325 sz.height()); 355 sz.height());
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 if (source == terms_of_service_url_) 758 if (source == terms_of_service_url_)
729 url = GURL(chrome::kAboutTermsURL); 759 url = GURL(chrome::kAboutTermsURL);
730 else if (source == chromium_url_) 760 else if (source == chromium_url_)
731 url = GURL(WideToUTF16Hack(l10n_util::GetString(IDS_CHROMIUM_PROJECT_URL))); 761 url = GURL(WideToUTF16Hack(l10n_util::GetString(IDS_CHROMIUM_PROJECT_URL)));
732 else if (source == open_source_url_) 762 else if (source == open_source_url_)
733 url = GURL(chrome::kAboutCreditsURL); 763 url = GURL(chrome::kAboutCreditsURL);
734 else 764 else
735 NOTREACHED() << "Unknown link source"; 765 NOTREACHED() << "Unknown link source";
736 766
737 Browser* browser = BrowserList::GetLastActive(); 767 Browser* browser = BrowserList::GetLastActive();
768 #if defined(OS_CHROMEOS)
769 browser->OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
Finnur 2009/11/24 18:54:38 Won't this open a tab behind the About box, which
770 #else
738 browser->OpenURL(url, GURL(), NEW_WINDOW, PageTransition::LINK); 771 browser->OpenURL(url, GURL(), NEW_WINDOW, PageTransition::LINK);
772 #endif
739 } 773 }
740 774
775 #if defined(OS_CHROMEOS)
776 void AboutChromeView::OnOSVersion(
777 chromeos::VersionLoader::Handle handle,
778 std::string version) {
779 os_version_label_->SetText(UTF8ToUTF16(version));
780 }
781 #endif
782
741 #if defined(OS_WIN) 783 #if defined(OS_WIN)
742 //////////////////////////////////////////////////////////////////////////////// 784 ////////////////////////////////////////////////////////////////////////////////
743 // AboutChromeView, GoogleUpdateStatusListener implementation: 785 // AboutChromeView, GoogleUpdateStatusListener implementation:
744 786
745 void AboutChromeView::OnReportResults(GoogleUpdateUpgradeResult result, 787 void AboutChromeView::OnReportResults(GoogleUpdateUpgradeResult result,
746 GoogleUpdateErrorCode error_code, 788 GoogleUpdateErrorCode error_code,
747 const std::wstring& version) { 789 const std::wstring& version) {
748 // Drop the last reference to the object so that it gets cleaned up here. 790 // Drop the last reference to the object so that it gets cleaned up here.
749 google_updater_ = NULL; 791 google_updater_ = NULL;
750 792
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 View* parent = GetParent(); 902 View* parent = GetParent();
861 parent->Layout(); 903 parent->Layout();
862 904
863 // Check button may have appeared/disappeared. We cannot call this during 905 // Check button may have appeared/disappeared. We cannot call this during
864 // ViewHierarchyChanged because the |window()| pointer hasn't been set yet. 906 // ViewHierarchyChanged because the |window()| pointer hasn't been set yet.
865 if (window()) 907 if (window())
866 GetDialogClientView()->UpdateDialogButtons(); 908 GetDialogClientView()->UpdateDialogButtons();
867 } 909 }
868 910
869 #endif 911 #endif
OLDNEW
« chrome/browser/views/about_chrome_view.h ('K') | « chrome/browser/views/about_chrome_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698