Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h

Issue 10532048: [cros] Initial WebRTC-enabled implementation of user image picker on OOBE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert ImageDecoder changes. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/browser/chromeos/login/user_image_screen_actor.h" 10 #include "chrome/browser/chromeos/login/user_image_screen_actor.h"
11 #include "chrome/browser/chromeos/options/take_photo_dialog.h" 11 #include "chrome/browser/chromeos/options/take_photo_dialog.h"
12 #include "chrome/browser/image_decoder.h"
12 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" 13 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
13 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 14 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
16 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
17 18
18 namespace base { 19 namespace base {
19 class ListValue; 20 class ListValue;
20 } // namespace base 21 } // namespace base
21 22
22 namespace chromeos { 23 namespace chromeos {
23 24
24 // WebUI implementation of UserImageScreenActor. It is used to interact 25 // WebUI implementation of UserImageScreenActor. It is used to interact
25 // with JS page part allowing user to select avatar. 26 // with JS page part allowing user to select avatar.
26 class UserImageScreenHandler : public UserImageScreenActor, 27 class UserImageScreenHandler : public UserImageScreenActor,
27 public BaseScreenHandler, 28 public BaseScreenHandler,
28 public TakePhotoDialog::Delegate { 29 public TakePhotoDialog::Delegate,
30 public ImageDecoder::Delegate {
29 public: 31 public:
30 UserImageScreenHandler(); 32 UserImageScreenHandler();
31 virtual ~UserImageScreenHandler(); 33 virtual ~UserImageScreenHandler();
32 34
33 // BaseScreenHandler implementation: 35 // BaseScreenHandler implementation:
34 virtual void GetLocalizedStrings( 36 virtual void GetLocalizedStrings(
35 base::DictionaryValue* localized_strings) OVERRIDE; 37 base::DictionaryValue* localized_strings) OVERRIDE;
36 virtual void Initialize() OVERRIDE; 38 virtual void Initialize() OVERRIDE;
37 39
38 // UserImageScreenActor implementation: 40 // UserImageScreenActor implementation:
(...skipping 17 matching lines...) Expand all
56 // TakePhotoDialog::Delegate implementation. 58 // TakePhotoDialog::Delegate implementation.
57 virtual void OnPhotoAccepted(const gfx::ImageSkia& photo) OVERRIDE; 59 virtual void OnPhotoAccepted(const gfx::ImageSkia& photo) OVERRIDE;
58 60
59 private: 61 private:
60 // Sends profile image as a data URL to the page. 62 // Sends profile image as a data URL to the page.
61 void SendProfileImage(const std::string& data_url); 63 void SendProfileImage(const std::string& data_url);
62 64
63 // Opens the camera capture dialog. 65 // Opens the camera capture dialog.
64 void HandleTakePhoto(const base::ListValue* args); 66 void HandleTakePhoto(const base::ListValue* args);
65 67
68 // Handles photo taken with WebRTC UI.
69 void HandlePhotoTaken(const base::ListValue* args);
70
66 // Handles clicking on default user image. 71 // Handles clicking on default user image.
67 void HandleSelectImage(const base::ListValue* args); 72 void HandleSelectImage(const base::ListValue* args);
68 73
69 // Called when user accept the image closing the screen. 74 // Called when user accept the image closing the screen.
70 void HandleImageAccepted(const base::ListValue* args); 75 void HandleImageAccepted(const base::ListValue* args);
71 76
72 // Called when the user image screen has been loaded and shown. 77 // Called when the user image screen has been loaded and shown.
73 void HandleScreenShown(const base::ListValue* args); 78 void HandleScreenShown(const base::ListValue* args);
74 79
75 // Called when the camera presence check has been completed. 80 // Called when the camera presence check has been completed.
76 void OnCameraPresenceCheckDone(); 81 void OnCameraPresenceCheckDone();
77 82
83 // Overriden from ImageDecoder::Delegate:
84 virtual void OnImageDecoded(const ImageDecoder* decoder,
85 const SkBitmap& decoded_image) OVERRIDE;
86 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE;
87
88
78 UserImageScreenActor::Delegate* screen_; 89 UserImageScreenActor::Delegate* screen_;
79 90
80 // Keeps whether screen should be shown right after initialization. 91 // Keeps whether screen should be shown right after initialization.
81 bool show_on_init_; 92 bool show_on_init_;
82 93
83 // Index of the selected user image. 94 // Index of the selected user image.
84 int selected_image_; 95 int selected_image_;
85 96
86 // Last user photo, if taken. 97 // Last user photo, if taken.
87 gfx::ImageSkia user_photo_; 98 gfx::ImageSkia user_photo_;
88 99
100 // Last ImageDecoder instance used to decode an image blob received by
101 // HandlePhotoTaken.
102 scoped_refptr<ImageDecoder> image_decoder_;
103
104 // If |true|, decoded photo should be immediately accepeted (i.e., both
105 // HandleTakePhoto and HandleImageAccepted have already been called but we're
106 // still waiting for photo image decoding to finish.
107 bool accept_photo_after_decoding_;
108
89 // Data URL for |user_photo_|. 109 // Data URL for |user_photo_|.
90 std::string user_photo_data_url_; 110 std::string user_photo_data_url_;
91 111
92 // Data URL of the profile picture; 112 // Data URL of the profile picture;
93 std::string profile_picture_data_url_; 113 std::string profile_picture_data_url_;
94 114
95 // True if user has no custom profile picture. 115 // True if user has no custom profile picture.
96 bool profile_picture_absent_; 116 bool profile_picture_absent_;
97 117
98 base::WeakPtrFactory<UserImageScreenHandler> weak_factory_; 118 base::WeakPtrFactory<UserImageScreenHandler> weak_factory_;
99 119
100 base::Time screen_show_time_; 120 base::Time screen_show_time_;
101 121
102 DISALLOW_COPY_AND_ASSIGN(UserImageScreenHandler); 122 DISALLOW_COPY_AND_ASSIGN(UserImageScreenHandler);
103 }; 123 };
104 124
105 } // namespace chromeos 125 } // namespace chromeos
106 126
107 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_ 127 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698