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

Unified Diff: chrome/browser/chromeos/arc/arc_wallpaper_service.cc

Issue 2345153002: cheets: add wallpaper observer to arc_wallpaper_service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change null check in ~ArcWallpaperService(), modified instance version check / null check to follow… Created 4 years, 3 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
« no previous file with comments | « chrome/browser/chromeos/arc/arc_wallpaper_service.h ('k') | components/arc/common/wallpaper.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/arc_wallpaper_service.cc
diff --git a/chrome/browser/chromeos/arc/arc_wallpaper_service.cc b/chrome/browser/chromeos/arc/arc_wallpaper_service.cc
index f6a12cdb5a1eaba07ac09ec039de27a4aba85917..5cb7a9dfd26c3138d964f40471edf3f51c4c7fce 100644
--- a/chrome/browser/chromeos/arc/arc_wallpaper_service.cc
+++ b/chrome/browser/chromeos/arc/arc_wallpaper_service.cc
@@ -31,6 +31,7 @@ namespace arc {
namespace {
+constexpr uint32_t kMinOnWallpaperChangedVersion = 1;
constexpr char kAndroidWallpaperFilename[] = "android.jpg";
// Sets a decoded bitmap as the wallpaper.
@@ -81,6 +82,10 @@ ArcWallpaperService::~ArcWallpaperService() {
// 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);
+ ash::WmShell* wm_shell = ash::WmShell::Get();
+ if (wm_shell && wm_shell->wallpaper_controller()) {
+ wm_shell->wallpaper_controller()->RemoveObserver(this);
+ }
arc_bridge_service()->wallpaper()->RemoveObserver(this);
}
@@ -94,6 +99,7 @@ void ArcWallpaperService::OnInstanceReady() {
return;
}
wallpaper_instance->Init(binding_.CreateInterfacePtrAndBind());
+ ash::WmShell::Get()->wallpaper_controller()->AddObserver(this);
}
void ArcWallpaperService::SetWallpaper(mojo::Array<uint8_t> png_data) {
@@ -122,4 +128,33 @@ void ArcWallpaperService::OnDecodeImageFailed() {
LOG(ERROR) << "Failed to decode wallpaper image.";
}
+void ArcWallpaperService::OnWallpaperDataChanged() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ mojom::WallpaperInstance* instance =
+ GetWallpaperInstance(kMinOnWallpaperChangedVersion);
+ if (!instance) {
+ ash::WmShell::Get()->wallpaper_controller()->RemoveObserver(this);
Luis Héctor Chávez 2016/09/16 19:58:11 It's better to do this in the OnInstanceClosed() r
Muyuan 2016/09/16 20:19:08 I see. So here is a question: Is there a guarantee
Luis Héctor Chávez 2016/09/16 20:27:37 There are cases where Android outlives Chrome, but
Muyuan 2016/09/16 20:48:56 Done.
+ return;
+ }
+ instance->OnWallpaperChanged();
+}
+
+mojom::WallpaperInstance* ArcWallpaperService::GetWallpaperInstance(
+ uint32_t min_version) {
+ uint32_t version = arc_bridge_service()->wallpaper()->version();
+ if (version < min_version) {
+ VLOG(1) << "ARC wallpaper instance is too old. required: " << min_version
+ << ", actual: " << version;
+ return nullptr;
+ }
+
+ mojom::WallpaperInstance* instance =
+ arc_bridge_service()->wallpaper()->instance();
+ if (!instance) {
+ VLOG(2) << "ARC wallpaper instance is not ready.";
+ }
+
+ return instance;
+}
+
} // namespace arc
« no previous file with comments | « chrome/browser/chromeos/arc/arc_wallpaper_service.h ('k') | components/arc/common/wallpaper.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698