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

Side by Side Diff: extensions/browser/api/app_runtime/app_runtime_api.cc

Issue 344543006: Disable ephemeral apps after they stop running (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prevent demotion of installed app due to race condition Created 6 years, 5 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 unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
26 BrowserContext* context) { 26 BrowserContext* context) {
27 // "Forced app mode" is true for Chrome OS kiosk mode. 27 // "Forced app mode" is true for Chrome OS kiosk mode.
28 launch_data->SetBoolean( 28 launch_data->SetBoolean(
29 "isKioskSession", 29 "isKioskSession",
30 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()); 30 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode());
31 scoped_ptr<base::ListValue> args(new base::ListValue()); 31 scoped_ptr<base::ListValue> args(new base::ListValue());
32 args->Append(launch_data.release()); 32 args->Append(launch_data.release());
33 scoped_ptr<Event> event( 33 scoped_ptr<Event> event(
34 new Event(app_runtime::OnLaunched::kEventName, args.Pass())); 34 new Event(app_runtime::OnLaunched::kEventName, args.Pass()));
35 event->restrict_to_browser_context = context; 35 event->restrict_to_browser_context = context;
36 event->can_load_ephemeral_apps = true;
37 EventRouter::Get(context) 36 EventRouter::Get(context)
38 ->DispatchEventWithLazyListener(extension_id, event.Pass()); 37 ->DispatchEventWithLazyListener(extension_id, event.Pass());
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 } // namespace 42 } // namespace
44 43
45 // static 44 // static
46 void AppRuntimeEventRouter::DispatchOnLaunchedEvent( 45 void AppRuntimeEventRouter::DispatchOnLaunchedEvent(
47 BrowserContext* context, 46 BrowserContext* context,
48 const Extension* extension) { 47 const Extension* extension) {
49 scoped_ptr<base::DictionaryValue> launch_data(new base::DictionaryValue()); 48 scoped_ptr<base::DictionaryValue> launch_data(new base::DictionaryValue());
50 DispatchOnLaunchedEventImpl(extension->id(), launch_data.Pass(), context); 49 DispatchOnLaunchedEventImpl(extension->id(), launch_data.Pass(), context);
51 } 50 }
52 51
53 // static 52 // static
54 void AppRuntimeEventRouter::DispatchOnRestartedEvent( 53 void AppRuntimeEventRouter::DispatchOnRestartedEvent(
55 BrowserContext* context, 54 BrowserContext* context,
56 const Extension* extension) { 55 const Extension* extension) {
57 scoped_ptr<base::ListValue> arguments(new base::ListValue()); 56 scoped_ptr<base::ListValue> arguments(new base::ListValue());
58 scoped_ptr<Event> event( 57 scoped_ptr<Event> event(
59 new Event(app_runtime::OnRestarted::kEventName, arguments.Pass())); 58 new Event(app_runtime::OnRestarted::kEventName, arguments.Pass()));
60 event->restrict_to_browser_context = context; 59 event->restrict_to_browser_context = context;
61 event->can_load_ephemeral_apps = true;
62 EventRouter::Get(context) 60 EventRouter::Get(context)
63 ->DispatchEventToExtension(extension->id(), event.Pass()); 61 ->DispatchEventToExtension(extension->id(), event.Pass());
64 } 62 }
65 63
66 // static 64 // static
67 void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries( 65 void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries(
68 BrowserContext* context, 66 BrowserContext* context,
69 const Extension* extension, 67 const Extension* extension,
70 const std::string& handler_id, 68 const std::string& handler_id,
71 const std::vector<std::string>& mime_types, 69 const std::vector<std::string>& mime_types,
(...skipping 25 matching lines...) Expand all
97 const GURL& referrer_url) { 95 const GURL& referrer_url) {
98 app_runtime::LaunchData launch_data; 96 app_runtime::LaunchData launch_data;
99 launch_data.id.reset(new std::string(handler_id)); 97 launch_data.id.reset(new std::string(handler_id));
100 launch_data.url.reset(new std::string(url.spec())); 98 launch_data.url.reset(new std::string(url.spec()));
101 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); 99 launch_data.referrer_url.reset(new std::string(referrer_url.spec()));
102 DispatchOnLaunchedEventImpl( 100 DispatchOnLaunchedEventImpl(
103 extension->id(), launch_data.ToValue().Pass(), context); 101 extension->id(), launch_data.ToValue().Pass(), context);
104 } 102 }
105 103
106 } // namespace extensions 104 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698