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

Unified Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc

Issue 2220433002: ChromeOS: fix crash in HashWallpaperFilesIdStr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AddOnSystemSaltReady() should immediately run callback if system salt is ready. Created 4 years, 4 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 | chromeos/cryptohome/system_salt_getter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
index 44b02c8385a3fe081bc879507df4d73c1bfd4355..06ac0f5e9d82322f438961677ae6ae8be3a4df74 100644
--- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
+++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
@@ -15,6 +15,7 @@
#include "ash/shell.h"
#include "ash/sysui/public/interfaces/wallpaper.mojom.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
@@ -170,6 +171,16 @@ wallpaper::WallpaperFilesId HashWallpaperFilesIdStr(
return wallpaper::WallpaperFilesId::FromString(result);
}
+// Returns true if HashWallpaperFilesIdStr will not assert().
+bool CanGetFilesId() {
+ return SystemSaltGetter::Get()->GetRawSalt();
+}
+
+// Call |closure| when HashWallpaperFilesIdStr will not assert().
+void CallWhenCanGetFilesId(const base::Closure& closure) {
+ SystemSaltGetter::Get()->AddOnSystemSaltReady(closure);
+}
+
void SetKnownUserWallpaperFilesId(
const AccountId& account_id,
const wallpaper::WallpaperFilesId& wallpaper_files_id) {
@@ -881,6 +892,14 @@ void WallpaperManager::RemovePendingWallpaperFromList(
void WallpaperManager::SetPolicyControlledWallpaper(
const AccountId& account_id,
std::unique_ptr<user_manager::UserImage> user_image) {
+ if (!CanGetFilesId()) {
+ CallWhenCanGetFilesId(
+ base::Bind(&WallpaperManager::SetPolicyControlledWallpaper,
+ weak_factory_.GetWeakPtr(), account_id,
+ base::Passed(std::move(user_image))));
+ return;
+ }
+
const wallpaper::WallpaperFilesId wallpaper_files_id = GetFilesId(account_id);
if (!wallpaper_files_id.is_valid())
« no previous file with comments | « no previous file | chromeos/cryptohome/system_salt_getter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698