Chromium Code Reviews| 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/constants.h" |
| 11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 #include "ui/base/window_open_disposition.h" | 12 #include "ui/base/window_open_disposition.h" |
| 13 | 13 |
| 14 using extensions::ExtensionPrefs; | 14 using extensions::ExtensionPrefs; |
| 15 | 15 |
| 16 AppLaunchParams::AppLaunchParams(Profile* profile, | 16 AppLaunchParams::AppLaunchParams(Profile* profile, |
| 17 const extensions::Extension* extension, | 17 const extensions::Extension* extension, |
| 18 extensions::LaunchContainer container, | 18 extensions::LaunchContainer container, |
| 19 WindowOpenDisposition disposition, | 19 WindowOpenDisposition disposition, |
| 20 extensions::AppLaunchSource source) | 20 extensions::AppLaunchSource source) |
| 21 : profile(profile), | 21 : profile(profile), |
| 22 extension_id(extension ? extension->id() : std::string()), | 22 extension_id(extension ? extension->id() : std::string()), |
| 23 container(container), | 23 container(container), |
| 24 disposition(disposition), | 24 disposition(disposition), |
| 25 desktop_type(chrome::GetActiveDesktop()), | |
| 26 override_url(), | |
| 27 override_bounds(), | |
| 28 command_line(base::CommandLine::NO_PROGRAM), | 25 command_line(base::CommandLine::NO_PROGRAM), |
| 29 source(source) { | 26 source(source) {} |
| 27 | |
| 28 AppLaunchParams CreateAppLaunchParamsUserContainer( | |
| 29 Profile* profile, | |
| 30 const extensions::Extension* extension, | |
| 31 WindowOpenDisposition disposition, | |
| 32 extensions::AppLaunchSource source) { | |
| 33 // Look up the app preference to find out the right launch container. Default | |
| 34 // is to launch as a regular tab. | |
| 35 extensions::LaunchContainer container = | |
| 36 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); | |
| 37 return AppLaunchParams(profile, extension, container, disposition, source); | |
| 30 } | 38 } |
| 31 | 39 |
| 32 AppLaunchParams::AppLaunchParams(Profile* profile, | 40 AppLaunchParams CreateAppLaunchParamsOverriddenContainer( |
|
benwells
2016/03/16 06:29:43
All but one of the callers of this call it with ra
scottmg
2016/03/16 16:38:54
OK, for these 3, I switched to CreateAppLaunchPara
| |
| 33 const extensions::Extension* extension, | 41 Profile* profile, |
| 34 WindowOpenDisposition disposition, | 42 const extensions::Extension* extension, |
| 35 extensions::AppLaunchSource source) | 43 WindowOpenDisposition raw_disposition, |
| 36 : profile(profile), | 44 extensions::AppLaunchSource source) { |
| 37 extension_id(extension ? extension->id() : std::string()), | 45 extensions::LaunchContainer container; |
| 38 container(extensions::LAUNCH_CONTAINER_NONE), | 46 WindowOpenDisposition disposition; |
| 39 disposition(disposition), | |
| 40 desktop_type(chrome::GetActiveDesktop()), | |
| 41 override_url(), | |
| 42 override_bounds(), | |
| 43 command_line(base::CommandLine::NO_PROGRAM), | |
| 44 source(source) { | |
| 45 // Look up the app preference to find out the right launch container. Default | |
| 46 // is to launch as a regular tab. | |
| 47 container = | |
| 48 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); | |
| 49 } | |
| 50 | |
| 51 AppLaunchParams::AppLaunchParams(Profile* profile, | |
| 52 const extensions::Extension* extension, | |
| 53 WindowOpenDisposition raw_disposition, | |
| 54 chrome::HostDesktopType desktop_type, | |
| 55 extensions::AppLaunchSource source) | |
| 56 : profile(profile), | |
| 57 extension_id(extension ? extension->id() : std::string()), | |
| 58 container(extensions::LAUNCH_CONTAINER_NONE), | |
| 59 desktop_type(desktop_type), | |
| 60 override_url(), | |
| 61 override_bounds(), | |
| 62 command_line(base::CommandLine::NO_PROGRAM), | |
| 63 source(source) { | |
| 64 if (raw_disposition == NEW_FOREGROUND_TAB || | 47 if (raw_disposition == NEW_FOREGROUND_TAB || |
| 65 raw_disposition == NEW_BACKGROUND_TAB) { | 48 raw_disposition == NEW_BACKGROUND_TAB) { |
| 66 container = extensions::LAUNCH_CONTAINER_TAB; | 49 container = extensions::LAUNCH_CONTAINER_TAB; |
| 67 disposition = raw_disposition; | 50 disposition = raw_disposition; |
| 68 } else if (raw_disposition == NEW_WINDOW) { | 51 } else if (raw_disposition == NEW_WINDOW) { |
| 69 container = extensions::LAUNCH_CONTAINER_WINDOW; | 52 container = extensions::LAUNCH_CONTAINER_WINDOW; |
| 70 disposition = raw_disposition; | 53 disposition = raw_disposition; |
| 71 } else { | 54 } else { |
| 72 // Look at preference to find the right launch container. If no preference | 55 // Look at preference to find the right launch container. If no preference |
| 73 // is set, launch as a regular tab. | 56 // is set, launch as a regular tab. |
| 74 container = | 57 container = |
| 75 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); | 58 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); |
| 76 disposition = NEW_FOREGROUND_TAB; | 59 disposition = NEW_FOREGROUND_TAB; |
| 77 } | 60 } |
| 61 return AppLaunchParams(profile, extension, container, disposition, source); | |
| 78 } | 62 } |
| 79 | |
| 80 AppLaunchParams::AppLaunchParams(const AppLaunchParams& other) = default; | |
| 81 | |
| 82 AppLaunchParams::~AppLaunchParams() { | |
| 83 } | |
| OLD | NEW |