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

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h

Issue 2572793003: [Chrome OS] Implement the device wallpaper policy. (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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/public/interfaces/wallpaper.mojom.h" 12 #include "ash/public/interfaces/wallpaper.mojom.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted_memory.h" 14 #include "base/memory/ref_counted_memory.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/chromeos/customization/customization_wallpaper_download er.h"
16 #include "chrome/browser/chromeos/settings/cros_settings.h" 17 #include "chrome/browser/chromeos/settings/cros_settings.h"
17 #include "components/user_manager/user.h" 18 #include "components/user_manager/user.h"
18 #include "components/user_manager/user_image/user_image.h" 19 #include "components/user_manager/user_image/user_image.h"
19 #include "components/user_manager/user_manager.h" 20 #include "components/user_manager/user_manager.h"
20 #include "components/wallpaper/wallpaper_layout.h" 21 #include "components/wallpaper/wallpaper_layout.h"
21 #include "components/wallpaper/wallpaper_manager_base.h" 22 #include "components/wallpaper/wallpaper_manager_base.h"
22 #include "content/public/browser/notification_observer.h" 23 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_registrar.h" 24 #include "content/public/browser/notification_registrar.h"
24 #include "mojo/public/cpp/bindings/binding.h" 25 #include "mojo/public/cpp/bindings/binding.h"
25 #include "ui/gfx/image/image_skia.h" 26 #include "ui/gfx/image/image_skia.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void ScheduleSetUserWallpaper(const AccountId& account_id, 75 void ScheduleSetUserWallpaper(const AccountId& account_id,
75 bool delayed) override; 76 bool delayed) override;
76 void SetWallpaperFromImageSkia(const AccountId& account_id, 77 void SetWallpaperFromImageSkia(const AccountId& account_id,
77 const gfx::ImageSkia& image, 78 const gfx::ImageSkia& image,
78 wallpaper::WallpaperLayout layout, 79 wallpaper::WallpaperLayout layout,
79 bool update_wallpaper) override; 80 bool update_wallpaper) override;
80 void UpdateWallpaper(bool clear_cache) override; 81 void UpdateWallpaper(bool clear_cache) override;
81 size_t GetPendingListSizeForTesting() const override; 82 size_t GetPendingListSizeForTesting() const override;
82 wallpaper::WallpaperFilesId GetFilesId( 83 wallpaper::WallpaperFilesId GetFilesId(
83 const AccountId& account_id) const override; 84 const AccountId& account_id) const override;
85 bool SetDeviceWallpaperIfApplicable(const AccountId& account_id) override;
84 86
85 // ash::mojom::WallpaperPicker: 87 // ash::mojom::WallpaperPicker:
86 void Open() override; 88 void Open() override;
87 89
88 // content::NotificationObserver: 90 // content::NotificationObserver:
89 void Observe(int type, 91 void Observe(int type,
90 const content::NotificationSource& source, 92 const content::NotificationSource& source,
91 const content::NotificationDetails& details) override; 93 const content::NotificationDetails& details) override;
92 94
93 // user_manager::UserManager::UserSessionStateObserver: 95 // user_manager::UserManager::UserSessionStateObserver:
(...skipping 14 matching lines...) Expand all
108 110
109 // This is called by PendingWallpaper when load is finished. 111 // This is called by PendingWallpaper when load is finished.
110 void RemovePendingWallpaperFromList(PendingWallpaper* pending); 112 void RemovePendingWallpaperFromList(PendingWallpaper* pending);
111 113
112 // Set wallpaper to |user_image| controlled by policy. (Takes a UserImage 114 // Set wallpaper to |user_image| controlled by policy. (Takes a UserImage
113 // because that's the callback interface provided by UserImageLoader.) 115 // because that's the callback interface provided by UserImageLoader.)
114 void SetPolicyControlledWallpaper( 116 void SetPolicyControlledWallpaper(
115 const AccountId& account_id, 117 const AccountId& account_id,
116 std::unique_ptr<user_manager::UserImage> user_image); 118 std::unique_ptr<user_manager::UserImage> user_image);
117 119
120 // This is called when the device wallpaper policy changes.
121 void OnDeviceWallpaperPolicyChanged();
122 // This is call after checking if the device wallpaper exists.
123 void OnDeviceWallpaperExists(const AccountId& account_id,
124 const std::string& url,
125 const std::string& hash,
126 bool exist);
127 // This is called after the device wallpaper is download (either successful or
128 // failed).
129 void OnDeviceWallpaperDownloaded(const AccountId& account_id,
130 const std::string& hash,
131 bool success,
132 const GURL& url);
133 // Check if the device wallpaper matches the hash that's provided in the
134 // device wallpaper policy setting.
135 void OnCheckDeviceWallpaperMatchHash(const AccountId& account_id,
136 const std::string& url,
137 const std::string& hash,
138 bool match);
139 // This is called when the device wallpaper is decoded successfully.
140 void OnDeviceWallpaperDecoded(
141 const AccountId& account_id,
142 std::unique_ptr<user_manager::UserImage> user_image);
143
118 // wallpaper::WallpaperManagerBase: 144 // wallpaper::WallpaperManagerBase:
119 void InitializeRegisteredDeviceWallpaper() override; 145 void InitializeRegisteredDeviceWallpaper() override;
120 bool GetUserWallpaperInfo(const AccountId& account_id, 146 bool GetUserWallpaperInfo(const AccountId& account_id,
121 wallpaper::WallpaperInfo* info) const override; 147 wallpaper::WallpaperInfo* info) const override;
148 // Returns true if the device wallpaper should be set for the account.
149 bool ShouldSetDeviceWallpaper(const AccountId& account_id,
150 std::string* url,
151 std::string* hash) override;
152 base::FilePath GetDeviceWallpaperDir() override;
153 base::FilePath GetDeviceWallpaperFilePath() override;
122 void OnWallpaperDecoded( 154 void OnWallpaperDecoded(
123 const AccountId& account_id, 155 const AccountId& account_id,
124 wallpaper::WallpaperLayout layout, 156 wallpaper::WallpaperLayout layout,
125 bool update_wallpaper, 157 bool update_wallpaper,
126 wallpaper::MovableOnDestroyCallbackHolder on_finish, 158 wallpaper::MovableOnDestroyCallbackHolder on_finish,
127 std::unique_ptr<user_manager::UserImage> user_image) override; 159 std::unique_ptr<user_manager::UserImage> user_image) override;
128 void StartLoad(const AccountId& account_id, 160 void StartLoad(const AccountId& account_id,
129 const wallpaper::WallpaperInfo& info, 161 const wallpaper::WallpaperInfo& info,
130 bool update_wallpaper, 162 bool update_wallpaper,
131 const base::FilePath& wallpaper_path, 163 const base::FilePath& wallpaper_path,
(...skipping 26 matching lines...) Expand all
158 const base::FilePath& customized_default_wallpaper_file_small, 190 const base::FilePath& customized_default_wallpaper_file_small,
159 std::unique_ptr<gfx::ImageSkia> small_wallpaper_image, 191 std::unique_ptr<gfx::ImageSkia> small_wallpaper_image,
160 const base::FilePath& customized_default_wallpaper_file_large, 192 const base::FilePath& customized_default_wallpaper_file_large,
161 std::unique_ptr<gfx::ImageSkia> large_wallpaper_image) override; 193 std::unique_ptr<gfx::ImageSkia> large_wallpaper_image) override;
162 194
163 mojo::Binding<ash::mojom::WallpaperPicker> binding_; 195 mojo::Binding<ash::mojom::WallpaperPicker> binding_;
164 196
165 std::unique_ptr<CrosSettings::ObserverSubscription> 197 std::unique_ptr<CrosSettings::ObserverSubscription>
166 show_user_name_on_signin_subscription_; 198 show_user_name_on_signin_subscription_;
167 199
200 std::unique_ptr<CrosSettings::ObserverSubscription>
201 device_wallpaper_image_subscription_;
202 std::unique_ptr<CustomizationWallpaperDownloader>
203 device_wallpaper_downloader_;
204 bool retry_download_if_failed_ = true;
205
168 // Pointer to last inactive (waiting) entry of 'loading_' list. 206 // Pointer to last inactive (waiting) entry of 'loading_' list.
169 // NULL when there is no inactive request. 207 // NULL when there is no inactive request.
170 PendingWallpaper* pending_inactive_; 208 PendingWallpaper* pending_inactive_;
171 209
172 // Owns PendingWallpaper. 210 // Owns PendingWallpaper.
173 // PendingWallpaper deletes itself from here on load complete. 211 // PendingWallpaper deletes itself from here on load complete.
174 // All pending will be finally deleted on destroy. 212 // All pending will be finally deleted on destroy.
175 typedef std::vector<scoped_refptr<PendingWallpaper>> PendingList; 213 typedef std::vector<scoped_refptr<PendingWallpaper>> PendingList;
176 PendingList loading_; 214 PendingList loading_;
177 215
178 content::NotificationRegistrar registrar_; 216 content::NotificationRegistrar registrar_;
179 217
180 base::WeakPtrFactory<WallpaperManager> weak_factory_; 218 base::WeakPtrFactory<WallpaperManager> weak_factory_;
181 219
182 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 220 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
183 }; 221 };
184 222
185 } // namespace chromeos 223 } // namespace chromeos
186 224
187 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ 225 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698