OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/login/user_view.h" | 5 #include "chrome/browser/chromeos/login/user_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/chromeos/login/helper.h" | 10 #include "chrome/browser/chromeos/login/helper.h" |
10 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 11 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
11 #include "chrome/browser/chromeos/login/rounded_view.h" | 12 #include "chrome/browser/chromeos/login/rounded_view.h" |
12 #include "gfx/canvas.h" | 13 #include "gfx/canvas.h" |
13 #include "gfx/canvas_skia.h" | 14 #include "gfx/canvas_skia.h" |
14 #include "gfx/gtk_util.h" | 15 #include "gfx/gtk_util.h" |
15 #include "gfx/rect.h" | 16 #include "gfx/rect.h" |
16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
17 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
18 #include "views/background.h" | 19 #include "views/background.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 using login::kUserImageSize; | 69 using login::kUserImageSize; |
69 | 70 |
70 // The view that shows the Sign out button below the user's image. | 71 // The view that shows the Sign out button below the user's image. |
71 class SignoutView : public views::View { | 72 class SignoutView : public views::View { |
72 public: | 73 public: |
73 explicit SignoutView(views::LinkController* link_controller) { | 74 explicit SignoutView(views::LinkController* link_controller) { |
74 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 75 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
75 const gfx::Font& font = rb.GetFont(ResourceBundle::SmallFont); | 76 const gfx::Font& font = rb.GetFont(ResourceBundle::SmallFont); |
76 | 77 |
77 active_user_label_ = new views::Label( | 78 active_user_label_ = new views::Label( |
78 l10n_util::GetString(IDS_SCREEN_LOCK_ACTIVE_USER)); | 79 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SCREEN_LOCK_ACTIVE_USER))); |
79 active_user_label_->SetFont(font); | 80 active_user_label_->SetFont(font); |
80 active_user_label_->SetColor(kTextColor); | 81 active_user_label_->SetColor(kTextColor); |
81 | 82 |
82 signout_link_ = new views::Link( | 83 signout_link_ = new views::Link( |
83 l10n_util::GetString(IDS_SCREEN_LOCK_SIGN_OUT)); | 84 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SCREEN_LOCK_SIGN_OUT))); |
84 signout_link_->SetController(link_controller); | 85 signout_link_->SetController(link_controller); |
85 signout_link_->SetFont(font); | 86 signout_link_->SetFont(font); |
86 signout_link_->SetColor(kTextColor); | 87 signout_link_->SetColor(kTextColor); |
87 signout_link_->SetFocusable(true); | 88 signout_link_->SetFocusable(true); |
88 | 89 |
89 AddChildView(active_user_label_); | 90 AddChildView(active_user_label_); |
90 AddChildView(signout_link_); | 91 AddChildView(signout_link_); |
91 | 92 |
92 set_background(views::Background::CreateBackgroundPainter( | 93 set_background(views::Background::CreateBackgroundPainter( |
93 true, new SignoutBackgroundPainter())); | 94 true, new SignoutBackgroundPainter())); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 if (signout_view_) { | 276 if (signout_view_) { |
276 signout_view_->SetBounds(0, kUserImageSize, kUserImageSize, | 277 signout_view_->SetBounds(0, kUserImageSize, kUserImageSize, |
277 signout_view_->GetPreferredSize().height()); | 278 signout_view_->GetPreferredSize().height()); |
278 AddChildView(signout_view_); | 279 AddChildView(signout_view_); |
279 } | 280 } |
280 | 281 |
281 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 282 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
282 remove_button_ = new RemoveButton( | 283 remove_button_ = new RemoveButton( |
283 this, | 284 this, |
284 *rb.GetBitmapNamed(IDR_CLOSE_BAR_H), | 285 *rb.GetBitmapNamed(IDR_CLOSE_BAR_H), |
285 l10n_util::GetString(IDS_LOGIN_REMOVE), | 286 UTF16ToWide(l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE)), |
286 gfx::Point(kUserImageSize - kRemoveButtonPadding, kRemoveButtonPadding)); | 287 gfx::Point(kUserImageSize - kRemoveButtonPadding, kRemoveButtonPadding)); |
287 remove_button_->SetVisible(false); | 288 remove_button_->SetVisible(false); |
288 AddChildView(remove_button_); | 289 AddChildView(remove_button_); |
289 } | 290 } |
290 | 291 |
291 void UserView::SetImage(const SkBitmap& image, const SkBitmap& image_hot) { | 292 void UserView::SetImage(const SkBitmap& image, const SkBitmap& image_hot) { |
292 int desired_size = std::min(image.width(), image.height()); | 293 int desired_size = std::min(image.width(), image.height()); |
293 // Desired size is not preserved if it's greater than 75% of kUserImageSize. | 294 // Desired size is not preserved if it's greater than 75% of kUserImageSize. |
294 if (desired_size * 4 > 3 * kUserImageSize) | 295 if (desired_size * 4 > 3 * kUserImageSize) |
295 desired_size = kUserImageSize; | 296 desired_size = kUserImageSize; |
(...skipping 29 matching lines...) Expand all Loading... |
325 remove_button_->SetVisible(flag); | 326 remove_button_->SetVisible(flag); |
326 } | 327 } |
327 | 328 |
328 void UserView::ButtonPressed(views::Button* sender, const views::Event& event) { | 329 void UserView::ButtonPressed(views::Button* sender, const views::Event& event) { |
329 DCHECK(delegate_); | 330 DCHECK(delegate_); |
330 if (remove_button_ == sender) | 331 if (remove_button_ == sender) |
331 delegate_->OnRemoveUser(); | 332 delegate_->OnRemoveUser(); |
332 } | 333 } |
333 | 334 |
334 void UserView::OnLocaleChanged() { | 335 void UserView::OnLocaleChanged() { |
335 remove_button_->SetText(l10n_util::GetString(IDS_LOGIN_REMOVE)); | 336 remove_button_->SetText( |
| 337 UTF16ToWide(l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE))); |
336 } | 338 } |
337 | 339 |
338 } // namespace chromeos | 340 } // namespace chromeos |
OLD | NEW |