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_browser_operations.h" | 5 #include "chrome/installer/util/chrome_browser_operations.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/installer/util/browser_distribution.h" | 12 #include "chrome/installer/util/browser_distribution.h" |
13 #include "chrome/installer/util/channel_info.h" | 13 #include "chrome/installer/util/channel_info.h" |
14 #include "chrome/installer/util/helper.h" | 14 #include "chrome/installer/util/helper.h" |
15 #include "chrome/installer/util/install_util.h" | 15 #include "chrome/installer/util/install_util.h" |
16 #include "chrome/installer/util/master_preferences.h" | 16 #include "chrome/installer/util/master_preferences.h" |
17 #include "chrome/installer/util/master_preferences_constants.h" | 17 #include "chrome/installer/util/master_preferences_constants.h" |
18 #include "chrome/installer/util/shell_util.h" | 18 #include "chrome/installer/util/shell_util.h" |
| 19 #include "chrome/installer/util/user_experiment.h" |
19 #include "chrome/installer/util/util_constants.h" | 20 #include "chrome/installer/util/util_constants.h" |
20 | 21 |
21 namespace installer { | 22 namespace installer { |
22 | 23 |
23 void ChromeBrowserOperations::ReadOptions( | 24 void ChromeBrowserOperations::ReadOptions(const MasterPreferences& prefs, |
24 const MasterPreferences& prefs, | 25 std::set<string16>* options) const { |
25 std::set<std::wstring>* options) const { | |
26 DCHECK(options); | 26 DCHECK(options); |
27 | 27 |
28 bool pref_value; | 28 bool pref_value; |
29 | 29 |
30 if (prefs.GetBool(master_preferences::kMultiInstall, &pref_value) && | 30 if (prefs.GetBool(master_preferences::kMultiInstall, &pref_value) && |
31 pref_value) { | 31 pref_value) { |
32 options->insert(kOptionMultiInstall); | 32 options->insert(kOptionMultiInstall); |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 void ChromeBrowserOperations::ReadOptions( | 36 void ChromeBrowserOperations::ReadOptions(const CommandLine& uninstall_command, |
37 const CommandLine& uninstall_command, | 37 std::set<string16>* options) const { |
38 std::set<std::wstring>* options) const { | |
39 DCHECK(options); | 38 DCHECK(options); |
40 | 39 |
41 if (uninstall_command.HasSwitch(switches::kMultiInstall)) | 40 if (uninstall_command.HasSwitch(switches::kMultiInstall)) |
42 options->insert(kOptionMultiInstall); | 41 options->insert(kOptionMultiInstall); |
43 } | 42 } |
44 | 43 |
45 void ChromeBrowserOperations::AddKeyFiles( | 44 void ChromeBrowserOperations::AddKeyFiles( |
46 const std::set<std::wstring>& options, | 45 const std::set<string16>& options, |
47 std::vector<base::FilePath>* key_files) const { | 46 std::vector<base::FilePath>* key_files) const { |
48 DCHECK(key_files); | 47 DCHECK(key_files); |
49 key_files->push_back(base::FilePath(installer::kChromeDll)); | 48 key_files->push_back(base::FilePath(installer::kChromeDll)); |
50 } | 49 } |
51 | 50 |
52 void ChromeBrowserOperations::AddComDllList( | 51 void ChromeBrowserOperations::AddComDllList( |
53 const std::set<std::wstring>& options, | 52 const std::set<string16>& options, |
54 std::vector<base::FilePath>* com_dll_list) const { | 53 std::vector<base::FilePath>* com_dll_list) const { |
55 } | 54 } |
56 | 55 |
57 void ChromeBrowserOperations::AppendProductFlags( | 56 void ChromeBrowserOperations::AppendProductFlags( |
58 const std::set<std::wstring>& options, | 57 const std::set<string16>& options, |
59 CommandLine* cmd_line) const { | 58 CommandLine* cmd_line) const { |
60 DCHECK(cmd_line); | 59 DCHECK(cmd_line); |
61 | 60 |
62 if (options.find(kOptionMultiInstall) != options.end()) { | 61 if (options.find(kOptionMultiInstall) != options.end()) { |
63 // Add --multi-install if it isn't already there. | 62 // Add --multi-install if it isn't already there. |
64 if (!cmd_line->HasSwitch(switches::kMultiInstall)) | 63 if (!cmd_line->HasSwitch(switches::kMultiInstall)) |
65 cmd_line->AppendSwitch(switches::kMultiInstall); | 64 cmd_line->AppendSwitch(switches::kMultiInstall); |
66 | 65 |
67 // --chrome is only needed in multi-install. | 66 // --chrome is only needed in multi-install. |
68 cmd_line->AppendSwitch(switches::kChrome); | 67 cmd_line->AppendSwitch(switches::kChrome); |
69 } | 68 } |
70 } | 69 } |
71 | 70 |
72 void ChromeBrowserOperations::AppendRenameFlags( | 71 void ChromeBrowserOperations::AppendRenameFlags( |
73 const std::set<std::wstring>& options, | 72 const std::set<string16>& options, |
74 CommandLine* cmd_line) const { | 73 CommandLine* cmd_line) const { |
75 DCHECK(cmd_line); | 74 DCHECK(cmd_line); |
76 | 75 |
77 // Add --multi-install if it isn't already there. | 76 // Add --multi-install if it isn't already there. |
78 if (options.find(kOptionMultiInstall) != options.end() && | 77 if (options.find(kOptionMultiInstall) != options.end() && |
79 !cmd_line->HasSwitch(switches::kMultiInstall)) { | 78 !cmd_line->HasSwitch(switches::kMultiInstall)) { |
80 cmd_line->AppendSwitch(switches::kMultiInstall); | 79 cmd_line->AppendSwitch(switches::kMultiInstall); |
81 } | 80 } |
82 } | 81 } |
83 | 82 |
84 bool ChromeBrowserOperations::SetChannelFlags( | 83 bool ChromeBrowserOperations::SetChannelFlags(const std::set<string16>& options, |
85 const std::set<std::wstring>& options, | 84 bool set, |
86 bool set, | 85 ChannelInfo* channel_info) const { |
87 ChannelInfo* channel_info) const { | |
88 #if defined(GOOGLE_CHROME_BUILD) | 86 #if defined(GOOGLE_CHROME_BUILD) |
89 DCHECK(channel_info); | 87 DCHECK(channel_info); |
90 return channel_info->SetChrome(set); | 88 return channel_info->SetChrome(set); |
91 #else | 89 #else |
92 return false; | 90 return false; |
93 #endif | 91 #endif |
94 } | 92 } |
95 | 93 |
96 bool ChromeBrowserOperations::ShouldCreateUninstallEntry( | 94 bool ChromeBrowserOperations::ShouldCreateUninstallEntry( |
97 const std::set<std::wstring>& options) const { | 95 const std::set<string16>& options) const { |
98 return true; | 96 return true; |
99 } | 97 } |
100 | 98 |
101 // Modifies a ShortcutProperties object by adding default values to | 99 // Modifies a ShortcutProperties object by adding default values to |
102 // uninitialized members. Tries to assign: | 100 // uninitialized members. Tries to assign: |
103 // - target: |chrome_exe|. | 101 // - target: |chrome_exe|. |
104 // - icon: from |chrome_exe|. | 102 // - icon: from |chrome_exe|. |
105 // - icon_index: |dist|'s icon index (possibly overridden by | 103 // - icon_index: |dist|'s icon index (possibly overridden by |
106 // khromeShortcutIconIndex in master_preferences) | 104 // khromeShortcutIconIndex in master_preferences) |
107 // - app_id: the browser model id for the current install. | 105 // - app_id: the browser model id for the current install. |
(...skipping 21 matching lines...) Expand all Loading... |
129 bool is_per_user_install = | 127 bool is_per_user_install = |
130 InstallUtil::IsPerUserInstall(target_exe.value().c_str()); | 128 InstallUtil::IsPerUserInstall(target_exe.value().c_str()); |
131 properties->set_app_id( | 129 properties->set_app_id( |
132 ShellUtil::GetBrowserModelId(dist, is_per_user_install)); | 130 ShellUtil::GetBrowserModelId(dist, is_per_user_install)); |
133 } | 131 } |
134 | 132 |
135 if (!properties->has_description()) | 133 if (!properties->has_description()) |
136 properties->set_description(dist->GetAppDescription()); | 134 properties->set_description(dist->GetAppDescription()); |
137 } | 135 } |
138 | 136 |
| 137 void ChromeBrowserOperations::LaunchUserExperiment( |
| 138 const base::FilePath& setup_path, |
| 139 const std::set<string16>& options, |
| 140 InstallStatus status, |
| 141 bool system_level) const { |
| 142 CommandLine base_command(setup_path); |
| 143 AppendProductFlags(options, &base_command); |
| 144 installer::LaunchBrowserUserExperiment(base_command, status, system_level); |
| 145 } |
| 146 |
139 } // namespace installer | 147 } // namespace installer |
OLD | NEW |