Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / apps / browser / api / app_runtime / app_runtime_api.h
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
3 // found in the LICENSE file.
4
5 #ifndef APPS_BROWSER_API_APP_RUNTIME_APP_RUNTIME_API_H_
6 #define APPS_BROWSER_API_APP_RUNTIME_APP_RUNTIME_API_H_
7
8 #include <string>
9
10 class GURL;
11
12 namespace content {
13 class BrowserContext;
14 class WebContents;
15 }
16
17 namespace extensions {
18 class Extension;
19 }
20
21 namespace apps {
22
23 namespace file_handler_util {
24 struct GrantedFileEntry;
25 }
26
27 class AppEventRouter {
28  public:
29   // Dispatches the onLaunched event to the given app.
30   static void DispatchOnLaunchedEvent(content::BrowserContext* context,
31                                       const extensions::Extension* extension);
32
33   // Dispatches the onRestarted event to the given app, providing a list of
34   // restored file entries from the previous run.
35   static void DispatchOnRestartedEvent(content::BrowserContext* context,
36                                        const extensions::Extension* extension);
37
38   // TODO(benwells): Update this comment, it is out of date.
39   // Dispatches the onLaunched event to the given app, providing launch data of
40   // the form:
41   // {
42   //   "intent" : {
43   //     "type" : "chrome-extension://fileentry",
44   //     "data" : a FileEntry,
45   //     "postResults" : a null function,
46   //     "postFailure" : a null function
47   //   }
48   // }
49
50   // The FileEntry is created from |file_system_id| and |base_name|.
51   // |handler_id| corresponds to the id of the file_handlers item in the
52   // manifest that resulted in a match which triggered this launch.
53   static void DispatchOnLaunchedEventWithFileEntry(
54       content::BrowserContext* context,
55       const extensions::Extension* extension,
56       const std::string& handler_id,
57       const std::string& mime_type,
58       const file_handler_util::GrantedFileEntry& file_entry);
59
60   // |handler_id| corresponds to the id of the url_handlers item
61   // in the manifest that resulted in a match which triggered this launch.
62   static void DispatchOnLaunchedEventWithUrl(
63       content::BrowserContext* context,
64       const extensions::Extension* extension,
65       const std::string& handler_id,
66       const GURL& url,
67       const GURL& referrer_url);
68 };
69
70 }  // namespace apps
71
72 #endif  // APPS_BROWSER_API_APP_RUNTIME_APP_RUNTIME_API_H_