Commit 9aea0003 authored by kbr's avatar kbr Committed by Commit bot

Revert of cheets: implement cros side of WallpaperManagerService. (patchset...

Revert of cheets: implement cros side of WallpaperManagerService. (patchset #16 id:300001 of https://codereview.chromium.org/2264743002/ )

Reason for revert:
Broke the build. Not sure how this made it past the CQ:
https://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Builder/builds/45818

Original issue's description:
> cheets: implement cros side of WallpaperManagerService.
>
> Rename ArcWallpaperHandler to ArcWallpaperService and implement it as an ArcService, which handles WallpaperManager API from Android.
>
> Test=Manually open PickMyWallpaper app and set wallpaper
> Test=run cts android.content.cts.ContextWrapperTest
>
> Bug=642465
>
> Committed: https://crrev.com/533be7ef1063d285008913c9784d8d852055c8bd
> Cr-Commit-Position: refs/heads/master@{#417428}

TBR=xiaohuic@chromium.org,xiyuan@chromium.org,nya@chromium.org,lhchavez@chromium.org,hidehiko@chromium.org,dcheng@chromium.org,yusukes@chromium.org,muyuanli@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Bug=642465

Review-Url: https://codereview.chromium.org/2320323002
Cr-Commit-Position: refs/heads/master@{#417431}
parent 8ccc7ad8
......@@ -224,8 +224,8 @@ source_set("chromeos") {
"arc/arc_support_host.h",
"arc/arc_tts_service.cc",
"arc/arc_tts_service.h",
"arc/arc_wallpaper_service.cc",
"arc/arc_wallpaper_service.h",
"arc/arc_wallpaper_handler.cc",
"arc/arc_wallpaper_handler.h",
"arc/gpu_arc_video_service_host.cc",
"arc/gpu_arc_video_service_host.h",
"attestation/attestation_ca_client.cc",
......
......@@ -15,7 +15,7 @@
#include "chrome/browser/chromeos/arc/arc_process_service.h"
#include "chrome/browser/chromeos/arc/arc_settings_service.h"
#include "chrome/browser/chromeos/arc/arc_tts_service.h"
#include "chrome/browser/chromeos/arc/arc_wallpaper_service.h"
#include "chrome/browser/chromeos/arc/arc_wallpaper_handler.h"
#include "chrome/browser/chromeos/arc/gpu_arc_video_service_host.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
......@@ -43,6 +43,7 @@ void ArcServiceLauncher::Initialize() {
arc_service_manager_->AddService(base::MakeUnique<ArcIntentHelperBridge>(
arc_service_manager_->arc_bridge_service(),
arc_service_manager_->icon_loader(),
base::MakeUnique<ArcWallpaperHandler>(),
arc_service_manager_->activity_resolver()));
arc_service_manager_->AddService(base::MakeUnique<ArcPolicyBridge>(
arc_service_manager_->arc_bridge_service()));
......@@ -54,8 +55,6 @@ void ArcServiceLauncher::Initialize() {
arc_service_manager_->arc_bridge_service()));
arc_service_manager_->AddService(base::MakeUnique<ArcTtsService>(
arc_service_manager_->arc_bridge_service()));
arc_service_manager_->AddService(base::MakeUnique<ArcWallpaperService>(
arc_service_manager_->arc_bridge_service()));
arc_service_manager_->AddService(base::MakeUnique<GpuArcVideoServiceHost>(
arc_service_manager_->arc_bridge_service()));
}
......
......@@ -2,28 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/arc/arc_wallpaper_service.h"
#include "chrome/browser/chromeos/arc/arc_wallpaper_handler.h"
#include <string>
#include <utility>
#include <vector>
#include "ash/shell.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/task_runner_util.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "components/arc/arc_bridge_service.h"
#include "components/signin/core/account_id/account_id.h"
#include "components/user_manager/user_manager.h"
#include "components/wallpaper/wallpaper_files_id.h"
#include "components/wallpaper/wallpaper_layout.h"
#include "content/public/browser/browser_thread.h"
#include "ui/gfx/codec/png_codec.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;
......@@ -63,62 +56,18 @@ void SetBitmapAsWallpaper(const SkBitmap& bitmap) {
// wallpaper_private_api.cc.
}
std::vector<uint8_t> EncodeImagePng(const gfx::ImageSkia image) {
std::vector<uint8_t> result;
gfx::PNGCodec::FastEncodeBGRASkBitmap(*image.bitmap(), true, &result);
return result;
}
} // namespace
ArcWallpaperService::ArcWallpaperService(ArcBridgeService* bridge_service)
: ArcService(bridge_service), binding_(this) {
arc_bridge_service()->wallpaper()->AddObserver(this);
DCHECK(!ArcWallpaperService::instance());
ArcWallpaperService::set_instance(this);
}
ArcWallpaperHandler::ArcWallpaperHandler() = default;
ArcWallpaperService::~ArcWallpaperService() {
ArcWallpaperHandler::~ArcWallpaperHandler() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// Make sure the callback is never called after destruction. It is safe to
// call Cancel() even when there is no in-flight request.
ImageDecoder::Cancel(this);
arc_bridge_service()->wallpaper()->RemoveObserver(this);
DCHECK(ArcWallpaperService::instance() == this);
ArcWallpaperService::set_instance(nullptr);
}
void ArcWallpaperService::OnInstanceReady() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
mojom::WallpaperInstance* wallpaper_instance =
arc_bridge_service()->wallpaper()->instance();
if (!wallpaper_instance) {
LOG(DFATAL) << "OnWallpaperInstanceReady called, "
<< "but no wallpaper instance found";
return;
}
wallpaper_instance->Init(binding_.CreateInterfacePtrAndBind());
}
void ArcWallpaperService::SetWallpaper(mojo::Array<uint8_t> png_data) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
ImageDecoder::Cancel(this);
ImageDecoder::StartWithOptions(this, png_data.PassStorage(),
ImageDecoder::ROBUST_PNG_CODEC, true);
}
void ArcWallpaperService::GetWallpaper(const GetWallpaperCallback& callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
ash::WallpaperController* wc =
ash::Shell::GetInstance()->wallpaper_controller();
gfx::ImageSkia wallpaper = wc->GetWallpaper();
base::PostTaskAndReplyWithResult(
content::BrowserThread::GetBlockingPool(), FROM_HERE,
base::Bind(&EncodeImagePng, wallpaper), callback);
}
void ArcWallpaperService::SetWallpaperJpeg(
const std::vector<uint8_t>& jpeg_data) {
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()
// even when there is no in-flight request.
......@@ -127,12 +76,12 @@ void ArcWallpaperService::SetWallpaperJpeg(
ImageDecoder::ROBUST_JPEG_CODEC, true);
}
void ArcWallpaperService::OnImageDecoded(const SkBitmap& bitmap) {
void ArcWallpaperHandler::OnImageDecoded(const SkBitmap& bitmap) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
SetBitmapAsWallpaper(bitmap);
}
void ArcWallpaperService::OnDecodeImageFailed() {
void ArcWallpaperHandler::OnDecodeImageFailed() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
LOG(ERROR) << "Failed to decode wallpaper image.";
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_SERVICE_H_
#define CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_SERVICE_H_
#ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_HANDLER_H_
#include <stdint.h>
......@@ -13,47 +13,30 @@
#include "base/macros.h"
#include "chrome/browser/image_decoder.h"
#include "components/arc/arc_service.h"
#include "components/arc/common/wallpaper.mojom.h"
#include "components/arc/instance_holder.h"
#include "components/arc/set_wallpaper_delegate.h"
#include "mojo/public/cpp/bindings/binding.h"
class SkBitmap;
namespace arc {
// Lives on the UI thread.
class ArcWallpaperService
: public ArcService,
public SetWallpaperDelegate,
public ImageDecoder::ImageRequest,
public InstanceHolder<mojom::WallpaperInstance>::Observer,
public mojom::WallpaperHost {
class ArcWallpaperHandler : public SetWallpaperDelegate,
public ImageDecoder::ImageRequest {
public:
explicit ArcWallpaperService(ArcBridgeService* bridge_service);
~ArcWallpaperService() override;
// InstanceHolder<mojom::WallpaperInstance>::Observer overrides.
void OnInstanceReady() override;
// mojom::WallpaperHost overrides.
// TODO(muyuanli): change callback prototype when use_new_wrapper_types is
// updated and merge them with the functions below.
void SetWallpaper(mojo::Array<uint8_t> png_data) override;
void GetWallpaper(const GetWallpaperCallback& callback) override;
ArcWallpaperHandler();
~ArcWallpaperHandler() override;
// SetWallpaperDelegate implementation.
void SetWallpaperJpeg(const std::vector<uint8_t>& jpeg_data) override;
void SetWallpaper(std::vector<uint8_t> jpeg_data) override;
// ImageDecoder::ImageRequest implementation.
void OnImageDecoded(const SkBitmap& bitmap) override;
void OnDecodeImageFailed() override;
private:
mojo::Binding<mojom::WallpaperHost> binding_;
DISALLOW_COPY_AND_ASSIGN(ArcWallpaperService);
DISALLOW_COPY_AND_ASSIGN(ArcWallpaperHandler);
};
} // namespace arc
#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_SERVICE_H_
#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_HANDLER_H_
......@@ -156,7 +156,6 @@ mojom("arc_bindings") {
"common/tts.mojom",
"common/video.mojom",
"common/video_accelerator.mojom",
"common/wallpaper.mojom",
]
deps = [
......
......@@ -188,12 +188,6 @@ void ArcBridgeHostImpl::OnVideoInstanceReady(
OnInstanceReady(ArcBridgeService::Get()->video(), std::move(video_ptr));
}
void ArcBridgeHostImpl::OnWallpaperInstanceReady(
mojom::WallpaperInstancePtr wallpaper_ptr) {
OnInstanceReady(ArcBridgeService::Get()->wallpaper(),
std::move(wallpaper_ptr));
}
void ArcBridgeHostImpl::OnClosed() {
DCHECK(thread_checker_.CalledOnValidThread());
VLOG(1) << "Mojo connection lost";
......
......@@ -65,8 +65,6 @@ class ArcBridgeHostImpl : public mojom::ArcBridgeHost {
mojom::StorageManagerInstancePtr storage_manager_ptr) override;
void OnTtsInstanceReady(mojom::TtsInstancePtr tts_ptr) override;
void OnVideoInstanceReady(mojom::VideoInstancePtr video_ptr) override;
void OnWallpaperInstanceReady(
mojom::WallpaperInstancePtr wallpaper_ptr) override;
private:
// Called when the bridge channel is closed. This typically only happens when
......
......@@ -120,7 +120,6 @@ class ArcBridgeService {
}
InstanceHolder<mojom::TtsInstance>* tts() { return &tts_; }
InstanceHolder<mojom::VideoInstance>* video() { return &video_; }
InstanceHolder<mojom::WallpaperInstance>* wallpaper() { return &wallpaper_; }
// Gets if ARC is currently running.
bool ready() const { return state() == State::READY; }
......@@ -189,7 +188,6 @@ class ArcBridgeService {
InstanceHolder<mojom::StorageManagerInstance> storage_manager_;
InstanceHolder<mojom::TtsInstance> tts_;
InstanceHolder<mojom::VideoInstance> video_;
InstanceHolder<mojom::WallpaperInstance> wallpaper_;
// Gets the current state of the bridge service.
State state() const { return state_; }
......
......@@ -25,11 +25,10 @@ import "process.mojom";
import "storage_manager.mojom";
import "tts.mojom";
import "video.mojom";
import "wallpaper.mojom";
// Next MinVersion: 19
// Next MinVersion: 18
// Deprecated method IDs: 101, 105
// Next method ID: 125
// Next method ID: 124
interface ArcBridgeHost {
// Keep the entries alphabetical. In order to do so without breaking
// compatibility with the ARC instance, explicitly assign each interface a
......@@ -101,9 +100,6 @@ interface ArcBridgeHost {
// Notifies Chrome that the VideoInstance interface is ready.
[MinVersion=6] OnVideoInstanceReady@107(VideoInstance instance_ptr);
// Notifies Chrome that the WallpaperInstance interface is ready.
[MinVersion=18] OnWallpaperInstanceReady@124(WallpaperInstance instance_ptr);
};
interface ArcBridgeInstance {
......
// 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.
//
// Next MinVersion: 1
module arc.mojom;
// Handles wallpaper calls from ARC in Chrome.
// Next method ID:2
interface WallpaperHost {
// Gets current wallpaper encoded in PNG and send it back to ARC.
GetWallpaper@0() => (array<uint8> wallpaper);
// Sets an image from ARC as the wallpaper.
// |png_data| is a PNG encoded wallpaper image.
SetWallpaper@1(array<uint8> png_data);
};
// Connects with container side to publish wallpaper related intents.
// Next method ID:1
interface WallpaperInstance {
// Establishes communication with the container side.
Init@0(WallpaperHost host_ptr);
};
\ No newline at end of file
......@@ -28,17 +28,15 @@ constexpr char kArcIntentHelperPackageName[] = "org.chromium.arc.intent_helper";
} // namespace
// TODO(muyuanli): This will be removed once SetWallpaperDelegate class is
// removed.
SetWallpaperDelegate* SetWallpaperDelegate::instance_ = nullptr;
ArcIntentHelperBridge::ArcIntentHelperBridge(
ArcBridgeService* bridge_service,
const scoped_refptr<ActivityIconLoader>& icon_loader,
std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate,
const scoped_refptr<LocalActivityResolver>& activity_resolver)
: ArcService(bridge_service),
binding_(this),
icon_loader_(icon_loader),
set_wallpaper_delegate_(std::move(set_wallpaper_delegate)),
activity_resolver_(activity_resolver) {
DCHECK(thread_checker_.CalledOnValidThread());
arc_bridge_service()->intent_helper()->AddObserver(this);
......@@ -89,12 +87,7 @@ void ArcIntentHelperBridge::OpenWallpaperPicker() {
void ArcIntentHelperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) {
DCHECK(thread_checker_.CalledOnValidThread());
SetWallpaperDelegate* delegate = SetWallpaperDelegate::instance();
if (delegate == nullptr) {
LOG(ERROR) << "SetWallpaperDelegate is not available.";
return;
}
delegate->SetWallpaperJpeg(jpeg_data.PassStorage());
set_wallpaper_delegate_->SetWallpaper(jpeg_data.PassStorage());
}
std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel(
......
......@@ -40,6 +40,7 @@ class ArcIntentHelperBridge
ArcIntentHelperBridge(
ArcBridgeService* bridge_service,
const scoped_refptr<ActivityIconLoader>& icon_loader,
std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate,
const scoped_refptr<LocalActivityResolver>& activity_resolver);
~ArcIntentHelperBridge() override;
......@@ -70,6 +71,7 @@ class ArcIntentHelperBridge
private:
mojo::Binding<mojom::IntentHelperHost> binding_;
scoped_refptr<ActivityIconLoader> icon_loader_;
std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate_;
scoped_refptr<LocalActivityResolver> activity_resolver_;
base::ThreadChecker thread_checker_;
......
......@@ -12,22 +12,12 @@
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_;
virtual void SetWallpaper(std::vector<uint8_t> jpeg_data) = 0;
};
} // namespace arc
......
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