| 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 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 ArcIntentHelperBridge::~ArcIntentHelperBridge() { | 43 ArcIntentHelperBridge::~ArcIntentHelperBridge() { |
| 44 DCHECK(thread_checker_.CalledOnValidThread()); | 44 DCHECK(thread_checker_.CalledOnValidThread()); |
| 45 arc_bridge_service()->intent_helper()->RemoveObserver(this); | 45 arc_bridge_service()->intent_helper()->RemoveObserver(this); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void ArcIntentHelperBridge::OnInstanceReady() { | 48 void ArcIntentHelperBridge::OnInstanceReady() { |
| 49 DCHECK(thread_checker_.CalledOnValidThread()); | 49 DCHECK(thread_checker_.CalledOnValidThread()); |
| 50 ash::Shell::GetInstance()->set_link_handler_model_factory(this); | 50 ash::Shell::GetInstance()->set_link_handler_model_factory(this); |
| 51 arc_bridge_service()->intent_helper()->instance()->Init( | 51 auto* instance = |
| 52 binding_.CreateInterfacePtrAndBind()); | 52 arc_bridge_service()->intent_helper()->GetInstanceForMethod("Init"); |
| 53 CHECK(instance); |
| 54 instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 53 } | 55 } |
| 54 | 56 |
| 55 void ArcIntentHelperBridge::OnInstanceClosed() { | 57 void ArcIntentHelperBridge::OnInstanceClosed() { |
| 56 DCHECK(thread_checker_.CalledOnValidThread()); | 58 DCHECK(thread_checker_.CalledOnValidThread()); |
| 57 ash::Shell::GetInstance()->set_link_handler_model_factory(nullptr); | 59 ash::Shell::GetInstance()->set_link_handler_model_factory(nullptr); |
| 58 } | 60 } |
| 59 | 61 |
| 60 void ArcIntentHelperBridge::OnIconInvalidated( | 62 void ArcIntentHelperBridge::OnIconInvalidated( |
| 61 const mojo::String& package_name) { | 63 const mojo::String& package_name) { |
| 62 DCHECK(thread_checker_.CalledOnValidThread()); | 64 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 if (IsIntentHelperPackage(handler->package_name.get())) | 116 if (IsIntentHelperPackage(handler->package_name.get())) |
| 115 continue; | 117 continue; |
| 116 handlers_filtered.push_back(std::move(handler)); | 118 handlers_filtered.push_back(std::move(handler)); |
| 117 } | 119 } |
| 118 return handlers_filtered; | 120 return handlers_filtered; |
| 119 } | 121 } |
| 120 | 122 |
| 121 // static | 123 // static |
| 122 mojom::IntentHelperInstance* | 124 mojom::IntentHelperInstance* |
| 123 ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode( | 125 ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode( |
| 124 int min_instance_version, | 126 const std::string& method_name_for_logging, |
| 127 uint32_t min_instance_version, |
| 125 GetResult* out_error_code) { | 128 GetResult* out_error_code) { |
| 126 ArcBridgeService* bridge_service = ArcBridgeService::Get(); | 129 ArcBridgeService* bridge_service = ArcBridgeService::Get(); |
| 127 if (!bridge_service) { | 130 if (!bridge_service) { |
| 128 if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) { | 131 if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) { |
| 129 VLOG(2) << "ARC bridge is not supported."; | 132 VLOG(2) << "ARC bridge is not supported."; |
| 130 if (out_error_code) | 133 if (out_error_code) |
| 131 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED; | 134 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED; |
| 132 } else { | 135 } else { |
| 133 VLOG(2) << "ARC bridge is not ready."; | 136 VLOG(2) << "ARC bridge is not ready."; |
| 134 if (out_error_code) | 137 if (out_error_code) |
| 135 *out_error_code = GetResult::FAILED_ARC_NOT_READY; | 138 *out_error_code = GetResult::FAILED_ARC_NOT_READY; |
| 136 } | 139 } |
| 137 return nullptr; | 140 return nullptr; |
| 138 } | 141 } |
| 139 mojom::IntentHelperInstance* intent_helper_instance = | 142 |
| 140 bridge_service->intent_helper()->instance(); | 143 if (!bridge_service->intent_helper()->has_instance()) { |
| 141 if (!intent_helper_instance) { | |
| 142 VLOG(2) << "ARC intent helper instance is not ready."; | 144 VLOG(2) << "ARC intent helper instance is not ready."; |
| 143 if (out_error_code) | 145 if (out_error_code) |
| 144 *out_error_code = GetResult::FAILED_ARC_NOT_READY; | 146 *out_error_code = GetResult::FAILED_ARC_NOT_READY; |
| 145 return nullptr; | 147 return nullptr; |
| 146 } | 148 } |
| 147 const int version = bridge_service->intent_helper()->version(); | 149 |
| 148 if (version < min_instance_version) { | 150 auto* instance = bridge_service->intent_helper()->GetInstanceForMethod( |
| 149 VLOG(1) << "ARC intent helper instance is too old. required: " | 151 method_name_for_logging, min_instance_version); |
| 150 << min_instance_version << ", actual: " << version; | 152 if (!instance) { |
| 151 if (out_error_code) | 153 if (out_error_code) |
| 152 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED; | 154 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED; |
| 153 return nullptr; | 155 return nullptr; |
| 154 } | 156 } |
| 155 return intent_helper_instance; | 157 return instance; |
| 156 } | 158 } |
| 157 | 159 |
| 158 // static | 160 // static |
| 159 mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance( | 161 mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance( |
| 160 int min_instance_version) { | 162 const std::string& method_name_for_logging, |
| 161 return GetIntentHelperInstanceWithErrorCode(min_instance_version, nullptr); | 163 uint32_t min_instance_version) { |
| 164 return GetIntentHelperInstanceWithErrorCode(method_name_for_logging, |
| 165 min_instance_version, nullptr); |
| 162 } | 166 } |
| 163 | 167 |
| 164 void ArcIntentHelperBridge::OnIntentFiltersUpdated( | 168 void ArcIntentHelperBridge::OnIntentFiltersUpdated( |
| 165 mojo::Array<mojom::IntentFilterPtr> filters) { | 169 mojo::Array<mojom::IntentFilterPtr> filters) { |
| 166 DCHECK(thread_checker_.CalledOnValidThread()); | 170 DCHECK(thread_checker_.CalledOnValidThread()); |
| 167 activity_resolver_->UpdateIntentFilters(std::move(filters)); | 171 activity_resolver_->UpdateIntentFilters(std::move(filters)); |
| 168 } | 172 } |
| 169 | 173 |
| 170 } // namespace arc | 174 } // namespace arc |
| OLD | NEW |