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/options2/chromeos/change_picture_options_handl
er.h" | 5 #include "chrome/browser/ui/webui/options2/chromeos/change_picture_options_handl
er.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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO)); | 98 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO)); |
99 localized_strings->SetString("chooseFile", | 99 localized_strings->SetString("chooseFile", |
100 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_CHOOSE_FILE)); | 100 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_CHOOSE_FILE)); |
101 localized_strings->SetString("profilePhoto", | 101 localized_strings->SetString("profilePhoto", |
102 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_PROFILE_PHOTO)); | 102 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_PROFILE_PHOTO)); |
103 localized_strings->SetString("profilePhotoLoading", | 103 localized_strings->SetString("profilePhotoLoading", |
104 l10n_util::GetStringUTF16( | 104 l10n_util::GetStringUTF16( |
105 IDS_OPTIONS_CHANGE_PICTURE_PROFILE_LOADING_PHOTO)); | 105 IDS_OPTIONS_CHANGE_PICTURE_PROFILE_LOADING_PHOTO)); |
106 localized_strings->SetString("previewAltText", | 106 localized_strings->SetString("previewAltText", |
107 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_PREVIEW_ALT)); | 107 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_PREVIEW_ALT)); |
| 108 localized_strings->SetString("authorCredit", |
| 109 l10n_util::GetStringUTF16(IDS_OPTIONS_SET_WALLPAPER_AUTHOR_TEXT)); |
108 if (!CommandLine::ForCurrentProcess()-> | 110 if (!CommandLine::ForCurrentProcess()-> |
109 HasSwitch(switches::kDisableHtml5Camera)) { | 111 HasSwitch(switches::kDisableHtml5Camera)) { |
110 localized_strings->SetString("cameraType", "webrtc"); | 112 localized_strings->SetString("cameraType", "webrtc"); |
111 } else { | 113 } else { |
112 localized_strings->SetString("cameraType", "old"); | 114 localized_strings->SetString("cameraType", "old"); |
113 } | 115 } |
114 } | 116 } |
115 | 117 |
116 void ChangePictureOptionsHandler::RegisterMessages() { | 118 void ChangePictureOptionsHandler::RegisterMessages() { |
117 web_ui()->RegisterMessageCallback("chooseFile", | 119 web_ui()->RegisterMessageCallback("chooseFile", |
(...skipping 10 matching lines...) Expand all Loading... |
128 base::Unretained(this))); | 130 base::Unretained(this))); |
129 web_ui()->RegisterMessageCallback("onChangePicturePageInitialized", | 131 web_ui()->RegisterMessageCallback("onChangePicturePageInitialized", |
130 base::Bind(&ChangePictureOptionsHandler::HandlePageInitialized, | 132 base::Bind(&ChangePictureOptionsHandler::HandlePageInitialized, |
131 base::Unretained(this))); | 133 base::Unretained(this))); |
132 web_ui()->RegisterMessageCallback("selectImage", | 134 web_ui()->RegisterMessageCallback("selectImage", |
133 base::Bind(&ChangePictureOptionsHandler::HandleSelectImage, | 135 base::Bind(&ChangePictureOptionsHandler::HandleSelectImage, |
134 base::Unretained(this))); | 136 base::Unretained(this))); |
135 } | 137 } |
136 | 138 |
137 void ChangePictureOptionsHandler::SendDefaultImages() { | 139 void ChangePictureOptionsHandler::SendDefaultImages() { |
138 ListValue image_urls; | 140 base::ListValue image_urls; |
139 for (int i = kFirstDefaultImageIndex; i < kDefaultImagesCount; ++i) { | 141 for (int i = kFirstDefaultImageIndex; i < kDefaultImagesCount; ++i) { |
140 image_urls.Append(new StringValue(GetDefaultImageUrl(i))); | 142 scoped_ptr<base::DictionaryValue> image_data(new base::DictionaryValue); |
| 143 image_data->SetString("url", GetDefaultImageUrl(i)); |
| 144 image_data->SetString( |
| 145 "author", l10n_util::GetStringUTF16(kDefaultImageAuthorIDs[i])); |
| 146 image_data->SetString( |
| 147 "website", l10n_util::GetStringUTF16(kDefaultImageWebsiteIDs[i])); |
| 148 image_urls.Append(image_data.release()); |
141 } | 149 } |
142 web_ui()->CallJavascriptFunction("ChangePictureOptions.setDefaultImages", | 150 web_ui()->CallJavascriptFunction("ChangePictureOptions.setDefaultImages", |
143 image_urls); | 151 image_urls); |
144 } | 152 } |
145 | 153 |
146 void ChangePictureOptionsHandler::HandleChooseFile(const ListValue* args) { | 154 void ChangePictureOptionsHandler::HandleChooseFile(const ListValue* args) { |
147 DCHECK(args && args->empty()); | 155 DCHECK(args && args->empty()); |
148 select_file_dialog_ = ui::SelectFileDialog::Create( | 156 select_file_dialog_ = ui::SelectFileDialog::Create( |
149 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); | 157 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); |
150 | 158 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 OnPhotoAccepted(user_photo_); | 443 OnPhotoAccepted(user_photo_); |
436 } | 444 } |
437 | 445 |
438 void ChangePictureOptionsHandler::OnDecodeImageFailed( | 446 void ChangePictureOptionsHandler::OnDecodeImageFailed( |
439 const ImageDecoder* decoder) { | 447 const ImageDecoder* decoder) { |
440 NOTREACHED() << "Failed to decode PNG image from WebUI"; | 448 NOTREACHED() << "Failed to decode PNG image from WebUI"; |
441 } | 449 } |
442 | 450 |
443 } // namespace options2 | 451 } // namespace options2 |
444 } // namespace chromeos | 452 } // namespace chromeos |
OLD | NEW |