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

Side by Side Diff: chrome/browser/first_run_win.cc

Issue 165382: Merge 22284 - Refactoring of master preferences parsing before adding a new p... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/first_run.h ('k') | chrome/common/temp_scaffolding_stubs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
Merged /trunk/src/chrome/browser/first_run_win.cc:r22284
Merged /branches/chrome_webkit_merge_branch/chrome/browser/first_run_win.cc:r69-2775
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/browser/first_run.h" 5 #include "chrome/browser/first_run.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 #include <windows.h> 9 #include <windows.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) 160 if (!PathService::Get(base::FILE_EXE, &chrome_exe))
161 return false; 161 return false;
162 return ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe, 162 return ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe,
163 ShellUtil::CURRENT_USER, // create only for current user. 163 ShellUtil::CURRENT_USER, // create only for current user.
164 true); // create if doesn't exist. 164 true); // create if doesn't exist.
165 } 165 }
166 166
167 167
168 bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, 168 bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
169 const FilePath& master_prefs_path, 169 const FilePath& master_prefs_path,
170 int* preference_details, 170 std::vector<std::wstring>* new_tabs,
171 std::vector<std::wstring>* new_tabs) { 171 int* ping_delay) {
172 DCHECK(!user_data_dir.empty()); 172 DCHECK(!user_data_dir.empty());
173 if (preference_details)
174 *preference_details = 0;
175
176 FilePath master_prefs = master_prefs_path; 173 FilePath master_prefs = master_prefs_path;
177 if (master_prefs.empty()) { 174 if (master_prefs.empty()) {
178 // The default location of the master prefs is next to the chrome exe. 175 // The default location of the master prefs is next to the chrome exe.
179 // TODO(port): port installer_util and use this. 176 // TODO(port): port installer_util and use this.
180 if (!PathService::Get(base::DIR_EXE, &master_prefs)) 177 if (!PathService::Get(base::DIR_EXE, &master_prefs))
181 return true; 178 return true;
182 master_prefs = master_prefs.Append(installer_util::kDefaultMasterPrefs); 179 master_prefs = master_prefs.Append(installer_util::kDefaultMasterPrefs);
183 } 180 }
184 181
185 int parse_result = installer_util::ParseDistributionPreferences( 182 scoped_ptr<DictionaryValue> prefs(
186 master_prefs.ToWStringHack()); 183 installer_util::ParseDistributionPreferences(master_prefs));
187 if (preference_details) 184 if (!prefs.get())
188 *preference_details = parse_result;
189
190 if (parse_result & installer_util::MASTER_PROFILE_ERROR)
191 return true; 185 return true;
192 186
193 if (new_tabs) 187 if (new_tabs)
194 *new_tabs = installer_util::ParseFirstRunTabs(master_prefs.ToWStringHack()); 188 *new_tabs = installer_util::GetFirstRunTabs(prefs.get());
189 if (ping_delay)
190 installer_util::GetDistributionPingDelay(prefs.get(), ping_delay);
195 191
196 if (parse_result & installer_util::MASTER_PROFILE_REQUIRE_EULA) { 192 if (installer_util::GetDistroBooleanPreference(prefs.get(),
193 installer_util::master_preferences::kRequireEula)) {
197 // Show the post-installation EULA. This is done by setup.exe and the 194 // Show the post-installation EULA. This is done by setup.exe and the
198 // result determines if we continue or not. We wait here until the user 195 // result determines if we continue or not. We wait here until the user
199 // dismisses the dialog. 196 // dismisses the dialog.
200 197
201 // The actual eula text is in a resource in chrome. We extract it to 198 // The actual eula text is in a resource in chrome. We extract it to
202 // a text file so setup.exe can use it as an inner frame. 199 // a text file so setup.exe can use it as an inner frame.
203 FilePath inner_html; 200 FilePath inner_html;
204 if (WriteEULAtoTempFile(&inner_html)) { 201 if (WriteEULAtoTempFile(&inner_html)) {
205 int retcode = 0; 202 int retcode = 0;
206 const std::wstring& eula = installer_util::switches::kShowEula; 203 const std::wstring& eula = installer_util::switches::kShowEula;
207 if (!LaunchSetupWithParam(eula, inner_html.ToWStringHack(), &retcode) || 204 if (!LaunchSetupWithParam(eula, inner_html.ToWStringHack(), &retcode) ||
208 (retcode == installer_util::EULA_REJECTED)) { 205 (retcode == installer_util::EULA_REJECTED)) {
209 LOG(WARNING) << "EULA rejected. Fast exit."; 206 LOG(WARNING) << "EULA rejected. Fast exit.";
210 ::ExitProcess(1); 207 ::ExitProcess(1);
211 } 208 }
212 if (retcode == installer_util::EULA_ACCEPTED) { 209 if (retcode == installer_util::EULA_ACCEPTED) {
213 LOG(INFO) << "EULA : no collection"; 210 LOG(INFO) << "EULA : no collection";
214 GoogleUpdateSettings::SetCollectStatsConsent(false); 211 GoogleUpdateSettings::SetCollectStatsConsent(false);
215 } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) { 212 } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) {
216 LOG(INFO) << "EULA : collection consent"; 213 LOG(INFO) << "EULA : collection consent";
217 GoogleUpdateSettings::SetCollectStatsConsent(true); 214 GoogleUpdateSettings::SetCollectStatsConsent(true);
218 } 215 }
219 } 216 }
220 } 217 }
221 218
222 if (parse_result & installer_util::MASTER_PROFILE_OEM_FIRST_RUN_BUBBLE) 219 if (installer_util::GetDistroBooleanPreference(prefs.get(),
220 installer_util::master_preferences::kAltFirstRunBubble))
223 FirstRun::SetOEMFirstRunBubblePref(); 221 FirstRun::SetOEMFirstRunBubblePref();
224 222
225 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); 223 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir);
226 if (user_prefs.empty()) 224 if (user_prefs.empty())
227 return true; 225 return true;
228 226
229 // The master prefs are regular prefs so we can just copy the file 227 // The master prefs are regular prefs so we can just copy the file
230 // to the default place and they just work. 228 // to the default place and they just work.
231 if (!file_util::CopyFile(master_prefs, user_prefs)) 229 if (!file_util::CopyFile(master_prefs, user_prefs))
232 return true; 230 return true;
233 231
234 if (!(parse_result & installer_util::MASTER_PROFILE_NO_FIRST_RUN_UI)) 232 if (!installer_util::GetDistroBooleanPreference(prefs.get(),
233 installer_util::master_preferences::kDistroSkipFirstRunPref))
235 return true; 234 return true;
236 235
237 // From here on we won't show first run so we need to do the work to set the 236 // From here on we won't show first run so we need to do the work to set the
238 // required state given that FirstRunView is not going to be called. 237 // required state given that FirstRunView is not going to be called.
239 FirstRun::SetShowFirstRunBubblePref(); 238 FirstRun::SetShowFirstRunBubblePref();
240 239
241 // We need to be able to create the first run sentinel or else we cannot 240 // We need to be able to create the first run sentinel or else we cannot
242 // proceed because ImportSettings will launch the importer process which 241 // proceed because ImportSettings will launch the importer process which
243 // would end up here if the sentinel is not present. 242 // would end up here if the sentinel is not present.
244 if (!FirstRun::CreateSentinel()) 243 if (!FirstRun::CreateSentinel())
245 return false; 244 return false;
246 245
247 if (parse_result & installer_util::MASTER_PROFILE_SHOW_WELCOME) 246 if (installer_util::GetDistroBooleanPreference(prefs.get(),
247 installer_util::master_preferences::kDistroShowWelcomePage))
248 FirstRun::SetShowWelcomePagePref(); 248 FirstRun::SetShowWelcomePagePref();
249 249
250 int import_items = 0; 250 int import_items = 0;
251 if (parse_result & installer_util::MASTER_PROFILE_IMPORT_SEARCH_ENGINE) 251 if (installer_util::GetDistroBooleanPreference(prefs.get(),
252 installer_util::master_preferences::kDistroImportSearchPref))
252 import_items += SEARCH_ENGINES; 253 import_items += SEARCH_ENGINES;
253 if (parse_result & installer_util::MASTER_PROFILE_IMPORT_HISTORY) 254 if (installer_util::GetDistroBooleanPreference(prefs.get(),
255 installer_util::master_preferences::kDistroImportHistoryPref))
254 import_items += HISTORY; 256 import_items += HISTORY;
255 if (parse_result & installer_util::MASTER_PROFILE_IMPORT_BOOKMARKS) 257 if (installer_util::GetDistroBooleanPreference(prefs.get(),
258 installer_util::master_preferences::kDistroImportBookmarksPref))
256 import_items += FAVORITES; 259 import_items += FAVORITES;
257 if (parse_result & installer_util::MASTER_PROFILE_IMPORT_HOME_PAGE) 260 if (installer_util::GetDistroBooleanPreference(prefs.get(),
261 installer_util::master_preferences::kDistroImportHomePagePref))
258 import_items += HOME_PAGE; 262 import_items += HOME_PAGE;
259 263
260 if (import_items) { 264 if (import_items) {
261 // There is something to import from the default browser. This launches 265 // There is something to import from the default browser. This launches
262 // the importer process and blocks until done or until it fails. 266 // the importer process and blocks until done or until it fails.
263 scoped_refptr<ImporterHost> importer_host = new ImporterHost(); 267 scoped_refptr<ImporterHost> importer_host = new ImporterHost();
264 if (!FirstRun::ImportSettings(NULL, 268 if (!FirstRun::ImportSettings(NULL,
265 importer_host->GetSourceProfileInfoAt(0).browser_type, 269 importer_host->GetSourceProfileInfoAt(0).browser_type,
266 import_items, NULL)) { 270 import_items, NULL)) {
267 LOG(WARNING) << "silent import failed"; 271 LOG(WARNING) << "silent import failed";
268 } 272 }
269 } 273 }
270 274
271 if (parse_result & 275 if (installer_util::GetDistroBooleanPreference(prefs.get(),
272 installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT_FOR_USER) 276 installer_util::master_preferences::kMakeChromeDefaultForUser))
273 ShellIntegration::SetAsDefaultBrowser(); 277 ShellIntegration::SetAsDefaultBrowser();
274 278
275 return false; 279 return false;
276 } 280 }
277 281
278 bool Upgrade::IsBrowserAlreadyRunning() { 282 bool Upgrade::IsBrowserAlreadyRunning() {
279 static HANDLE handle = NULL; 283 static HANDLE handle = NULL;
280 std::wstring exe; 284 std::wstring exe;
281 PathService::Get(base::FILE_EXE, &exe); 285 PathService::Get(base::FILE_EXE, &exe);
282 std::replace(exe.begin(), exe.end(), '\\', '!'); 286 std::replace(exe.begin(), exe.end(), '\\', '!');
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 854
851 DISALLOW_COPY_AND_ASSIGN(TryChromeDialog); 855 DISALLOW_COPY_AND_ASSIGN(TryChromeDialog);
852 }; 856 };
853 857
854 } // namespace 858 } // namespace
855 859
856 Upgrade::TryResult Upgrade::ShowTryChromeDialog() { 860 Upgrade::TryResult Upgrade::ShowTryChromeDialog() {
857 TryChromeDialog td; 861 TryChromeDialog td;
858 return td.ShowModal(); 862 return td.ShowModal();
859 } 863 }
OLDNEW
« no previous file with comments | « chrome/browser/first_run.h ('k') | chrome/common/temp_scaffolding_stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698