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

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

Issue 2614173002: Use ARC_GET_INSTANCE_FOR_METHOD for getting intent_helper instance (Closed)
Patch Set: review Created 3 years, 11 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 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"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 std::vector<mojom::IntentHandlerInfoPtr> handlers_filtered; 119 std::vector<mojom::IntentHandlerInfoPtr> handlers_filtered;
120 for (auto& handler : handlers) { 120 for (auto& handler : handlers) {
121 if (IsIntentHelperPackage(handler->package_name)) 121 if (IsIntentHelperPackage(handler->package_name))
122 continue; 122 continue;
123 handlers_filtered.push_back(std::move(handler)); 123 handlers_filtered.push_back(std::move(handler));
124 } 124 }
125 return handlers_filtered; 125 return handlers_filtered;
126 } 126 }
127 127
128 // static 128 // static
129 mojom::IntentHelperInstance* 129 bool ArcIntentHelperBridge::IsIntentHelperAvailable(GetResult* out_error_code) {
130 ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode(
131 const std::string& method_name_for_logging,
132 uint32_t min_instance_version,
133 GetResult* out_error_code) {
134 auto* arc_service_manager = ArcServiceManager::Get(); 130 auto* arc_service_manager = ArcServiceManager::Get();
135 if (!arc_service_manager) { 131 if (!arc_service_manager) {
136 if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) { 132 if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) {
137 VLOG(2) << "ARC bridge is not supported."; 133 VLOG(2) << "ARC bridge is not supported.";
138 if (out_error_code) 134 if (out_error_code)
139 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED; 135 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
140 } else { 136 } else {
141 VLOG(2) << "ARC bridge is not ready."; 137 VLOG(2) << "ARC bridge is not ready.";
142 if (out_error_code) 138 if (out_error_code)
143 *out_error_code = GetResult::FAILED_ARC_NOT_READY; 139 *out_error_code = GetResult::FAILED_ARC_NOT_READY;
144 } 140 }
145 return nullptr; 141 return false;
146 } 142 }
147 143
148 auto* intent_helper_holder = 144 auto* intent_helper_holder =
149 arc_service_manager->arc_bridge_service()->intent_helper(); 145 arc_service_manager->arc_bridge_service()->intent_helper();
150 if (!intent_helper_holder->has_instance()) { 146 if (!intent_helper_holder->has_instance()) {
151 VLOG(2) << "ARC intent helper instance is not ready."; 147 VLOG(2) << "ARC intent helper instance is not ready.";
152 if (out_error_code) 148 if (out_error_code)
153 *out_error_code = GetResult::FAILED_ARC_NOT_READY; 149 *out_error_code = GetResult::FAILED_ARC_NOT_READY;
154 return nullptr; 150 return false;
155 } 151 }
156 152
157 // TODO(lhchavez): Stop calling GetInstanceForVersion() directly. 153 return true;
158 auto* instance = intent_helper_holder->GetInstanceForVersion(
159 min_instance_version, method_name_for_logging.c_str());
160 if (!instance) {
161 if (out_error_code)
162 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
163 return nullptr;
164 }
165 return instance;
166 }
167
168 // static
169 mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance(
170 const std::string& method_name_for_logging,
171 uint32_t min_instance_version) {
172 return GetIntentHelperInstanceWithErrorCode(method_name_for_logging,
173 min_instance_version, nullptr);
174 } 154 }
175 155
176 void ArcIntentHelperBridge::OnIntentFiltersUpdated( 156 void ArcIntentHelperBridge::OnIntentFiltersUpdated(
177 std::vector<IntentFilter> filters) { 157 std::vector<IntentFilter> filters) {
178 DCHECK(thread_checker_.CalledOnValidThread()); 158 DCHECK(thread_checker_.CalledOnValidThread());
179 activity_resolver_->UpdateIntentFilters(std::move(filters)); 159 activity_resolver_->UpdateIntentFilters(std::move(filters));
180 160
181 for (auto& observer : observer_list_) 161 for (auto& observer : observer_list_)
182 observer.OnIntentFiltersUpdated(); 162 observer.OnIntentFiltersUpdated();
183 } 163 }
184 164
185 } // namespace arc 165 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698