Commit 0b7b15ba authored by muyuanli's avatar muyuanli Committed by Commit bot

cheets: deprecate setWallpaper from ArcIntentHelper.

This CL deprecates setWallpaper call in intent_helper.mojom.

It also removes set_wallpaper_delegate.h since it's no
longer needed.

This is going to be committed only after ag/1432663/ enters
canary.

Test=Manually test setting wallpaper with OGQ Backgrounds
  app in Arc++.

Bug=642465

Review-Url: https://codereview.chromium.org/2332063004
Cr-Commit-Position: refs/heads/master@{#419015}
parent 824ff459
...@@ -74,8 +74,6 @@ std::vector<uint8_t> EncodeImagePng(const gfx::ImageSkia image) { ...@@ -74,8 +74,6 @@ std::vector<uint8_t> EncodeImagePng(const gfx::ImageSkia image) {
ArcWallpaperService::ArcWallpaperService(ArcBridgeService* bridge_service) ArcWallpaperService::ArcWallpaperService(ArcBridgeService* bridge_service)
: ArcService(bridge_service), binding_(this) { : ArcService(bridge_service), binding_(this) {
arc_bridge_service()->wallpaper()->AddObserver(this); arc_bridge_service()->wallpaper()->AddObserver(this);
DCHECK(!ArcWallpaperService::instance());
ArcWallpaperService::set_instance(this);
} }
ArcWallpaperService::~ArcWallpaperService() { ArcWallpaperService::~ArcWallpaperService() {
...@@ -84,8 +82,6 @@ ArcWallpaperService::~ArcWallpaperService() { ...@@ -84,8 +82,6 @@ ArcWallpaperService::~ArcWallpaperService() {
// call Cancel() even when there is no in-flight request. // call Cancel() even when there is no in-flight request.
ImageDecoder::Cancel(this); ImageDecoder::Cancel(this);
arc_bridge_service()->wallpaper()->RemoveObserver(this); arc_bridge_service()->wallpaper()->RemoveObserver(this);
DCHECK(ArcWallpaperService::instance() == this);
ArcWallpaperService::set_instance(nullptr);
} }
void ArcWallpaperService::OnInstanceReady() { void ArcWallpaperService::OnInstanceReady() {
...@@ -116,16 +112,6 @@ void ArcWallpaperService::GetWallpaper(const GetWallpaperCallback& callback) { ...@@ -116,16 +112,6 @@ void ArcWallpaperService::GetWallpaper(const GetWallpaperCallback& callback) {
base::Bind(&EncodeImagePng, wallpaper), callback); base::Bind(&EncodeImagePng, wallpaper), callback);
} }
void ArcWallpaperService::SetWallpaperJpeg(
const 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()
// even when there is no in-flight request.
ImageDecoder::Cancel(this);
ImageDecoder::StartWithOptions(this, std::move(jpeg_data),
ImageDecoder::ROBUST_JPEG_CODEC, true);
}
void ArcWallpaperService::OnImageDecoded(const SkBitmap& bitmap) { void ArcWallpaperService::OnImageDecoded(const SkBitmap& bitmap) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
SetBitmapAsWallpaper(bitmap); SetBitmapAsWallpaper(bitmap);
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "components/arc/arc_service.h" #include "components/arc/arc_service.h"
#include "components/arc/common/wallpaper.mojom.h" #include "components/arc/common/wallpaper.mojom.h"
#include "components/arc/instance_holder.h" #include "components/arc/instance_holder.h"
#include "components/arc/set_wallpaper_delegate.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
class SkBitmap; class SkBitmap;
...@@ -26,7 +25,6 @@ namespace arc { ...@@ -26,7 +25,6 @@ namespace arc {
// Lives on the UI thread. // Lives on the UI thread.
class ArcWallpaperService class ArcWallpaperService
: public ArcService, : public ArcService,
public SetWallpaperDelegate,
public ImageDecoder::ImageRequest, public ImageDecoder::ImageRequest,
public InstanceHolder<mojom::WallpaperInstance>::Observer, public InstanceHolder<mojom::WallpaperInstance>::Observer,
public mojom::WallpaperHost { public mojom::WallpaperHost {
...@@ -43,8 +41,6 @@ class ArcWallpaperService ...@@ -43,8 +41,6 @@ class ArcWallpaperService
void SetWallpaper(mojo::Array<uint8_t> png_data) override; void SetWallpaper(mojo::Array<uint8_t> png_data) override;
void GetWallpaper(const GetWallpaperCallback& callback) override; void GetWallpaper(const GetWallpaperCallback& callback) override;
// SetWallpaperDelegate implementation.
void SetWallpaperJpeg(const std::vector<uint8_t>& jpeg_data) override;
// ImageDecoder::ImageRequest implementation. // ImageDecoder::ImageRequest implementation.
void OnImageDecoded(const SkBitmap& bitmap) override; void OnImageDecoded(const SkBitmap& bitmap) override;
void OnDecodeImageFailed() override; void OnDecodeImageFailed() override;
......
...@@ -57,7 +57,6 @@ static_library("arc") { ...@@ -57,7 +57,6 @@ static_library("arc") {
"obb_mounter/arc_obb_mounter_bridge.h", "obb_mounter/arc_obb_mounter_bridge.h",
"power/arc_power_bridge.cc", "power/arc_power_bridge.cc",
"power/arc_power_bridge.h", "power/arc_power_bridge.h",
"set_wallpaper_delegate.h",
"storage_manager/arc_storage_manager.cc", "storage_manager/arc_storage_manager.cc",
"storage_manager/arc_storage_manager.h", "storage_manager/arc_storage_manager.h",
"user_data/arc_user_data_service.cc", "user_data/arc_user_data_service.cc",
......
...@@ -71,6 +71,7 @@ struct UrlWithMimeType { ...@@ -71,6 +71,7 @@ struct UrlWithMimeType {
}; };
// Handles intents from ARC in Chrome. // Handles intents from ARC in Chrome.
// Deprecated method ID: 4
// Next method ID: 6 // Next method ID: 6
interface IntentHelperHost { interface IntentHelperHost {
// Called when icons associated with the package are no longer up to date. // Called when icons associated with the package are no longer up to date.
...@@ -91,7 +92,7 @@ interface IntentHelperHost { ...@@ -91,7 +92,7 @@ interface IntentHelperHost {
// Sets an image as the wallpaper. // Sets an image as the wallpaper.
// |jpeg_data| is a JPEG encoded wallpaper image. // |jpeg_data| is a JPEG encoded wallpaper image.
[MinVersion=8] SetWallpaper@4(array<uint8> jpeg_data); [MinVersion=8] SetWallpaperDeprecated@4(array<uint8> jpeg_data);
}; };
// Sends intents to ARC on behalf of Chrome. // Sends intents to ARC on behalf of Chrome.
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "components/arc/intent_helper/activity_icon_loader.h" #include "components/arc/intent_helper/activity_icon_loader.h"
#include "components/arc/intent_helper/link_handler_model_impl.h" #include "components/arc/intent_helper/link_handler_model_impl.h"
#include "components/arc/intent_helper/local_activity_resolver.h" #include "components/arc/intent_helper/local_activity_resolver.h"
#include "components/arc/set_wallpaper_delegate.h"
#include "ui/base/layout.h" #include "ui/base/layout.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -29,10 +28,6 @@ constexpr char kArcIntentHelperPackageName[] = "org.chromium.arc.intent_helper"; ...@@ -29,10 +28,6 @@ constexpr char kArcIntentHelperPackageName[] = "org.chromium.arc.intent_helper";
} // namespace } // namespace
// TODO(muyuanli): This will be removed once SetWallpaperDelegate class is
// removed.
SetWallpaperDelegate* SetWallpaperDelegate::instance_ = nullptr;
ArcIntentHelperBridge::ArcIntentHelperBridge( ArcIntentHelperBridge::ArcIntentHelperBridge(
ArcBridgeService* bridge_service, ArcBridgeService* bridge_service,
const scoped_refptr<ActivityIconLoader>& icon_loader, const scoped_refptr<ActivityIconLoader>& icon_loader,
...@@ -88,14 +83,10 @@ void ArcIntentHelperBridge::OpenWallpaperPicker() { ...@@ -88,14 +83,10 @@ void ArcIntentHelperBridge::OpenWallpaperPicker() {
ash::WmShell::Get()->wallpaper_delegate()->OpenSetWallpaperPage(); ash::WmShell::Get()->wallpaper_delegate()->OpenSetWallpaperPage();
} }
void ArcIntentHelperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) { void ArcIntentHelperBridge::SetWallpaperDeprecated(
mojo::Array<uint8_t> jpeg_data) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
SetWallpaperDelegate* delegate = SetWallpaperDelegate::instance(); LOG(ERROR) << "IntentHelper.SetWallpaper is deprecated";
if (delegate == nullptr) {
LOG(ERROR) << "SetWallpaperDelegate is not available.";
return;
}
delegate->SetWallpaperJpeg(jpeg_data.PassStorage());
} }
std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel(
......
...@@ -63,7 +63,7 @@ class ArcIntentHelperBridge ...@@ -63,7 +63,7 @@ class ArcIntentHelperBridge
void OnOpenDownloads() override; void OnOpenDownloads() override;
void OnOpenUrl(const mojo::String& url) override; void OnOpenUrl(const mojo::String& url) override;
void OpenWallpaperPicker() override; void OpenWallpaperPicker() override;
void SetWallpaper(mojo::Array<uint8_t> jpeg_data) override; void SetWallpaperDeprecated(mojo::Array<uint8_t> jpeg_data) override;
// ash::LinkHandlerModelFactory // ash::LinkHandlerModelFactory
std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override;
......
// 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.
#ifndef COMPONENTS_ARC_SET_WALLPAPER_DELEGATE_H_
#define COMPONENTS_ARC_SET_WALLPAPER_DELEGATE_H_
#include <stdint.h>
#include <vector>
namespace arc {
// Delegate to allow setting the wallpaper.
// TODO(muyuanli): This class will be removed once ArcIntentHelper migrates to
// WallpaperManager API.
class SetWallpaperDelegate {
public:
virtual ~SetWallpaperDelegate() = default;
static SetWallpaperDelegate* instance() { return instance_; }
static void set_instance(SetWallpaperDelegate* delegate) {
instance_ = delegate;
}
// Sets an image represented in JPEG format as the wallpaper.
virtual void SetWallpaperJpeg(const std::vector<uint8_t>& jpeg_data) = 0;
private:
static SetWallpaperDelegate* instance_;
};
} // namespace arc
#endif // COMPONENTS_ARC_SET_WALLPAPER_DELEGATE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment