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