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

Side by Side Diff: chrome/browser/chromeos/arc/wallpaper/arc_wallpaper_service.cc

Issue 2599673005: arc: Use GET_INTERFACE_FOR_METHOD macro (Closed)
Patch Set: Addressed feedback Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/arc/wallpaper/arc_wallpaper_service.h" 5 #include "chrome/browser/chromeos/arc/wallpaper/arc_wallpaper_service.h"
6 6
7 #include "ash/common/wallpaper/wallpaper_controller.h" 7 #include "ash/common/wallpaper/wallpaper_controller.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/task_runner_util.h" 11 #include "base/task_runner_util.h"
12 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 12 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
13 #include "components/arc/arc_bridge_service.h" 13 #include "components/arc/arc_bridge_service.h"
14 #include "components/signin/core/account_id/account_id.h" 14 #include "components/signin/core/account_id/account_id.h"
15 #include "components/user_manager/user_manager.h" 15 #include "components/user_manager/user_manager.h"
16 #include "components/wallpaper/wallpaper_files_id.h" 16 #include "components/wallpaper/wallpaper_files_id.h"
17 #include "components/wallpaper/wallpaper_layout.h" 17 #include "components/wallpaper/wallpaper_layout.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "ui/gfx/codec/png_codec.h" 19 #include "ui/gfx/codec/png_codec.h"
20 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
21 #include "ui/gfx/image/image_skia.h" 21 #include "ui/gfx/image/image_skia.h"
22 #include "ui/gfx/image/image_util.h" 22 #include "ui/gfx/image/image_util.h"
23 23
24 using user_manager::UserManager; 24 using user_manager::UserManager;
25 25
26 namespace arc { 26 namespace arc {
27 27
28 namespace { 28 namespace {
29 29
30 constexpr uint32_t kMinOnWallpaperChangedVersion = 1;
31 constexpr char kAndroidWallpaperFilename[] = "android.jpg"; 30 constexpr char kAndroidWallpaperFilename[] = "android.jpg";
32 31
33 // Sets a decoded bitmap as the wallpaper. 32 // Sets a decoded bitmap as the wallpaper.
34 void SetBitmapAsWallpaper(const SkBitmap& bitmap) { 33 void SetBitmapAsWallpaper(const SkBitmap& bitmap) {
35 // Make the SkBitmap immutable as we won't modify it. This is important 34 // Make the SkBitmap immutable as we won't modify it. This is important
36 // because otherwise it gets duplicated during painting, wasting memory. 35 // because otherwise it gets duplicated during painting, wasting memory.
37 SkBitmap immutable_bitmap(bitmap); 36 SkBitmap immutable_bitmap(bitmap);
38 immutable_bitmap.setImmutable(); 37 immutable_bitmap.setImmutable();
39 gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(immutable_bitmap); 38 gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(immutable_bitmap);
40 image.MakeThreadSafe(); 39 image.MakeThreadSafe();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ImageDecoder::Cancel(this); 86 ImageDecoder::Cancel(this);
88 ash::WallpaperController* wc = GetWallpaperController(); 87 ash::WallpaperController* wc = GetWallpaperController();
89 if (wc) 88 if (wc)
90 wc->RemoveObserver(this); 89 wc->RemoveObserver(this);
91 arc_bridge_service()->wallpaper()->RemoveObserver(this); 90 arc_bridge_service()->wallpaper()->RemoveObserver(this);
92 } 91 }
93 92
94 void ArcWallpaperService::OnInstanceReady() { 93 void ArcWallpaperService::OnInstanceReady() {
95 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 94 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
96 mojom::WallpaperInstance* wallpaper_instance = 95 mojom::WallpaperInstance* wallpaper_instance =
97 arc_bridge_service()->wallpaper()->GetInstanceForMethod("Init"); 96 ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->wallpaper(), Init);
98 DCHECK(wallpaper_instance); 97 DCHECK(wallpaper_instance);
99 wallpaper_instance->Init(binding_.CreateInterfacePtrAndBind()); 98 wallpaper_instance->Init(binding_.CreateInterfacePtrAndBind());
100 ash::WmShell::Get()->wallpaper_controller()->AddObserver(this); 99 ash::WmShell::Get()->wallpaper_controller()->AddObserver(this);
101 } 100 }
102 101
103 void ArcWallpaperService::OnInstanceClosed() { 102 void ArcWallpaperService::OnInstanceClosed() {
104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 103 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
105 ash::WallpaperController* wc = GetWallpaperController(); 104 ash::WallpaperController* wc = GetWallpaperController();
106 if (wc) 105 if (wc)
107 wc->RemoveObserver(this); 106 wc->RemoveObserver(this);
(...skipping 19 matching lines...) Expand all
127 SetBitmapAsWallpaper(bitmap); 126 SetBitmapAsWallpaper(bitmap);
128 } 127 }
129 128
130 void ArcWallpaperService::OnDecodeImageFailed() { 129 void ArcWallpaperService::OnDecodeImageFailed() {
131 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 130 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
132 LOG(ERROR) << "Failed to decode wallpaper image."; 131 LOG(ERROR) << "Failed to decode wallpaper image.";
133 } 132 }
134 133
135 void ArcWallpaperService::OnWallpaperDataChanged() { 134 void ArcWallpaperService::OnWallpaperDataChanged() {
136 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 135 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
137 auto* wallpaper_instance = 136 auto* wallpaper_instance = ARC_GET_INSTANCE_FOR_METHOD(
138 arc_bridge_service()->wallpaper()->GetInstanceForMethod( 137 arc_bridge_service()->wallpaper(), OnWallpaperChanged);
139 "OnWallpaperChanged", kMinOnWallpaperChangedVersion);
140 if (!wallpaper_instance) 138 if (!wallpaper_instance)
141 return; 139 return;
142 wallpaper_instance->OnWallpaperChanged(); 140 wallpaper_instance->OnWallpaperChanged();
143 } 141 }
144 142
145 } // namespace arc 143 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/video/gpu_arc_video_service_host.cc ('k') | chrome/browser/chromeos/note_taking_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698