Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Side by Side Diff: chrome/installer/util/chrome_frame_operations.cc

Issue 12321061: Pulling user experiment code from BrowserDistribution to a new class. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: *Only* making ProductOperation to use string16 instead of std::wstring; wrapping changes. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_frame_operations.h" 5 #include "chrome/installer/util/chrome_frame_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/installer/util/channel_info.h" 10 #include "chrome/installer/util/channel_info.h"
11 #include "chrome/installer/util/helper.h" 11 #include "chrome/installer/util/helper.h"
12 #include "chrome/installer/util/master_preferences.h" 12 #include "chrome/installer/util/master_preferences.h"
13 #include "chrome/installer/util/master_preferences_constants.h" 13 #include "chrome/installer/util/master_preferences_constants.h"
14 #include "chrome/installer/util/util_constants.h" 14 #include "chrome/installer/util/util_constants.h"
15 15
16 namespace installer { 16 namespace installer {
17 17
18 // Remove ready-mode if not multi-install. 18 // Remove ready-mode if not multi-install.
19 void ChromeFrameOperations::NormalizeOptions( 19 void ChromeFrameOperations::NormalizeOptions(
20 std::set<std::wstring>* options) const { 20 std::set<string16>* options) const {
21 std::set<std::wstring>::iterator ready_mode(options->find(kOptionReadyMode)); 21 std::set<string16>::iterator ready_mode(options->find(kOptionReadyMode));
22 if (ready_mode != options->end() && 22 if (ready_mode != options->end() &&
23 options->find(kOptionMultiInstall) == options->end()) { 23 options->find(kOptionMultiInstall) == options->end()) {
24 LOG(WARNING) << "--ready-mode option does not apply when --multi-install " 24 LOG(WARNING) << "--ready-mode option does not apply when --multi-install "
25 "is not also specified; ignoring."; 25 "is not also specified; ignoring.";
26 options->erase(ready_mode); 26 options->erase(ready_mode);
27 } 27 }
28 } 28 }
29 29
30 void ChromeFrameOperations::ReadOptions( 30 void ChromeFrameOperations::ReadOptions(const MasterPreferences& prefs,
31 const MasterPreferences& prefs, 31 std::set<string16>* options) const {
32 std::set<std::wstring>* options) const {
33 DCHECK(options); 32 DCHECK(options);
34 33
35 static const struct PrefToOption { 34 static const struct PrefToOption {
36 const char* pref_name; 35 const char* pref_name;
37 const wchar_t* option_name; 36 const wchar_t* option_name;
38 } map[] = { 37 } map[] = {
39 { master_preferences::kChromeFrameReadyMode, kOptionReadyMode }, 38 { master_preferences::kChromeFrameReadyMode, kOptionReadyMode },
40 { master_preferences::kMultiInstall, kOptionMultiInstall } 39 { master_preferences::kMultiInstall, kOptionMultiInstall }
41 }; 40 };
42 41
43 bool pref_value; 42 bool pref_value;
44 43
45 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)]; 44 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)];
46 scan != end; ++scan) { 45 scan != end; ++scan) {
47 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value) 46 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value)
48 options->insert(scan->option_name); 47 options->insert(scan->option_name);
49 } 48 }
50 49
51 NormalizeOptions(options); 50 NormalizeOptions(options);
52 } 51 }
53 52
54 void ChromeFrameOperations::ReadOptions( 53 void ChromeFrameOperations::ReadOptions(const CommandLine& uninstall_command,
55 const CommandLine& uninstall_command, 54 std::set<string16>* options) const {
56 std::set<std::wstring>* options) const {
57 DCHECK(options); 55 DCHECK(options);
58 56
59 static const struct FlagToOption { 57 static const struct FlagToOption {
60 const char* flag_name; 58 const char* flag_name;
61 const wchar_t* option_name; 59 const wchar_t* option_name;
62 } map[] = { 60 } map[] = {
63 { switches::kChromeFrameReadyMode, kOptionReadyMode }, 61 { switches::kChromeFrameReadyMode, kOptionReadyMode },
64 { switches::kMultiInstall, kOptionMultiInstall } 62 { switches::kMultiInstall, kOptionMultiInstall }
65 }; 63 };
66 64
67 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)]; 65 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)];
68 scan != end; ++scan) { 66 scan != end; ++scan) {
69 if (uninstall_command.HasSwitch(scan->flag_name)) 67 if (uninstall_command.HasSwitch(scan->flag_name))
70 options->insert(scan->option_name); 68 options->insert(scan->option_name);
71 } 69 }
72 70
73 NormalizeOptions(options); 71 NormalizeOptions(options);
74 } 72 }
75 73
76 void ChromeFrameOperations::AddKeyFiles( 74 void ChromeFrameOperations::AddKeyFiles(
77 const std::set<std::wstring>& options, 75 const std::set<string16>& options,
78 std::vector<base::FilePath>* key_files) const { 76 std::vector<base::FilePath>* key_files) const {
79 DCHECK(key_files); 77 DCHECK(key_files);
80 key_files->push_back(base::FilePath(installer::kChromeFrameDll)); 78 key_files->push_back(base::FilePath(installer::kChromeFrameDll));
81 key_files->push_back(base::FilePath(installer::kChromeFrameHelperExe)); 79 key_files->push_back(base::FilePath(installer::kChromeFrameHelperExe));
82 } 80 }
83 81
84 void ChromeFrameOperations::AddComDllList( 82 void ChromeFrameOperations::AddComDllList(
85 const std::set<std::wstring>& options, 83 const std::set<string16>& options,
86 std::vector<base::FilePath>* com_dll_list) const { 84 std::vector<base::FilePath>* com_dll_list) const {
87 DCHECK(com_dll_list); 85 DCHECK(com_dll_list);
88 com_dll_list->push_back(base::FilePath(installer::kChromeFrameDll)); 86 com_dll_list->push_back(base::FilePath(installer::kChromeFrameDll));
89 } 87 }
90 88
91 void ChromeFrameOperations::AppendProductFlags( 89 void ChromeFrameOperations::AppendProductFlags(
92 const std::set<std::wstring>& options, 90 const std::set<string16>& options,
93 CommandLine* cmd_line) const { 91 CommandLine* cmd_line) const {
94 DCHECK(cmd_line); 92 DCHECK(cmd_line);
95 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); 93 bool is_multi_install = options.find(kOptionMultiInstall) != options.end();
96 94
97 // Add --multi-install if it isn't already there. 95 // Add --multi-install if it isn't already there.
98 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) 96 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall))
99 cmd_line->AppendSwitch(switches::kMultiInstall); 97 cmd_line->AppendSwitch(switches::kMultiInstall);
100 98
101 // --chrome-frame is always needed. 99 // --chrome-frame is always needed.
102 cmd_line->AppendSwitch(switches::kChromeFrame); 100 cmd_line->AppendSwitch(switches::kChromeFrame);
103 101
104 // ready-mode is only supported in multi-installs of Chrome Frame. 102 // ready-mode is only supported in multi-installs of Chrome Frame.
105 if (is_multi_install && options.find(kOptionReadyMode) != options.end()) 103 if (is_multi_install && options.find(kOptionReadyMode) != options.end())
106 cmd_line->AppendSwitch(switches::kChromeFrameReadyMode); 104 cmd_line->AppendSwitch(switches::kChromeFrameReadyMode);
107 } 105 }
108 106
109 void ChromeFrameOperations::AppendRenameFlags( 107 void ChromeFrameOperations::AppendRenameFlags(const std::set<string16>& options,
110 const std::set<std::wstring>& options, 108 CommandLine* cmd_line) const {
111 CommandLine* cmd_line) const {
112 DCHECK(cmd_line); 109 DCHECK(cmd_line);
113 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); 110 bool is_multi_install = options.find(kOptionMultiInstall) != options.end();
114 111
115 // Add --multi-install if it isn't already there. 112 // Add --multi-install if it isn't already there.
116 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) 113 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall))
117 cmd_line->AppendSwitch(switches::kMultiInstall); 114 cmd_line->AppendSwitch(switches::kMultiInstall);
118 115
119 // --chrome-frame is needed for single installs. 116 // --chrome-frame is needed for single installs.
120 if (!is_multi_install) 117 if (!is_multi_install)
121 cmd_line->AppendSwitch(switches::kChromeFrame); 118 cmd_line->AppendSwitch(switches::kChromeFrame);
122 } 119 }
123 120
124 bool ChromeFrameOperations::SetChannelFlags( 121 bool ChromeFrameOperations::SetChannelFlags(const std::set<string16>& options,
125 const std::set<std::wstring>& options, 122 bool set,
126 bool set, 123 ChannelInfo* channel_info) const {
127 ChannelInfo* channel_info) const {
128 #if defined(GOOGLE_CHROME_BUILD) 124 #if defined(GOOGLE_CHROME_BUILD)
129 DCHECK(channel_info); 125 DCHECK(channel_info);
130 bool modified = channel_info->SetChromeFrame(set); 126 bool modified = channel_info->SetChromeFrame(set);
131 127
132 // Always remove the options if we're called to remove flags or if the 128 // Always remove the options if we're called to remove flags or if the
133 // corresponding option isn't set. 129 // corresponding option isn't set.
134 modified |= channel_info->SetReadyMode( 130 modified |= channel_info->SetReadyMode(
135 set && options.find(kOptionReadyMode) != options.end()); 131 set && options.find(kOptionReadyMode) != options.end());
136 132
137 return modified; 133 return modified;
138 #else 134 #else
139 return false; 135 return false;
140 #endif 136 #endif
141 } 137 }
142 138
143 bool ChromeFrameOperations::ShouldCreateUninstallEntry( 139 bool ChromeFrameOperations::ShouldCreateUninstallEntry(
144 const std::set<std::wstring>& options) const { 140 const std::set<string16>& options) const {
145 return options.find(kOptionReadyMode) == options.end(); 141 return options.find(kOptionReadyMode) == options.end();
146 } 142 }
147 143
148 void ChromeFrameOperations::AddDefaultShortcutProperties( 144 void ChromeFrameOperations::AddDefaultShortcutProperties(
149 BrowserDistribution* dist, 145 BrowserDistribution* dist,
150 const base::FilePath& target_exe, 146 const base::FilePath& target_exe,
151 ShellUtil::ShortcutProperties* properties) const { 147 ShellUtil::ShortcutProperties* properties) const {
152 NOTREACHED() << "Chrome Frame does not create shortcuts."; 148 NOTREACHED() << "Chrome Frame does not create shortcuts.";
153 } 149 }
154 150
151 void ChromeFrameOperations::LaunchUserExperiment(
152 const base::FilePath& setup_path,
153 const std::set<string16>& options,
154 InstallStatus status,
155 bool system_level) const {
156 // No experiments yet. If adding some in the future, need to have
157 // ChromeFrameDistribution::HasUserExperiments() return true.
158 NOTREACHED();
159 }
160
155 } // namespace installer 161 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698