OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/extensions/app_launch_params.h" | 5 #include "chrome/browser/ui/extensions/app_launch_params.h" |
6 | 6 |
7 #include "chrome/browser/extensions/launch_util.h" | 7 #include "chrome/browser/extensions/launch_util.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "extensions/browser/extension_prefs.h" | 9 #include "extensions/browser/extension_prefs.h" |
| 10 #include "extensions/common/constants.h" |
10 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 #include "ui/base/window_open_disposition.h" |
11 | 13 |
12 using extensions::ExtensionPrefs; | 14 using extensions::ExtensionPrefs; |
13 | 15 |
14 AppLaunchParams::AppLaunchParams(Profile* profile, | 16 AppLaunchParams::AppLaunchParams(Profile* profile, |
15 const extensions::Extension* extension, | 17 const extensions::Extension* extension, |
16 extensions::LaunchContainer container, | 18 extensions::LaunchContainer container, |
17 WindowOpenDisposition disposition) | 19 WindowOpenDisposition disposition, |
| 20 extensions::AppLaunchSource source) |
18 : profile(profile), | 21 : profile(profile), |
19 extension_id(extension ? extension->id() : std::string()), | 22 extension_id(extension ? extension->id() : std::string()), |
20 container(container), | 23 container(container), |
21 disposition(disposition), | 24 disposition(disposition), |
22 desktop_type(chrome::GetActiveDesktop()), | 25 desktop_type(chrome::GetActiveDesktop()), |
23 override_url(), | 26 override_url(), |
24 override_bounds(), | 27 override_bounds(), |
25 command_line(CommandLine::NO_PROGRAM), | 28 command_line(CommandLine::NO_PROGRAM), |
26 source(extensions::SOURCE_UNTRACKED) { | 29 source(source) { |
27 } | 30 } |
28 | 31 |
29 AppLaunchParams::AppLaunchParams(Profile* profile, | 32 AppLaunchParams::AppLaunchParams(Profile* profile, |
30 const extensions::Extension* extension, | 33 const extensions::Extension* extension, |
31 WindowOpenDisposition disposition) | 34 WindowOpenDisposition disposition, |
| 35 extensions::AppLaunchSource source) |
32 : profile(profile), | 36 : profile(profile), |
33 extension_id(extension ? extension->id() : std::string()), | 37 extension_id(extension ? extension->id() : std::string()), |
34 container(extensions::LAUNCH_CONTAINER_NONE), | 38 container(extensions::LAUNCH_CONTAINER_NONE), |
35 disposition(disposition), | 39 disposition(disposition), |
36 desktop_type(chrome::GetActiveDesktop()), | 40 desktop_type(chrome::GetActiveDesktop()), |
37 override_url(), | 41 override_url(), |
38 override_bounds(), | 42 override_bounds(), |
39 command_line(CommandLine::NO_PROGRAM), | 43 command_line(CommandLine::NO_PROGRAM), |
40 source(extensions::SOURCE_UNTRACKED) { | 44 source(source) { |
41 // Look up the app preference to find out the right launch container. Default | 45 // Look up the app preference to find out the right launch container. Default |
42 // is to launch as a regular tab. | 46 // is to launch as a regular tab. |
43 container = | 47 container = |
44 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); | 48 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); |
45 } | 49 } |
46 | 50 |
47 AppLaunchParams::AppLaunchParams(Profile* profile, | 51 AppLaunchParams::AppLaunchParams(Profile* profile, |
48 const extensions::Extension* extension, | 52 const extensions::Extension* extension, |
49 int event_flags, | 53 WindowOpenDisposition raw_disposition, |
50 chrome::HostDesktopType desktop_type) | 54 chrome::HostDesktopType desktop_type, |
| 55 extensions::AppLaunchSource source) |
51 : profile(profile), | 56 : profile(profile), |
52 extension_id(extension ? extension->id() : std::string()), | 57 extension_id(extension ? extension->id() : std::string()), |
53 container(extensions::LAUNCH_CONTAINER_NONE), | 58 container(extensions::LAUNCH_CONTAINER_NONE), |
54 disposition(ui::DispositionFromEventFlags(event_flags)), | |
55 desktop_type(desktop_type), | 59 desktop_type(desktop_type), |
56 override_url(), | 60 override_url(), |
57 override_bounds(), | 61 override_bounds(), |
58 command_line(CommandLine::NO_PROGRAM), | 62 command_line(CommandLine::NO_PROGRAM), |
59 source(extensions::SOURCE_UNTRACKED) { | 63 source(source) { |
60 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { | 64 if (raw_disposition == NEW_FOREGROUND_TAB || |
| 65 raw_disposition == NEW_BACKGROUND_TAB) { |
61 container = extensions::LAUNCH_CONTAINER_TAB; | 66 container = extensions::LAUNCH_CONTAINER_TAB; |
62 } else if (disposition == NEW_WINDOW) { | 67 disposition = raw_disposition; |
| 68 } else if (raw_disposition == NEW_WINDOW) { |
63 container = extensions::LAUNCH_CONTAINER_WINDOW; | 69 container = extensions::LAUNCH_CONTAINER_WINDOW; |
| 70 disposition = raw_disposition; |
64 } else { | 71 } else { |
65 // Look at preference to find the right launch container. If no preference | 72 // Look at preference to find the right launch container. If no preference |
66 // is set, launch as a regular tab. | 73 // is set, launch as a regular tab. |
67 container = | 74 container = |
68 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); | 75 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); |
69 disposition = NEW_FOREGROUND_TAB; | 76 disposition = NEW_FOREGROUND_TAB; |
70 } | 77 } |
71 } | 78 } |
72 | 79 |
73 AppLaunchParams::~AppLaunchParams() { | 80 AppLaunchParams::~AppLaunchParams() { |
74 } | 81 } |
OLD | NEW |