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" |
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/command_line.h" | |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "components/arc/intent_helper/activity_icon_loader.h" | 17 #include "components/arc/intent_helper/activity_icon_loader.h" |
17 #include "components/arc/intent_helper/link_handler_model_impl.h" | 18 #include "components/arc/intent_helper/link_handler_model_impl.h" |
18 #include "components/arc/intent_helper/local_activity_resolver.h" | 19 #include "components/arc/intent_helper/local_activity_resolver.h" |
19 #include "components/arc/set_wallpaper_delegate.h" | 20 #include "components/arc/set_wallpaper_delegate.h" |
20 #include "ui/base/layout.h" | 21 #include "ui/base/layout.h" |
21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
22 | 23 |
23 namespace arc { | 24 namespace arc { |
24 | 25 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 mojo::Array<mojom::UrlHandlerInfoPtr> handlers) { | 120 mojo::Array<mojom::UrlHandlerInfoPtr> handlers) { |
120 mojo::Array<mojom::UrlHandlerInfoPtr> handlers_filtered; | 121 mojo::Array<mojom::UrlHandlerInfoPtr> handlers_filtered; |
121 for (auto& handler : handlers) { | 122 for (auto& handler : handlers) { |
122 if (IsIntentHelperPackage(handler->package_name.get())) | 123 if (IsIntentHelperPackage(handler->package_name.get())) |
123 continue; | 124 continue; |
124 handlers_filtered.push_back(std::move(handler)); | 125 handlers_filtered.push_back(std::move(handler)); |
125 } | 126 } |
126 return handlers_filtered; | 127 return handlers_filtered; |
127 } | 128 } |
128 | 129 |
130 // static | |
131 mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance( | |
132 int min_instance_version, | |
133 GetResult* out_error_code) { | |
134 if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) { | |
Luis Héctor Chávez
2016/09/14 21:09:12
Maybe only do this if |bridge_service| is nullptr.
Yusuke Sato
2016/09/14 21:21:49
Done.
| |
135 VLOG(2) << "ARC bridge is not supported."; | |
136 if (out_error_code) | |
137 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED; | |
138 return nullptr; | |
139 } | |
140 ArcBridgeService* bridge_service = ArcBridgeService::Get(); | |
141 if (!bridge_service) { | |
142 VLOG(2) << "ARC bridge is not ready."; | |
143 if (out_error_code) | |
144 *out_error_code = GetResult::FAILED_ARC_NOT_READY; | |
145 return nullptr; | |
146 } | |
147 mojom::IntentHelperInstance* intent_helper_instance = | |
148 bridge_service->intent_helper()->instance(); | |
149 if (!intent_helper_instance) { | |
150 VLOG(2) << "ARC intent helper instance is not ready."; | |
151 if (out_error_code) | |
152 *out_error_code = GetResult::FAILED_ARC_NOT_READY; | |
153 return nullptr; | |
154 } | |
155 const int version = bridge_service->intent_helper()->version(); | |
156 if (version < min_instance_version) { | |
157 VLOG(1) << "ARC intent helper instance is too old. required: " | |
158 << min_instance_version << ", actual: " << version; | |
159 if (out_error_code) | |
160 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED; | |
161 return nullptr; | |
162 } | |
163 return intent_helper_instance; | |
164 } | |
165 | |
166 // static | |
167 mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance( | |
168 int min_instance_version) { | |
169 return GetIntentHelperInstance(min_instance_version, nullptr); | |
170 } | |
171 | |
129 void ArcIntentHelperBridge::OnIntentFiltersUpdated( | 172 void ArcIntentHelperBridge::OnIntentFiltersUpdated( |
130 mojo::Array<mojom::IntentFilterPtr> filters) { | 173 mojo::Array<mojom::IntentFilterPtr> filters) { |
131 DCHECK(thread_checker_.CalledOnValidThread()); | 174 DCHECK(thread_checker_.CalledOnValidThread()); |
132 activity_resolver_->UpdateIntentFilters(std::move(filters)); | 175 activity_resolver_->UpdateIntentFilters(std::move(filters)); |
133 } | 176 } |
134 | 177 |
135 } // namespace arc | 178 } // namespace arc |
OLD | NEW |