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 @@
#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;
}
......
......@@ -42,6 +42,8 @@ static_library("arc") {
"intent_helper/arc_intent_helper_bridge.h",
"intent_helper/font_size_util.cc",
"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.h",
"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