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

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

Issue 354483004: Implement <appview> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@app_view_skeleton
Patch Set: Fixed formatting 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"
11 #include "extensions/browser/extension_system.h"
11 #include "extensions/browser/extensions_browser_client.h" 12 #include "extensions/browser/extensions_browser_client.h"
12 #include "extensions/browser/granted_file_entry.h" 13 #include "extensions/browser/granted_file_entry.h"
13 #include "extensions/common/api/app_runtime.h" 14 #include "extensions/common/api/app_runtime.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 using content::BrowserContext; 17 using content::BrowserContext;
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 namespace app_runtime = core_api::app_runtime; 21 namespace app_runtime = core_api::app_runtime;
21 22
22 namespace { 23 namespace {
23 24
25 void DispatchOnEmbedRequestedEventImpl(
26 const std::string& extension_id,
27 scoped_ptr<base::DictionaryValue> app_embedding_request_data,
28 content::BrowserContext* context) {
29 scoped_ptr<base::ListValue> args(new base::ListValue());
30 args->Append(app_embedding_request_data.release());
31 ExtensionSystem* system = ExtensionSystem::Get(context);
32 scoped_ptr<Event> event(
33 new Event(app_runtime::OnEmbedRequested::kEventName, args.Pass()));
34 event->restrict_to_browser_context = context;
35 event->can_load_ephemeral_apps = true;
36 system->event_router()->DispatchEventWithLazyListener(extension_id,
37 event.Pass());
38
39 ExtensionPrefs::Get(context)
40 ->SetLastLaunchTime(extension_id, base::Time::Now());
41 }
42
24 void DispatchOnLaunchedEventImpl(const std::string& extension_id, 43 void DispatchOnLaunchedEventImpl(const std::string& extension_id,
25 scoped_ptr<base::DictionaryValue> launch_data, 44 scoped_ptr<base::DictionaryValue> launch_data,
26 BrowserContext* context) { 45 BrowserContext* context) {
27 // "Forced app mode" is true for Chrome OS kiosk mode. 46 // "Forced app mode" is true for Chrome OS kiosk mode.
28 launch_data->SetBoolean( 47 launch_data->SetBoolean(
29 "isKioskSession", 48 "isKioskSession",
30 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()); 49 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode());
31 scoped_ptr<base::ListValue> args(new base::ListValue()); 50 scoped_ptr<base::ListValue> args(new base::ListValue());
32 args->Append(launch_data.release()); 51 args->Append(launch_data.release());
33 scoped_ptr<Event> event( 52 scoped_ptr<Event> event(
34 new Event(app_runtime::OnLaunched::kEventName, args.Pass())); 53 new Event(app_runtime::OnLaunched::kEventName, args.Pass()));
35 event->restrict_to_browser_context = context; 54 event->restrict_to_browser_context = context;
36 event->can_load_ephemeral_apps = true; 55 event->can_load_ephemeral_apps = true;
37 EventRouter::Get(context) 56 EventRouter::Get(context)
38 ->DispatchEventWithLazyListener(extension_id, event.Pass()); 57 ->DispatchEventWithLazyListener(extension_id, event.Pass());
39 ExtensionPrefs::Get(context) 58 ExtensionPrefs::Get(context)
40 ->SetLastLaunchTime(extension_id, base::Time::Now()); 59 ->SetLastLaunchTime(extension_id, base::Time::Now());
41 } 60 }
42 61
43 } // namespace 62 } // namespace
44 63
45 // static 64 // static
65 void AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent(
66 content::BrowserContext* context,
67 scoped_ptr<base::DictionaryValue> embed_app_data,
68 const Extension* extension) {
69 DispatchOnEmbedRequestedEventImpl(
70 extension->id(), embed_app_data.Pass(), context);
71 }
72
73 // static
46 void AppRuntimeEventRouter::DispatchOnLaunchedEvent( 74 void AppRuntimeEventRouter::DispatchOnLaunchedEvent(
47 BrowserContext* context, 75 BrowserContext* context,
48 const Extension* extension) { 76 const Extension* extension) {
49 scoped_ptr<base::DictionaryValue> launch_data(new base::DictionaryValue()); 77 scoped_ptr<base::DictionaryValue> launch_data(new base::DictionaryValue());
50 DispatchOnLaunchedEventImpl(extension->id(), launch_data.Pass(), context); 78 DispatchOnLaunchedEventImpl(extension->id(), launch_data.Pass(), context);
51 } 79 }
52 80
53 // static 81 // static
54 void AppRuntimeEventRouter::DispatchOnRestartedEvent( 82 void AppRuntimeEventRouter::DispatchOnRestartedEvent(
55 BrowserContext* context, 83 BrowserContext* context,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 const GURL& referrer_url) { 125 const GURL& referrer_url) {
98 app_runtime::LaunchData launch_data; 126 app_runtime::LaunchData launch_data;
99 launch_data.id.reset(new std::string(handler_id)); 127 launch_data.id.reset(new std::string(handler_id));
100 launch_data.url.reset(new std::string(url.spec())); 128 launch_data.url.reset(new std::string(url.spec()));
101 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); 129 launch_data.referrer_url.reset(new std::string(referrer_url.spec()));
102 DispatchOnLaunchedEventImpl( 130 DispatchOnLaunchedEventImpl(
103 extension->id(), launch_data.ToValue().Pass(), context); 131 extension->id(), launch_data.ToValue().Pass(), context);
104 } 132 }
105 133
106 } // namespace extensions 134 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/app_runtime/app_runtime_api.h ('k') | extensions/browser/api/app_view/app_view_internal_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698