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

Unified Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc

Issue 1984433002: Hook up Chrome's wallpaper picker for mash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp builds; address Sadrul's comment. Created 4 years, 7 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/login/users/wallpaper/wallpaper_manager.cc
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
index eac4ab8f45341ff25769a07253a02f001113e7dc..8598098331e879ac52ba09e3de43f74d3230ae7f 100644
--- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
+++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
@@ -36,6 +36,7 @@
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
+#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -57,11 +58,18 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/common/content_switches.h"
+#include "content/public/common/mojo_shell_connection.h"
+#include "services/shell/public/cpp/connector.h"
+#include "skia/public/type_converters.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/codec/jpeg_codec.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/skia_util.h"
+#if defined(MOJO_SHELL_CLIENT)
+#include "mash/public/interfaces/wallpaper.mojom.h"
+#endif
+
using content::BrowserThread;
using wallpaper::WallpaperManagerBase;
using wallpaper::WallpaperInfo;
@@ -172,6 +180,25 @@ void SetKnownUserWallpaperFilesId(
wallpaper_files_id.id());
}
+// A helper to set the wallpaper image for Ash and Mash.
+void SetWallpaper(const gfx::ImageSkia& image,
+ wallpaper::WallpaperLayout layout) {
+#if defined(MOJO_SHELL_CLIENT)
+ if (chrome::IsRunningInMash()) {
+ shell::Connector* connector =
+ content::MojoShellConnection::Get()->GetConnector();
+ mash::mojom::WallpaperControllerPtr wallpaper_controller;
+ connector->ConnectToInterface("mojo:ash_sysui", &wallpaper_controller);
+ wallpaper_controller->SetWallpaper(
+ skia::mojom::Bitmap::From(*image.bitmap()),
+ static_cast<int32_t>(layout));
+ return;
+ }
+#endif
+ ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage(
James Cook 2016/05/19 22:30:00 Do you need to do this in the mash case? In partic
msw 2016/05/20 19:53:05 Perhaps you missed the early return on line 195, o
James Cook 2016/05/20 20:47:13 Yeah, I missed the early return. I think it's wor
msw 2016/05/20 21:31:48 Done. I filed http://crbug.com/613707
+ image, layout);
+}
+
} // namespace
// This is "wallpaper either scheduled to load, or loading right now".
@@ -202,8 +229,7 @@ class WallpaperManager::PendingWallpaper :
// There are 4 cases in SetUserWallpaper:
// 1) gfx::ImageSkia is found in cache.
// - Schedule task to (probably) resize it and install:
- // call ash::Shell::GetInstance()->desktop_background_controller()->
- // SetCustomWallpaper(user_wallpaper, layout);
+ // call SetWallpaper(user_wallpaper, layout);
// 2) WallpaperInfo is found in cache
// - need to LoadWallpaper(), resize and install.
// 3) wallpaper path is not NULL, load image URL, then resize, etc...
@@ -257,9 +283,7 @@ class WallpaperManager::PendingWallpaper :
if (default_) {
manager->DoSetDefaultWallpaper(account_id_, std::move(on_finish_));
} else if (!user_wallpaper_.isNull()) {
- ash::Shell::GetInstance()
- ->desktop_background_controller()
- ->SetWallpaperImage(user_wallpaper_, info_.layout);
+ SetWallpaper(user_wallpaper_, info_.layout);
} else if (!wallpaper_path_.empty()) {
manager->task_runner_->PostTask(
FROM_HERE,
@@ -598,11 +622,6 @@ void WallpaperManager::DoSetDefaultWallpaper(
if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp())
return;
wallpaper_cache_.erase(account_id);
- // Some browser tests do not have a shell instance. As no wallpaper is needed
James Cook 2016/05/19 22:30:00 Maybe this should be unit tests? It looks like som
msw 2016/05/20 19:53:05 Done; added GetMaxDisplaySizeInNative and SetWallp
- // in these tests anyway, avoid loading one, preventing crashes and speeding
- // up the tests.
- if (!ash::Shell::HasInstance())
- return;
WallpaperResolution resolution = GetAppropriateResolution();
const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL);
@@ -643,8 +662,7 @@ void WallpaperManager::DoSetDefaultWallpaper(
default_wallpaper_image_->image().height() == 1)
layout = wallpaper::WALLPAPER_LAYOUT_STRETCH;
- ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage(
- default_wallpaper_image_->image(), layout);
+ SetWallpaper(default_wallpaper_image_->image(), layout);
}
void WallpaperManager::SetUserWallpaperInfo(const AccountId& account_id,
@@ -959,11 +977,8 @@ void WallpaperManager::OnWallpaperDecoded(
// Update the image, but keep the path which was set earlier.
wallpaper_cache_[account_id].second = user_image->image();
- if (update_wallpaper) {
- ash::Shell::GetInstance()
- ->desktop_background_controller()
- ->SetWallpaperImage(user_image->image(), layout);
- }
+ if (update_wallpaper)
+ SetWallpaper(user_image->image(), layout);
}
void WallpaperManager::StartLoad(const AccountId& account_id,
@@ -1068,8 +1083,7 @@ void WallpaperManager::OnDefaultWallpaperDecoded(
MovableOnDestroyCallbackHolder on_finish,
std::unique_ptr<user_manager::UserImage> user_image) {
*result_out = std::move(user_image);
- ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage(
- (*result_out)->image(), layout);
+ SetWallpaper((*result_out)->image(), layout);
}
void WallpaperManager::StartLoadAndSetDefaultWallpaper(

Powered by Google App Engine
This is Rietveld 408576698