OLD | NEW |
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 #ifndef CHROME_BROWSER_EXTENSIONS_API_APP_APP_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_APP_APP_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_APP_APP_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_APP_APP_API_H_ |
7 | 7 |
8 #include "chrome/browser/extensions/extension_function.h" | 8 #include "chrome/browser/extensions/extension_function.h" |
9 | 9 |
10 class Profile; | |
11 class GURL; | |
12 | |
13 namespace webkit_glue { | |
14 struct WebIntentData; | |
15 } | |
16 | |
17 namespace extensions { | 10 namespace extensions { |
18 | 11 |
19 class Extension; | |
20 | |
21 class AppNotifyFunction : public SyncExtensionFunction { | 12 class AppNotifyFunction : public SyncExtensionFunction { |
22 public: | 13 public: |
23 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.notify"); | 14 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.notify"); |
24 | 15 |
25 protected: | 16 protected: |
26 virtual ~AppNotifyFunction() {} | 17 virtual ~AppNotifyFunction() {} |
27 virtual bool RunImpl() OVERRIDE; | 18 virtual bool RunImpl() OVERRIDE; |
28 }; | 19 }; |
29 | 20 |
30 class AppClearAllNotificationsFunction : public SyncExtensionFunction { | 21 class AppClearAllNotificationsFunction : public SyncExtensionFunction { |
31 public: | 22 public: |
32 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.clearAllNotifications"); | 23 DECLARE_EXTENSION_FUNCTION_NAME("experimental.app.clearAllNotifications"); |
33 | 24 |
34 protected: | 25 protected: |
35 virtual ~AppClearAllNotificationsFunction() {} | 26 virtual ~AppClearAllNotificationsFunction() {} |
36 virtual bool RunImpl() OVERRIDE; | 27 virtual bool RunImpl() OVERRIDE; |
37 }; | 28 }; |
38 | 29 |
39 class AppEventRouter { | |
40 public: | |
41 // Dispatches the onLaunched event to the given app, providing no launch | |
42 // data. | |
43 static void DispatchOnLaunchedEvent(Profile* profile, | |
44 const Extension* extension); | |
45 | |
46 // Dispatches the onLaunched event to the given app, providing launch data of | |
47 // the form: | |
48 // { | |
49 // "intent" : { | |
50 // "action" : |action|, | |
51 // "type" : "chrome-extension://fileentry", | |
52 // "data" : a FileEntry, | |
53 // "postResults" : a null function, | |
54 // "postFailure" : a null function | |
55 // } | |
56 // } | |
57 | |
58 // launchData.intent.data and launchData.intent.postResults are created in a | |
59 // custom dispatch event in javascript. The FileEntry is created from | |
60 // |file_system_id| and |base_name|. | |
61 static void DispatchOnLaunchedEventWithFileEntry( | |
62 Profile* profile, | |
63 const Extension* extension, | |
64 const string16& action, | |
65 const std::string& file_system_id, | |
66 const std::string& base_name); | |
67 | |
68 // Dispatches the onLaunched event to the app implemented by |extension| | |
69 // running in |profile|. The event parameter launchData will have a field | |
70 // called intent, populated by |web_intent_data|. | |
71 static void DispatchOnLaunchedEventWithWebIntent( | |
72 Profile* profile, | |
73 const Extension* extension, | |
74 const webkit_glue::WebIntentData web_intent_data); | |
75 }; | |
76 | |
77 } // namespace extensions | 30 } // namespace extensions |
78 | 31 |
79 #endif // CHROME_BROWSER_EXTENSIONS_API_APP_APP_API_H_ | 32 #endif // CHROME_BROWSER_EXTENSIONS_API_APP_APP_API_H_ |
OLD | NEW |