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

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

Issue 1878943007: Support multiprofile mode in WallpaperAPI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 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_api.cc
diff --git a/chrome/browser/chromeos/extensions/wallpaper_api.cc b/chrome/browser/chromeos/extensions/wallpaper_api.cc
index c08a9be2fdf8beed7af57fb9ac1ec53bc33ca24a..0c7fe14abe744b3dccf1e135d1a6f36cd0ef9569 100644
--- a/chrome/browser/chromeos/extensions/wallpaper_api.cc
+++ b/chrome/browser/chromeos/extensions/wallpaper_api.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/extensions/wallpaper_private_api.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/common/chrome_paths.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -93,6 +94,18 @@ class WallpaperFetcher : public net::URLFetcherDelegate {
base::LazyInstance<WallpaperFetcher> g_wallpaper_fetcher =
LAZY_INSTANCE_INITIALIZER;
+// 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;
+}
+
} // namespace
WallpaperSetWallpaperFunction::WallpaperSetWallpaperFunction() {
@@ -106,9 +119,8 @@ bool WallpaperSetWallpaperFunction::RunAsync() {
params_ = set_wallpaper::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_);
- // Gets account id and user wallpaper files id while at UI thread.
- const user_manager::User* user =
- user_manager::UserManager::Get()->GetLoggedInUser();
+ // Gets account id from the caller, ensuring multiprofile compatibility.
+ const user_manager::User* user = GetUserFromBrowserContext(browser_context());
account_id_ = user->GetAccountId();
chromeos::WallpaperManager* wallpaper_manager =
chromeos::WallpaperManager::Get();
« 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