Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: components/arc/intent_helper/arc_intent_helper_bridge.cc

Issue 2337193005: Consolidate 4 GetIntentHelper functions (Closed)
Patch Set: Address comments2 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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*
132 ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode(
133 int min_instance_version,
134 GetResult* out_error_code) {
135 ArcBridgeService* bridge_service = ArcBridgeService::Get();
136 if (!bridge_service) {
137 if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) {
138 VLOG(2) << "ARC bridge is not supported.";
139 if (out_error_code)
140 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
141 } else {
142 VLOG(2) << "ARC bridge is not ready.";
143 if (out_error_code)
144 *out_error_code = GetResult::FAILED_ARC_NOT_READY;
145 }
146 return nullptr;
147 }
148 mojom::IntentHelperInstance* intent_helper_instance =
149 bridge_service->intent_helper()->instance();
150 if (!intent_helper_instance) {
151 VLOG(2) << "ARC intent helper instance is not ready.";
152 if (out_error_code)
153 *out_error_code = GetResult::FAILED_ARC_NOT_READY;
154 return nullptr;
155 }
156 const int version = bridge_service->intent_helper()->version();
157 if (version < min_instance_version) {
158 VLOG(1) << "ARC intent helper instance is too old. required: "
159 << min_instance_version << ", actual: " << version;
160 if (out_error_code)
161 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
162 return nullptr;
163 }
164 return intent_helper_instance;
165 }
166
167 // static
168 mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance(
169 int min_instance_version) {
170 return GetIntentHelperInstanceWithErrorCode(min_instance_version, nullptr);
171 }
172
129 void ArcIntentHelperBridge::OnIntentFiltersUpdated( 173 void ArcIntentHelperBridge::OnIntentFiltersUpdated(
130 mojo::Array<mojom::IntentFilterPtr> filters) { 174 mojo::Array<mojom::IntentFilterPtr> filters) {
131 DCHECK(thread_checker_.CalledOnValidThread()); 175 DCHECK(thread_checker_.CalledOnValidThread());
132 activity_resolver_->UpdateIntentFilters(std::move(filters)); 176 activity_resolver_->UpdateIntentFilters(std::move(filters));
133 } 177 }
134 178
135 } // namespace arc 179 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/intent_helper/arc_intent_helper_bridge.h ('k') | components/arc/intent_helper/link_handler_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698