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

Unified Diff: chrome/browser/chromeos/extensions/wallpaper_private_api.cc

Issue 939233004: Fixing remote wallpaper change in multi profile cases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed reference to one more active user. Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698