| 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 "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "extensions/browser/event_router.h" | 9 #include "extensions/browser/event_router.h" |
| 10 #include "extensions/browser/extension_prefs.h" | 10 #include "extensions/browser/extension_prefs.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 void DispatchOnEmbedRequestedEventImpl( | 25 void DispatchOnEmbedRequestedEventImpl( |
| 26 const std::string& extension_id, | 26 const std::string& extension_id, |
| 27 scoped_ptr<base::DictionaryValue> app_embedding_request_data, | 27 scoped_ptr<base::DictionaryValue> app_embedding_request_data, |
| 28 content::BrowserContext* context) { | 28 content::BrowserContext* context) { |
| 29 scoped_ptr<base::ListValue> args(new base::ListValue()); | 29 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 30 args->Append(app_embedding_request_data.release()); | 30 args->Append(app_embedding_request_data.release()); |
| 31 ExtensionSystem* system = ExtensionSystem::Get(context); | 31 ExtensionSystem* system = ExtensionSystem::Get(context); |
| 32 scoped_ptr<Event> event( | 32 scoped_ptr<Event> event( |
| 33 new Event(app_runtime::OnEmbedRequested::kEventName, args.Pass())); | 33 new Event(app_runtime::OnEmbedRequested::kEventName, args.Pass())); |
| 34 event->restrict_to_browser_context = context; | 34 event->restrict_to_browser_context = context; |
| 35 event->can_load_ephemeral_apps = true; | |
| 36 system->event_router()->DispatchEventWithLazyListener(extension_id, | 35 system->event_router()->DispatchEventWithLazyListener(extension_id, |
| 37 event.Pass()); | 36 event.Pass()); |
| 38 | 37 |
| 39 ExtensionPrefs::Get(context) | 38 ExtensionPrefs::Get(context) |
| 40 ->SetLastLaunchTime(extension_id, base::Time::Now()); | 39 ->SetLastLaunchTime(extension_id, base::Time::Now()); |
| 41 } | 40 } |
| 42 | 41 |
| 43 void DispatchOnLaunchedEventImpl(const std::string& extension_id, | 42 void DispatchOnLaunchedEventImpl(const std::string& extension_id, |
| 44 scoped_ptr<base::DictionaryValue> launch_data, | 43 scoped_ptr<base::DictionaryValue> launch_data, |
| 45 BrowserContext* context) { | 44 BrowserContext* context) { |
| 46 // "Forced app mode" is true for Chrome OS kiosk mode. | 45 // "Forced app mode" is true for Chrome OS kiosk mode. |
| 47 launch_data->SetBoolean( | 46 launch_data->SetBoolean( |
| 48 "isKioskSession", | 47 "isKioskSession", |
| 49 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()); | 48 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()); |
| 50 scoped_ptr<base::ListValue> args(new base::ListValue()); | 49 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 51 args->Append(launch_data.release()); | 50 args->Append(launch_data.release()); |
| 52 scoped_ptr<Event> event( | 51 scoped_ptr<Event> event( |
| 53 new Event(app_runtime::OnLaunched::kEventName, args.Pass())); | 52 new Event(app_runtime::OnLaunched::kEventName, args.Pass())); |
| 54 event->restrict_to_browser_context = context; | 53 event->restrict_to_browser_context = context; |
| 55 event->can_load_ephemeral_apps = true; | |
| 56 EventRouter::Get(context) | 54 EventRouter::Get(context) |
| 57 ->DispatchEventWithLazyListener(extension_id, event.Pass()); | 55 ->DispatchEventWithLazyListener(extension_id, event.Pass()); |
| 58 ExtensionPrefs::Get(context) | 56 ExtensionPrefs::Get(context) |
| 59 ->SetLastLaunchTime(extension_id, base::Time::Now()); | 57 ->SetLastLaunchTime(extension_id, base::Time::Now()); |
| 60 } | 58 } |
| 61 | 59 |
| 62 } // namespace | 60 } // namespace |
| 63 | 61 |
| 64 // static | 62 // static |
| 65 void AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( | 63 void AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 } | 77 } |
| 80 | 78 |
| 81 // static | 79 // static |
| 82 void AppRuntimeEventRouter::DispatchOnRestartedEvent( | 80 void AppRuntimeEventRouter::DispatchOnRestartedEvent( |
| 83 BrowserContext* context, | 81 BrowserContext* context, |
| 84 const Extension* extension) { | 82 const Extension* extension) { |
| 85 scoped_ptr<base::ListValue> arguments(new base::ListValue()); | 83 scoped_ptr<base::ListValue> arguments(new base::ListValue()); |
| 86 scoped_ptr<Event> event( | 84 scoped_ptr<Event> event( |
| 87 new Event(app_runtime::OnRestarted::kEventName, arguments.Pass())); | 85 new Event(app_runtime::OnRestarted::kEventName, arguments.Pass())); |
| 88 event->restrict_to_browser_context = context; | 86 event->restrict_to_browser_context = context; |
| 89 event->can_load_ephemeral_apps = true; | |
| 90 EventRouter::Get(context) | 87 EventRouter::Get(context) |
| 91 ->DispatchEventToExtension(extension->id(), event.Pass()); | 88 ->DispatchEventToExtension(extension->id(), event.Pass()); |
| 92 } | 89 } |
| 93 | 90 |
| 94 // static | 91 // static |
| 95 void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries( | 92 void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries( |
| 96 BrowserContext* context, | 93 BrowserContext* context, |
| 97 const Extension* extension, | 94 const Extension* extension, |
| 98 const std::string& handler_id, | 95 const std::string& handler_id, |
| 99 const std::vector<std::string>& mime_types, | 96 const std::vector<std::string>& mime_types, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 125 const GURL& referrer_url) { | 122 const GURL& referrer_url) { |
| 126 app_runtime::LaunchData launch_data; | 123 app_runtime::LaunchData launch_data; |
| 127 launch_data.id.reset(new std::string(handler_id)); | 124 launch_data.id.reset(new std::string(handler_id)); |
| 128 launch_data.url.reset(new std::string(url.spec())); | 125 launch_data.url.reset(new std::string(url.spec())); |
| 129 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); | 126 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); |
| 130 DispatchOnLaunchedEventImpl( | 127 DispatchOnLaunchedEventImpl( |
| 131 extension->id(), launch_data.ToValue().Pass(), context); | 128 extension->id(), launch_data.ToValue().Pass(), context); |
| 132 } | 129 } |
| 133 | 130 |
| 134 } // namespace extensions | 131 } // namespace extensions |
| OLD | NEW |