| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/installer/util/chrome_app_host_operations.h" | 5 #include "chrome/installer/util/chrome_app_host_operations.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/installer/util/browser_distribution.h" | 11 #include "chrome/installer/util/browser_distribution.h" |
| 12 #include "chrome/installer/util/channel_info.h" | 12 #include "chrome/installer/util/channel_info.h" |
| 13 #include "chrome/installer/util/helper.h" | 13 #include "chrome/installer/util/helper.h" |
| 14 #include "chrome/installer/util/master_preferences.h" | 14 #include "chrome/installer/util/master_preferences.h" |
| 15 #include "chrome/installer/util/master_preferences_constants.h" | 15 #include "chrome/installer/util/master_preferences_constants.h" |
| 16 #include "chrome/installer/util/shell_util.h" | 16 #include "chrome/installer/util/shell_util.h" |
| 17 #include "chrome/installer/util/util_constants.h" | 17 #include "chrome/installer/util/util_constants.h" |
| 18 | 18 |
| 19 namespace installer { | 19 namespace installer { |
| 20 | 20 |
| 21 void ChromeAppHostOperations::ReadOptions(const MasterPreferences& prefs, | 21 void ChromeAppHostOperations::ReadOptions(const MasterPreferences& prefs, |
| 22 std::set<string16>* options) const { | 22 std::set<base::string16>* options) |
| 23 const { |
| 23 DCHECK(options); | 24 DCHECK(options); |
| 24 | 25 |
| 25 bool pref_value; | 26 bool pref_value; |
| 26 if (prefs.GetBool(master_preferences::kMultiInstall, &pref_value) && | 27 if (prefs.GetBool(master_preferences::kMultiInstall, &pref_value) && |
| 27 pref_value) { | 28 pref_value) { |
| 28 options->insert(kOptionMultiInstall); | 29 options->insert(kOptionMultiInstall); |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 | 32 |
| 32 void ChromeAppHostOperations::ReadOptions(const CommandLine& uninstall_command, | 33 void ChromeAppHostOperations::ReadOptions(const CommandLine& uninstall_command, |
| 33 std::set<string16>* options) const { | 34 std::set<base::string16>* options) |
| 35 const { |
| 34 DCHECK(options); | 36 DCHECK(options); |
| 35 | 37 |
| 36 if (uninstall_command.HasSwitch(switches::kMultiInstall)) | 38 if (uninstall_command.HasSwitch(switches::kMultiInstall)) |
| 37 options->insert(kOptionMultiInstall); | 39 options->insert(kOptionMultiInstall); |
| 38 } | 40 } |
| 39 | 41 |
| 40 void ChromeAppHostOperations::AddKeyFiles( | 42 void ChromeAppHostOperations::AddKeyFiles( |
| 41 const std::set<string16>& options, | 43 const std::set<base::string16>& options, |
| 42 std::vector<base::FilePath>* key_files) const { | 44 std::vector<base::FilePath>* key_files) const { |
| 43 } | 45 } |
| 44 | 46 |
| 45 void ChromeAppHostOperations::AddComDllList( | 47 void ChromeAppHostOperations::AddComDllList( |
| 46 const std::set<string16>& options, | 48 const std::set<base::string16>& options, |
| 47 std::vector<base::FilePath>* com_dll_list) const { | 49 std::vector<base::FilePath>* com_dll_list) const { |
| 48 } | 50 } |
| 49 | 51 |
| 50 void ChromeAppHostOperations::AppendProductFlags( | 52 void ChromeAppHostOperations::AppendProductFlags( |
| 51 const std::set<string16>& options, | 53 const std::set<base::string16>& options, |
| 52 CommandLine* cmd_line) const { | 54 CommandLine* cmd_line) const { |
| 53 DCHECK(cmd_line); | 55 DCHECK(cmd_line); |
| 54 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); | 56 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); |
| 55 | 57 |
| 56 // Non-multi-install not supported for the app host. | 58 // Non-multi-install not supported for the app host. |
| 57 DCHECK(is_multi_install); | 59 DCHECK(is_multi_install); |
| 58 | 60 |
| 59 // Add --multi-install if it isn't already there. | 61 // Add --multi-install if it isn't already there. |
| 60 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) | 62 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) |
| 61 cmd_line->AppendSwitch(switches::kMultiInstall); | 63 cmd_line->AppendSwitch(switches::kMultiInstall); |
| 62 | 64 |
| 63 // Add --app-launcher. | 65 // Add --app-launcher. |
| 64 cmd_line->AppendSwitch(switches::kChromeAppLauncher); | 66 cmd_line->AppendSwitch(switches::kChromeAppLauncher); |
| 65 } | 67 } |
| 66 | 68 |
| 67 void ChromeAppHostOperations::AppendRenameFlags( | 69 void ChromeAppHostOperations::AppendRenameFlags( |
| 68 const std::set<string16>& options, | 70 const std::set<base::string16>& options, |
| 69 CommandLine* cmd_line) const { | 71 CommandLine* cmd_line) const { |
| 70 DCHECK(cmd_line); | 72 DCHECK(cmd_line); |
| 71 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); | 73 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); |
| 72 | 74 |
| 73 // Non-multi-install not supported for the app host. | 75 // Non-multi-install not supported for the app host. |
| 74 DCHECK(is_multi_install); | 76 DCHECK(is_multi_install); |
| 75 | 77 |
| 76 // Add --multi-install if it isn't already there. | 78 // Add --multi-install if it isn't already there. |
| 77 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) | 79 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) |
| 78 cmd_line->AppendSwitch(switches::kMultiInstall); | 80 cmd_line->AppendSwitch(switches::kMultiInstall); |
| 79 } | 81 } |
| 80 | 82 |
| 81 bool ChromeAppHostOperations::SetChannelFlags(const std::set<string16>& options, | 83 bool ChromeAppHostOperations::SetChannelFlags( |
| 82 bool set, | 84 const std::set<base::string16>& options, |
| 83 ChannelInfo* channel_info) const { | 85 bool set, |
| 86 ChannelInfo* channel_info) const { |
| 84 #if defined(GOOGLE_CHROME_BUILD) | 87 #if defined(GOOGLE_CHROME_BUILD) |
| 85 DCHECK(channel_info); | 88 DCHECK(channel_info); |
| 86 return channel_info->SetAppLauncher(set); | 89 return channel_info->SetAppLauncher(set); |
| 87 #else | 90 #else |
| 88 return false; | 91 return false; |
| 89 #endif | 92 #endif |
| 90 } | 93 } |
| 91 | 94 |
| 92 bool ChromeAppHostOperations::ShouldCreateUninstallEntry( | 95 bool ChromeAppHostOperations::ShouldCreateUninstallEntry( |
| 93 const std::set<string16>& options) const { | 96 const std::set<base::string16>& options) const { |
| 94 return true; | 97 return true; |
| 95 } | 98 } |
| 96 | 99 |
| 97 void ChromeAppHostOperations::AddDefaultShortcutProperties( | 100 void ChromeAppHostOperations::AddDefaultShortcutProperties( |
| 98 BrowserDistribution* dist, | 101 BrowserDistribution* dist, |
| 99 const base::FilePath& target_exe, | 102 const base::FilePath& target_exe, |
| 100 ShellUtil::ShortcutProperties* properties) const { | 103 ShellUtil::ShortcutProperties* properties) const { |
| 101 if (!properties->has_target()) | 104 if (!properties->has_target()) |
| 102 properties->set_target(target_exe); | 105 properties->set_target(target_exe); |
| 103 | 106 |
| 104 if (!properties->has_arguments()) { | 107 if (!properties->has_arguments()) { |
| 105 CommandLine app_host_args(CommandLine::NO_PROGRAM); | 108 CommandLine app_host_args(CommandLine::NO_PROGRAM); |
| 106 app_host_args.AppendSwitch(::switches::kShowAppList); | 109 app_host_args.AppendSwitch(::switches::kShowAppList); |
| 107 properties->set_arguments(app_host_args.GetCommandLineString()); | 110 properties->set_arguments(app_host_args.GetCommandLineString()); |
| 108 } | 111 } |
| 109 | 112 |
| 110 if (!properties->has_icon()) | 113 if (!properties->has_icon()) |
| 111 properties->set_icon(target_exe, | 114 properties->set_icon(target_exe, |
| 112 dist->GetIconIndex(BrowserDistribution::SHORTCUT_APP_LAUNCHER)); | 115 dist->GetIconIndex(BrowserDistribution::SHORTCUT_APP_LAUNCHER)); |
| 113 | 116 |
| 114 if (!properties->has_app_id()) { | 117 if (!properties->has_app_id()) { |
| 115 std::vector<string16> components; | 118 std::vector<base::string16> components; |
| 116 components.push_back(dist->GetBaseAppId()); | 119 components.push_back(dist->GetBaseAppId()); |
| 117 properties->set_app_id(ShellUtil::BuildAppModelId(components)); | 120 properties->set_app_id(ShellUtil::BuildAppModelId(components)); |
| 118 } | 121 } |
| 119 } | 122 } |
| 120 | 123 |
| 121 void ChromeAppHostOperations::LaunchUserExperiment( | 124 void ChromeAppHostOperations::LaunchUserExperiment( |
| 122 const base::FilePath& setup_path, | 125 const base::FilePath& setup_path, |
| 123 const std::set<string16>& options, | 126 const std::set<base::string16>& options, |
| 124 InstallStatus status, | 127 InstallStatus status, |
| 125 bool system_level) const { | 128 bool system_level) const { |
| 126 // No experiments yet. If adding some in the future, need to have | 129 // No experiments yet. If adding some in the future, need to have |
| 127 // ChromeAppHostDistribution::HasUserExperiments() return true. | 130 // ChromeAppHostDistribution::HasUserExperiments() return true. |
| 128 NOTREACHED(); | 131 NOTREACHED(); |
| 129 } | 132 } |
| 130 | 133 |
| 131 } // namespace installer | 134 } // namespace installer |
| OLD | NEW |