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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "chrome/browser/extensions/launch_util.h" | 8 #include "chrome/browser/extensions/launch_util.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "extensions/browser/extension_prefs.h" | 10 #include "extensions/browser/extension_prefs.h" |
11 #include "extensions/common/constants.h" | 11 #include "extensions/common/constants.h" |
12 #include "extensions/common/extension.h" | 12 #include "extensions/common/extension.h" |
13 #include "ui/base/window_open_disposition.h" | 13 #include "ui/base/window_open_disposition.h" |
14 | 14 |
15 #if defined(OS_CHROMEOS) | 15 #if defined(OS_CHROMEOS) |
16 #include "chrome/browser/chromeos/arc/arc_util.h" | 16 #include "chrome/browser/chromeos/arc/arc_util.h" |
17 #include "components/arc/arc_util.h" | 17 #include "components/arc/arc_util.h" |
18 #endif | 18 #endif |
19 | 19 |
20 using extensions::ExtensionPrefs; | 20 using extensions::ExtensionPrefs; |
21 using extensions::api::app_runtime::PlayStoreStatus; | 21 using extensions::api::app_runtime::PlayStoreStatus; |
22 | 22 |
23 AppLaunchParams::AppLaunchParams(Profile* profile, | 23 AppLaunchParams::AppLaunchParams(Profile* profile, |
24 const extensions::Extension* extension, | 24 const extensions::Extension* extension, |
25 extensions::LaunchContainer container, | 25 extensions::LaunchContainer container, |
26 WindowOpenDisposition disposition, | 26 WindowOpenDisposition disposition, |
27 extensions::AppLaunchSource source, | 27 extensions::AppLaunchSource source, |
28 bool set_playstore_status) | 28 bool set_playstore_status, |
| 29 int64_t display_id) |
29 : profile(profile), | 30 : profile(profile), |
30 extension_id(extension ? extension->id() : std::string()), | 31 extension_id(extension ? extension->id() : std::string()), |
31 container(container), | 32 container(container), |
32 disposition(disposition), | 33 disposition(disposition), |
33 command_line(base::CommandLine::NO_PROGRAM), | 34 command_line(base::CommandLine::NO_PROGRAM), |
34 source(source), | 35 source(source), |
35 play_store_status(PlayStoreStatus::PLAY_STORE_STATUS_UNKNOWN) { | 36 play_store_status(PlayStoreStatus::PLAY_STORE_STATUS_UNKNOWN), |
| 37 display_id(display_id) { |
36 #if defined(OS_CHROMEOS) | 38 #if defined(OS_CHROMEOS) |
37 // TODO(b/34478891): Remove this from app launch. | 39 // TODO(b/34478891): Remove this from app launch. |
38 if (set_playstore_status) { | 40 if (set_playstore_status) { |
39 if (arc::IsArcAllowedForProfile(profile)) | 41 if (arc::IsArcAllowedForProfile(profile)) |
40 play_store_status = PlayStoreStatus::PLAY_STORE_STATUS_ENABLED; | 42 play_store_status = PlayStoreStatus::PLAY_STORE_STATUS_ENABLED; |
41 else if (arc::IsArcAvailable()) | 43 else if (arc::IsArcAvailable()) |
42 play_store_status = PlayStoreStatus::PLAY_STORE_STATUS_AVAILABLE; | 44 play_store_status = PlayStoreStatus::PLAY_STORE_STATUS_AVAILABLE; |
43 // else, default to PLAY_STORE_STATUS_UNKNOWN. | 45 // else, default to PLAY_STORE_STATUS_UNKNOWN. |
44 } | 46 } |
45 #endif | 47 #endif |
(...skipping 12 matching lines...) Expand all Loading... |
58 // is to launch as a regular tab. | 60 // is to launch as a regular tab. |
59 extensions::LaunchContainer container = | 61 extensions::LaunchContainer container = |
60 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); | 62 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); |
61 return AppLaunchParams(profile, extension, container, disposition, source); | 63 return AppLaunchParams(profile, extension, container, disposition, source); |
62 } | 64 } |
63 | 65 |
64 AppLaunchParams CreateAppLaunchParamsWithEventFlags( | 66 AppLaunchParams CreateAppLaunchParamsWithEventFlags( |
65 Profile* profile, | 67 Profile* profile, |
66 const extensions::Extension* extension, | 68 const extensions::Extension* extension, |
67 int event_flags, | 69 int event_flags, |
68 extensions::AppLaunchSource source) { | 70 extensions::AppLaunchSource source, |
| 71 int64_t display_id) { |
69 WindowOpenDisposition raw_disposition = | 72 WindowOpenDisposition raw_disposition = |
70 ui::DispositionFromEventFlags(event_flags); | 73 ui::DispositionFromEventFlags(event_flags); |
71 | 74 |
72 extensions::LaunchContainer container; | 75 extensions::LaunchContainer container; |
73 WindowOpenDisposition disposition; | 76 WindowOpenDisposition disposition; |
74 if (raw_disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB || | 77 if (raw_disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB || |
75 raw_disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) { | 78 raw_disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) { |
76 container = extensions::LAUNCH_CONTAINER_TAB; | 79 container = extensions::LAUNCH_CONTAINER_TAB; |
77 disposition = raw_disposition; | 80 disposition = raw_disposition; |
78 } else if (raw_disposition == WindowOpenDisposition::NEW_WINDOW) { | 81 } else if (raw_disposition == WindowOpenDisposition::NEW_WINDOW) { |
79 container = extensions::LAUNCH_CONTAINER_WINDOW; | 82 container = extensions::LAUNCH_CONTAINER_WINDOW; |
80 disposition = raw_disposition; | 83 disposition = raw_disposition; |
81 } else { | 84 } else { |
82 // Look at preference to find the right launch container. If no preference | 85 // Look at preference to find the right launch container. If no preference |
83 // is set, launch as a regular tab. | 86 // is set, launch as a regular tab. |
84 container = | 87 container = |
85 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); | 88 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); |
86 disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; | 89 disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
87 } | 90 } |
88 return AppLaunchParams(profile, extension, container, disposition, source); | 91 return AppLaunchParams(profile, extension, container, disposition, source, |
| 92 false, display_id); |
89 } | 93 } |
OLD | NEW |