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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO)); | 94 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO)); |
95 localized_strings->SetString("chooseFile", | 95 localized_strings->SetString("chooseFile", |
96 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_CHOOSE_FILE)); | 96 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_CHOOSE_FILE)); |
97 localized_strings->SetString("profilePhoto", | 97 localized_strings->SetString("profilePhoto", |
98 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_PROFILE_PHOTO)); | 98 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_PROFILE_PHOTO)); |
99 localized_strings->SetString("profilePhotoLoading", | 99 localized_strings->SetString("profilePhotoLoading", |
100 l10n_util::GetStringUTF16( | 100 l10n_util::GetStringUTF16( |
101 IDS_OPTIONS_CHANGE_PICTURE_PROFILE_LOADING_PHOTO)); | 101 IDS_OPTIONS_CHANGE_PICTURE_PROFILE_LOADING_PHOTO)); |
102 localized_strings->SetString("previewAltText", | 102 localized_strings->SetString("previewAltText", |
103 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_PREVIEW_ALT)); | 103 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE_PREVIEW_ALT)); |
104 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHtml5Camera)) | 104 if (!CommandLine::ForCurrentProcess()-> |
| 105 HasSwitch(switches::kDisableHtml5Camera)) { |
105 localized_strings->SetString("cameraType", "webrtc"); | 106 localized_strings->SetString("cameraType", "webrtc"); |
106 else | 107 } else { |
107 localized_strings->SetString("cameraType", "old"); | 108 localized_strings->SetString("cameraType", "old"); |
| 109 } |
108 } | 110 } |
109 | 111 |
110 void ChangePictureOptionsHandler::RegisterMessages() { | 112 void ChangePictureOptionsHandler::RegisterMessages() { |
111 web_ui()->RegisterMessageCallback("chooseFile", | 113 web_ui()->RegisterMessageCallback("chooseFile", |
112 base::Bind(&ChangePictureOptionsHandler::HandleChooseFile, | 114 base::Bind(&ChangePictureOptionsHandler::HandleChooseFile, |
113 base::Unretained(this))); | 115 base::Unretained(this))); |
114 web_ui()->RegisterMessageCallback("takePhoto", | 116 web_ui()->RegisterMessageCallback("takePhoto", |
115 base::Bind(&ChangePictureOptionsHandler::HandleTakePhoto, | 117 base::Bind(&ChangePictureOptionsHandler::HandleTakePhoto, |
116 base::Unretained(this))); | 118 base::Unretained(this))); |
117 web_ui()->RegisterMessageCallback("photoTaken", | 119 web_ui()->RegisterMessageCallback("photoTaken", |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 if (image_decoder_.get()) | 191 if (image_decoder_.get()) |
190 image_decoder_->set_delegate(NULL); | 192 image_decoder_->set_delegate(NULL); |
191 image_decoder_ = new ImageDecoder(this, raw_data); | 193 image_decoder_ = new ImageDecoder(this, raw_data); |
192 image_decoder_->Start(); | 194 image_decoder_->Start(); |
193 } | 195 } |
194 | 196 |
195 void ChangePictureOptionsHandler::HandlePageInitialized( | 197 void ChangePictureOptionsHandler::HandlePageInitialized( |
196 const base::ListValue* args) { | 198 const base::ListValue* args) { |
197 DCHECK(args && args->empty()); | 199 DCHECK(args && args->empty()); |
198 | 200 |
199 if (!CommandLine::ForCurrentProcess()-> | 201 if (CommandLine::ForCurrentProcess()-> |
200 HasSwitch(switches::kEnableHtml5Camera)) { | 202 HasSwitch(switches::kDisableHtml5Camera)) { |
201 // If no camera presence check has been performed in this session, | 203 // If no camera presence check has been performed in this session, |
202 // start one now. | 204 // start one now. |
203 if (CameraDetector::camera_presence() == | 205 if (CameraDetector::camera_presence() == |
204 CameraDetector::kCameraPresenceUnknown) { | 206 CameraDetector::kCameraPresenceUnknown) { |
205 CheckCameraPresence(); | 207 CheckCameraPresence(); |
206 } | 208 } |
207 | 209 |
208 // While the check is in progress, use previous camera presence state and | 210 // While the check is in progress, use previous camera presence state and |
209 // presume it is present if no check has been performed yet. | 211 // presume it is present if no check has been performed yet. |
210 SetCameraPresent(CameraDetector::camera_presence() != | 212 SetCameraPresent(CameraDetector::camera_presence() != |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 user_manager->SaveUserImage(user_manager->GetLoggedInUser().email(), | 360 user_manager->SaveUserImage(user_manager->GetLoggedInUser().email(), |
359 chromeos::UserImage(photo)); | 361 chromeos::UserImage(photo)); |
360 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 362 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
361 kHistogramImageFromCamera, | 363 kHistogramImageFromCamera, |
362 kHistogramImagesCount); | 364 kHistogramImagesCount); |
363 VLOG(1) << "Selected camera photo"; | 365 VLOG(1) << "Selected camera photo"; |
364 } | 366 } |
365 | 367 |
366 void ChangePictureOptionsHandler::CheckCameraPresence() { | 368 void ChangePictureOptionsHandler::CheckCameraPresence() { |
367 // For WebRTC, camera presence checked is done on JS side. | 369 // For WebRTC, camera presence checked is done on JS side. |
368 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHtml5Camera)) | 370 if (!CommandLine::ForCurrentProcess()-> |
| 371 HasSwitch(switches::kDisableHtml5Camera)) { |
369 return; | 372 return; |
| 373 } |
370 CameraDetector::StartPresenceCheck( | 374 CameraDetector::StartPresenceCheck( |
371 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone, | 375 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone, |
372 weak_factory_.GetWeakPtr())); | 376 weak_factory_.GetWeakPtr())); |
373 } | 377 } |
374 | 378 |
375 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { | 379 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { |
376 base::FundamentalValue present_value(present); | 380 base::FundamentalValue present_value(present); |
377 web_ui()->CallJavascriptFunction("ChangePictureOptions.setCameraPresent", | 381 web_ui()->CallJavascriptFunction("ChangePictureOptions.setCameraPresent", |
378 present_value); | 382 present_value); |
379 } | 383 } |
(...skipping 30 matching lines...) Expand all Loading... |
410 OnPhotoAccepted(user_photo_); | 414 OnPhotoAccepted(user_photo_); |
411 } | 415 } |
412 | 416 |
413 void ChangePictureOptionsHandler::OnDecodeImageFailed( | 417 void ChangePictureOptionsHandler::OnDecodeImageFailed( |
414 const ImageDecoder* decoder) { | 418 const ImageDecoder* decoder) { |
415 NOTREACHED() << "Failed to decode PNG image from WebUI"; | 419 NOTREACHED() << "Failed to decode PNG image from WebUI"; |
416 } | 420 } |
417 | 421 |
418 } // namespace options2 | 422 } // namespace options2 |
419 } // namespace chromeos | 423 } // namespace chromeos |
OLD | NEW |