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

Unified Diff: extensions/browser/api/app_runtime/app_runtime_api.cc

Issue 2212303003: Implement app launch changes for app runtime extension proposal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tool-screenshot
Patch Set: Initial upload Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/app_runtime/app_runtime_api.cc
diff --git a/extensions/browser/api/app_runtime/app_runtime_api.cc b/extensions/browser/api/app_runtime/app_runtime_api.cc
index 2b225df2f2f35628f5559423d10840d59fafbd0b..07e262018e90c617535e9cdf1382b206b4239972 100644
--- a/extensions/browser/api/app_runtime/app_runtime_api.cc
+++ b/extensions/browser/api/app_runtime/app_runtime_api.cc
@@ -29,6 +29,25 @@ namespace app_runtime = api::app_runtime;
namespace {
+// Converts an ActionType instance to an app_runtime::ActionType instance.
+app_runtime::ActionType MapActionType(ActionType action_type) {
+ switch (action_type) {
+ case ActionType::NEW_NOTE:
+ return app_runtime::ActionType::ACTION_TYPE_NEW_NOTE;
+ default:
+ return app_runtime::ActionType::ACTION_TYPE_NONE;
+ }
+}
+
+// Converts an ActionData instance to an app_runtime::ActionData instance.
+app_runtime::ActionData* BuildActionData(ActionData action_data) {
+ auto* data = new app_runtime::ActionData();
+
+ data->action_type = MapActionType(action_data.action_type);
+
+ return data;
+}
+
void DispatchOnEmbedRequestedEventImpl(
const std::string& extension_id,
std::unique_ptr<base::DictionaryValue> app_embedding_request_data,
@@ -116,6 +135,8 @@ app_runtime::LaunchSource getLaunchSourceEnum(
return app_runtime::LAUNCH_SOURCE_TEST;
case extensions::SOURCE_INSTALLED_NOTIFICATION:
return app_runtime::LAUNCH_SOURCE_INSTALLED_NOTIFICATION;
+ case extensions::SOURCE_ACTION:
+ return app_runtime::LAUNCH_SOURCE_ACTION;
default:
return app_runtime::LAUNCH_SOURCE_NONE;
@@ -217,4 +238,18 @@ void AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl(
launch_data.ToValue(), context);
}
+// static
+void AppRuntimeEventRouter::DispatchOnLaunchedEventWithAction(
+ content::BrowserContext* context,
+ const Extension* extension,
+ ActionData action_data) {
+ app_runtime::LaunchSource source_enum = app_runtime::LAUNCH_SOURCE_ACTION;
+
+ app_runtime::LaunchData launch_data;
+ launch_data.action_data.reset(BuildActionData(action_data));
Daniel Erat 2016/08/05 23:36:45 does the action_data member end up being a unique_
jdufault 2016/08/10 22:01:17 Done.
+
+ DispatchOnLaunchedEventImpl(extension->id(), source_enum,
+ launch_data.ToValue(), context);
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698