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/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | |
10 #include "base/logging.h" | 9 #include "base/logging.h" |
11 #include "base/strings/string_util.h" | |
12 #include "chrome/installer/util/browser_distribution.h" | 10 #include "chrome/installer/util/browser_distribution.h" |
13 #include "chrome/installer/util/channel_info.h" | |
14 #include "chrome/installer/util/helper.h" | |
15 #include "chrome/installer/util/install_util.h" | 11 #include "chrome/installer/util/install_util.h" |
16 #include "chrome/installer/util/master_preferences.h" | |
17 #include "chrome/installer/util/master_preferences_constants.h" | |
18 #include "chrome/installer/util/shell_util.h" | 12 #include "chrome/installer/util/shell_util.h" |
19 #include "chrome/installer/util/user_experiment.h" | 13 #include "chrome/installer/util/user_experiment.h" |
20 #include "chrome/installer/util/util_constants.h" | 14 #include "chrome/installer/util/util_constants.h" |
21 | 15 |
22 namespace installer { | 16 namespace installer { |
23 | 17 |
24 void ChromeBrowserOperations::ReadOptions(const MasterPreferences& prefs, | |
25 std::set<base::string16>* options) | |
26 const { | |
27 DCHECK(options); | |
28 | |
29 bool pref_value; | |
30 | |
31 if (prefs.GetBool(master_preferences::kMultiInstall, &pref_value) && | |
32 pref_value) { | |
33 options->insert(kOptionMultiInstall); | |
34 } | |
35 } | |
36 | |
37 void ChromeBrowserOperations::ReadOptions( | |
38 const base::CommandLine& uninstall_command, | |
39 std::set<base::string16>* options) const { | |
40 DCHECK(options); | |
41 | |
42 if (uninstall_command.HasSwitch(switches::kMultiInstall)) | |
43 options->insert(kOptionMultiInstall); | |
44 } | |
45 | |
46 void ChromeBrowserOperations::AddKeyFiles( | 18 void ChromeBrowserOperations::AddKeyFiles( |
47 const std::set<base::string16>& options, | |
48 std::vector<base::FilePath>* key_files) const { | 19 std::vector<base::FilePath>* key_files) const { |
49 DCHECK(key_files); | 20 DCHECK(key_files); |
50 key_files->push_back(base::FilePath(installer::kChromeDll)); | 21 key_files->push_back(base::FilePath(installer::kChromeDll)); |
51 } | 22 } |
52 | 23 |
53 void ChromeBrowserOperations::AppendProductFlags( | 24 void ChromeBrowserOperations::AppendProductFlags( |
54 const std::set<base::string16>& options, | |
55 base::CommandLine* cmd_line) const { | 25 base::CommandLine* cmd_line) const { |
56 DCHECK(cmd_line); | |
57 | |
58 if (options.find(kOptionMultiInstall) != options.end()) { | |
59 // Add --multi-install if it isn't already there. | |
60 if (!cmd_line->HasSwitch(switches::kMultiInstall)) | |
61 cmd_line->AppendSwitch(switches::kMultiInstall); | |
62 | |
63 // --chrome is only needed in multi-install. | |
64 cmd_line->AppendSwitch(switches::kChrome); | |
65 } | |
66 } | 26 } |
67 | 27 |
68 void ChromeBrowserOperations::AppendRenameFlags( | 28 void ChromeBrowserOperations::AppendRenameFlags( |
69 const std::set<base::string16>& options, | |
70 base::CommandLine* cmd_line) const { | 29 base::CommandLine* cmd_line) const { |
71 DCHECK(cmd_line); | |
72 | |
73 // Add --multi-install if it isn't already there. | |
74 if (options.find(kOptionMultiInstall) != options.end() && | |
75 !cmd_line->HasSwitch(switches::kMultiInstall)) { | |
76 cmd_line->AppendSwitch(switches::kMultiInstall); | |
77 } | |
78 } | |
79 | |
80 bool ChromeBrowserOperations::SetChannelFlags( | |
81 const std::set<base::string16>& options, | |
82 bool set, | |
83 ChannelInfo* channel_info) const { | |
84 #if defined(GOOGLE_CHROME_BUILD) | |
85 DCHECK(channel_info); | |
86 bool chrome_changed = channel_info->SetChrome(set); | |
87 // Remove App Launcher's channel flags, since App Launcher does not exist as | |
88 // an independent product, and is a part of Chrome. | |
89 bool app_launcher_changed = channel_info->SetAppLauncher(false); | |
90 return chrome_changed || app_launcher_changed; | |
91 #else | |
92 return false; | |
93 #endif | |
94 } | 30 } |
95 | 31 |
96 // Modifies a ShortcutProperties object by adding default values to | 32 // Modifies a ShortcutProperties object by adding default values to |
97 // uninitialized members. Tries to assign: | 33 // uninitialized members. Tries to assign: |
98 // - target: |chrome_exe|. | 34 // - target: |chrome_exe|. |
99 // - icon: from |chrome_exe|. | 35 // - icon: from |chrome_exe|. |
100 // - icon_index: |dist|'s icon index | 36 // - icon_index: |dist|'s icon index |
101 // - app_id: the browser model id for the current install. | 37 // - app_id: the browser model id for the current install. |
102 // - description: |dist|'s description. | 38 // - description: |dist|'s description. |
103 void ChromeBrowserOperations::AddDefaultShortcutProperties( | 39 void ChromeBrowserOperations::AddDefaultShortcutProperties( |
(...skipping 10 matching lines...) Expand all Loading... |
114 properties->set_app_id(ShellUtil::GetBrowserModelId( | 50 properties->set_app_id(ShellUtil::GetBrowserModelId( |
115 dist, InstallUtil::IsPerUserInstall(target_exe))); | 51 dist, InstallUtil::IsPerUserInstall(target_exe))); |
116 } | 52 } |
117 | 53 |
118 if (!properties->has_description()) | 54 if (!properties->has_description()) |
119 properties->set_description(dist->GetAppDescription()); | 55 properties->set_description(dist->GetAppDescription()); |
120 } | 56 } |
121 | 57 |
122 void ChromeBrowserOperations::LaunchUserExperiment( | 58 void ChromeBrowserOperations::LaunchUserExperiment( |
123 const base::FilePath& setup_path, | 59 const base::FilePath& setup_path, |
124 const std::set<base::string16>& options, | |
125 InstallStatus status, | 60 InstallStatus status, |
126 bool system_level) const { | 61 bool system_level) const { |
127 base::CommandLine base_command(setup_path); | 62 base::CommandLine base_command(setup_path); |
128 AppendProductFlags(options, &base_command); | 63 AppendProductFlags(&base_command); |
129 installer::LaunchBrowserUserExperiment(base_command, status, system_level); | 64 installer::LaunchBrowserUserExperiment(base_command, status, system_level); |
130 } | 65 } |
131 | 66 |
132 } // namespace installer | 67 } // namespace installer |
OLD | NEW |