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

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h

Issue 2568973002: chromeos: Replace user image notifications with observer (Closed)
Patch Set: rebase Created 4 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_SETTINGS_CHROMEOS_CHANGE_PICTURE_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CHANGE_PICTURE_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CHANGE_PICTURE_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CHANGE_PICTURE_HANDLER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/scoped_observer.h" 9 #include "base/scoped_observer.h"
10 #include "chrome/browser/chromeos/camera_presence_notifier.h" 10 #include "chrome/browser/chromeos/camera_presence_notifier.h"
11 #include "chrome/browser/image_decoder.h" 11 #include "chrome/browser/image_decoder.h"
12 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" 12 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
13 #include "content/public/browser/notification_observer.h" 13 #include "components/user_manager/user_manager.h"
14 #include "content/public/browser/notification_registrar.h"
15 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
16 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
17 #include "ui/shell_dialogs/select_file_dialog.h" 16 #include "ui/shell_dialogs/select_file_dialog.h"
18 17
19 namespace base { 18 namespace base {
20 class ListValue; 19 class ListValue;
21 } 20 }
22 21
23 namespace user_manager { 22 namespace user_manager {
24 class User; 23 class User;
25 } 24 }
26 25
27 namespace chromeos { 26 namespace chromeos {
28 27
29 namespace settings { 28 namespace settings {
30 29
31 // ChromeOS user image settings page UI handler. 30 // ChromeOS user image settings page UI handler.
32 class ChangePictureHandler : public ::settings::SettingsPageUIHandler, 31 class ChangePictureHandler : public ::settings::SettingsPageUIHandler,
33 public ui::SelectFileDialog::Listener, 32 public ui::SelectFileDialog::Listener,
34 public content::NotificationObserver, 33 public user_manager::UserManager::Observer,
35 public ImageDecoder::ImageRequest, 34 public ImageDecoder::ImageRequest,
36 public CameraPresenceNotifier::Observer { 35 public CameraPresenceNotifier::Observer {
37 public: 36 public:
38 ChangePictureHandler(); 37 ChangePictureHandler();
39 ~ChangePictureHandler() override; 38 ~ChangePictureHandler() override;
40 39
41 // WebUIMessageHandler implementation. 40 // WebUIMessageHandler implementation.
42 void RegisterMessages() override; 41 void RegisterMessages() override;
43 void OnJavascriptAllowed() override; 42 void OnJavascriptAllowed() override;
44 void OnJavascriptDisallowed() override; 43 void OnJavascriptDisallowed() override;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 void HandlePageInitialized(const base::ListValue* args); 85 void HandlePageInitialized(const base::ListValue* args);
87 86
88 // Selects one of the available images as user's. 87 // Selects one of the available images as user's.
89 void HandleSelectImage(const base::ListValue* args); 88 void HandleSelectImage(const base::ListValue* args);
90 89
91 // SelectFileDialog::Delegate implementation. 90 // SelectFileDialog::Delegate implementation.
92 void FileSelected(const base::FilePath& path, 91 void FileSelected(const base::FilePath& path,
93 int index, 92 int index,
94 void* params) override; 93 void* params) override;
95 94
96 // content::NotificationObserver implementation. 95 // user_manager::UserManager::Observer implementation.
97 void Observe(int type, 96 void OnUserImageChanged(const user_manager::User& user) override;
98 const content::NotificationSource& source, 97 void OnUserProfileImageUpdated(const user_manager::User& user,
99 const content::NotificationDetails& details) override; 98 const gfx::ImageSkia& profile_image) override;
100 99
101 // Sets user image to photo taken from camera. 100 // Sets user image to photo taken from camera.
102 void SetImageFromCamera(const gfx::ImageSkia& photo); 101 void SetImageFromCamera(const gfx::ImageSkia& photo);
103 102
104 // Returns handle to browser window or NULL if it can't be found. 103 // Returns handle to browser window or NULL if it can't be found.
105 gfx::NativeWindow GetBrowserWindow() const; 104 gfx::NativeWindow GetBrowserWindow() const;
106 105
107 // Overriden from ImageDecoder::ImageRequest: 106 // Overriden from ImageDecoder::ImageRequest:
108 void OnImageDecoded(const SkBitmap& decoded_image) override; 107 void OnImageDecoded(const SkBitmap& decoded_image) override;
109 void OnDecodeImageFailed() override; 108 void OnDecodeImageFailed() override;
(...skipping 10 matching lines...) Expand all
120 119
121 // Index of the previous user image. 120 // Index of the previous user image.
122 int previous_image_index_; 121 int previous_image_index_;
123 122
124 // Last user photo, if taken. 123 // Last user photo, if taken.
125 gfx::ImageSkia user_photo_; 124 gfx::ImageSkia user_photo_;
126 125
127 // Data URL for |user_photo_|. 126 // Data URL for |user_photo_|.
128 std::string user_photo_data_url_; 127 std::string user_photo_data_url_;
129 128
130 content::NotificationRegistrar registrar_;
131
132 ScopedObserver<CameraPresenceNotifier, ChangePictureHandler> camera_observer_; 129 ScopedObserver<CameraPresenceNotifier, ChangePictureHandler> camera_observer_;
133 130
134 DISALLOW_COPY_AND_ASSIGN(ChangePictureHandler); 131 DISALLOW_COPY_AND_ASSIGN(ChangePictureHandler);
135 }; 132 };
136 133
137 } // namespace settings 134 } // namespace settings
138 } // namespace chromeos 135 } // namespace chromeos
139 136
140 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CHANGE_PICTURE_HANDLER_H_ 137 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CHANGE_PICTURE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698