| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/audio/sounds.h" | |
| 8 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 8 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 11 #include "base/values.h" | 10 #include "base/values.h" |
| 12 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 11 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 13 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 12 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 14 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 13 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 15 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
| 18 #include "chromeos/audio/chromeos_sounds.h" | 17 #include "chromeos/audio/chromeos_sounds.h" |
| 19 #include "components/user_manager/user.h" | 18 #include "components/user_manager/user.h" |
| 20 #include "components/user_manager/user_image/default_user_images.h" | 19 #include "components/user_manager/user_image/default_user_images.h" |
| 21 #include "grit/browser_resources.h" | 20 #include "grit/browser_resources.h" |
| 22 #include "net/base/data_url.h" | 21 #include "net/base/data_url.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 26 | 25 |
| 26 #if defined(USE_ASH) |
| 27 #include "ash/audio/sounds.h" |
| 28 #endif |
| 29 |
| 27 namespace { | 30 namespace { |
| 28 | 31 |
| 29 const char kJsScreenPath[] = "login.UserImageScreen"; | 32 const char kJsScreenPath[] = "login.UserImageScreen"; |
| 30 | 33 |
| 31 } // namespace | 34 } // namespace |
| 32 | 35 |
| 33 namespace chromeos { | 36 namespace chromeos { |
| 34 | 37 |
| 35 UserImageScreenHandler::UserImageScreenHandler() | 38 UserImageScreenHandler::UserImageScreenHandler() |
| 36 : BaseScreenHandler(kJsScreenPath), | 39 : BaseScreenHandler(kJsScreenPath), |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 std::string mime_type, charset, raw_data; | 181 std::string mime_type, charset, raw_data; |
| 179 if (!net::DataURL::Parse(GURL(image_url), &mime_type, &charset, &raw_data)) | 182 if (!net::DataURL::Parse(GURL(image_url), &mime_type, &charset, &raw_data)) |
| 180 NOTREACHED(); | 183 NOTREACHED(); |
| 181 DCHECK_EQ("image/png", mime_type); | 184 DCHECK_EQ("image/png", mime_type); |
| 182 | 185 |
| 183 if (screen_) | 186 if (screen_) |
| 184 screen_->OnPhotoTaken(raw_data); | 187 screen_->OnPhotoTaken(raw_data); |
| 185 } | 188 } |
| 186 | 189 |
| 187 void UserImageScreenHandler::HandleTakePhoto() { | 190 void UserImageScreenHandler::HandleTakePhoto() { |
| 191 #if defined(USE_ASH) |
| 188 ash::PlaySystemSoundIfSpokenFeedback(SOUND_CAMERA_SNAP); | 192 ash::PlaySystemSoundIfSpokenFeedback(SOUND_CAMERA_SNAP); |
| 193 #endif |
| 189 } | 194 } |
| 190 | 195 |
| 191 void UserImageScreenHandler::HandleDiscardPhoto() { | 196 void UserImageScreenHandler::HandleDiscardPhoto() { |
| 197 #if defined(USE_ASH) |
| 192 ash::PlaySystemSoundIfSpokenFeedback(SOUND_OBJECT_DELETE); | 198 ash::PlaySystemSoundIfSpokenFeedback(SOUND_OBJECT_DELETE); |
| 199 #endif |
| 193 } | 200 } |
| 194 | 201 |
| 195 void UserImageScreenHandler::HandleSelectImage(const std::string& image_url, | 202 void UserImageScreenHandler::HandleSelectImage(const std::string& image_url, |
| 196 const std::string& image_type, | 203 const std::string& image_type, |
| 197 bool is_user_selection) { | 204 bool is_user_selection) { |
| 198 if (screen_) | 205 if (screen_) |
| 199 screen_->OnImageSelected(image_type, image_url, is_user_selection); | 206 screen_->OnImageSelected(image_type, image_url, is_user_selection); |
| 200 } | 207 } |
| 201 | 208 |
| 202 void UserImageScreenHandler::HandleImageAccepted() { | 209 void UserImageScreenHandler::HandleImageAccepted() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 214 | 221 |
| 215 void UserImageScreenHandler::SetCameraPresent(bool present) { | 222 void UserImageScreenHandler::SetCameraPresent(bool present) { |
| 216 CallJS("setCameraPresent", present); | 223 CallJS("setCameraPresent", present); |
| 217 } | 224 } |
| 218 | 225 |
| 219 void UserImageScreenHandler::HideCurtain() { | 226 void UserImageScreenHandler::HideCurtain() { |
| 220 CallJS("hideCurtain"); | 227 CallJS("hideCurtain"); |
| 221 } | 228 } |
| 222 | 229 |
| 223 } // namespace chromeos | 230 } // namespace chromeos |
| OLD | NEW |