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