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

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..b32c4c7ad90469639ad8614a994dee60982ee57f 100644
--- a/chrome/browser/chromeos/arc/arc_wallpaper_handler.cc
+++ b/chrome/browser/chromeos/arc/arc_wallpaper_handler.cc
@@ -8,6 +8,9 @@
#include <utility>
#include <vector>
+#include "ash/desktop_background/desktop_background_controller.h"
+#include "ash/shell.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
@@ -16,7 +19,9 @@
#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;
@@ -56,6 +61,14 @@ void SetBitmapAsWallpaper(const SkBitmap& bitmap) {
// wallpaper_private_api.cc.
}
+void EncodeImageJPEG(
+ const gfx::Image image,
+ const base::Callback<void(std::vector<uint8_t> result)>& callback) {
+ std::vector<uint8_t> result;
+ gfx::JPEG1xEncodedDataFromImage(image, 100, &result);
+ callback.Run(result);
Shuhei Takahashi 2016/08/23 09:34:21 We must invoke |callback| on UI thread. Please use
Muyuan 2016/08/23 19:45:49 Acknowledged.
+}
+
} // namespace
ArcWallpaperHandler::ArcWallpaperHandler() = default;
@@ -76,6 +89,17 @@ void ArcWallpaperHandler::SetWallpaper(std::vector<uint8_t> jpeg_data) {
ImageDecoder::ROBUST_JPEG_CODEC, true);
}
+void ArcWallpaperHandler::GetWallpaper(
+ const base::Callback<void(std::vector<uint8_t> image)>& callback) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ ash::DesktopBackgroundController* dbc =
+ ash::Shell::GetInstance()->desktop_background_controller();
+ gfx::Image wallpaper(dbc->GetWallpaper());
Shuhei Takahashi 2016/08/23 09:34:21 I know gfx::JPEG1xEncodedDataFromImage() actually
Muyuan 2016/08/23 19:45:49 DesktopBackgroundController::GetWallpaper() will r
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
xiyuan 2016/08/22 22:49:41 IO thread is for network IO etc. Maybe do the job
Muyuan 2016/08/22 23:48:19 Acknowledged.
Shuhei Takahashi 2016/08/23 09:34:21 As xiyuan said, please avoid doing CPU-intensive t
Muyuan 2016/08/23 19:45:49 Acknowledged.
+ base::Bind(&EncodeImageJPEG, wallpaper, callback));
+}
+
void ArcWallpaperHandler::OnImageDecoded(const SkBitmap& bitmap) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
SetBitmapAsWallpaper(bitmap);

Powered by Google App Engine
This is Rietveld 408576698