| 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_image_view.h" | 5 #include "chrome/browser/chromeos/login/user_image_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/chromeos/login/helper.h" | 13 #include "chrome/browser/chromeos/login/helper.h" |
| 13 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 14 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| 14 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" | 15 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "gfx/canvas.h" | 17 #include "gfx/canvas.h" |
| 17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 19 #include "skia/ext/image_operations.h" | 20 #include "skia/ext/image_operations.h" |
| 20 #include "views/controls/button/image_button.h" | 21 #include "views/controls/button/image_button.h" |
| 21 #include "views/controls/button/native_button.h" | 22 #include "views/controls/button/native_button.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 IDR_USER_IMAGE_INITIALIZING)); | 81 IDR_USER_IMAGE_INITIALIZING)); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void SetNormalState() { | 84 void SetNormalState() { |
| 84 HideThrobber(); | 85 HideThrobber(); |
| 85 SetMessage(std::wstring()); | 86 SetMessage(std::wstring()); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void SetErrorState() { | 89 void SetErrorState() { |
| 89 HideThrobber(); | 90 HideThrobber(); |
| 90 SetMessage(l10n_util::GetString(IDS_USER_IMAGE_NO_VIDEO)); | 91 SetMessage(UTF16ToWide(l10n_util::GetStringUTF16(IDS_USER_IMAGE_NO_VIDEO))); |
| 91 SetImage( | 92 SetImage( |
| 92 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 93 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 93 IDR_USER_IMAGE_NO_VIDEO)); | 94 IDR_USER_IMAGE_NO_VIDEO)); |
| 94 } | 95 } |
| 95 | 96 |
| 96 private: | 97 private: |
| 97 void ShowThrobber() { | 98 void ShowThrobber() { |
| 98 DCHECK(throbber_); | 99 DCHECK(throbber_); |
| 99 throbber_->SetVisible(true); | 100 throbber_->SetVisible(true); |
| 100 throbber_->Start(); | 101 throbber_->Start(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 UserImageView::~UserImageView() { | 162 UserImageView::~UserImageView() { |
| 162 } | 163 } |
| 163 | 164 |
| 164 void UserImageView::Init() { | 165 void UserImageView::Init() { |
| 165 // Use rounded rect background. | 166 // Use rounded rect background. |
| 166 set_border(CreateWizardBorder(&BorderDefinition::kScreenBorder)); | 167 set_border(CreateWizardBorder(&BorderDefinition::kScreenBorder)); |
| 167 views::Painter* painter = CreateWizardPainter( | 168 views::Painter* painter = CreateWizardPainter( |
| 168 &BorderDefinition::kScreenBorder); | 169 &BorderDefinition::kScreenBorder); |
| 169 set_background(views::Background::CreateBackgroundPainter(true, painter)); | 170 set_background(views::Background::CreateBackgroundPainter(true, painter)); |
| 170 | 171 |
| 171 title_label_ = | 172 title_label_ = new views::Label( |
| 172 new views::Label(l10n_util::GetString(IDS_USER_IMAGE_SCREEN_TITLE)); | 173 UTF16ToWide(l10n_util::GetStringUTF16(IDS_USER_IMAGE_SCREEN_TITLE))); |
| 173 title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 174 title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 174 title_label_->SetMultiLine(true); | 175 title_label_->SetMultiLine(true); |
| 175 CorrectLabelFontSize(title_label_); | 176 CorrectLabelFontSize(title_label_); |
| 176 | 177 |
| 177 user_image_ = new CameraImageView(); | 178 user_image_ = new CameraImageView(); |
| 178 user_image_->SetImageSize( | 179 user_image_->SetImageSize( |
| 179 gfx::Size(kUserImageSize, kUserImageSize)); | 180 gfx::Size(kUserImageSize, kUserImageSize)); |
| 180 user_image_->Init(); | 181 user_image_->Init(); |
| 181 | 182 |
| 182 snapshot_button_ = new views::ImageButton(this); | 183 snapshot_button_ = new views::ImageButton(this); |
| 183 snapshot_button_->SetFocusable(true); | 184 snapshot_button_->SetFocusable(true); |
| 184 snapshot_button_->SetImage(views::CustomButton::BS_NORMAL, | 185 snapshot_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 185 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 186 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 186 IDR_USER_IMAGE_CAPTURE)); | 187 IDR_USER_IMAGE_CAPTURE)); |
| 187 snapshot_button_->SetImage(views::CustomButton::BS_DISABLED, | 188 snapshot_button_->SetImage(views::CustomButton::BS_DISABLED, |
| 188 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 189 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 189 IDR_USER_IMAGE_CAPTURE_DISABLED)); | 190 IDR_USER_IMAGE_CAPTURE_DISABLED)); |
| 190 | 191 |
| 191 ok_button_ = new login::WideButton(this, l10n_util::GetString(IDS_OK)); | 192 ok_button_ = new login::WideButton( |
| 193 this, UTF16ToWide(l10n_util::GetStringUTF16(IDS_OK))); |
| 192 ok_button_->SetEnabled(!is_capturing_); | 194 ok_button_->SetEnabled(!is_capturing_); |
| 193 | 195 |
| 194 skip_button_ = new login::WideButton(this, l10n_util::GetString(IDS_SKIP)); | 196 skip_button_ = new login::WideButton( |
| 197 this, UTF16ToWide(l10n_util::GetStringUTF16(IDS_SKIP))); |
| 195 skip_button_->SetEnabled(true); | 198 skip_button_->SetEnabled(true); |
| 196 | 199 |
| 197 InitLayout(); | 200 InitLayout(); |
| 198 // Request focus only after the button is added to views hierarchy. | 201 // Request focus only after the button is added to views hierarchy. |
| 199 snapshot_button_->RequestFocus(); | 202 snapshot_button_->RequestFocus(); |
| 200 user_image_->SetInitializingState(); | 203 user_image_->SetInitializingState(); |
| 201 } | 204 } |
| 202 | 205 |
| 203 void UserImageView::InitLayout() { | 206 void UserImageView::InitLayout() { |
| 204 views::GridLayout* layout = new views::GridLayout(this); | 207 views::GridLayout* layout = new views::GridLayout(this); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 delegate_->OnOK(user_image_->GetImage()); | 323 delegate_->OnOK(user_image_->GetImage()); |
| 321 } else if (sender == skip_button_) { | 324 } else if (sender == skip_button_) { |
| 322 delegate_->OnSkip(); | 325 delegate_->OnSkip(); |
| 323 } else { | 326 } else { |
| 324 NOTREACHED(); | 327 NOTREACHED(); |
| 325 } | 328 } |
| 326 } | 329 } |
| 327 | 330 |
| 328 } // namespace chromeos | 331 } // namespace chromeos |
| 329 | 332 |
| OLD | NEW |