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