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/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/installer/util/browser_distribution.h" | 10 #include "chrome/installer/util/browser_distribution.h" |
11 #include "chrome/installer/util/channel_info.h" | 11 #include "chrome/installer/util/channel_info.h" |
12 #include "chrome/installer/util/helper.h" | 12 #include "chrome/installer/util/helper.h" |
13 #include "chrome/installer/util/master_preferences.h" | 13 #include "chrome/installer/util/master_preferences.h" |
14 #include "chrome/installer/util/master_preferences_constants.h" | 14 #include "chrome/installer/util/master_preferences_constants.h" |
15 #include "chrome/installer/util/util_constants.h" | 15 #include "chrome/installer/util/util_constants.h" |
16 | 16 |
17 namespace installer { | 17 namespace installer { |
18 | 18 |
19 void ChromeAppHostOperations::ReadOptions( | 19 void ChromeAppHostOperations::ReadOptions( |
20 const MasterPreferences& prefs, | 20 const MasterPreferences& prefs, |
21 std::set<std::wstring>* options) const { | 21 std::set<std::wstring>* options) const { |
22 DCHECK(options); | 22 DCHECK(options); |
23 | 23 |
24 bool pref_value; | 24 bool pref_value; |
25 if (prefs.GetBool(master_preferences::kMultiInstall, &pref_value) && | 25 if (prefs.GetBool(master_preferences::kMultiInstall, &pref_value) && |
26 pref_value) { | 26 pref_value) { |
27 options->insert(kOptionMultiInstall); | 27 options->insert(kOptionMultiInstall); |
28 } | 28 } |
29 if (prefs.GetBool(master_preferences::kChromeAppLauncher, &pref_value) && | |
30 pref_value) { | |
31 options->insert(kOptionAppLauncher); | |
32 } | |
29 } | 33 } |
30 | 34 |
31 void ChromeAppHostOperations::ReadOptions( | 35 void ChromeAppHostOperations::ReadOptions( |
32 const CommandLine& uninstall_command, | 36 const CommandLine& uninstall_command, |
33 std::set<std::wstring>* options) const { | 37 std::set<std::wstring>* options) const { |
34 DCHECK(options); | 38 DCHECK(options); |
35 | 39 |
36 if (uninstall_command.HasSwitch(switches::kMultiInstall)) | 40 if (uninstall_command.HasSwitch(switches::kMultiInstall)) |
37 options->insert(kOptionMultiInstall); | 41 options->insert(kOptionMultiInstall); |
42 if (uninstall_command.HasSwitch(switches::kChromeAppLauncher)) | |
43 options->insert(kOptionAppLauncher); | |
38 } | 44 } |
39 | 45 |
40 void ChromeAppHostOperations::AddKeyFiles( | 46 void ChromeAppHostOperations::AddKeyFiles( |
41 const std::set<std::wstring>& options, | 47 const std::set<std::wstring>& options, |
42 std::vector<FilePath>* key_files) const { | 48 std::vector<FilePath>* key_files) const { |
43 } | 49 } |
44 | 50 |
45 void ChromeAppHostOperations::AddComDllList( | 51 void ChromeAppHostOperations::AddComDllList( |
46 const std::set<std::wstring>& options, | 52 const std::set<std::wstring>& options, |
47 std::vector<FilePath>* com_dll_list) const { | 53 std::vector<FilePath>* com_dll_list) const { |
48 } | 54 } |
49 | 55 |
50 void ChromeAppHostOperations::AppendProductFlags( | 56 void ChromeAppHostOperations::AppendProductFlags( |
51 const std::set<std::wstring>& options, | 57 const std::set<std::wstring>& options, |
52 CommandLine* cmd_line) const { | 58 CommandLine* cmd_line) const { |
53 DCHECK(cmd_line); | 59 DCHECK(cmd_line); |
54 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); | 60 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); |
55 | 61 |
56 // Non-multi-install not supported for the app host. | 62 // Non-multi-install not supported for the app host. |
57 DCHECK(is_multi_install); | 63 DCHECK(is_multi_install); |
58 | 64 |
59 // Add --multi-install if it isn't already there. | 65 // Add --multi-install if it isn't already there. |
60 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) | 66 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) |
61 cmd_line->AppendSwitch(switches::kMultiInstall); | 67 cmd_line->AppendSwitch(switches::kMultiInstall); |
62 | 68 |
63 // --app-host is always needed. | 69 // Either --app-host or --app-launcher is always needed. |
64 cmd_line->AppendSwitch(switches::kChromeAppHost); | 70 if (options.find(kOptionAppLauncher) != options.end()) |
71 cmd_line->AppendSwitch(switches::kChromeAppLauncher); | |
72 else | |
73 cmd_line->AppendSwitch(switches::kChromeAppHost); | |
65 } | 74 } |
66 | 75 |
67 void ChromeAppHostOperations::AppendRenameFlags( | 76 void ChromeAppHostOperations::AppendRenameFlags( |
68 const std::set<std::wstring>& options, | 77 const std::set<std::wstring>& options, |
69 CommandLine* cmd_line) const { | 78 CommandLine* cmd_line) const { |
70 DCHECK(cmd_line); | 79 DCHECK(cmd_line); |
71 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); | 80 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); |
72 | 81 |
73 // Non-multi-install not supported for the app host. | 82 // Non-multi-install not supported for the app host. |
74 DCHECK(is_multi_install); | 83 DCHECK(is_multi_install); |
75 | 84 |
76 // Add --multi-install if it isn't already there. | 85 // Add --multi-install if it isn't already there. |
77 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) | 86 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) |
78 cmd_line->AppendSwitch(switches::kMultiInstall); | 87 cmd_line->AppendSwitch(switches::kMultiInstall); |
79 } | 88 } |
80 | 89 |
81 bool ChromeAppHostOperations::SetChannelFlags( | 90 bool ChromeAppHostOperations::SetChannelFlags( |
82 const std::set<std::wstring>& options, | 91 const std::set<std::wstring>& options, |
83 bool set, | 92 bool set, |
84 ChannelInfo* channel_info) const { | 93 ChannelInfo* channel_info) const { |
85 #if defined(GOOGLE_CHROME_BUILD) | 94 #if defined(GOOGLE_CHROME_BUILD) |
86 DCHECK(channel_info); | 95 DCHECK(channel_info); |
87 bool modified = channel_info->SetAppHost(set); | 96 bool modified = false; |
88 | 97 // App Host and App Launcher are mutually exclusive. |
98 if (options.find(kOptionAppLauncher) != options.end()) { | |
99 modified = channel_info->SetAppLauncher(set); | |
100 if (set) | |
101 modified |= channel_info->SetAppHost(false); | |
grt (UTC plus 2)
2012/10/25 14:46:53
since |= is a bitwise operation, this is subtle.
huangs
2012/10/29 21:15:16
Done (taking note of short-circuiting). Note that
grt (UTC plus 2)
2012/10/30 13:02:55
I don't feel strongly that it should, although I r
| |
102 } else { | |
103 modified = channel_info->SetAppHost(set); | |
104 if (set) | |
105 modified |= channel_info->SetAppLauncher(false); | |
106 } | |
89 return modified; | 107 return modified; |
90 #else | 108 #else |
91 return false; | 109 return false; |
92 #endif | 110 #endif |
93 } | 111 } |
94 | 112 |
95 bool ChromeAppHostOperations::ShouldCreateUninstallEntry( | 113 bool ChromeAppHostOperations::ShouldCreateUninstallEntry( |
96 const std::set<std::wstring>& options) const { | 114 const std::set<std::wstring>& options) const { |
97 return false; | 115 return (options.find(kOptionAppLauncher) != options.end()); |
98 } | 116 } |
99 | 117 |
100 } // namespace installer | 118 } // namespace installer |
OLD | NEW |