Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webui/chromeos/login/user_image_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 void UserImageScreenHandler::GetLocalizedStrings( | 54 void UserImageScreenHandler::GetLocalizedStrings( |
| 55 DictionaryValue *localized_strings) { | 55 DictionaryValue *localized_strings) { |
| 56 // TODO(ivankr): string should be renamed to something like | 56 // TODO(ivankr): string should be renamed to something like |
| 57 // IDS_USER_IMAGE_SCREEN_TITLE (currently used for Take Photo dialog). | 57 // IDS_USER_IMAGE_SCREEN_TITLE (currently used for Take Photo dialog). |
| 58 localized_strings->SetString("userImageScreenTitle", | 58 localized_strings->SetString("userImageScreenTitle", |
| 59 l10n_util::GetStringUTF16(IDS_OOBE_PICTURE)); | 59 l10n_util::GetStringUTF16(IDS_OOBE_PICTURE)); |
| 60 localized_strings->SetString("userImageScreenDescription", | 60 localized_strings->SetString("userImageScreenDescription", |
| 61 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_DIALOG_TEXT)); | 61 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_DIALOG_TEXT)); |
| 62 localized_strings->SetString("takePhoto", | 62 localized_strings->SetString("takePhoto", |
| 63 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO)); | 63 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO)); |
| 64 localized_strings->SetString("discardPhoto", | |
| 65 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_DISCARD_PHOTO)); | |
| 66 localized_strings->SetString("flipPhoto", | |
| 67 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_FLIP_PHOTO)); | |
| 64 localized_strings->SetString("profilePhoto", | 68 localized_strings->SetString("profilePhoto", |
| 65 l10n_util::GetStringUTF16(IDS_IMAGE_SCREEN_PROFILE_PHOTO)); | 69 l10n_util::GetStringUTF16(IDS_IMAGE_SCREEN_PROFILE_PHOTO)); |
| 66 localized_strings->SetString("profilePhotoLoading", | 70 localized_strings->SetString("profilePhotoLoading", |
| 67 l10n_util::GetStringUTF16(IDS_IMAGE_SCREEN_PROFILE_LOADING_PHOTO)); | 71 l10n_util::GetStringUTF16(IDS_IMAGE_SCREEN_PROFILE_LOADING_PHOTO)); |
| 68 localized_strings->SetString("okButtonText", | 72 localized_strings->SetString("okButtonText", |
| 69 l10n_util::GetStringUTF16(IDS_OK)); | 73 l10n_util::GetStringUTF16(IDS_OK)); |
| 70 if (!CommandLine::ForCurrentProcess()-> | 74 if (!CommandLine::ForCurrentProcess()-> |
| 71 HasSwitch(switches::kDisableHtml5Camera)) { | 75 HasSwitch(switches::kDisableHtml5Camera)) { |
| 72 localized_strings->SetString("cameraType", "webrtc"); | 76 localized_strings->SetString("cameraType", "webrtc"); |
| 73 } else { | 77 } else { |
| 74 localized_strings->SetString("cameraType", "old"); | 78 localized_strings->SetString("cameraType", "old"); |
| 75 } | 79 } |
| 76 } | 80 } |
| 77 | 81 |
| 78 void UserImageScreenHandler::Initialize() { | 82 void UserImageScreenHandler::Initialize() { |
| 79 ListValue image_urls; | 83 ListValue image_urls; |
| 80 for (int i = 0; i < kDefaultImagesCount; ++i) { | 84 for (int i = 0; i < kDefaultImagesCount; ++i) { |
| 81 image_urls.Append(new StringValue(GetDefaultImageUrl(i))); | 85 DictionaryValue* dict = new DictionaryValue(); |
|
Ivan Korotkov
2012/08/03 01:00:23
Please use base::, scoped_ptr and release:
scoped_
dmazzoni
2012/08/03 22:59:01
Nice, thanks.
| |
| 86 dict->Set("url", new StringValue(GetDefaultImageUrl(i))); | |
| 87 dict->Set("title", new StringValue(GetDefaultImageDescription(i))); | |
|
Ivan Korotkov
2012/08/03 01:00:23
Use dict->SetString
dmazzoni
2012/08/03 22:59:01
Done.
| |
| 88 image_urls.Append(dict); | |
| 82 } | 89 } |
| 83 web_ui()->CallJavascriptFunction("oobe.UserImageScreen.setUserImages", | 90 web_ui()->CallJavascriptFunction("oobe.UserImageScreen.setUserImages", |
| 84 image_urls); | 91 image_urls); |
| 85 | 92 |
| 86 if (selected_image_ != User::kInvalidImageIndex) | 93 if (selected_image_ != User::kInvalidImageIndex) |
| 87 SelectImage(selected_image_); | 94 SelectImage(selected_image_); |
| 88 | 95 |
| 89 if (profile_picture_data_url_ != chrome::kAboutBlankURL) | 96 if (profile_picture_data_url_ != chrome::kAboutBlankURL) |
| 90 SendProfileImage(profile_picture_data_url_); | 97 SendProfileImage(profile_picture_data_url_); |
| 91 else if (profile_picture_absent_) | 98 else if (profile_picture_absent_) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 user_photo_ = gfx::ImageSkia(decoded_image); | 300 user_photo_ = gfx::ImageSkia(decoded_image); |
| 294 if (screen_ && accept_photo_after_decoding_) | 301 if (screen_ && accept_photo_after_decoding_) |
| 295 screen_->OnPhotoTaken(user_photo_); | 302 screen_->OnPhotoTaken(user_photo_); |
| 296 } | 303 } |
| 297 | 304 |
| 298 void UserImageScreenHandler::OnDecodeImageFailed(const ImageDecoder* decoder) { | 305 void UserImageScreenHandler::OnDecodeImageFailed(const ImageDecoder* decoder) { |
| 299 NOTREACHED() << "Failed to decode PNG image from WebUI"; | 306 NOTREACHED() << "Failed to decode PNG image from WebUI"; |
| 300 } | 307 } |
| 301 | 308 |
| 302 } // namespace chromeos | 309 } // namespace chromeos |
| OLD | NEW |