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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/change_picture_options_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 (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 "base/macros.h" 8 #include "base/macros.h"
9 #include "chrome/browser/chromeos/camera_presence_notifier.h" 9 #include "chrome/browser/chromeos/camera_presence_notifier.h"
10 #include "chrome/browser/image_decoder.h" 10 #include "chrome/browser/image_decoder.h"
11 #include "chrome/browser/ui/webui/options/options_ui.h" 11 #include "chrome/browser/ui/webui/options/options_ui.h"
12 #include "content/public/browser/notification_observer.h" 12 #include "components/user_manager/user_manager.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "ui/gfx/image/image_skia.h" 13 #include "ui/gfx/image/image_skia.h"
15 #include "ui/gfx/native_widget_types.h" 14 #include "ui/gfx/native_widget_types.h"
16 #include "ui/shell_dialogs/select_file_dialog.h" 15 #include "ui/shell_dialogs/select_file_dialog.h"
17 16
18 namespace base { 17 namespace base {
19 class DictionaryValue; 18 class DictionaryValue;
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 options { 28 namespace options {
30 29
31 // ChromeOS user image options page UI handler. 30 // ChromeOS user image options page UI handler.
32 class ChangePictureOptionsHandler : public ::options::OptionsPageUIHandler, 31 class ChangePictureOptionsHandler : public ::options::OptionsPageUIHandler,
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 ChangePictureOptionsHandler(); 37 ChangePictureOptionsHandler();
39 ~ChangePictureOptionsHandler() override; 38 ~ChangePictureOptionsHandler() override;
40 39
41 // OptionsPageUIHandler implementation. 40 // OptionsPageUIHandler implementation.
42 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; 41 void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
43 42
44 // WebUIMessageHandler implementation. 43 // WebUIMessageHandler implementation.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 void HandlePageHidden(const base::ListValue* args); 95 void HandlePageHidden(const base::ListValue* args);
97 96
98 // Selects one of the available images as user's. 97 // Selects one of the available images as user's.
99 void HandleSelectImage(const base::ListValue* args); 98 void HandleSelectImage(const base::ListValue* args);
100 99
101 // SelectFileDialog::Delegate implementation. 100 // SelectFileDialog::Delegate implementation.
102 void FileSelected(const base::FilePath& path, 101 void FileSelected(const base::FilePath& path,
103 int index, 102 int index,
104 void* params) override; 103 void* params) override;
105 104
106 // content::NotificationObserver implementation. 105 // user_manager::UserManager::Observer implementation.
107 void Observe(int type, 106 void OnUserImageChanged(const user_manager::User& user) override;
108 const content::NotificationSource& source, 107 void OnUserProfileImageUpdated(const user_manager::User& user,
109 const content::NotificationDetails& details) override; 108 const gfx::ImageSkia& profile_image) override;
110 109
111 // Sets user image to photo taken from camera. 110 // Sets user image to photo taken from camera.
112 void SetImageFromCamera(const gfx::ImageSkia& photo); 111 void SetImageFromCamera(const gfx::ImageSkia& photo);
113 112
114 // 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.
115 gfx::NativeWindow GetBrowserWindow() const; 114 gfx::NativeWindow GetBrowserWindow() const;
116 115
117 // Overriden from ImageDecoder::ImageRequest: 116 // Overriden from ImageDecoder::ImageRequest:
118 void OnImageDecoded(const SkBitmap& decoded_image) override; 117 void OnImageDecoded(const SkBitmap& decoded_image) override;
119 void OnDecodeImageFailed() override; 118 void OnDecodeImageFailed() override;
(...skipping 10 matching lines...) Expand all
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_;
141
142 DISALLOW_COPY_AND_ASSIGN(ChangePictureOptionsHandler); 139 DISALLOW_COPY_AND_ASSIGN(ChangePictureOptionsHandler);
143 }; 140 };
144 141
145 } // namespace options 142 } // namespace options
146 } // namespace chromeos 143 } // namespace chromeos
147 144
148 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDL ER_H_ 145 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CHANGE_PICTURE_OPTIONS_HANDL ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698