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

Unified Diff: ash/common/wallpaper/wallpaper_controller.cc

Issue 2413503002: Cleanup mojo Wallpaper interfaces for mash. (Closed)
Patch Set: Cleanup. Created 4 years, 2 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: ash/common/wallpaper/wallpaper_controller.cc
diff --git a/ash/common/wallpaper/wallpaper_controller.cc b/ash/common/wallpaper/wallpaper_controller.cc
index 76864c6e04b3de1c6a3b1327fbf7f783a713ca59..6757c598869718845e81a1fe6f94f9e0717d5404 100644
--- a/ash/common/wallpaper/wallpaper_controller.cc
+++ b/ash/common/wallpaper/wallpaper_controller.cc
@@ -4,6 +4,7 @@
#include "ash/common/wallpaper/wallpaper_controller.h"
+#include "ash/common/shell_delegate.h"
#include "ash/common/shell_window_ids.h"
#include "ash/common/wallpaper/wallpaper_controller_observer.h"
#include "ash/common/wallpaper/wallpaper_delegate.h"
@@ -16,6 +17,7 @@
#include "base/logging.h"
#include "base/task_runner.h"
#include "components/wallpaper/wallpaper_resizer.h"
+#include "services/shell/public/cpp/connector.h"
#include "ui/display/manager/managed_display_info.h"
#include "ui/display/screen.h"
#include "ui/views/widget/widget.h"
@@ -26,6 +28,23 @@ namespace {
// How long to wait reloading the wallpaper after the display size has changed.
const int kWallpaperReloadDelayMs = 100;
+// TODO(msw): Use enum traits instead.
+wallpaper::WallpaperLayout WallpaperLayoutFromMojo(
+ ash::mojom::WallpaperLayout layout) {
+ switch (layout) {
+ case ash::mojom::WallpaperLayout::CENTER:
James Cook 2016/10/11 23:21:49 nit: ash:: not needed?
msw 2016/10/14 21:07:43 Done.
+ return wallpaper::WALLPAPER_LAYOUT_CENTER;
+ case ash::mojom::WallpaperLayout::CENTER_CROPPED:
+ return wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED;
+ case ash::mojom::WallpaperLayout::STRETCH:
+ return wallpaper::WALLPAPER_LAYOUT_STRETCH;
+ case ash::mojom::WallpaperLayout::TILE:
+ return wallpaper::WALLPAPER_LAYOUT_TILE;
+ }
+ NOTREACHED();
+ return wallpaper::WALLPAPER_LAYOUT_CENTER;
+}
+
} // namespace
WallpaperController::WallpaperController(
@@ -43,6 +62,11 @@ WallpaperController::~WallpaperController() {
WmShell::Get()->RemoveShellObserver(this);
}
+void WallpaperController::BindRequest(
+ mojom::WallpaperControllerRequest request) {
+ bindings_.AddBinding(this, std::move(request));
+}
+
gfx::ImageSkia WallpaperController::GetWallpaper() const {
if (current_wallpaper_)
return current_wallpaper_->image();
@@ -182,6 +206,26 @@ bool WallpaperController::WallpaperIsAlreadyLoaded(
current_wallpaper_->original_image_id();
}
+void WallpaperController::OpenSetWallpaperPage() {
+ auto shell = WmShell::Get();
James Cook 2016/10/11 23:21:49 nit: I think WmShell* is better than auto here. Th
msw 2016/10/14 21:07:43 Done.
+ auto connector = shell->delegate()->GetShellConnector();
James Cook 2016/10/11 23:21:49 This one might be worth it for wrapping, but also
msw 2016/10/14 21:07:43 Done.
+ if (!connector || !shell->wallpaper_delegate()->CanOpenSetWallpaperPage())
+ return;
+
+ mojom::WallpaperManagerPtr wallpaper_manager;
+ connector->ConnectToInterface("service:content_browser", &wallpaper_manager);
+ wallpaper_manager->Open();
+}
+
+void WallpaperController::SetWallpaper(const SkBitmap& wallpaper,
+ mojom::WallpaperLayout layout) {
+ if (wallpaper.isNull())
+ return;
+
+ gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(wallpaper);
+ SetWallpaperImage(image, WallpaperLayoutFromMojo(layout));
+}
+
void WallpaperController::InstallDesktopController(WmWindow* root_window) {
WallpaperWidgetController* component = nullptr;
int container_id = GetWallpaperContainerId(locked_);

Powered by Google App Engine
This is Rietveld 408576698