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

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: 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 | no next file » | 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"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_split.h" 15 #include "base/string_split.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "base/win/object_watcher.h" 18 #include "base/win/object_watcher.h"
19 #include "base/win/registry.h"
19 #include "base/win/windows_version.h" 20 #include "base/win/windows_version.h"
20 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/updater/extension_updater.h" 23 #include "chrome/browser/extensions/updater/extension_updater.h"
23 #include "chrome/browser/first_run/first_run_import_observer.h" 24 #include "chrome/browser/first_run/first_run_import_observer.h"
24 #include "chrome/browser/first_run/first_run_internal.h" 25 #include "chrome/browser/first_run/first_run_internal.h"
25 #include "chrome/browser/importer/importer_host.h" 26 #include "chrome/browser/importer/importer_host.h"
26 #include "chrome/browser/importer/importer_list.h" 27 #include "chrome/browser/importer/importer_list.h"
27 #include "chrome/browser/importer/importer_progress_dialog.h" 28 #include "chrome/browser/importer/importer_progress_dialog.h"
28 #include "chrome/browser/prefs/pref_service.h" 29 #include "chrome/browser/prefs/pref_service.h"
29 #include "chrome/browser/process_singleton.h" 30 #include "chrome/browser/process_singleton.h"
30 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
33 #include "chrome/common/chrome_result_codes.h" 34 #include "chrome/common/chrome_result_codes.h"
34 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
36 #include "chrome/common/worker_thread_ticker.h" 37 #include "chrome/common/worker_thread_ticker.h"
37 #include "chrome/installer/util/browser_distribution.h" 38 #include "chrome/installer/util/browser_distribution.h"
39 #include "chrome/installer/util/google_update_constants.h"
38 #include "chrome/installer/util/google_update_settings.h" 40 #include "chrome/installer/util/google_update_settings.h"
39 #include "chrome/installer/util/install_util.h" 41 #include "chrome/installer/util/install_util.h"
40 #include "chrome/installer/util/master_preferences.h" 42 #include "chrome/installer/util/master_preferences.h"
41 #include "chrome/installer/util/master_preferences_constants.h" 43 #include "chrome/installer/util/master_preferences_constants.h"
42 #include "chrome/installer/util/shell_util.h" 44 #include "chrome/installer/util/shell_util.h"
43 #include "chrome/installer/util/util_constants.h" 45 #include "chrome/installer/util/util_constants.h"
44 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
45 #include "content/public/browser/user_metrics.h" 47 #include "content/public/browser/user_metrics.h"
46 #include "google_update/google_update_idl.h" 48 #include "google_update/google_update_idl.h"
47 #include "grit/chromium_strings.h" 49 #include "grit/chromium_strings.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 166
165 // TODO(evan): should this use options.wait = true? 167 // TODO(evan): should this use options.wait = true?
166 if (!base::LaunchProcess(cl, base::LaunchOptions(), &ph)) 168 if (!base::LaunchProcess(cl, base::LaunchOptions(), &ph))
167 return false; 169 return false;
168 DWORD wr = ::WaitForSingleObject(ph, INFINITE); 170 DWORD wr = ::WaitForSingleObject(ph, INFINITE);
169 if (wr != WAIT_OBJECT_0) 171 if (wr != WAIT_OBJECT_0)
170 return false; 172 return false;
171 return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code))); 173 return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code)));
172 } 174 }
173 175
176 // The EULA is considered to have not yet been accepted if both of the following
177 // are true:
178 // 1) ClientState\<guid>\eulaaccepted is present and has a value of 0
179 // AND
180 // 2) ClientStateMedium\<guid>\eulaaccepted is not present OR is present
181 // and has a value of 0.
182 bool IsEulaNotAccepted() {
183 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
robertshield 2012/06/14 02:50:06 nit: double spaces
grt (UTC plus 2) 2012/06/14 03:39:00 Done.
184 DWORD eula_accepted = 1;
185 base::win::RegKey reg_key;
186 if ((reg_key.Open(HKEY_LOCAL_MACHINE, dist->GetStateKey().c_str(),
187 KEY_QUERY_VALUE) == ERROR_SUCCESS) &&
188 (reg_key.ReadValueDW(google_update::kRegEULAAceptedField,
189 &eula_accepted) == ERROR_SUCCESS) &&
190 (eula_accepted == 0)) {
191 // Google Update says that the EULA has not been accepted. Check that
192 // Chrome hasn't written its acceptance value into ClientStateMedium.
193 if (reg_key.Open(HKEY_LOCAL_MACHINE, dist->GetStateMediumKey().c_str(),
194 KEY_QUERY_VALUE) == ERROR_SUCCESS) {
195 reg_key.ReadValueDW(google_update::kRegEULAAceptedField, &eula_accepted);
196 }
197 }
198 return eula_accepted == 0;
199 }
200
174 // Writes the EULA to a temporary file, returned in |*eula_path|, and returns 201 // Writes the EULA to a temporary file, returned in |*eula_path|, and returns
175 // true if successful. 202 // true if successful.
176 bool WriteEULAtoTempFile(FilePath* eula_path) { 203 bool WriteEULAtoTempFile(FilePath* eula_path) {
177 base::StringPiece terms = 204 base::StringPiece terms =
178 ResourceBundle::GetSharedInstance().GetRawDataResource( 205 ResourceBundle::GetSharedInstance().GetRawDataResource(
179 IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE); 206 IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE);
180 if (terms.empty()) 207 if (terms.empty())
181 return false; 208 return false;
182 FILE *file = file_util::CreateAndOpenTemporaryFile(eula_path); 209 FILE *file = file_util::CreateAndOpenTemporaryFile(eula_path);
183 if (!file) 210 if (!file)
184 return false; 211 return false;
185 bool good = fwrite(terms.data(), terms.size(), 1, file) == 1; 212 bool good = fwrite(terms.data(), terms.size(), 1, file) == 1;
186 fclose(file); 213 fclose(file);
187 return good; 214 return good;
188 } 215 }
189 216
190 void ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) { 217 void ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) {
191 bool value = false; 218 bool value = false;
192 if (install_prefs->GetBool(installer::master_preferences::kRequireEula, 219 if (install_prefs->GetBool(installer::master_preferences::kRequireEula,
grt (UTC plus 2) 2012/06/14 02:09:52 i'm tempted to get rid of this check for require_e
robertshield 2012/06/14 02:50:06 If require_eula is not present and the eulaaccepte
grt (UTC plus 2) 2012/06/14 03:39:00 Done.
193 &value) && value) { 220 &value) && value && IsEulaNotAccepted()) {
194 // Show the post-installation EULA. This is done by setup.exe and the 221 // 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 222 // result determines if we continue or not. We wait here until the user
196 // dismisses the dialog. 223 // dismisses the dialog.
197 224
198 // The actual eula text is in a resource in chrome. We extract it to 225 // 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. 226 // a text file so setup.exe can use it as an inner frame.
200 FilePath inner_html; 227 FilePath inner_html;
201 if (WriteEULAtoTempFile(&inner_html)) { 228 if (WriteEULAtoTempFile(&inner_html)) {
202 int retcode = 0; 229 int retcode = 0;
203 if (!LaunchSetupWithParam(installer::switches::kShowEula, 230 if (!LaunchSetupWithParam(installer::switches::kShowEula,
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 return false; 613 return false;
587 614
588 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get()); 615 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get());
589 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); 616 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get());
590 internal::SetDefaultBrowser(install_prefs.get()); 617 internal::SetDefaultBrowser(install_prefs.get());
591 618
592 return false; 619 return false;
593 } 620 }
594 621
595 } // namespace first_run 622 } // namespace first_run
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698