| 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 | 8 |
| 9 #include "ash/common/new_window_controller.h" | 9 #include "ash/common/new_window_controller.h" |
| 10 #include "ash/common/shell_delegate.h" | 10 #include "ash/common/shell_delegate.h" |
| 11 #include "ash/common/wallpaper/wallpaper_controller.h" | 11 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "components/arc/arc_bridge_service.h" | 16 #include "components/arc/arc_bridge_service.h" |
| 17 #include "components/arc/arc_service_manager.h" | 17 #include "components/arc/arc_service_manager.h" |
| 18 #include "components/arc/intent_helper/activity_icon_loader.h" | |
| 19 #include "components/arc/intent_helper/link_handler_model_impl.h" | 18 #include "components/arc/intent_helper/link_handler_model_impl.h" |
| 20 #include "components/arc/intent_helper/local_activity_resolver.h" | 19 #include "components/arc/intent_helper/local_activity_resolver.h" |
| 21 #include "ui/base/layout.h" | 20 #include "ui/base/layout.h" |
| 22 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 23 | 22 |
| 24 namespace arc { | 23 namespace arc { |
| 25 | 24 |
| 26 // static | 25 // static |
| 27 const char ArcIntentHelperBridge::kArcServiceName[] = | 26 const char ArcIntentHelperBridge::kArcServiceName[] = |
| 28 "arc::ArcIntentHelperBridge"; | 27 "arc::ArcIntentHelperBridge"; |
| 29 | 28 |
| 30 // static | 29 // static |
| 31 const char ArcIntentHelperBridge::kArcIntentHelperPackageName[] = | 30 const char ArcIntentHelperBridge::kArcIntentHelperPackageName[] = |
| 32 "org.chromium.arc.intent_helper"; | 31 "org.chromium.arc.intent_helper"; |
| 33 | 32 |
| 34 ArcIntentHelperBridge::ArcIntentHelperBridge( | 33 ArcIntentHelperBridge::ArcIntentHelperBridge( |
| 35 ArcBridgeService* bridge_service, | 34 ArcBridgeService* bridge_service, |
| 36 const scoped_refptr<ActivityIconLoader>& icon_loader, | |
| 37 const scoped_refptr<LocalActivityResolver>& activity_resolver) | 35 const scoped_refptr<LocalActivityResolver>& activity_resolver) |
| 38 : ArcService(bridge_service), | 36 : ArcService(bridge_service), |
| 39 binding_(this), | 37 binding_(this), |
| 40 icon_loader_(icon_loader), | |
| 41 activity_resolver_(activity_resolver) { | 38 activity_resolver_(activity_resolver) { |
| 42 DCHECK(thread_checker_.CalledOnValidThread()); | 39 DCHECK(thread_checker_.CalledOnValidThread()); |
| 43 arc_bridge_service()->intent_helper()->AddObserver(this); | 40 arc_bridge_service()->intent_helper()->AddObserver(this); |
| 44 } | 41 } |
| 45 | 42 |
| 46 ArcIntentHelperBridge::~ArcIntentHelperBridge() { | 43 ArcIntentHelperBridge::~ArcIntentHelperBridge() { |
| 47 DCHECK(thread_checker_.CalledOnValidThread()); | 44 DCHECK(thread_checker_.CalledOnValidThread()); |
| 48 arc_bridge_service()->intent_helper()->RemoveObserver(this); | 45 arc_bridge_service()->intent_helper()->RemoveObserver(this); |
| 49 } | 46 } |
| 50 | 47 |
| 51 void ArcIntentHelperBridge::OnInstanceReady() { | 48 void ArcIntentHelperBridge::OnInstanceReady() { |
| 52 DCHECK(thread_checker_.CalledOnValidThread()); | 49 DCHECK(thread_checker_.CalledOnValidThread()); |
| 53 ash::Shell::GetInstance()->set_link_handler_model_factory(this); | 50 ash::Shell::GetInstance()->set_link_handler_model_factory(this); |
| 54 auto* instance = | 51 auto* instance = |
| 55 ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->intent_helper(), Init); | 52 ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->intent_helper(), Init); |
| 56 DCHECK(instance); | 53 DCHECK(instance); |
| 57 instance->Init(binding_.CreateInterfacePtrAndBind()); | 54 instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 58 } | 55 } |
| 59 | 56 |
| 60 void ArcIntentHelperBridge::OnInstanceClosed() { | 57 void ArcIntentHelperBridge::OnInstanceClosed() { |
| 61 DCHECK(thread_checker_.CalledOnValidThread()); | 58 DCHECK(thread_checker_.CalledOnValidThread()); |
| 62 ash::Shell::GetInstance()->set_link_handler_model_factory(nullptr); | 59 ash::Shell::GetInstance()->set_link_handler_model_factory(nullptr); |
| 63 } | 60 } |
| 64 | 61 |
| 65 void ArcIntentHelperBridge::OnIconInvalidated(const std::string& package_name) { | 62 void ArcIntentHelperBridge::OnIconInvalidated(const std::string& package_name) { |
| 66 DCHECK(thread_checker_.CalledOnValidThread()); | 63 DCHECK(thread_checker_.CalledOnValidThread()); |
| 67 icon_loader_->InvalidateIcons(package_name); | 64 |
| 65 icon_loader_.InvalidateIcons(package_name); |
| 68 } | 66 } |
| 69 | 67 |
| 70 void ArcIntentHelperBridge::OnOpenDownloads() { | 68 void ArcIntentHelperBridge::OnOpenDownloads() { |
| 71 DCHECK(thread_checker_.CalledOnValidThread()); | 69 DCHECK(thread_checker_.CalledOnValidThread()); |
| 72 // TODO(607411): If the FileManager is not yet open this will open to | 70 // TODO(607411): If the FileManager is not yet open this will open to |
| 73 // downloads by default, which is what we want. However if it is open it will | 71 // downloads by default, which is what we want. However if it is open it will |
| 74 // simply be brought to the forgeground without forcibly being navigated to | 72 // simply be brought to the forgeground without forcibly being navigated to |
| 75 // downloads, which is probably not ideal. | 73 // downloads, which is probably not ideal. |
| 76 ash::WmShell::Get()->new_window_controller()->OpenFileManager(); | 74 ash::WmShell::Get()->new_window_controller()->OpenFileManager(); |
| 77 } | 75 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 96 observer_list_.AddObserver(observer); | 94 observer_list_.AddObserver(observer); |
| 97 } | 95 } |
| 98 | 96 |
| 99 void ArcIntentHelperBridge::RemoveObserver(ArcIntentHelperObserver* observer) { | 97 void ArcIntentHelperBridge::RemoveObserver(ArcIntentHelperObserver* observer) { |
| 100 observer_list_.RemoveObserver(observer); | 98 observer_list_.RemoveObserver(observer); |
| 101 } | 99 } |
| 102 | 100 |
| 103 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( | 101 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( |
| 104 const GURL& url) { | 102 const GURL& url) { |
| 105 DCHECK(thread_checker_.CalledOnValidThread()); | 103 DCHECK(thread_checker_.CalledOnValidThread()); |
| 106 std::unique_ptr<LinkHandlerModelImpl> impl( | 104 auto impl = base::MakeUnique<LinkHandlerModelImpl>(); |
| 107 new LinkHandlerModelImpl(icon_loader_)); | |
| 108 if (!impl->Init(url)) | 105 if (!impl->Init(url)) |
| 109 return nullptr; | 106 return nullptr; |
| 110 return std::move(impl); | 107 return std::move(impl); |
| 111 } | 108 } |
| 112 | 109 |
| 113 // static | 110 // static |
| 114 bool ArcIntentHelperBridge::IsIntentHelperPackage( | 111 bool ArcIntentHelperBridge::IsIntentHelperPackage( |
| 115 const std::string& package_name) { | 112 const std::string& package_name) { |
| 116 return package_name == kArcIntentHelperPackageName; | 113 return package_name == kArcIntentHelperPackageName; |
| 117 } | 114 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 void ArcIntentHelperBridge::OnIntentFiltersUpdated( | 157 void ArcIntentHelperBridge::OnIntentFiltersUpdated( |
| 161 std::vector<IntentFilter> filters) { | 158 std::vector<IntentFilter> filters) { |
| 162 DCHECK(thread_checker_.CalledOnValidThread()); | 159 DCHECK(thread_checker_.CalledOnValidThread()); |
| 163 activity_resolver_->UpdateIntentFilters(std::move(filters)); | 160 activity_resolver_->UpdateIntentFilters(std::move(filters)); |
| 164 | 161 |
| 165 for (auto& observer : observer_list_) | 162 for (auto& observer : observer_list_) |
| 166 observer.OnIntentFiltersUpdated(); | 163 observer.OnIntentFiltersUpdated(); |
| 167 } | 164 } |
| 168 | 165 |
| 169 } // namespace arc | 166 } // namespace arc |
| OLD | NEW |