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

Side by Side Diff: components/arc/intent_helper/arc_intent_helper_bridge.cc

Issue 2264743002: cheets: implement cros side of WallpaperManagerService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a static instance to SetWallpaperDelegate and null check to ArcIntentHelper. 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 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 "components/arc/intent_helper/arc_intent_helper_bridge.h" 5 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/new_window_delegate.h" 10 #include "ash/common/new_window_delegate.h"
(...skipping 13 matching lines...) Expand all
24 24
25 namespace { 25 namespace {
26 26
27 constexpr char kArcIntentHelperPackageName[] = "org.chromium.arc.intent_helper"; 27 constexpr char kArcIntentHelperPackageName[] = "org.chromium.arc.intent_helper";
28 28
29 } // namespace 29 } // namespace
30 30
31 ArcIntentHelperBridge::ArcIntentHelperBridge( 31 ArcIntentHelperBridge::ArcIntentHelperBridge(
32 ArcBridgeService* bridge_service, 32 ArcBridgeService* bridge_service,
33 const scoped_refptr<ActivityIconLoader>& icon_loader, 33 const scoped_refptr<ActivityIconLoader>& icon_loader,
34 std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate,
35 const scoped_refptr<LocalActivityResolver>& activity_resolver) 34 const scoped_refptr<LocalActivityResolver>& activity_resolver)
36 : ArcService(bridge_service), 35 : ArcService(bridge_service),
37 binding_(this), 36 binding_(this),
38 icon_loader_(icon_loader), 37 icon_loader_(icon_loader),
39 set_wallpaper_delegate_(std::move(set_wallpaper_delegate)),
40 activity_resolver_(activity_resolver) { 38 activity_resolver_(activity_resolver) {
41 DCHECK(thread_checker_.CalledOnValidThread()); 39 DCHECK(thread_checker_.CalledOnValidThread());
42 arc_bridge_service()->intent_helper()->AddObserver(this); 40 arc_bridge_service()->intent_helper()->AddObserver(this);
43 } 41 }
44 42
45 ArcIntentHelperBridge::~ArcIntentHelperBridge() { 43 ArcIntentHelperBridge::~ArcIntentHelperBridge() {
46 DCHECK(thread_checker_.CalledOnValidThread()); 44 DCHECK(thread_checker_.CalledOnValidThread());
47 arc_bridge_service()->intent_helper()->RemoveObserver(this); 45 arc_bridge_service()->intent_helper()->RemoveObserver(this);
48 } 46 }
49 47
(...skipping 30 matching lines...) Expand all
80 ash::WmShell::Get()->delegate()->OpenUrlFromArc(gurl); 78 ash::WmShell::Get()->delegate()->OpenUrlFromArc(gurl);
81 } 79 }
82 80
83 void ArcIntentHelperBridge::OpenWallpaperPicker() { 81 void ArcIntentHelperBridge::OpenWallpaperPicker() {
84 DCHECK(thread_checker_.CalledOnValidThread()); 82 DCHECK(thread_checker_.CalledOnValidThread());
85 ash::WmShell::Get()->wallpaper_delegate()->OpenSetWallpaperPage(); 83 ash::WmShell::Get()->wallpaper_delegate()->OpenSetWallpaperPage();
86 } 84 }
87 85
88 void ArcIntentHelperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) { 86 void ArcIntentHelperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) {
89 DCHECK(thread_checker_.CalledOnValidThread()); 87 DCHECK(thread_checker_.CalledOnValidThread());
90 set_wallpaper_delegate_->SetWallpaper(jpeg_data.PassStorage()); 88 SetWallpaperDelegate* delegate = SetWallpaperDelegate::GetInstance();
89 if (delegate == nullptr) {
90 LOG(ERROR) << "SetWallpaperDelegate is not available.";
91 return;
92 }
93 delegate->SetWallpaperJPEG(jpeg_data.PassStorage());
91 } 94 }
92 95
93 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( 96 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel(
94 const GURL& url) { 97 const GURL& url) {
95 DCHECK(thread_checker_.CalledOnValidThread()); 98 DCHECK(thread_checker_.CalledOnValidThread());
96 std::unique_ptr<LinkHandlerModelImpl> impl( 99 std::unique_ptr<LinkHandlerModelImpl> impl(
97 new LinkHandlerModelImpl(icon_loader_)); 100 new LinkHandlerModelImpl(icon_loader_));
98 if (!impl->Init(url)) 101 if (!impl->Init(url))
99 return nullptr; 102 return nullptr;
100 return std::move(impl); 103 return std::move(impl);
(...skipping 18 matching lines...) Expand all
119 return handlers_filtered; 122 return handlers_filtered;
120 } 123 }
121 124
122 void ArcIntentHelperBridge::OnIntentFiltersUpdated( 125 void ArcIntentHelperBridge::OnIntentFiltersUpdated(
123 mojo::Array<mojom::IntentFilterPtr> filters) { 126 mojo::Array<mojom::IntentFilterPtr> filters) {
124 DCHECK(thread_checker_.CalledOnValidThread()); 127 DCHECK(thread_checker_.CalledOnValidThread());
125 activity_resolver_->UpdateIntentFilters(std::move(filters)); 128 activity_resolver_->UpdateIntentFilters(std::move(filters));
126 } 129 }
127 130
128 } // namespace arc 131 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698