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

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

Issue 10539153: Do not show the EULA if it has already been accepted by the user in another user data dir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DIR_ALT_USER_DATA is windows only Created 8 years, 6 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 | « no previous file | chrome/common/chrome_paths.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/first_run/first_run.h" 5 #include "chrome/browser/first_run/first_run.h"
6 6
7 #include <shlobj.h> 7 #include <shlobj.h>
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 // TODO(evan): should this use options.wait = true? 165 // TODO(evan): should this use options.wait = true?
166 if (!base::LaunchProcess(cl, base::LaunchOptions(), &ph)) 166 if (!base::LaunchProcess(cl, base::LaunchOptions(), &ph))
167 return false; 167 return false;
168 DWORD wr = ::WaitForSingleObject(ph, INFINITE); 168 DWORD wr = ::WaitForSingleObject(ph, INFINITE);
169 if (wr != WAIT_OBJECT_0) 169 if (wr != WAIT_OBJECT_0)
170 return false; 170 return false;
171 return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code))); 171 return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code)));
172 } 172 }
173 173
174 // Returns true if the EULA is required but has not been accepted by this user.
175 // The EULA is considered having been accepted if the user has gotten past
176 // first run in the "other" environment (desktop or metro).
177 bool IsEulaNotAccepted(installer::MasterPreferences* install_prefs) {
178 bool value = false;
179 if (install_prefs->GetBool(installer::master_preferences::kRequireEula,
180 &value) && value) {
181 // Check for a first run sentinel in the alternate user data dir.
182 FilePath alt_user_data_dir;
183 if (!PathService::Get(chrome::DIR_ALT_USER_DATA, &alt_user_data_dir) ||
184 !file_util::DirectoryExists(alt_user_data_dir) ||
185 !file_util::PathExists(alt_user_data_dir.AppendASCII(
186 first_run::internal::kSentinelFile))) {
187 return true;
188 }
189 }
190 return false;
191 }
192
174 // Writes the EULA to a temporary file, returned in |*eula_path|, and returns 193 // Writes the EULA to a temporary file, returned in |*eula_path|, and returns
175 // true if successful. 194 // true if successful.
176 bool WriteEULAtoTempFile(FilePath* eula_path) { 195 bool WriteEULAtoTempFile(FilePath* eula_path) {
177 base::StringPiece terms = 196 base::StringPiece terms =
178 ResourceBundle::GetSharedInstance().GetRawDataResource( 197 ResourceBundle::GetSharedInstance().GetRawDataResource(
179 IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE); 198 IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE);
180 if (terms.empty()) 199 if (terms.empty())
181 return false; 200 return false;
182 FILE *file = file_util::CreateAndOpenTemporaryFile(eula_path); 201 FILE *file = file_util::CreateAndOpenTemporaryFile(eula_path);
183 if (!file) 202 if (!file)
184 return false; 203 return false;
185 bool good = fwrite(terms.data(), terms.size(), 1, file) == 1; 204 bool good = fwrite(terms.data(), terms.size(), 1, file) == 1;
186 fclose(file); 205 fclose(file);
187 return good; 206 return good;
188 } 207 }
189 208
190 void ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) { 209 void ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) {
191 bool value = false; 210 if (IsEulaNotAccepted(install_prefs)) {
192 if (install_prefs->GetBool(installer::master_preferences::kRequireEula,
193 &value) && value) {
194 // Show the post-installation EULA. This is done by setup.exe and the 211 // Show the post-installation EULA. This is done by setup.exe and the
195 // result determines if we continue or not. We wait here until the user 212 // result determines if we continue or not. We wait here until the user
196 // dismisses the dialog. 213 // dismisses the dialog.
197 214
198 // The actual eula text is in a resource in chrome. We extract it to 215 // The actual eula text is in a resource in chrome. We extract it to
199 // a text file so setup.exe can use it as an inner frame. 216 // a text file so setup.exe can use it as an inner frame.
200 FilePath inner_html; 217 FilePath inner_html;
201 if (WriteEULAtoTempFile(&inner_html)) { 218 if (WriteEULAtoTempFile(&inner_html)) {
202 int retcode = 0; 219 int retcode = 0;
203 if (!LaunchSetupWithParam(installer::switches::kShowEula, 220 if (!LaunchSetupWithParam(installer::switches::kShowEula,
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 return false; 603 return false;
587 604
588 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get()); 605 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get());
589 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); 606 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get());
590 internal::SetDefaultBrowser(install_prefs.get()); 607 internal::SetDefaultBrowser(install_prefs.get());
591 608
592 return false; 609 return false;
593 } 610 }
594 611
595 } // namespace first_run 612 } // namespace first_run
OLDNEW
« no previous file with comments | « no previous file | chrome/common/chrome_paths.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698