| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 namespace arc { | 23 namespace arc { |
| 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 // TODO(muyuanli): This will be removed once SetWallpaperDelegate class is |
| 32 // removed. |
| 33 SetWallpaperDelegate* SetWallpaperDelegate::instance_ = nullptr; |
| 34 |
| 31 ArcIntentHelperBridge::ArcIntentHelperBridge( | 35 ArcIntentHelperBridge::ArcIntentHelperBridge( |
| 32 ArcBridgeService* bridge_service, | 36 ArcBridgeService* bridge_service, |
| 33 const scoped_refptr<ActivityIconLoader>& icon_loader, | 37 const scoped_refptr<ActivityIconLoader>& icon_loader, |
| 34 std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate, | |
| 35 const scoped_refptr<LocalActivityResolver>& activity_resolver) | 38 const scoped_refptr<LocalActivityResolver>& activity_resolver) |
| 36 : ArcService(bridge_service), | 39 : ArcService(bridge_service), |
| 37 binding_(this), | 40 binding_(this), |
| 38 icon_loader_(icon_loader), | 41 icon_loader_(icon_loader), |
| 39 set_wallpaper_delegate_(std::move(set_wallpaper_delegate)), | |
| 40 activity_resolver_(activity_resolver) { | 42 activity_resolver_(activity_resolver) { |
| 41 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
| 42 arc_bridge_service()->intent_helper()->AddObserver(this); | 44 arc_bridge_service()->intent_helper()->AddObserver(this); |
| 43 } | 45 } |
| 44 | 46 |
| 45 ArcIntentHelperBridge::~ArcIntentHelperBridge() { | 47 ArcIntentHelperBridge::~ArcIntentHelperBridge() { |
| 46 DCHECK(thread_checker_.CalledOnValidThread()); | 48 DCHECK(thread_checker_.CalledOnValidThread()); |
| 47 arc_bridge_service()->intent_helper()->RemoveObserver(this); | 49 arc_bridge_service()->intent_helper()->RemoveObserver(this); |
| 48 } | 50 } |
| 49 | 51 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 80 ash::WmShell::Get()->delegate()->OpenUrlFromArc(gurl); | 82 ash::WmShell::Get()->delegate()->OpenUrlFromArc(gurl); |
| 81 } | 83 } |
| 82 | 84 |
| 83 void ArcIntentHelperBridge::OpenWallpaperPicker() { | 85 void ArcIntentHelperBridge::OpenWallpaperPicker() { |
| 84 DCHECK(thread_checker_.CalledOnValidThread()); | 86 DCHECK(thread_checker_.CalledOnValidThread()); |
| 85 ash::WmShell::Get()->wallpaper_delegate()->OpenSetWallpaperPage(); | 87 ash::WmShell::Get()->wallpaper_delegate()->OpenSetWallpaperPage(); |
| 86 } | 88 } |
| 87 | 89 |
| 88 void ArcIntentHelperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) { | 90 void ArcIntentHelperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) { |
| 89 DCHECK(thread_checker_.CalledOnValidThread()); | 91 DCHECK(thread_checker_.CalledOnValidThread()); |
| 90 set_wallpaper_delegate_->SetWallpaper(jpeg_data.PassStorage()); | 92 SetWallpaperDelegate* delegate = SetWallpaperDelegate::instance(); |
| 93 if (delegate == nullptr) { |
| 94 LOG(ERROR) << "SetWallpaperDelegate is not available."; |
| 95 return; |
| 96 } |
| 97 delegate->SetWallpaperJpeg(jpeg_data.PassStorage()); |
| 91 } | 98 } |
| 92 | 99 |
| 93 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( | 100 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( |
| 94 const GURL& url) { | 101 const GURL& url) { |
| 95 DCHECK(thread_checker_.CalledOnValidThread()); | 102 DCHECK(thread_checker_.CalledOnValidThread()); |
| 96 std::unique_ptr<LinkHandlerModelImpl> impl( | 103 std::unique_ptr<LinkHandlerModelImpl> impl( |
| 97 new LinkHandlerModelImpl(icon_loader_)); | 104 new LinkHandlerModelImpl(icon_loader_)); |
| 98 if (!impl->Init(url)) | 105 if (!impl->Init(url)) |
| 99 return nullptr; | 106 return nullptr; |
| 100 return std::move(impl); | 107 return std::move(impl); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 119 return handlers_filtered; | 126 return handlers_filtered; |
| 120 } | 127 } |
| 121 | 128 |
| 122 void ArcIntentHelperBridge::OnIntentFiltersUpdated( | 129 void ArcIntentHelperBridge::OnIntentFiltersUpdated( |
| 123 mojo::Array<mojom::IntentFilterPtr> filters) { | 130 mojo::Array<mojom::IntentFilterPtr> filters) { |
| 124 DCHECK(thread_checker_.CalledOnValidThread()); | 131 DCHECK(thread_checker_.CalledOnValidThread()); |
| 125 activity_resolver_->UpdateIntentFilters(std::move(filters)); | 132 activity_resolver_->UpdateIntentFilters(std::move(filters)); |
| 126 } | 133 } |
| 127 | 134 |
| 128 } // namespace arc | 135 } // namespace arc |
| OLD | NEW |