Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / chromeos / change_picture_options_handler.h
blob033067747f121eb4b25a96c7006a06aebb772e25
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDLER_H_
8 #include "chrome/browser/chromeos/camera_presence_notifier.h"
9 #include "chrome/browser/image_decoder.h"
10 #include "chrome/browser/ui/webui/options/options_ui.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "ui/gfx/image/image_skia.h"
14 #include "ui/gfx/native_widget_types.h"
15 #include "ui/shell_dialogs/select_file_dialog.h"
17 namespace base {
18 class DictionaryValue;
19 class ListValue;
22 namespace chromeos {
24 class User;
26 namespace options {
28 // ChromeOS user image options page UI handler.
29 class ChangePictureOptionsHandler : public ::options::OptionsPageUIHandler,
30 public ui::SelectFileDialog::Listener,
31 public content::NotificationObserver,
32 public ImageDecoder::Delegate,
33 public CameraPresenceNotifier::Observer {
34 public:
35 ChangePictureOptionsHandler();
36 virtual ~ChangePictureOptionsHandler();
38 // OptionsPageUIHandler implementation.
39 virtual void GetLocalizedValues(
40 base::DictionaryValue* localized_strings) OVERRIDE;
42 // WebUIMessageHandler implementation.
43 virtual void RegisterMessages() OVERRIDE;
45 // CameraPresenceNotifier::Observer implementation:
46 virtual void OnCameraPresenceCheckDone(bool is_camera_present) OVERRIDE;
48 private:
49 // Sends list of available default images to the page.
50 void SendDefaultImages();
52 // Sends current selection to the page.
53 void SendSelectedImage();
55 // Sends the profile image to the page. If |should_select| is true then
56 // the profile image element is selected.
57 void SendProfileImage(const gfx::ImageSkia& image, bool should_select);
59 // Starts profile image update and shows the last downloaded profile image,
60 // if any, on the page. Shouldn't be called before |SendProfileImage|.
61 void UpdateProfileImage();
63 // Sends previous user image to the page.
64 void SendOldImage(const std::string& image_url);
66 // Starts camera presence check.
67 void CheckCameraPresence();
69 // Updates UI with camera presence state.
70 void SetCameraPresent(bool present);
72 // Opens a file selection dialog to choose user image from file.
73 void HandleChooseFile(const base::ListValue* args);
75 // Handles 'take-photo' button click.
76 void HandleTakePhoto(const base::ListValue* args);
78 // Handles photo taken with WebRTC UI.
79 void HandlePhotoTaken(const base::ListValue* args);
81 // Handles 'discard-photo' button click.
82 void HandleDiscardPhoto(const base::ListValue* args);
84 // Gets the list of available user images and sends it to the page.
85 void HandleGetAvailableImages(const base::ListValue* args);
87 // Handles page initialized event.
88 void HandlePageInitialized(const base::ListValue* args);
90 // Handles page shown event.
91 void HandlePageShown(const base::ListValue* args);
93 // Handles page hidden event.
94 void HandlePageHidden(const base::ListValue* args);
96 // Selects one of the available images as user's.
97 void HandleSelectImage(const base::ListValue* args);
99 // SelectFileDialog::Delegate implementation.
100 virtual void FileSelected(
101 const base::FilePath& path,
102 int index, void* params) OVERRIDE;
104 // content::NotificationObserver implementation.
105 virtual void Observe(int type,
106 const content::NotificationSource& source,
107 const content::NotificationDetails& details) OVERRIDE;
109 // Sets user image to photo taken from camera.
110 void SetImageFromCamera(const gfx::ImageSkia& photo);
112 // Returns handle to browser window or NULL if it can't be found.
113 gfx::NativeWindow GetBrowserWindow() const;
115 // Overriden from ImageDecoder::Delegate:
116 virtual void OnImageDecoded(const ImageDecoder* decoder,
117 const SkBitmap& decoded_image) OVERRIDE;
118 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE;
120 // Returns user related to current WebUI. If this user doesn't exist,
121 // returns active user.
122 User* GetUser() const;
124 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
126 // Previous user image from camera/file and its data URL.
127 gfx::ImageSkia previous_image_;
128 std::string previous_image_url_;
130 // Index of the previous user image.
131 int previous_image_index_;
133 // Last user photo, if taken.
134 gfx::ImageSkia user_photo_;
136 // Data URL for |user_photo_|.
137 std::string user_photo_data_url_;
139 content::NotificationRegistrar registrar_;
141 // Last ImageDecoder instance used to decode an image blob received by
142 // HandlePhotoTaken.
143 scoped_refptr<ImageDecoder> image_decoder_;
145 DISALLOW_COPY_AND_ASSIGN(ChangePictureOptionsHandler);
148 } // namespace options
149 } // namespace chromeos
151 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDLER_H_