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..df8deb2a8fca73267ce9425637b89d6a8eed438e 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,7 @@ 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::Get()->wallpaper_controller()->RemoveObserver(this); |
Yusuke Sato
2016/09/16 00:45:19
You need null check(s). See the trybot (browser_te
Muyuan
2016/09/16 17:35:16
Done.
|
arc_bridge_service()->wallpaper()->RemoveObserver(this); |
} |
@@ -94,6 +96,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 +125,22 @@ void ArcWallpaperService::OnDecodeImageFailed() { |
LOG(ERROR) << "Failed to decode wallpaper image."; |
} |
+void ArcWallpaperService::OnWallpaperDataChanged() { |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
+ if (!CheckWallpaperInstanceVersion(kMinOnWallpaperChangedVersion)) { |
+ return; |
+ } |
+ arc_bridge_service()->wallpaper()->instance()->OnWallpaperChanged(); |
Luis Héctor Chávez
2016/09/16 00:01:58
what if instance() is null? It's probably better t
Muyuan
2016/09/16 16:30:05
The observer is registered in OnInstanceReady, so
Luis Héctor Chávez
2016/09/16 16:34:02
You can't assume that: What happens if the other s
Muyuan
2016/09/16 17:35:16
Done.
Muyuan
2016/09/16 17:37:22
Should I remove the wallpaper observer when the in
Luis Héctor Chávez
2016/09/16 17:49:14
So what I'm saying is:
a) Change CheckWallpaperIn
Muyuan
2016/09/16 19:52:07
Done.
|
+} |
+ |
+bool ArcWallpaperService::CheckWallpaperInstanceVersion(uint32_t version_need) { |
+ uint32_t version = arc_bridge_service()->wallpaper()->version(); |
+ if (version >= version_need) { |
+ return true; |
+ } |
+ LOG(WARNING) << "Wallpaper instance is too old (version " << version |
+ << ") need version " << version_need; |
+ return false; |
+} |
+ |
} // namespace arc |