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

Side by Side Diff: chrome/browser/extensions/api/runtime/runtime_api.cc

Issue 9969087: Switch platform apps from a declarative launch container to handling an onLaunched event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/runtime/runtime_api.h" 5 #include "chrome/browser/extensions/api/runtime/runtime_api.h"
6 6
7 #include "chrome/common/extensions/extension.h" 7 #include "chrome/common/extensions/extension.h"
8 #include "chrome/browser/extensions/extension_event_router.h" 8 #include "chrome/browser/extensions/extension_event_router.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 11
12 namespace { 12 namespace {
13 13
14 const char kOnInstalledEvent[] = "experimental.runtime.onInstalled"; 14 const char kOnInstalledEvent[] = "experimental.runtime.onInstalled";
15 const char kOnLaunchedEvent[] = "experimental.runtime.onLaunched";
15 16
16 } 17 }
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 // static 21 // static
21 void RuntimeEventRouter::DispatchOnInstalledEvent( 22 void RuntimeEventRouter::DispatchOnInstalledEvent(
22 Profile* profile, const Extension* extension) { 23 Profile* profile, const Extension* extension) {
23 // Special case: normally, extensions add their own lazy event listeners. 24 // Special case: normally, extensions add their own lazy event listeners.
24 // However, since the extension has just been installed, it hasn't had a 25 // However, since the extension has just been installed, it hasn't had a
25 // chance to register for events. So we register on its behalf. If the 26 // chance to register for events. So we register on its behalf. If the
26 // extension does not actually have a listener, the event will just be 27 // extension does not actually have a listener, the event will just be
27 // ignored. 28 // ignored.
28 ExtensionEventRouter* router = profile->GetExtensionEventRouter(); 29 ExtensionEventRouter* router = profile->GetExtensionEventRouter();
29 router->AddLazyEventListener(kOnInstalledEvent, extension->id()); 30 router->AddLazyEventListener(kOnInstalledEvent, extension->id());
30 router->DispatchEventToExtension( 31 router->DispatchEventToExtension(
31 extension->id(), kOnInstalledEvent, "[]", NULL, GURL()); 32 extension->id(), kOnInstalledEvent, "[]", NULL, GURL());
32 } 33 }
33 34
35 void RuntimeEventRouter::DispatchOnLaunchedEvent(
36 Profile* profile, const Extension* extension) {
37 profile->GetExtensionEventRouter()->DispatchEventToExtension(
38 extension->id(), kOnLaunchedEvent, "[]", NULL, GURL());
39 }
40
34 } // namespace extensions 41 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698