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

Unified Diff: chrome/browser/chromeos/arc/arc_wallpaper_handler.cc

Issue 2061183002: arc: IPC method to set custom wallpaper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add next IDs. Created 4 years, 6 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
Index: chrome/browser/chromeos/arc/arc_wallpaper_handler.cc
diff --git a/chrome/browser/chromeos/arc/arc_wallpaper_handler.cc b/chrome/browser/chromeos/arc/arc_wallpaper_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..334f283648783169dd3d3836cff64a21380f27e8
--- /dev/null
+++ b/chrome/browser/chromeos/arc/arc_wallpaper_handler.cc
@@ -0,0 +1,48 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/arc/arc_wallpaper_handler.h"
+
+#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
+#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/user_manager.h"
+#include "components/wallpaper/wallpaper_files_id.h"
+#include "components/wallpaper/wallpaper_layout.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace arc {
+
+namespace {
+
+const char kAndroidWallpaperFilename[] = "android.jpg";
Yusuke Sato 2016/06/15 16:45:01 nit: constexpr seems to be the new preferred way.
Shuhei Takahashi 2016/06/15 18:14:37 Done.
+
+} // namespace
+
+void ArcWallpaperHandler::SetWallpaper(const gfx::ImageSkia& image) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ chromeos::WallpaperManager* wallpaper_manager =
+ chromeos::WallpaperManager::Get();
+
+ const AccountId& account_id =
+ user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId();
+ wallpaper::WallpaperFilesId wallpaper_files_id =
+ wallpaper_manager->GetFilesId(account_id);
+ bool update_wallpaper =
+ account_id ==
+ user_manager::UserManager::Get()->GetActiveUser()->GetAccountId();
+ // TODO(crbug.com/618922): Allow specifying layout.
+ wallpaper_manager->SetCustomWallpaper(
+ account_id, wallpaper_files_id, kAndroidWallpaperFilename,
+ wallpaper::WALLPAPER_LAYOUT_STRETCH, user_manager::User::CUSTOMIZED,
+ image, update_wallpaper);
+
+ // TODO(crbug.com/618922): Register the wallpaper to Chrome OS wallpaper
+ // picker. Currently the new wallpaper does not appear there. The best way to
+ // make this happen seems to refactor thumbnail generation logic in
+ // wallpaper_api.cc and wallpaper_private_api.cc into WallpaperManager, but
+ // it might be quite a lot of work.
xdai1 2016/06/15 16:30:14 That won't work. What you need to do is save the w
Shuhei Takahashi 2016/06/15 18:14:37 Thanks, updated the comment accordingly.
+}
+
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698