| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_OPTIONS_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDLER_
H_ | 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_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDLER_
H_ |
| 7 | 7 |
| 8 #include "chrome/browser/chromeos/camera_presence_notifier.h" | 8 #include "chrome/browser/chromeos/camera_presence_notifier.h" |
| 9 #include "chrome/browser/image_decoder.h" | 9 #include "chrome/browser/image_decoder.h" |
| 10 #include "chrome/browser/ui/webui/options/options_ui.h" | 10 #include "chrome/browser/ui/webui/options/options_ui.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 | 27 |
| 28 namespace options { | 28 namespace options { |
| 29 | 29 |
| 30 // ChromeOS user image options page UI handler. | 30 // ChromeOS user image options page UI handler. |
| 31 class ChangePictureOptionsHandler : public ::options::OptionsPageUIHandler, | 31 class ChangePictureOptionsHandler : public ::options::OptionsPageUIHandler, |
| 32 public ui::SelectFileDialog::Listener, | 32 public ui::SelectFileDialog::Listener, |
| 33 public content::NotificationObserver, | 33 public content::NotificationObserver, |
| 34 public ImageDecoder::Delegate, | 34 public ImageDecoder::ImageRequest, |
| 35 public CameraPresenceNotifier::Observer { | 35 public CameraPresenceNotifier::Observer { |
| 36 public: | 36 public: |
| 37 ChangePictureOptionsHandler(); | 37 ChangePictureOptionsHandler(); |
| 38 ~ChangePictureOptionsHandler() override; | 38 ~ChangePictureOptionsHandler() override; |
| 39 | 39 |
| 40 // OptionsPageUIHandler implementation. | 40 // OptionsPageUIHandler implementation. |
| 41 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; | 41 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; |
| 42 | 42 |
| 43 // WebUIMessageHandler implementation. | 43 // WebUIMessageHandler implementation. |
| 44 void RegisterMessages() override; | 44 void RegisterMessages() override; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 void Observe(int type, | 106 void Observe(int type, |
| 107 const content::NotificationSource& source, | 107 const content::NotificationSource& source, |
| 108 const content::NotificationDetails& details) override; | 108 const content::NotificationDetails& details) override; |
| 109 | 109 |
| 110 // Sets user image to photo taken from camera. | 110 // Sets user image to photo taken from camera. |
| 111 void SetImageFromCamera(const gfx::ImageSkia& photo); | 111 void SetImageFromCamera(const gfx::ImageSkia& photo); |
| 112 | 112 |
| 113 // Returns handle to browser window or NULL if it can't be found. | 113 // Returns handle to browser window or NULL if it can't be found. |
| 114 gfx::NativeWindow GetBrowserWindow() const; | 114 gfx::NativeWindow GetBrowserWindow() const; |
| 115 | 115 |
| 116 // Overriden from ImageDecoder::Delegate: | 116 // Overriden from ImageDecoder::ImageRequest: |
| 117 void OnImageDecoded(const ImageDecoder* decoder, | 117 void OnImageDecoded(const SkBitmap& decoded_image) override; |
| 118 const SkBitmap& decoded_image) override; | 118 void OnDecodeImageFailed() override; |
| 119 void OnDecodeImageFailed(const ImageDecoder* decoder) override; | |
| 120 | 119 |
| 121 // Returns user related to current WebUI. If this user doesn't exist, | 120 // Returns user related to current WebUI. If this user doesn't exist, |
| 122 // returns active user. | 121 // returns active user. |
| 123 const user_manager::User* GetUser() const; | 122 const user_manager::User* GetUser() const; |
| 124 | 123 |
| 125 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 124 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
| 126 | 125 |
| 127 // Previous user image from camera/file and its data URL. | 126 // Previous user image from camera/file and its data URL. |
| 128 gfx::ImageSkia previous_image_; | 127 gfx::ImageSkia previous_image_; |
| 129 std::string previous_image_url_; | 128 std::string previous_image_url_; |
| 130 | 129 |
| 131 // Index of the previous user image. | 130 // Index of the previous user image. |
| 132 int previous_image_index_; | 131 int previous_image_index_; |
| 133 | 132 |
| 134 // Last user photo, if taken. | 133 // Last user photo, if taken. |
| 135 gfx::ImageSkia user_photo_; | 134 gfx::ImageSkia user_photo_; |
| 136 | 135 |
| 137 // Data URL for |user_photo_|. | 136 // Data URL for |user_photo_|. |
| 138 std::string user_photo_data_url_; | 137 std::string user_photo_data_url_; |
| 139 | 138 |
| 140 content::NotificationRegistrar registrar_; | 139 content::NotificationRegistrar registrar_; |
| 141 | 140 |
| 142 // Last ImageDecoder instance used to decode an image blob received by | |
| 143 // HandlePhotoTaken. | |
| 144 scoped_refptr<ImageDecoder> image_decoder_; | |
| 145 | |
| 146 DISALLOW_COPY_AND_ASSIGN(ChangePictureOptionsHandler); | 141 DISALLOW_COPY_AND_ASSIGN(ChangePictureOptionsHandler); |
| 147 }; | 142 }; |
| 148 | 143 |
| 149 } // namespace options | 144 } // namespace options |
| 150 } // namespace chromeos | 145 } // namespace chromeos |
| 151 | 146 |
| 152 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDL
ER_H_ | 147 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDL
ER_H_ |
| OLD | NEW |