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