| 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";
|
| +
|
| +} // 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.
|
| +}
|
| +
|
| +} // namespace arc
|
|
|