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

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

Issue 2264743002: cheets: implement cros side of WallpaperManagerService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cheets: implement cros side of WallpaperManagerService. 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
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
index 238a9837e121ffe019e3e1076c9429b7ff177420..83c2faab9d57f93a38a66a8174e7707d62f4e83f 100644
--- a/chrome/browser/chromeos/arc/arc_wallpaper_handler.cc
+++ b/chrome/browser/chromeos/arc/arc_wallpaper_handler.cc
@@ -4,10 +4,13 @@
#include "chrome/browser/chromeos/arc/arc_wallpaper_handler.h"
+#include <cstdlib>
hidehiko 2016/08/22 02:30:10 Clarification: for what?
#include <string>
#include <utility>
#include <vector>
+#include "ash/desktop_background/desktop_background_controller.h"
+#include "ash/shell.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
@@ -16,7 +19,10 @@
#include "components/wallpaper/wallpaper_files_id.h"
#include "components/wallpaper/wallpaper_layout.h"
#include "content/public/browser/browser_thread.h"
+#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image_util.h"
+
using user_manager::UserManager;
@@ -67,6 +73,11 @@ ArcWallpaperHandler::~ArcWallpaperHandler() {
ImageDecoder::Cancel(this);
}
+std::shared_ptr<ArcWallpaperHandler> ArcWallpaperHandler::Get() {
+ static std::shared_ptr<ArcWallpaperHandler> instance(new ArcWallpaperHandler);
xiyuan 2016/08/19 23:04:07 We might want to use CR_DEFINE_STATIC_LOCAL or a L
Luis Héctor Chávez 2016/08/19 23:22:56 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
hidehiko 2016/08/22 02:30:10 Could you get rid of Singleton? Instead, ArcLaunch
Muyuan 2016/08/22 22:25:00 It sounds better :) thx.
+ return instance;
+}
+
void ArcWallpaperHandler::SetWallpaper(std::vector<uint8_t> jpeg_data) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// If there is an in-flight request, cancel it. It is safe to call Cancel()
@@ -76,6 +87,15 @@ void ArcWallpaperHandler::SetWallpaper(std::vector<uint8_t> jpeg_data) {
ImageDecoder::ROBUST_JPEG_CODEC, true);
}
+std::vector<uint8_t> ArcWallpaperHandler::GetWallpaper() const {
Luis Héctor Chávez 2016/08/19 23:22:56 DCHECK_CURRENTLY_ON(...); Note that we should not
Muyuan 2016/08/22 22:25:00 Done.
+ ash::DesktopBackgroundController* dbc =
+ ash::Shell::GetInstance()->desktop_background_controller();
+ gfx::Image wallpaper(dbc->GetWallpaper());
+ std::vector<uint8_t> result;
+ gfx::JPEG1xEncodedDataFromImage(wallpaper, 100, &result);
xiyuan 2016/08/19 23:04:07 What happens if there is no wallpaper and JPEG1xEn
Muyuan 2016/08/22 22:25:00 When there is no wallpaper, JPEG1xEncodedDataFromI
+ return std::move(result);
Luis Héctor Chávez 2016/08/19 23:22:56 Can you run trybots? The compiler will complain ab
Muyuan 2016/08/22 22:25:00 Acknowledged.
+}
+
void ArcWallpaperHandler::OnImageDecoded(const SkBitmap& bitmap) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
SetBitmapAsWallpaper(bitmap);

Powered by Google App Engine
This is Rietveld 408576698