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 |
| 11 #include "base/memory/ptr_util.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "extensions/browser/entry_info.h" | 15 #include "extensions/browser/entry_info.h" |
15 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" |
16 #include "extensions/browser/extension_prefs.h" | 17 #include "extensions/browser/extension_prefs.h" |
17 #include "extensions/browser/extensions_browser_client.h" | 18 #include "extensions/browser/extensions_browser_client.h" |
18 #include "extensions/browser/granted_file_entry.h" | 19 #include "extensions/browser/granted_file_entry.h" |
19 #include "extensions/common/api/app_runtime.h" | 20 #include "extensions/common/api/app_runtime.h" |
20 #include "extensions/common/constants.h" | 21 #include "extensions/common/constants.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 const Extension* extension) { | 132 const Extension* extension) { |
132 DispatchOnEmbedRequestedEventImpl(extension->id(), std::move(embed_app_data), | 133 DispatchOnEmbedRequestedEventImpl(extension->id(), std::move(embed_app_data), |
133 context); | 134 context); |
134 } | 135 } |
135 | 136 |
136 // static | 137 // static |
137 void AppRuntimeEventRouter::DispatchOnLaunchedEvent( | 138 void AppRuntimeEventRouter::DispatchOnLaunchedEvent( |
138 BrowserContext* context, | 139 BrowserContext* context, |
139 const Extension* extension, | 140 const Extension* extension, |
140 extensions::AppLaunchSource source, | 141 extensions::AppLaunchSource source, |
141 std::unique_ptr<app_runtime::ActionData> action_data) { | 142 std::unique_ptr<app_runtime::LaunchData> launch_data) { |
142 app_runtime::LaunchData launch_data; | 143 if (!launch_data) |
143 | 144 launch_data = base::MakeUnique<app_runtime::LaunchData>(); |
144 app_runtime::LaunchSource source_enum = GetLaunchSourceEnum(source); | 145 app_runtime::LaunchSource source_enum = GetLaunchSourceEnum(source); |
145 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) { | 146 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) { |
146 launch_data.source = source_enum; | 147 launch_data->source = source_enum; |
147 } | 148 } |
148 | 149 |
149 launch_data.action_data = std::move(action_data); | |
150 | |
151 DispatchOnLaunchedEventImpl(extension->id(), source_enum, | 150 DispatchOnLaunchedEventImpl(extension->id(), source_enum, |
152 launch_data.ToValue(), context); | 151 launch_data->ToValue(), context); |
153 } | 152 } |
154 | 153 |
155 // static | 154 // static |
156 void AppRuntimeEventRouter::DispatchOnRestartedEvent( | 155 void AppRuntimeEventRouter::DispatchOnRestartedEvent( |
157 BrowserContext* context, | 156 BrowserContext* context, |
158 const Extension* extension) { | 157 const Extension* extension) { |
159 std::unique_ptr<base::ListValue> arguments(new base::ListValue()); | 158 std::unique_ptr<base::ListValue> arguments(new base::ListValue()); |
160 std::unique_ptr<Event> event(new Event(events::APP_RUNTIME_ON_RESTARTED, | 159 std::unique_ptr<Event> event(new Event(events::APP_RUNTIME_ON_RESTARTED, |
161 app_runtime::OnRestarted::kEventName, | 160 app_runtime::OnRestarted::kEventName, |
162 std::move(arguments))); | 161 std::move(arguments))); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 launch_data.url.reset(new std::string(url.spec())); | 222 launch_data.url.reset(new std::string(url.spec())); |
224 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); | 223 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); |
225 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) { | 224 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) { |
226 launch_data.source = source_enum; | 225 launch_data.source = source_enum; |
227 } | 226 } |
228 DispatchOnLaunchedEventImpl(extension->id(), source_enum, | 227 DispatchOnLaunchedEventImpl(extension->id(), source_enum, |
229 launch_data.ToValue(), context); | 228 launch_data.ToValue(), context); |
230 } | 229 } |
231 | 230 |
232 } // namespace extensions | 231 } // namespace extensions |
OLD | NEW |