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

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

Issue 2061183002: arc: IPC method to set custom wallpaper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tiny style fix. Created 4 years, 6 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 <vector> 8 #include <vector>
8 9
9 #include "ash/desktop_background/user_wallpaper_delegate.h" 10 #include "ash/desktop_background/user_wallpaper_delegate.h"
10 #include "ash/new_window_delegate.h" 11 #include "ash/new_window_delegate.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/shell_delegate.h" 13 #include "ash/shell_delegate.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "components/arc/intent_helper/activity_icon_loader.h" 15 #include "components/arc/intent_helper/activity_icon_loader.h"
15 #include "components/arc/intent_helper/link_handler_model_impl.h" 16 #include "components/arc/intent_helper/link_handler_model_impl.h"
17 #include "components/arc/set_wallpaper_delegate.h"
16 #include "ui/base/layout.h" 18 #include "ui/base/layout.h"
17 #include "url/gurl.h" 19 #include "url/gurl.h"
18 20
19 namespace arc { 21 namespace arc {
20 22
21 ArcIntentHelperBridge::ArcIntentHelperBridge( 23 ArcIntentHelperBridge::ArcIntentHelperBridge(
22 ArcBridgeService* bridge_service, 24 ArcBridgeService* bridge_service,
23 const scoped_refptr<ActivityIconLoader>& icon_loader) 25 const scoped_refptr<ActivityIconLoader>& icon_loader,
24 : ArcService(bridge_service), binding_(this), icon_loader_(icon_loader) { 26 std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate)
27 : ArcService(bridge_service),
28 binding_(this),
29 icon_loader_(icon_loader),
30 set_wallpaper_delegate_(std::move(set_wallpaper_delegate)) {
31 DCHECK(thread_checker_.CalledOnValidThread());
25 arc_bridge_service()->AddObserver(this); 32 arc_bridge_service()->AddObserver(this);
26 } 33 }
27 34
28 ArcIntentHelperBridge::~ArcIntentHelperBridge() { 35 ArcIntentHelperBridge::~ArcIntentHelperBridge() {
36 DCHECK(thread_checker_.CalledOnValidThread());
29 arc_bridge_service()->RemoveObserver(this); 37 arc_bridge_service()->RemoveObserver(this);
30 } 38 }
31 39
32 void ArcIntentHelperBridge::OnIntentHelperInstanceReady() { 40 void ArcIntentHelperBridge::OnIntentHelperInstanceReady() {
41 DCHECK(thread_checker_.CalledOnValidThread());
33 ash::Shell::GetInstance()->set_link_handler_model_factory(this); 42 ash::Shell::GetInstance()->set_link_handler_model_factory(this);
34 arc_bridge_service()->intent_helper_instance()->Init( 43 arc_bridge_service()->intent_helper_instance()->Init(
35 binding_.CreateInterfacePtrAndBind()); 44 binding_.CreateInterfacePtrAndBind());
36 } 45 }
37 46
38 void ArcIntentHelperBridge::OnIntentHelperInstanceClosed() { 47 void ArcIntentHelperBridge::OnIntentHelperInstanceClosed() {
48 DCHECK(thread_checker_.CalledOnValidThread());
39 ash::Shell::GetInstance()->set_link_handler_model_factory(nullptr); 49 ash::Shell::GetInstance()->set_link_handler_model_factory(nullptr);
40 } 50 }
41 51
42 void ArcIntentHelperBridge::OnIconInvalidated( 52 void ArcIntentHelperBridge::OnIconInvalidated(
43 const mojo::String& package_name) { 53 const mojo::String& package_name) {
54 DCHECK(thread_checker_.CalledOnValidThread());
44 icon_loader_->InvalidateIcons(package_name); 55 icon_loader_->InvalidateIcons(package_name);
45 } 56 }
46 57
47 void ArcIntentHelperBridge::OnOpenDownloads() { 58 void ArcIntentHelperBridge::OnOpenDownloads() {
59 DCHECK(thread_checker_.CalledOnValidThread());
48 // TODO(607411): If the FileManager is not yet open this will open to 60 // TODO(607411): If the FileManager is not yet open this will open to
49 // downloads by default, which is what we want. However if it is open it will 61 // downloads by default, which is what we want. However if it is open it will
50 // simply be brought to the forgeground without forcibly being navigated to 62 // simply be brought to the forgeground without forcibly being navigated to
51 // downloads, which is probably not ideal. 63 // downloads, which is probably not ideal.
52 ash::Shell::GetInstance()->new_window_delegate()->OpenFileManager(); 64 ash::Shell::GetInstance()->new_window_delegate()->OpenFileManager();
53 } 65 }
54 66
55 void ArcIntentHelperBridge::OnOpenUrl(const mojo::String& url) { 67 void ArcIntentHelperBridge::OnOpenUrl(const mojo::String& url) {
68 DCHECK(thread_checker_.CalledOnValidThread());
56 GURL gurl(url.get()); 69 GURL gurl(url.get());
57 ash::Shell::GetInstance()->delegate()->OpenUrl(gurl); 70 ash::Shell::GetInstance()->delegate()->OpenUrl(gurl);
58 } 71 }
59 72
60 void ArcIntentHelperBridge::OpenWallpaperPicker() { 73 void ArcIntentHelperBridge::OpenWallpaperPicker() {
74 DCHECK(thread_checker_.CalledOnValidThread());
61 ash::Shell::GetInstance()->user_wallpaper_delegate()->OpenSetWallpaperPage(); 75 ash::Shell::GetInstance()->user_wallpaper_delegate()->OpenSetWallpaperPage();
62 } 76 }
63 77
78 void ArcIntentHelperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) {
79 DCHECK(thread_checker_.CalledOnValidThread());
80 std::string jpeg_data_as_string(
81 reinterpret_cast<const char*>(&jpeg_data.storage()[0]), jpeg_data.size());
82 set_wallpaper_delegate_->SetWallpaper(jpeg_data_as_string);
Yusuke Sato 2016/06/15 19:44:32 nit: SetWallpaper(jpeg_data.PassStorage()); or s
Shuhei Takahashi 2016/06/15 22:58:39 That sounds better, I've updated the patch to use
83 }
84
64 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( 85 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel(
65 const GURL& url) { 86 const GURL& url) {
87 DCHECK(thread_checker_.CalledOnValidThread());
66 std::unique_ptr<LinkHandlerModelImpl> impl( 88 std::unique_ptr<LinkHandlerModelImpl> impl(
67 new LinkHandlerModelImpl(icon_loader_)); 89 new LinkHandlerModelImpl(icon_loader_));
68 if (!impl->Init(url)) 90 if (!impl->Init(url))
69 return nullptr; 91 return nullptr;
70 return std::move(impl); 92 return std::move(impl);
71 } 93 }
72 94
73 } // namespace arc 95 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698