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 16 matching lines...) Expand all Loading... |
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 void DispatchOnEmbedRequestedEventImpl( | 32 void DispatchOnEmbedRequestedEventImpl( |
33 const std::string& extension_id, | 33 const std::string& extension_id, |
34 std::unique_ptr<base::DictionaryValue> app_embedding_request_data, | 34 std::unique_ptr<base::DictionaryValue> app_embedding_request_data, |
35 content::BrowserContext* context) { | 35 content::BrowserContext* context) { |
36 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 36 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
37 args->Append(app_embedding_request_data.release()); | 37 args->Append(std::move(app_embedding_request_data)); |
38 std::unique_ptr<Event> event( | 38 std::unique_ptr<Event> event( |
39 new Event(events::APP_RUNTIME_ON_EMBED_REQUESTED, | 39 new Event(events::APP_RUNTIME_ON_EMBED_REQUESTED, |
40 app_runtime::OnEmbedRequested::kEventName, std::move(args))); | 40 app_runtime::OnEmbedRequested::kEventName, std::move(args))); |
41 event->restrict_to_browser_context = context; | 41 event->restrict_to_browser_context = context; |
42 EventRouter::Get(context) | 42 EventRouter::Get(context) |
43 ->DispatchEventWithLazyListener(extension_id, std::move(event)); | 43 ->DispatchEventWithLazyListener(extension_id, std::move(event)); |
44 | 44 |
45 ExtensionPrefs::Get(context) | 45 ExtensionPrefs::Get(context) |
46 ->SetLastLaunchTime(extension_id, base::Time::Now()); | 46 ->SetLastLaunchTime(extension_id, base::Time::Now()); |
47 } | 47 } |
48 | 48 |
49 void DispatchOnLaunchedEventImpl( | 49 void DispatchOnLaunchedEventImpl( |
50 const std::string& extension_id, | 50 const std::string& extension_id, |
51 app_runtime::LaunchSource source, | 51 app_runtime::LaunchSource source, |
52 std::unique_ptr<base::DictionaryValue> launch_data, | 52 std::unique_ptr<base::DictionaryValue> launch_data, |
53 BrowserContext* context) { | 53 BrowserContext* context) { |
54 UMA_HISTOGRAM_ENUMERATION( | 54 UMA_HISTOGRAM_ENUMERATION( |
55 "Extensions.AppLaunchSource", source, NUM_APP_LAUNCH_SOURCES); | 55 "Extensions.AppLaunchSource", source, NUM_APP_LAUNCH_SOURCES); |
56 | 56 |
57 // "Forced app mode" is true for Chrome OS kiosk mode. | 57 // "Forced app mode" is true for Chrome OS kiosk mode. |
58 launch_data->SetBoolean( | 58 launch_data->SetBoolean( |
59 "isKioskSession", | 59 "isKioskSession", |
60 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()); | 60 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()); |
61 | 61 |
62 launch_data->SetBoolean( | 62 launch_data->SetBoolean( |
63 "isPublicSession", | 63 "isPublicSession", |
64 ExtensionsBrowserClient::Get()->IsLoggedInAsPublicAccount()); | 64 ExtensionsBrowserClient::Get()->IsLoggedInAsPublicAccount()); |
65 | 65 |
66 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 66 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
67 args->Append(launch_data.release()); | 67 args->Append(std::move(launch_data)); |
68 std::unique_ptr<Event> event(new Event(events::APP_RUNTIME_ON_LAUNCHED, | 68 std::unique_ptr<Event> event(new Event(events::APP_RUNTIME_ON_LAUNCHED, |
69 app_runtime::OnLaunched::kEventName, | 69 app_runtime::OnLaunched::kEventName, |
70 std::move(args))); | 70 std::move(args))); |
71 event->restrict_to_browser_context = context; | 71 event->restrict_to_browser_context = context; |
72 EventRouter::Get(context) | 72 EventRouter::Get(context) |
73 ->DispatchEventWithLazyListener(extension_id, std::move(event)); | 73 ->DispatchEventWithLazyListener(extension_id, std::move(event)); |
74 ExtensionPrefs::Get(context) | 74 ExtensionPrefs::Get(context) |
75 ->SetLastLaunchTime(extension_id, base::Time::Now()); | 75 ->SetLastLaunchTime(extension_id, base::Time::Now()); |
76 } | 76 } |
77 | 77 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 DCHECK(file_entries.size() == entries.size()); | 183 DCHECK(file_entries.size() == entries.size()); |
184 for (size_t i = 0; i < file_entries.size(); ++i) { | 184 for (size_t i = 0; i < file_entries.size(); ++i) { |
185 std::unique_ptr<base::DictionaryValue> launch_item( | 185 std::unique_ptr<base::DictionaryValue> launch_item( |
186 new base::DictionaryValue); | 186 new base::DictionaryValue); |
187 | 187 |
188 launch_item->SetString("fileSystemId", file_entries[i].filesystem_id); | 188 launch_item->SetString("fileSystemId", file_entries[i].filesystem_id); |
189 launch_item->SetString("baseName", file_entries[i].registered_name); | 189 launch_item->SetString("baseName", file_entries[i].registered_name); |
190 launch_item->SetString("mimeType", entries[i].mime_type); | 190 launch_item->SetString("mimeType", entries[i].mime_type); |
191 launch_item->SetString("entryId", file_entries[i].id); | 191 launch_item->SetString("entryId", file_entries[i].id); |
192 launch_item->SetBoolean("isDirectory", entries[i].is_directory); | 192 launch_item->SetBoolean("isDirectory", entries[i].is_directory); |
193 items->Append(launch_item.release()); | 193 items->Append(std::move(launch_item)); |
194 } | 194 } |
195 launch_data->Set("items", items.release()); | 195 launch_data->Set("items", items.release()); |
196 DispatchOnLaunchedEventImpl(extension->id(), source_enum, | 196 DispatchOnLaunchedEventImpl(extension->id(), source_enum, |
197 std::move(launch_data), context); | 197 std::move(launch_data), context); |
198 } | 198 } |
199 | 199 |
200 // static | 200 // static |
201 void AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl( | 201 void AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl( |
202 BrowserContext* context, | 202 BrowserContext* context, |
203 const Extension* extension, | 203 const Extension* extension, |
204 const std::string& handler_id, | 204 const std::string& handler_id, |
205 const GURL& url, | 205 const GURL& url, |
206 const GURL& referrer_url) { | 206 const GURL& referrer_url) { |
207 app_runtime::LaunchData launch_data; | 207 app_runtime::LaunchData launch_data; |
208 app_runtime::LaunchSource source_enum = | 208 app_runtime::LaunchSource source_enum = |
209 app_runtime::LAUNCH_SOURCE_URL_HANDLER; | 209 app_runtime::LAUNCH_SOURCE_URL_HANDLER; |
210 launch_data.id.reset(new std::string(handler_id)); | 210 launch_data.id.reset(new std::string(handler_id)); |
211 launch_data.url.reset(new std::string(url.spec())); | 211 launch_data.url.reset(new std::string(url.spec())); |
212 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); | 212 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); |
213 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) { | 213 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) { |
214 launch_data.source = source_enum; | 214 launch_data.source = source_enum; |
215 } | 215 } |
216 DispatchOnLaunchedEventImpl(extension->id(), source_enum, | 216 DispatchOnLaunchedEventImpl(extension->id(), source_enum, |
217 launch_data.ToValue(), context); | 217 launch_data.ToValue(), context); |
218 } | 218 } |
219 | 219 |
220 } // namespace extensions | 220 } // namespace extensions |
OLD | NEW |