Index: chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc |
diff --git a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc |
index f7f4fc06b5a7ee3d4308601eee97d0bd17f81120..7ddce8cfe3abd9ca9c93b483828c534799982ff2 100644 |
--- a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc |
+++ b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h" |
+#include "base/command_line.h" |
Nikita (slow)
2012/06/07 15:26:55
nit: sort
Ivan Korotkov
2012/06/09 14:19:01
Done.
|
#include "base/bind.h" |
#include "base/bind_helpers.h" |
#include "base/logging.h" |
@@ -15,6 +16,7 @@ |
#include "chrome/browser/chromeos/login/webui_login_display.h" |
#include "chrome/browser/chromeos/options/take_photo_dialog.h" |
#include "chrome/browser/ui/webui/web_ui_util.h" |
+#include "chrome/common/chrome_switches.h" |
#include "chrome/common/url_constants.h" |
#include "grit/generated_resources.h" |
#include "ui/base/l10n/l10n_util.h" |
@@ -60,6 +62,11 @@ void UserImageScreenHandler::GetLocalizedStrings( |
l10n_util::GetStringUTF16(IDS_IMAGE_SCREEN_PROFILE_LOADING_PHOTO)); |
localized_strings->SetString("okButtonText", |
l10n_util::GetStringUTF16(IDS_OK)); |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHtml5Camera)) |
+ localized_strings->SetString("cameraType", "webrtc"); |
+ else |
+ localized_strings->SetString("cameraType", "old"); |
+ localized_strings->SetString("userImagesGridSrc", "../user_images_grid.js"); |
Nikita (slow)
2012/06/07 15:26:55
Is this somekind of hack till code is refactored i
Ivan Korotkov
2012/06/09 14:19:01
Obsolete hack, removed.
|
} |
void UserImageScreenHandler::Initialize() { |
@@ -127,6 +134,9 @@ void UserImageScreenHandler::ShowCameraInitializing() { |
} |
void UserImageScreenHandler::CheckCameraPresence() { |
+ // For WebRTC, camera presence checked is done on JS side. |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHtml5Camera)) |
+ return; |
CameraDetector::StartPresenceCheck( |
base::Bind(&UserImageScreenHandler::OnCameraPresenceCheckDone, |
weak_factory_.GetWeakPtr())); |
@@ -140,6 +150,9 @@ void UserImageScreenHandler::RegisterMessages() { |
web_ui()->RegisterMessageCallback("takePhoto", |
base::Bind(&UserImageScreenHandler::HandleTakePhoto, |
base::Unretained(this))); |
+ web_ui()->RegisterMessageCallback("photoTaken", |
+ base::Bind(&UserImageScreenHandler::HandlePhotoTaken, |
+ base::Unretained(this))); |
web_ui()->RegisterMessageCallback("selectImage", |
base::Bind(&UserImageScreenHandler::HandleSelectImage, |
base::Unretained(this))); |
@@ -182,6 +195,15 @@ void UserImageScreenHandler::OnPhotoAccepted(const gfx::ImageSkia& photo) { |
data_url); |
} |
+void UserImageScreenHandler::HandlePhotoTaken(const base::ListValue* args) { |
+ std::string image_url; |
+ if (!args || args->GetSize() != 1 || !args->GetString(0, &image_url)) |
+ NOTREACHED(); |
+ DCHECK(!image_url.empty()); |
+ user_photo_data_url_ = image_url; |
+ user_photo_ = web_ui_util::GetImageFromDataUrl(image_url); |
+} |
+ |
void UserImageScreenHandler::HandleTakePhoto(const base::ListValue* args) { |
DCHECK(args && args->empty()); |
views::Widget* window = views::Widget::CreateWindowWithParent( |
@@ -192,12 +214,8 @@ void UserImageScreenHandler::HandleTakePhoto(const base::ListValue* args) { |
void UserImageScreenHandler::HandleSelectImage(const base::ListValue* args) { |
std::string image_url; |
- if (!args || |
- args->GetSize() != 1 || |
- !args->GetString(0, &image_url)) { |
+ if (!args || args->GetSize() != 1 || !args->GetString(0, &image_url)) |
NOTREACHED(); |
- return; |
- } |
if (image_url.empty()) |
return; |
@@ -231,6 +249,8 @@ void UserImageScreenHandler::HandleImageAccepted(const base::ListValue* args) { |
} |
void UserImageScreenHandler::HandleScreenShown(const base::ListValue* args) { |
+ CheckCameraPresence(); |
Nikita (slow)
2012/06/07 15:26:55
Remove?
Ivan Korotkov
2012/06/09 14:19:01
Done.
|
+ return; |
DCHECK(args && args->empty()); |
DCHECK(!screen_show_time_.is_null()); |
@@ -240,6 +260,9 @@ void UserImageScreenHandler::HandleScreenShown(const base::ListValue* args) { |
} |
void UserImageScreenHandler::OnCameraPresenceCheckDone() { |
+ // For WebRTC, camera presence checked is done on JS side. |
Nikita (slow)
2012/06/07 15:26:55
You don't need this check here as you CamerDetecto
Ivan Korotkov
2012/06/09 14:19:01
Done.
|
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHtml5Camera)) |
+ return; |
base::FundamentalValue present_value( |
CameraDetector::camera_presence() == CameraDetector::kCameraPresent); |
web_ui()->CallJavascriptFunction("oobe.UserImageScreen.setCameraPresent", |