Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/app_runtime/app_runtime_api.h" | 5 #include "extensions/browser/api/app_runtime/app_runtime_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 | 23 |
| 24 using content::BrowserContext; | 24 using content::BrowserContext; |
| 25 | 25 |
| 26 namespace extensions { | 26 namespace extensions { |
| 27 | 27 |
| 28 namespace app_runtime = api::app_runtime; | 28 namespace app_runtime = api::app_runtime; |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 // Converts an ActionType instance to an app_runtime::ActionType instance. | |
| 33 app_runtime::ActionType MapActionType(ActionType action_type) { | |
| 34 switch (action_type) { | |
| 35 case ActionType::NEW_NOTE: | |
| 36 return app_runtime::ActionType::ACTION_TYPE_NEW_NOTE; | |
| 37 default: | |
| 38 return app_runtime::ActionType::ACTION_TYPE_NONE; | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 // Converts an ActionData instance to an app_runtime::ActionData instance. | |
| 43 app_runtime::ActionData* BuildActionData(ActionData action_data) { | |
| 44 auto* data = new app_runtime::ActionData(); | |
| 45 | |
| 46 data->action_type = MapActionType(action_data.action_type); | |
| 47 | |
| 48 return data; | |
| 49 } | |
| 50 | |
| 32 void DispatchOnEmbedRequestedEventImpl( | 51 void DispatchOnEmbedRequestedEventImpl( |
| 33 const std::string& extension_id, | 52 const std::string& extension_id, |
| 34 std::unique_ptr<base::DictionaryValue> app_embedding_request_data, | 53 std::unique_ptr<base::DictionaryValue> app_embedding_request_data, |
| 35 content::BrowserContext* context) { | 54 content::BrowserContext* context) { |
| 36 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 55 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 37 args->Append(std::move(app_embedding_request_data)); | 56 args->Append(std::move(app_embedding_request_data)); |
| 38 std::unique_ptr<Event> event( | 57 std::unique_ptr<Event> event( |
| 39 new Event(events::APP_RUNTIME_ON_EMBED_REQUESTED, | 58 new Event(events::APP_RUNTIME_ON_EMBED_REQUESTED, |
| 40 app_runtime::OnEmbedRequested::kEventName, std::move(args))); | 59 app_runtime::OnEmbedRequested::kEventName, std::move(args))); |
| 41 event->restrict_to_browser_context = context; | 60 event->restrict_to_browser_context = context; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 case extensions::SOURCE_BACKGROUND: | 128 case extensions::SOURCE_BACKGROUND: |
| 110 return app_runtime::LAUNCH_SOURCE_BACKGROUND; | 129 return app_runtime::LAUNCH_SOURCE_BACKGROUND; |
| 111 case extensions::SOURCE_KIOSK: | 130 case extensions::SOURCE_KIOSK: |
| 112 return app_runtime::LAUNCH_SOURCE_KIOSK; | 131 return app_runtime::LAUNCH_SOURCE_KIOSK; |
| 113 case extensions::SOURCE_CHROME_INTERNAL: | 132 case extensions::SOURCE_CHROME_INTERNAL: |
| 114 return app_runtime::LAUNCH_SOURCE_CHROME_INTERNAL; | 133 return app_runtime::LAUNCH_SOURCE_CHROME_INTERNAL; |
| 115 case extensions::SOURCE_TEST: | 134 case extensions::SOURCE_TEST: |
| 116 return app_runtime::LAUNCH_SOURCE_TEST; | 135 return app_runtime::LAUNCH_SOURCE_TEST; |
| 117 case extensions::SOURCE_INSTALLED_NOTIFICATION: | 136 case extensions::SOURCE_INSTALLED_NOTIFICATION: |
| 118 return app_runtime::LAUNCH_SOURCE_INSTALLED_NOTIFICATION; | 137 return app_runtime::LAUNCH_SOURCE_INSTALLED_NOTIFICATION; |
| 138 case extensions::SOURCE_ACTION: | |
| 139 return app_runtime::LAUNCH_SOURCE_ACTION; | |
| 119 | 140 |
| 120 default: | 141 default: |
| 121 return app_runtime::LAUNCH_SOURCE_NONE; | 142 return app_runtime::LAUNCH_SOURCE_NONE; |
| 122 } | 143 } |
| 123 } | 144 } |
| 124 | 145 |
| 125 } // namespace | 146 } // namespace |
| 126 | 147 |
| 127 // static | 148 // static |
| 128 void AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( | 149 void AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 launch_data.id.reset(new std::string(handler_id)); | 231 launch_data.id.reset(new std::string(handler_id)); |
| 211 launch_data.url.reset(new std::string(url.spec())); | 232 launch_data.url.reset(new std::string(url.spec())); |
| 212 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); | 233 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); |
| 213 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) { | 234 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) { |
| 214 launch_data.source = source_enum; | 235 launch_data.source = source_enum; |
| 215 } | 236 } |
| 216 DispatchOnLaunchedEventImpl(extension->id(), source_enum, | 237 DispatchOnLaunchedEventImpl(extension->id(), source_enum, |
| 217 launch_data.ToValue(), context); | 238 launch_data.ToValue(), context); |
| 218 } | 239 } |
| 219 | 240 |
| 241 // static | |
| 242 void AppRuntimeEventRouter::DispatchOnLaunchedEventWithAction( | |
| 243 content::BrowserContext* context, | |
| 244 const Extension* extension, | |
| 245 ActionData action_data) { | |
| 246 app_runtime::LaunchSource source_enum = app_runtime::LAUNCH_SOURCE_ACTION; | |
| 247 | |
| 248 app_runtime::LaunchData launch_data; | |
| 249 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.
| |
| 250 | |
| 251 DispatchOnLaunchedEventImpl(extension->id(), source_enum, | |
| 252 launch_data.ToValue(), context); | |
| 253 } | |
| 254 | |
| 220 } // namespace extensions | 255 } // namespace extensions |
| OLD | NEW |