| OLD | NEW |
| (Empty) |
| 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_UI_WEBUI_OPTIONS2_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDLER
_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDLER
_H_ | |
| 7 | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 #include "chrome/browser/chromeos/options2/take_photo_dialog.h" | |
| 10 #include "chrome/browser/ui/select_file_dialog.h" | |
| 11 #include "chrome/browser/ui/webui/options2/options_ui.h" | |
| 12 #include "content/public/browser/notification_registrar.h" | |
| 13 #include "ui/gfx/native_widget_types.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class DictionaryValue; | |
| 17 class ListValue; | |
| 18 } | |
| 19 | |
| 20 namespace chromeos { | |
| 21 | |
| 22 // ChromeOS user image options page UI handler. | |
| 23 class ChangePictureOptionsHandler : public OptionsPage2UIHandler, | |
| 24 public SelectFileDialog::Listener, | |
| 25 public TakePhotoDialog::Delegate { | |
| 26 public: | |
| 27 ChangePictureOptionsHandler(); | |
| 28 virtual ~ChangePictureOptionsHandler(); | |
| 29 | |
| 30 // OptionsPage2UIHandler implementation. | |
| 31 virtual void GetLocalizedValues( | |
| 32 base::DictionaryValue* localized_strings) OVERRIDE; | |
| 33 | |
| 34 // WebUIMessageHandler implementation. | |
| 35 virtual void RegisterMessages() OVERRIDE; | |
| 36 | |
| 37 private: | |
| 38 // Sends list of available default images to the page. | |
| 39 void SendDefaultImages(); | |
| 40 | |
| 41 // Sends current selection to the page. | |
| 42 void SendSelectedImage(); | |
| 43 | |
| 44 // Sends the profile image to the page. If |should_select| is true then | |
| 45 // the profile image element is selected. | |
| 46 void SendProfileImage(const SkBitmap& image, bool should_select); | |
| 47 | |
| 48 // Starts profile image update and shows the last downloaded profile image, | |
| 49 // if any, on the page. Shouldn't be called before |SendProfileImage|. | |
| 50 void UpdateProfileImage(); | |
| 51 | |
| 52 // Starts camera presence check. | |
| 53 void CheckCameraPresence(); | |
| 54 | |
| 55 // Updates UI with camera presence state. | |
| 56 void SetCameraPresent(bool present); | |
| 57 | |
| 58 // Opens a file selection dialog to choose user image from file. | |
| 59 void HandleChooseFile(const base::ListValue* args); | |
| 60 | |
| 61 // Opens the camera capture dialog. | |
| 62 void HandleTakePhoto(const base::ListValue* args); | |
| 63 | |
| 64 // Gets the list of available user images and sends it to the page. | |
| 65 void HandleGetAvailableImages(const base::ListValue* args); | |
| 66 | |
| 67 // Handles page initialized event. | |
| 68 void HandlePageInitialized(const base::ListValue* args); | |
| 69 | |
| 70 // Handles page shown event. | |
| 71 void HandlePageShown(const base::ListValue* args); | |
| 72 | |
| 73 // Selects one of the available images as user's. | |
| 74 void HandleSelectImage(const base::ListValue* args); | |
| 75 | |
| 76 // SelectFileDialog::Delegate implementation. | |
| 77 virtual void FileSelected( | |
| 78 const FilePath& path, | |
| 79 int index, void* params) OVERRIDE; | |
| 80 | |
| 81 // TakePhotoDialog::Delegate implementation. | |
| 82 virtual void OnPhotoAccepted(const SkBitmap& photo) OVERRIDE; | |
| 83 | |
| 84 // content::NotificationObserver implementation. | |
| 85 virtual void Observe(int type, | |
| 86 const content::NotificationSource& source, | |
| 87 const content::NotificationDetails& details) OVERRIDE; | |
| 88 | |
| 89 // Called when the camera presence check has been completed. | |
| 90 void OnCameraPresenceCheckDone(); | |
| 91 | |
| 92 // Returns handle to browser window or NULL if it can't be found. | |
| 93 gfx::NativeWindow GetBrowserWindow() const; | |
| 94 | |
| 95 scoped_refptr<SelectFileDialog> select_file_dialog_; | |
| 96 | |
| 97 // Previous user image from camera/file and its data URL. | |
| 98 SkBitmap previous_image_; | |
| 99 std::string previous_image_data_url_; | |
| 100 | |
| 101 // Index of the previous user image. | |
| 102 int previous_image_index_; | |
| 103 | |
| 104 content::NotificationRegistrar registrar_; | |
| 105 | |
| 106 base::WeakPtrFactory<ChangePictureOptionsHandler> weak_factory_; | |
| 107 | |
| 108 DISALLOW_COPY_AND_ASSIGN(ChangePictureOptionsHandler); | |
| 109 }; | |
| 110 | |
| 111 } // namespace chromeos | |
| 112 | |
| 113 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_CHANGE_PICTURE_OPTIONS_HAND
LER_H_ | |
| OLD | NEW |