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.
5 #include "chrome/browser/ui/extensions/app_launch_params.h"
7 #include "chrome/browser/extensions/launch_util.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "extensions/browser/extension_prefs.h"
10 #include "extensions/common/constants.h"
11 #include "extensions/common/extension.h"
12 #include "ui/base/window_open_disposition.h"
14 using extensions::ExtensionPrefs
;
16 AppLaunchParams::AppLaunchParams(Profile
* profile
,
17 const extensions::Extension
* extension
,
18 extensions::LaunchContainer container
,
19 WindowOpenDisposition disposition
,
20 extensions::AppLaunchSource source
)
22 extension_id(extension
? extension
->id() : std::string()),
24 disposition(disposition
),
25 desktop_type(chrome::GetActiveDesktop()),
28 command_line(base::CommandLine::NO_PROGRAM
),
32 AppLaunchParams::AppLaunchParams(Profile
* profile
,
33 const extensions::Extension
* extension
,
34 WindowOpenDisposition disposition
,
35 extensions::AppLaunchSource source
)
37 extension_id(extension
? extension
->id() : std::string()),
38 container(extensions::LAUNCH_CONTAINER_NONE
),
39 disposition(disposition
),
40 desktop_type(chrome::GetActiveDesktop()),
43 command_line(base::CommandLine::NO_PROGRAM
),
45 // Look up the app preference to find out the right launch container. Default
46 // is to launch as a regular tab.
48 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile
), extension
);
51 AppLaunchParams::AppLaunchParams(Profile
* profile
,
52 const extensions::Extension
* extension
,
53 WindowOpenDisposition raw_disposition
,
54 chrome::HostDesktopType desktop_type
,
55 extensions::AppLaunchSource source
)
57 extension_id(extension
? extension
->id() : std::string()),
58 container(extensions::LAUNCH_CONTAINER_NONE
),
59 desktop_type(desktop_type
),
62 command_line(base::CommandLine::NO_PROGRAM
),
64 if (raw_disposition
== NEW_FOREGROUND_TAB
||
65 raw_disposition
== NEW_BACKGROUND_TAB
) {
66 container
= extensions::LAUNCH_CONTAINER_TAB
;
67 disposition
= raw_disposition
;
68 } else if (raw_disposition
== NEW_WINDOW
) {
69 container
= extensions::LAUNCH_CONTAINER_WINDOW
;
70 disposition
= raw_disposition
;
72 // Look at preference to find the right launch container. If no preference
73 // is set, launch as a regular tab.
75 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile
), extension
);
76 disposition
= NEW_FOREGROUND_TAB
;
80 AppLaunchParams::~AppLaunchParams() {