Index: chrome/browser/chromeos/file_manager/arc_file_tasks.cc |
diff --git a/chrome/browser/chromeos/file_manager/arc_file_tasks.cc b/chrome/browser/chromeos/file_manager/arc_file_tasks.cc |
index 4ed9976320a66526a78863a9e3237ec1268bc220..892ff327a3ea34dc28be6468bf1323ec739fc402 100644 |
--- a/chrome/browser/chromeos/file_manager/arc_file_tasks.cc |
+++ b/chrome/browser/chromeos/file_manager/arc_file_tasks.cc |
@@ -24,6 +24,7 @@ |
#include "components/arc/common/intent_helper.mojom.h" |
#include "components/arc/intent_helper/activity_icon_loader.h" |
#include "components/arc/intent_helper/arc_intent_helper_bridge.h" |
+#include "components/arc/intent_helper/intent_constants.h" |
#include "components/user_manager/user_manager.h" |
#include "content/public/browser/browser_thread.h" |
#include "extensions/browser/entry_info.h" |
@@ -75,27 +76,31 @@ scoped_refptr<arc::ActivityIconLoader> GetArcActivityIconLoader() { |
return arc_service_manager->icon_loader(); |
} |
-std::string ArcActionTypeToString(arc::mojom::ActionType action_type) { |
- switch (action_type) { |
- case arc::mojom::ActionType::VIEW: |
- return "view"; |
- case arc::mojom::ActionType::SEND: |
- return "send"; |
- case arc::mojom::ActionType::SEND_MULTIPLE: |
- return "send_multiple"; |
- } |
- NOTREACHED(); |
+// Converts an Android intent action (see kIntentAction* in |
+// components/arc/intent_helper/intent_constants.h) to a file task action ID |
+// (see chrome/browser/chromeos/file_manager/file_tasks.h). |
+std::string ArcActionToFileTaskActionId(const std::string& action) { |
+ if (action == arc::kIntentActionView) |
+ return "view"; |
+ else if (action == arc::kIntentActionSend) |
+ return "send"; |
+ else if (action == arc::kIntentActionSendMultiple) |
+ return "send_multiple"; |
+ NOTREACHED() << "Unhandled ARC action \"" << action << "\""; |
return ""; |
} |
-arc::mojom::ActionType StringToArcActionType(const std::string& str) { |
- if (str == "view") |
+// TODO(derat): Replace this with a FileTaskActionIdToArcAction method once |
+// HandleUrlList has been updated to take a string action rather than an |
+// ArcActionType. |
+arc::mojom::ActionType FileTaskActionIdToArcActionType(const std::string& id) { |
+ if (id == "view") |
return arc::mojom::ActionType::VIEW; |
- if (str == "send") |
+ if (id == "send") |
return arc::mojom::ActionType::SEND; |
- if (str == "send_multiple") |
+ if (id == "send_multiple") |
return arc::mojom::ActionType::SEND_MULTIPLE; |
- NOTREACHED(); |
+ NOTREACHED() << "Unhandled file task action ID \"" << id << "\""; |
return arc::mojom::ActionType::VIEW; |
} |
@@ -253,8 +258,8 @@ void OnArcIconEncoded( |
for (const arc::mojom::IntentHandlerInfoPtr& handler : handlers) { |
std::string name(handler->name); |
Verb handler_verb = Verb::VERB_NONE; |
- if (handler->action_type == arc::mojom::ActionType::SEND || |
- handler->action_type == arc::mojom::ActionType::SEND_MULTIPLE) { |
+ if (handler->action == arc::kIntentActionSend || |
+ handler->action == arc::kIntentActionSendMultiple) { |
handler_verb = Verb::VERB_SHARE_WITH; |
} |
const GURL& icon_url = (*icons)[arc::ActivityIconLoader::ActivityName( |
@@ -262,9 +267,9 @@ void OnArcIconEncoded( |
result_list->push_back(FullTaskDescriptor( |
TaskDescriptor( |
ActivityNameToAppId(handler->package_name, handler->activity_name), |
- TASK_TYPE_ARC_APP, ArcActionTypeToString(handler->action_type)), |
+ TASK_TYPE_ARC_APP, ArcActionToFileTaskActionId(handler->action)), |
name, handler_verb, icon_url, false /* is_default */, |
- handler->action_type != arc::mojom::ActionType::VIEW /* is_generic */)); |
+ handler->action != arc::kIntentActionView /* is_generic */)); |
} |
callback.Run(std::move(result_list)); |
} |
@@ -337,9 +342,9 @@ bool ExecuteArcTask(Profile* profile, |
urls.push_back(std::move(url_with_type)); |
} |
- arc_intent_helper->HandleUrlList(std::move(urls), |
- AppIdToActivityName(task.app_id), |
- StringToArcActionType(task.action_id)); |
+ arc_intent_helper->HandleUrlList( |
+ std::move(urls), AppIdToActivityName(task.app_id), |
+ FileTaskActionIdToArcActionType(task.action_id)); |
return true; |
} |