Chromium Code Reviews| 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" |
| 11 #include "ash/common/shell_delegate.h" | 11 #include "ash/common/shell_delegate.h" |
| 12 #include "ash/common/wallpaper/wallpaper_delegate.h" | 12 #include "ash/common/wallpaper/wallpaper_delegate.h" |
|
Luis Héctor Chávez
2016/09/12 21:57:22
This looks unused now.
Muyuan
2016/09/12 22:05:44
It seems to be used to open wallpaper picker page:
| |
| 13 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "components/arc/intent_helper/activity_icon_loader.h" | 16 #include "components/arc/intent_helper/activity_icon_loader.h" |
| 17 #include "components/arc/intent_helper/link_handler_model_impl.h" | 17 #include "components/arc/intent_helper/link_handler_model_impl.h" |
| 18 #include "components/arc/intent_helper/local_activity_resolver.h" | 18 #include "components/arc/intent_helper/local_activity_resolver.h" |
| 19 #include "components/arc/set_wallpaper_delegate.h" | |
| 20 #include "ui/base/layout.h" | 19 #include "ui/base/layout.h" |
| 21 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 22 | 21 |
| 23 namespace arc { | 22 namespace arc { |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 27 constexpr char kArcIntentHelperPackageName[] = "org.chromium.arc.intent_helper"; | 26 constexpr char kArcIntentHelperPackageName[] = "org.chromium.arc.intent_helper"; |
| 28 | 27 |
| 29 } // namespace | 28 } // namespace |
| 30 | 29 |
| 31 // TODO(muyuanli): This will be removed once SetWallpaperDelegate class is | |
| 32 // removed. | |
| 33 SetWallpaperDelegate* SetWallpaperDelegate::instance_ = nullptr; | |
| 34 | |
| 35 ArcIntentHelperBridge::ArcIntentHelperBridge( | 30 ArcIntentHelperBridge::ArcIntentHelperBridge( |
| 36 ArcBridgeService* bridge_service, | 31 ArcBridgeService* bridge_service, |
| 37 const scoped_refptr<ActivityIconLoader>& icon_loader, | 32 const scoped_refptr<ActivityIconLoader>& icon_loader, |
| 38 const scoped_refptr<LocalActivityResolver>& activity_resolver) | 33 const scoped_refptr<LocalActivityResolver>& activity_resolver) |
| 39 : ArcService(bridge_service), | 34 : ArcService(bridge_service), |
| 40 binding_(this), | 35 binding_(this), |
| 41 icon_loader_(icon_loader), | 36 icon_loader_(icon_loader), |
| 42 activity_resolver_(activity_resolver) { | 37 activity_resolver_(activity_resolver) { |
| 43 DCHECK(thread_checker_.CalledOnValidThread()); | 38 DCHECK(thread_checker_.CalledOnValidThread()); |
| 44 arc_bridge_service()->intent_helper()->AddObserver(this); | 39 arc_bridge_service()->intent_helper()->AddObserver(this); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 DCHECK(thread_checker_.CalledOnValidThread()); | 75 DCHECK(thread_checker_.CalledOnValidThread()); |
| 81 GURL gurl(url.get()); | 76 GURL gurl(url.get()); |
| 82 ash::WmShell::Get()->delegate()->OpenUrlFromArc(gurl); | 77 ash::WmShell::Get()->delegate()->OpenUrlFromArc(gurl); |
| 83 } | 78 } |
| 84 | 79 |
| 85 void ArcIntentHelperBridge::OpenWallpaperPicker() { | 80 void ArcIntentHelperBridge::OpenWallpaperPicker() { |
| 86 DCHECK(thread_checker_.CalledOnValidThread()); | 81 DCHECK(thread_checker_.CalledOnValidThread()); |
| 87 ash::WmShell::Get()->wallpaper_delegate()->OpenSetWallpaperPage(); | 82 ash::WmShell::Get()->wallpaper_delegate()->OpenSetWallpaperPage(); |
| 88 } | 83 } |
| 89 | 84 |
| 90 void ArcIntentHelperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) { | |
| 91 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 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()); | |
| 98 } | |
| 99 | |
| 100 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( | 85 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( |
| 101 const GURL& url) { | 86 const GURL& url) { |
| 102 DCHECK(thread_checker_.CalledOnValidThread()); | 87 DCHECK(thread_checker_.CalledOnValidThread()); |
| 103 std::unique_ptr<LinkHandlerModelImpl> impl( | 88 std::unique_ptr<LinkHandlerModelImpl> impl( |
| 104 new LinkHandlerModelImpl(icon_loader_)); | 89 new LinkHandlerModelImpl(icon_loader_)); |
| 105 if (!impl->Init(url)) | 90 if (!impl->Init(url)) |
| 106 return nullptr; | 91 return nullptr; |
| 107 return std::move(impl); | 92 return std::move(impl); |
| 108 } | 93 } |
| 109 | 94 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 126 return handlers_filtered; | 111 return handlers_filtered; |
| 127 } | 112 } |
| 128 | 113 |
| 129 void ArcIntentHelperBridge::OnIntentFiltersUpdated( | 114 void ArcIntentHelperBridge::OnIntentFiltersUpdated( |
| 130 mojo::Array<mojom::IntentFilterPtr> filters) { | 115 mojo::Array<mojom::IntentFilterPtr> filters) { |
| 131 DCHECK(thread_checker_.CalledOnValidThread()); | 116 DCHECK(thread_checker_.CalledOnValidThread()); |
| 132 activity_resolver_->UpdateIntentFilters(std::move(filters)); | 117 activity_resolver_->UpdateIntentFilters(std::move(filters)); |
| 133 } | 118 } |
| 134 | 119 |
| 135 } // namespace arc | 120 } // namespace arc |
| OLD | NEW |