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_UI_EXTENSIONS_APPLICATION_LAUNCH_H_ 6 #define CHROME_BROWSER_UI_EXTENSIONS_APPLICATION_LAUNCH_H_ 7 8 #include "base/files/file_path.h" 9 #include "chrome/common/extensions/extension_constants.h" 10 #include "ui/base/window_open_disposition.h" 11 #include "ui/gfx/rect.h" 12 #include "url/gurl.h" 13 14 class Browser; 15 class CommandLine; 16 class Profile; 17 18 namespace content { 19 class WebContents; 20 } 21 22 namespace extensions { 23 class Extension; 24 } 25 26 namespace chrome { 27 28 struct AppLaunchParams { 29 AppLaunchParams(Profile* profile, 30 const extensions::Extension* extension, 31 extension_misc::LaunchContainer container, 32 WindowOpenDisposition disposition); 33 34 // Helper to create AppLaunchParams using ExtensionPrefs::GetLaunchContainer 35 // with ExtensionPrefs::LAUNCH_REGULAR to check for a user-configured 36 // container. 37 AppLaunchParams(Profile* profile, 38 const extensions::Extension* extension, 39 WindowOpenDisposition disposition); 40 41 // Helper to create AppLaunchParams using event flags that allows user to 42 // override the user-configured container using modifier keys. 43 AppLaunchParams(Profile* profile, 44 const extensions::Extension* extension, 45 int event_flags); 46 47 // The profile to load the application from. 48 Profile* profile; 49 50 // The extension to load. 51 const extensions::Extension* extension; 52 53 // The container type to launch the application in. 54 extension_misc::LaunchContainer container; 55 56 // If container is TAB, this field controls how the tab is opened. 57 WindowOpenDisposition disposition; 58 59 // If non-empty, use override_url in place of the application's launch url. 60 GURL override_url; 61 62 // If non-empty, use override_boudns in place of the application's default 63 // position and dimensions. 64 gfx::Rect override_bounds; 65 66 // If non-NULL, information from the command line may be passed on to the 67 // application. 68 const CommandLine* command_line; 69 70 // If non-empty, the current directory from which any relative paths on the 71 // command line should be expanded from. 72 base::FilePath current_directory; 73 }; 74 75 // Open the application in a way specified by |params|. 76 content::WebContents* OpenApplication(const AppLaunchParams& params); 77 78 // Open |url| in an app shortcut window. |override_bounds| param is optional. 79 // There are two kinds of app shortcuts: Shortcuts to a URL, 80 // and shortcuts that open an installed application. This function 81 // is used to open the former. To open the latter, use 82 // application_launch::OpenApplication(). 83 content::WebContents* OpenAppShortcutWindow(Profile* profile, 84 const GURL& url, 85 const gfx::Rect& override_bounds); 86 87 } // namespace chrome 88 89 #endif // CHROME_BROWSER_UI_EXTENSIONS_APPLICATION_LAUNCH_H_ 90