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

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

Issue 2557513004: Remove explicit singletonness of ArcBridgeService part 3. (Closed)
Patch Set: Created 4 years 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/shell_delegate.h" 9 #include "ash/common/shell_delegate.h"
10 #include "ash/common/wallpaper/wallpaper_controller.h" 10 #include "ash/common/wallpaper/wallpaper_controller.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/public/interfaces/new_window.mojom.h" 12 #include "ash/public/interfaces/new_window.mojom.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/intent_helper/activity_icon_loader.h" 18 #include "components/arc/intent_helper/activity_icon_loader.h"
18 #include "components/arc/intent_helper/link_handler_model_impl.h" 19 #include "components/arc/intent_helper/link_handler_model_impl.h"
19 #include "components/arc/intent_helper/local_activity_resolver.h" 20 #include "components/arc/intent_helper/local_activity_resolver.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
25 // static 26 // static
26 const char ArcIntentHelperBridge::kArcIntentHelperPackageName[] = 27 const char ArcIntentHelperBridge::kArcIntentHelperPackageName[] =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 124 }
124 return handlers_filtered; 125 return handlers_filtered;
125 } 126 }
126 127
127 // static 128 // static
128 mojom::IntentHelperInstance* 129 mojom::IntentHelperInstance*
129 ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode( 130 ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode(
130 const std::string& method_name_for_logging, 131 const std::string& method_name_for_logging,
131 uint32_t min_instance_version, 132 uint32_t min_instance_version,
132 GetResult* out_error_code) { 133 GetResult* out_error_code) {
133 ArcBridgeService* bridge_service = ArcBridgeService::Get(); 134 auto* arc_service_manager = ArcServiceManager::Get();
134 if (!bridge_service) { 135 if (!arc_service_manager) {
135 if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) { 136 if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) {
136 VLOG(2) << "ARC bridge is not supported."; 137 VLOG(2) << "ARC bridge is not supported.";
137 if (out_error_code) 138 if (out_error_code)
138 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED; 139 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
139 } else { 140 } else {
140 VLOG(2) << "ARC bridge is not ready."; 141 VLOG(2) << "ARC bridge is not ready.";
141 if (out_error_code) 142 if (out_error_code)
142 *out_error_code = GetResult::FAILED_ARC_NOT_READY; 143 *out_error_code = GetResult::FAILED_ARC_NOT_READY;
143 } 144 }
144 return nullptr; 145 return nullptr;
145 } 146 }
146 147
147 if (!bridge_service->intent_helper()->has_instance()) { 148 auto* intent_helper =
Luis Héctor Chávez 2016/12/06 18:55:00 nit: maybe intent_helper_holder? instance_holder?
hidehiko 2016/12/06 19:11:28 Thank you for suggestion. Replaced by intent_helpe
149 arc_service_manager->arc_bridge_service()->intent_helper();
150 if (!intent_helper->has_instance()) {
148 VLOG(2) << "ARC intent helper instance is not ready."; 151 VLOG(2) << "ARC intent helper instance is not ready.";
149 if (out_error_code) 152 if (out_error_code)
150 *out_error_code = GetResult::FAILED_ARC_NOT_READY; 153 *out_error_code = GetResult::FAILED_ARC_NOT_READY;
151 return nullptr; 154 return nullptr;
152 } 155 }
153 156
154 auto* instance = bridge_service->intent_helper()->GetInstanceForMethod( 157 auto* instance = intent_helper->GetInstanceForMethod(method_name_for_logging,
155 method_name_for_logging, min_instance_version); 158 min_instance_version);
156 if (!instance) { 159 if (!instance) {
157 if (out_error_code) 160 if (out_error_code)
158 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED; 161 *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
159 return nullptr; 162 return nullptr;
160 } 163 }
161 return instance; 164 return instance;
162 } 165 }
163 166
164 // static 167 // static
165 mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance( 168 mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance(
166 const std::string& method_name_for_logging, 169 const std::string& method_name_for_logging,
167 uint32_t min_instance_version) { 170 uint32_t min_instance_version) {
168 return GetIntentHelperInstanceWithErrorCode(method_name_for_logging, 171 return GetIntentHelperInstanceWithErrorCode(method_name_for_logging,
169 min_instance_version, nullptr); 172 min_instance_version, nullptr);
170 } 173 }
171 174
172 void ArcIntentHelperBridge::OnIntentFiltersUpdated( 175 void ArcIntentHelperBridge::OnIntentFiltersUpdated(
173 std::vector<mojom::IntentFilterPtr> filters) { 176 std::vector<mojom::IntentFilterPtr> filters) {
174 DCHECK(thread_checker_.CalledOnValidThread()); 177 DCHECK(thread_checker_.CalledOnValidThread());
175 activity_resolver_->UpdateIntentFilters(std::move(filters)); 178 activity_resolver_->UpdateIntentFilters(std::move(filters));
176 179
177 for (auto& observer : observer_list_) 180 for (auto& observer : observer_list_)
178 observer.OnAppsUpdated(); 181 observer.OnAppsUpdated();
179 } 182 }
180 183
181 } // namespace arc 184 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698