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

Side by Side Diff: chrome/browser/chromeos/file_manager/arc_file_tasks.cc

Issue 2655233007: Get rid of RefCounted for ActivityIconLoader. (Closed)
Patch Set: Created 3 years, 10 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/chromeos/file_manager/arc_file_tasks.h" 5 #include "chrome/browser/chromeos/file_manager/arc_file_tasks.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 17 matching lines...) Expand all
28 #include "storage/browser/fileapi/file_system_url.h" 28 #include "storage/browser/fileapi/file_system_url.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 30
31 namespace file_manager { 31 namespace file_manager {
32 namespace file_tasks { 32 namespace file_tasks {
33 33
34 namespace { 34 namespace {
35 35
36 constexpr char kAppIdSeparator = '/'; 36 constexpr char kAppIdSeparator = '/';
37 37
38 // Returns the icon loader that wraps the Mojo interface for ARC Intent Helper.
39 scoped_refptr<arc::ActivityIconLoader> GetArcActivityIconLoader() {
40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
41
42 arc::ArcServiceManager* arc_service_manager = arc::ArcServiceManager::Get();
43 if (!arc_service_manager)
44 return nullptr;
45 return arc_service_manager->icon_loader();
46 }
47
48 // Converts an Android intent action (see kIntentAction* in 38 // Converts an Android intent action (see kIntentAction* in
49 // components/arc/intent_helper/intent_constants.h) to a file task action ID 39 // components/arc/intent_helper/intent_constants.h) to a file task action ID
50 // (see chrome/browser/chromeos/file_manager/file_tasks.h). 40 // (see chrome/browser/chromeos/file_manager/file_tasks.h).
51 std::string ArcActionToFileTaskActionId(const std::string& action) { 41 std::string ArcActionToFileTaskActionId(const std::string& action) {
52 if (action == arc::kIntentActionView) 42 if (action == arc::kIntentActionView)
53 return "view"; 43 return "view";
54 else if (action == arc::kIntentActionSend) 44 else if (action == arc::kIntentActionSend)
55 return "send"; 45 return "send";
56 else if (action == arc::kIntentActionSendMultiple) 46 else if (action == arc::kIntentActionSendMultiple)
57 return "send_multiple"; 47 return "send_multiple";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 std::vector<arc::mojom::IntentHandlerInfoPtr> handlers, 94 std::vector<arc::mojom::IntentHandlerInfoPtr> handlers,
105 std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons); 95 std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons);
106 96
107 // Called after the handlers from ARC is obtained. Proceeds to OnArcIconLoaded. 97 // Called after the handlers from ARC is obtained. Proceeds to OnArcIconLoaded.
108 void OnArcHandlerList( 98 void OnArcHandlerList(
109 std::unique_ptr<std::vector<FullTaskDescriptor>> result_list, 99 std::unique_ptr<std::vector<FullTaskDescriptor>> result_list,
110 const FindTasksCallback& callback, 100 const FindTasksCallback& callback,
111 std::vector<arc::mojom::IntentHandlerInfoPtr> handlers) { 101 std::vector<arc::mojom::IntentHandlerInfoPtr> handlers) {
112 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 102 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
113 103
114 scoped_refptr<arc::ActivityIconLoader> icon_loader = 104 auto* intent_helper_bridge =
115 GetArcActivityIconLoader(); 105 arc::ArcServiceManager::GetGlobalService<arc::ArcIntentHelperBridge>();
116 if (!icon_loader) { 106 if (!intent_helper_bridge) {
117 callback.Run(std::move(result_list)); 107 callback.Run(std::move(result_list));
118 return; 108 return;
119 } 109 }
120 110
121 std::vector<arc::mojom::IntentHandlerInfoPtr> handlers_filtered = 111 std::vector<arc::mojom::IntentHandlerInfoPtr> handlers_filtered =
122 arc::ArcIntentHelperBridge::FilterOutIntentHelper(std::move(handlers)); 112 arc::ArcIntentHelperBridge::FilterOutIntentHelper(std::move(handlers));
123 std::vector<arc::ActivityIconLoader::ActivityName> activity_names; 113 std::vector<arc::ActivityIconLoader::ActivityName> activity_names;
124 for (const arc::mojom::IntentHandlerInfoPtr& handler : handlers_filtered) 114 for (const arc::mojom::IntentHandlerInfoPtr& handler : handlers_filtered)
125 activity_names.emplace_back(handler->package_name, handler->activity_name); 115 activity_names.emplace_back(handler->package_name, handler->activity_name);
126 116
127 icon_loader->GetActivityIcons( 117 intent_helper_bridge->icon_loader()->GetActivityIcons(
128 activity_names, base::Bind(&OnArcIconLoaded, base::Passed(&result_list), 118 activity_names, base::Bind(&OnArcIconLoaded, base::Passed(&result_list),
129 callback, base::Passed(&handlers_filtered))); 119 callback, base::Passed(&handlers_filtered)));
130 } 120 }
131 121
132 // Called after icon data for ARC apps are loaded. Proceeds to OnArcIconEncoded. 122 // Called after icon data for ARC apps are loaded. Proceeds to OnArcIconEncoded.
133 void OnArcIconLoaded( 123 void OnArcIconLoaded(
134 std::unique_ptr<std::vector<FullTaskDescriptor>> result_list, 124 std::unique_ptr<std::vector<FullTaskDescriptor>> result_list,
135 const FindTasksCallback& callback, 125 const FindTasksCallback& callback,
136 std::vector<arc::mojom::IntentHandlerInfoPtr> handlers, 126 std::vector<arc::mojom::IntentHandlerInfoPtr> handlers,
137 std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons) { 127 std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 236 }
247 237
248 arc_intent_helper->HandleUrlList( 238 arc_intent_helper->HandleUrlList(
249 std::move(urls), AppIdToActivityName(task.app_id), 239 std::move(urls), AppIdToActivityName(task.app_id),
250 FileTaskActionIdToArcActionType(task.action_id)); 240 FileTaskActionIdToArcActionType(task.action_id));
251 return true; 241 return true;
252 } 242 }
253 243
254 } // namespace file_tasks 244 } // namespace file_tasks
255 } // namespace file_manager 245 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698