Commit 76b5a10e authored by derat's avatar derat Committed by Commit bot

chromeos: Update ARC file task code to use action strings.

Make arc_file_tasks.cc use the IntentHandlerInfo struct's
string "action" field rather than the ActionType enum.
ActionTypes are still used when calling HandleUrlList.

BUG=647802
TEST=manual: still able to launch ARC apps for individual
     files or send multiple files from files app

Review-Url: https://codereview.chromium.org/2398063003
Cr-Commit-Position: refs/heads/master@{#423797}
parent 44adf07a
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "components/arc/common/intent_helper.mojom.h" #include "components/arc/common/intent_helper.mojom.h"
#include "components/arc/intent_helper/activity_icon_loader.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/arc_intent_helper_bridge.h"
#include "components/arc/intent_helper/intent_constants.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "extensions/browser/entry_info.h" #include "extensions/browser/entry_info.h"
...@@ -75,27 +76,31 @@ scoped_refptr<arc::ActivityIconLoader> GetArcActivityIconLoader() { ...@@ -75,27 +76,31 @@ scoped_refptr<arc::ActivityIconLoader> GetArcActivityIconLoader() {
return arc_service_manager->icon_loader(); return arc_service_manager->icon_loader();
} }
std::string ArcActionTypeToString(arc::mojom::ActionType action_type) { // Converts an Android intent action (see kIntentAction* in
switch (action_type) { // components/arc/intent_helper/intent_constants.h) to a file task action ID
case arc::mojom::ActionType::VIEW: // (see chrome/browser/chromeos/file_manager/file_tasks.h).
return "view"; std::string ArcActionToFileTaskActionId(const std::string& action) {
case arc::mojom::ActionType::SEND: if (action == arc::kIntentActionView)
return "send"; return "view";
case arc::mojom::ActionType::SEND_MULTIPLE: else if (action == arc::kIntentActionSend)
return "send_multiple"; return "send";
} else if (action == arc::kIntentActionSendMultiple)
NOTREACHED(); return "send_multiple";
NOTREACHED() << "Unhandled ARC action \"" << action << "\"";
return ""; return "";
} }
arc::mojom::ActionType StringToArcActionType(const std::string& str) { // TODO(derat): Replace this with a FileTaskActionIdToArcAction method once
if (str == "view") // 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; return arc::mojom::ActionType::VIEW;
if (str == "send") if (id == "send")
return arc::mojom::ActionType::SEND; return arc::mojom::ActionType::SEND;
if (str == "send_multiple") if (id == "send_multiple")
return arc::mojom::ActionType::SEND_MULTIPLE; return arc::mojom::ActionType::SEND_MULTIPLE;
NOTREACHED(); NOTREACHED() << "Unhandled file task action ID \"" << id << "\"";
return arc::mojom::ActionType::VIEW; return arc::mojom::ActionType::VIEW;
} }
...@@ -253,8 +258,8 @@ void OnArcIconEncoded( ...@@ -253,8 +258,8 @@ void OnArcIconEncoded(
for (const arc::mojom::IntentHandlerInfoPtr& handler : handlers) { for (const arc::mojom::IntentHandlerInfoPtr& handler : handlers) {
std::string name(handler->name); std::string name(handler->name);
Verb handler_verb = Verb::VERB_NONE; Verb handler_verb = Verb::VERB_NONE;
if (handler->action_type == arc::mojom::ActionType::SEND || if (handler->action == arc::kIntentActionSend ||
handler->action_type == arc::mojom::ActionType::SEND_MULTIPLE) { handler->action == arc::kIntentActionSendMultiple) {
handler_verb = Verb::VERB_SHARE_WITH; handler_verb = Verb::VERB_SHARE_WITH;
} }
const GURL& icon_url = (*icons)[arc::ActivityIconLoader::ActivityName( const GURL& icon_url = (*icons)[arc::ActivityIconLoader::ActivityName(
...@@ -262,9 +267,9 @@ void OnArcIconEncoded( ...@@ -262,9 +267,9 @@ void OnArcIconEncoded(
result_list->push_back(FullTaskDescriptor( result_list->push_back(FullTaskDescriptor(
TaskDescriptor( TaskDescriptor(
ActivityNameToAppId(handler->package_name, handler->activity_name), 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 */, 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)); callback.Run(std::move(result_list));
} }
...@@ -337,9 +342,9 @@ bool ExecuteArcTask(Profile* profile, ...@@ -337,9 +342,9 @@ bool ExecuteArcTask(Profile* profile,
urls.push_back(std::move(url_with_type)); urls.push_back(std::move(url_with_type));
} }
arc_intent_helper->HandleUrlList(std::move(urls), arc_intent_helper->HandleUrlList(
AppIdToActivityName(task.app_id), std::move(urls), AppIdToActivityName(task.app_id),
StringToArcActionType(task.action_id)); FileTaskActionIdToArcActionType(task.action_id));
return true; return true;
} }
......
...@@ -42,6 +42,8 @@ static_library("arc") { ...@@ -42,6 +42,8 @@ static_library("arc") {
"intent_helper/arc_intent_helper_bridge.h", "intent_helper/arc_intent_helper_bridge.h",
"intent_helper/font_size_util.cc", "intent_helper/font_size_util.cc",
"intent_helper/font_size_util.h", "intent_helper/font_size_util.h",
"intent_helper/intent_constants.cc",
"intent_helper/intent_constants.h",
"intent_helper/intent_filter.cc", "intent_helper/intent_filter.cc",
"intent_helper/intent_filter.h", "intent_helper/intent_filter.h",
"intent_helper/link_handler_model_impl.cc", "intent_helper/link_handler_model_impl.cc",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/arc/intent_helper/intent_constants.h"
namespace arc {
const char kIntentActionView[] = "android.intent.action.VIEW";
const char kIntentActionSend[] = "android.intent.action.SEND";
const char kIntentActionSendMultiple[] = "android.intent.action.SEND_MULTIPLE";
} // namespace arc
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_ARC_INTENT_HELPER_INTENT_CONSTANTS_H_
#define COMPONENTS_ARC_INTENT_HELPER_INTENT_CONSTANTS_H_
namespace arc {
// Well-known Android intent actions, e.g. "android.intent.action.VIEW"
// (corresponding to Android's android.content.Intent.ACTION_VIEW constant).
extern const char kIntentActionView[];
extern const char kIntentActionSend[];
extern const char kIntentActionSendMultiple[];
} // namespace arc
#endif // COMPONENTS_ARC_INTENT_HELPER_INTENT_CONSTANTS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment