| Index: chrome/browser/chromeos/extensions/wallpaper_private_api.cc
|
| diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
|
| index 289c38a5425a6a8c2c211197845834c16d4b14b6..d4983fe60acf9ca1dc046618d3bc2e7c6c96df5e 100644
|
| --- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
|
| +++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
|
| @@ -26,6 +26,7 @@
|
| #include "base/threading/worker_pool.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
|
| +#include "chrome/browser/chromeos/profiles/profile_helper.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/sync/profile_sync_service.h"
|
| #include "chrome/browser/sync/profile_sync_service_factory.h"
|
| @@ -101,6 +102,18 @@ bool GetData(const base::FilePath& path, std::string* data) {
|
| base::ReadFileToString(path, data);
|
| }
|
|
|
| +// Gets the |User| for a given |BrowserContext|. The function will only return
|
| +// valid objects.
|
| +const user_manager::User* GetUserFromBrowserContext(
|
| + content::BrowserContext* context) {
|
| + Profile* profile = Profile::FromBrowserContext(context);
|
| + DCHECK(profile);
|
| + const user_manager::User* user =
|
| + chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
|
| + DCHECK(user);
|
| + return user;
|
| +}
|
| +
|
| // WindowStateManager remembers which windows have been minimized in order to
|
| // restore them when the wallpaper viewer is hidden.
|
| class WindowStateManager : public aura::WindowObserver {
|
| @@ -323,7 +336,9 @@ bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() {
|
| params = set_wallpaper_if_exists::Params::Create(*args_);
|
| EXTENSION_FUNCTION_VALIDATE(params);
|
|
|
| - user_id_ = user_manager::UserManager::Get()->GetActiveUser()->email();
|
| + // Gets email address from caller, ensuring multiprofile compatibility.
|
| + const user_manager::User* user = GetUserFromBrowserContext(browser_context());
|
| + user_id_ = user->email();
|
|
|
| base::FilePath wallpaper_path;
|
| base::FilePath fallback_path;
|
| @@ -432,8 +447,9 @@ bool WallpaperPrivateSetWallpaperFunction::RunAsync() {
|
| params = set_wallpaper::Params::Create(*args_);
|
| EXTENSION_FUNCTION_VALIDATE(params);
|
|
|
| - // Gets email address while at UI thread.
|
| - user_id_ = user_manager::UserManager::Get()->GetActiveUser()->email();
|
| + // Gets email address from caller, ensuring multiprofile compatibility.
|
| + const user_manager::User* user = GetUserFromBrowserContext(browser_context());
|
| + user_id_ = user->email();
|
|
|
| StartDecode(params->wallpaper);
|
|
|
| @@ -567,10 +583,10 @@ bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() {
|
| params = set_custom_wallpaper::Params::Create(*args_);
|
| EXTENSION_FUNCTION_VALIDATE(params);
|
|
|
| - // Gets email address and username hash while at UI thread.
|
| - user_id_ = user_manager::UserManager::Get()->GetActiveUser()->email();
|
| - user_id_hash_ =
|
| - user_manager::UserManager::Get()->GetActiveUser()->username_hash();
|
| + // Gets email address from caller, ensuring multiprofile compatibility.
|
| + const user_manager::User* user = GetUserFromBrowserContext(browser_context());
|
| + user_id_ = user->email();
|
| + user_id_hash_ = user->username_hash();
|
|
|
| StartDecode(params->wallpaper);
|
|
|
|
|