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