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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_VIEW_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_VIEW_H_ 7 #pragma once 8 9 #include "chrome/browser/chromeos/login/default_images_view.h" 10 #include "chrome/browser/chromeos/login/take_photo_view.h" 11 #include "views/controls/button/button.h" 12 #include "views/view.h" 13 14 class SkBitmap; 15 16 namespace views { 17 class Label; 18 class NativeButton; 19 } // namespace views 20 21 namespace chromeos { 22 23 // View used for selecting user image on OOBE screen. 24 class UserImageView : public views::View, 25 public views::ButtonListener, 26 public TakePhotoView::Delegate, 27 public DefaultImagesView::Delegate { 28 public: 29 // Delegate class to get notifications from the view. 30 class Delegate { 31 public: 32 virtual ~Delegate() {} 33 34 // Initializes camera if needed and starts capturing. 35 virtual void StartCamera() = 0; 36 37 // Stops capturing from camera. 38 virtual void StopCamera() = 0; 39 40 // Called if user accepts the taken photo. The image is passed as a 41 // parameter. 42 virtual void OnPhotoTaken(const SkBitmap& image) = 0; 43 44 // Called if user accepts the chosen default image. The image index is 45 // passed as a parameter. 46 virtual void OnDefaultImageSelected(int index) = 0; 47 }; 48 49 explicit UserImageView(Delegate* delegate); 50 virtual ~UserImageView(); 51 52 // Initializes this view, its children and layout. 53 void Init(); 54 55 // Updates image from camera. 56 void UpdateVideoFrame(const SkBitmap& frame); 57 58 // If in capturing mode, shows that camera is initializing by running 59 // throbber above the picture. Disables snapshot button until frame is 60 // received. 61 void ShowCameraInitializing(); 62 63 // If in capturing mode, shows that camera is broken instead of video 64 // frame and disables snapshot button until new frame is received. 65 void ShowCameraError(); 66 67 // Returns true if video capture is the current state of the view. 68 bool IsCapturing() const; 69 70 // Overridden from views::View: 71 virtual gfx::Size GetPreferredSize(); 72 73 // Overridden from views::ButtonListener. 74 virtual void ButtonPressed(views::Button* sender, const views::Event& event); 75 76 // Overridden from TakePhotoView::Delegate. 77 virtual void OnCapturingStarted(); 78 virtual void OnCapturingStopped(); 79 80 // Overridden from DefaultImagesView::Delegate. 81 virtual void OnCaptureButtonClicked(); 82 virtual void OnImageSelected(int image_index); 83 84 private: 85 // Initializes layout manager for this view. 86 void InitLayout(); 87 88 views::Label* title_label_; 89 DefaultImagesView* default_images_view_; 90 TakePhotoView* take_photo_view_; 91 views::View* splitter_; 92 views::NativeButton* ok_button_; 93 94 // Notifications receiver. 95 Delegate* delegate_; 96 97 DISALLOW_COPY_AND_ASSIGN(UserImageView); 98 }; 99 100 } // namespace chromeos 101 102 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_VIEW_H_ 103