Chromium Code Reviews| 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..2e6f2e3abd7b25e9a245a91386365ccbf43c4b07 |
| --- /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: Allow specifying layout. |
|
hidehiko
2016/06/14 13:44:16
TODO(nya) or TODO(bug-id)
Shuhei Takahashi
2016/06/14 14:08:39
Done.
|
| + wallpaper_manager->SetCustomWallpaper( |
| + account_id, wallpaper_files_id, kAndroidWallpaperFilename, |
| + wallpaper::WALLPAPER_LAYOUT_STRETCH, user_manager::User::CUSTOMIZED, |
| + image, update_wallpaper); |
| + |
| + // TODO: 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 |