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

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

Issue 48114: Reuse the eula terms from the chrome resources... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <atlbase.h> 5 #include <atlbase.h>
6 #include <atlcom.h> 6 #include <atlcom.h>
7 #include <windows.h> 7 #include <windows.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 9
10 #include <sstream> 10 #include <sstream>
(...skipping 14 matching lines...) Expand all
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
27 #include "chrome/browser/hang_monitor/hung_window_detector.h" 27 #include "chrome/browser/hang_monitor/hung_window_detector.h"
28 #include "chrome/browser/importer/importer.h" 28 #include "chrome/browser/importer/importer.h"
29 #include "chrome/browser/profile.h" 29 #include "chrome/browser/profile.h"
30 #include "chrome/browser/profile_manager.h" 30 #include "chrome/browser/profile_manager.h"
31 #include "chrome/browser/views/first_run_view.h" 31 #include "chrome/browser/views/first_run_view.h"
32 #include "chrome/common/chrome_constants.h" 32 #include "chrome/common/chrome_constants.h"
33 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/pref_service.h" 34 #include "chrome/common/pref_service.h"
35 #include "chrome/common/resource_bundle.h"
35 #include "chrome/common/result_codes.h" 36 #include "chrome/common/result_codes.h"
36 #include "chrome/installer/util/browser_distribution.h" 37 #include "chrome/installer/util/browser_distribution.h"
37 #include "chrome/installer/util/google_update_constants.h" 38 #include "chrome/installer/util/google_update_constants.h"
38 #include "chrome/installer/util/google_update_settings.h" 39 #include "chrome/installer/util/google_update_settings.h"
39 #include "chrome/installer/util/install_util.h" 40 #include "chrome/installer/util/install_util.h"
40 #include "chrome/installer/util/master_preferences.h" 41 #include "chrome/installer/util/master_preferences.h"
41 #include "chrome/installer/util/shell_util.h" 42 #include "chrome/installer/util/shell_util.h"
42 #include "chrome/installer/util/util_constants.h" 43 #include "chrome/installer/util/util_constants.h"
43 #include "chrome/views/accelerator_handler.h" 44 #include "chrome/views/accelerator_handler.h"
44 #include "chrome/views/window.h" 45 #include "chrome/views/window.h"
45 46
46 #include "google_update_idl.h" 47 #include "google_update_idl.h"
47 48
49 #include "grit/locale_settings.h"
50
51
48 namespace { 52 namespace {
49 53
50 // The kSentinelFile file absence will tell us it is a first run. 54 // The kSentinelFile file absence will tell us it is a first run.
51 const wchar_t kSentinelFile[] = L"First Run"; 55 const wchar_t kSentinelFile[] = L"First Run";
52 56
53 // Gives the full path to the sentinel file. The file might not exist. 57 // Gives the full path to the sentinel file. The file might not exist.
54 bool GetFirstRunSentinelFilePath(std::wstring* path) { 58 bool GetFirstRunSentinelFilePath(std::wstring* path) {
55 std::wstring exe_path; 59 std::wstring exe_path;
56 if (!PathService::Get(base::DIR_EXE, &exe_path)) 60 if (!PathService::Get(base::DIR_EXE, &exe_path))
57 return false; 61 return false;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 DWORD exit_code; 113 DWORD exit_code;
110 ::GetExitCodeProcess(handle, &exit_code); 114 ::GetExitCodeProcess(handle, &exit_code);
111 ::CloseHandle(handle); 115 ::CloseHandle(handle);
112 if (exit_code == installer_util::RENAME_SUCCESSFUL) 116 if (exit_code == installer_util::RENAME_SUCCESSFUL)
113 return true; 117 return true;
114 } 118 }
115 } 119 }
116 return false; 120 return false;
117 } 121 }
118 122
119 bool LaunchSetupWithParam(const std::wstring& param, int* ret_code) { 123 bool LaunchSetupWithParam(const std::wstring& param, const std::wstring& value,
124 int* ret_code) {
120 FilePath exe_path; 125 FilePath exe_path;
121 if (!PathService::Get(base::DIR_MODULE, &exe_path)) 126 if (!PathService::Get(base::DIR_MODULE, &exe_path))
122 return false; 127 return false;
123 exe_path = exe_path.Append(installer_util::kInstallerDir); 128 exe_path = exe_path.Append(installer_util::kInstallerDir);
124 exe_path = exe_path.Append(installer_util::kSetupExe); 129 exe_path = exe_path.Append(installer_util::kSetupExe);
125 base::ProcessHandle ph; 130 base::ProcessHandle ph;
126 CommandLine cl(exe_path.ToWStringHack()); 131 CommandLine cl(exe_path.ToWStringHack());
127 cl.AppendSwitch(param); 132 cl.AppendSwitchWithValue(param, value);
128 if (!base::LaunchApp(cl, false, false, &ph)) 133 if (!base::LaunchApp(cl, false, false, &ph))
129 return false; 134 return false;
130 DWORD wr = ::WaitForSingleObject(ph, INFINITE); 135 DWORD wr = ::WaitForSingleObject(ph, INFINITE);
131 if (wr != WAIT_OBJECT_0) 136 if (wr != WAIT_OBJECT_0)
132 return false; 137 return false;
133 return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code))); 138 return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code)));
134 } 139 }
135 140
141 bool WriteEULAtoTempFile(FilePath* eula_path) {
142 std::string terms =
143 ResourceBundle::GetSharedInstance().GetDataResource(IDR_TERMS_HTML);
144 if (terms.empty())
145 return false;
146 FilePath temp_dir;
147 if (!file_util::GetTempDir(&temp_dir))
148 return false;
149 *eula_path = temp_dir.Append(L"chrome_eula_iframe.html");
150 return (file_util::WriteFile(*eula_path, terms.c_str(), terms.size()) > 0);
151 }
152
136 } // namespace 153 } // namespace
137 154
138 bool FirstRun::IsChromeFirstRun() { 155 bool FirstRun::IsChromeFirstRun() {
139 std::wstring first_run_sentinel; 156 std::wstring first_run_sentinel;
140 if (!GetFirstRunSentinelFilePath(&first_run_sentinel)) 157 if (!GetFirstRunSentinelFilePath(&first_run_sentinel))
141 return false; 158 return false;
142 if (file_util::PathExists(first_run_sentinel)) 159 if (file_util::PathExists(first_run_sentinel))
143 return false; 160 return false;
144 return true; 161 return true;
145 } 162 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (preference_details) 227 if (preference_details)
211 *preference_details = parse_result; 228 *preference_details = parse_result;
212 229
213 if (parse_result & installer_util::MASTER_PROFILE_ERROR) 230 if (parse_result & installer_util::MASTER_PROFILE_ERROR)
214 return true; 231 return true;
215 232
216 if (parse_result & installer_util::MASTER_PROFILE_REQUIRE_EULA) { 233 if (parse_result & installer_util::MASTER_PROFILE_REQUIRE_EULA) {
217 // Show the post-installation EULA. This is done by setup.exe and the 234 // Show the post-installation EULA. This is done by setup.exe and the
218 // result determines if we continue or not. We wait here until the user 235 // result determines if we continue or not. We wait here until the user
219 // dismisses the dialog. 236 // dismisses the dialog.
220 int retcode = 0; 237
221 if (!LaunchSetupWithParam(installer_util::switches::kShowEula, &retcode) || 238 // The actual eula text is in a resource in chrome. We extract it to
222 (retcode == installer_util::EULA_REJECTED)) { 239 // a text file so setup.exe can use it as an inner frame.
223 LOG(WARNING) << "EULA rejected. Fast exit."; 240 FilePath inner_html;
224 ::ExitProcess(1); 241 if (WriteEULAtoTempFile(&inner_html)) {
Glenn Wilson 2009/03/18 01:43:24 If the EULA is empty (language not supported?) or
cpu_(ooo_6.6-7.5) 2009/03/18 05:33:20 The temp dir is given by a window api which does n
225 } 242 int retcode = 0;
226 if (retcode == installer_util::EULA_ACCEPTED) { 243 const std::wstring& eula = installer_util::switches::kShowEula;
227 LOG(INFO) << "EULA : no collection"; 244 if (!LaunchSetupWithParam(eula, inner_html.ToWStringHack(), &retcode) ||
228 GoogleUpdateSettings::SetCollectStatsConsent(false); 245 (retcode == installer_util::EULA_REJECTED)) {
229 } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) { 246 LOG(WARNING) << "EULA rejected. Fast exit.";
230 LOG(INFO) << "EULA : collection consent"; 247 ::ExitProcess(1);
231 GoogleUpdateSettings::SetCollectStatsConsent(true); 248 }
249 if (retcode == installer_util::EULA_ACCEPTED) {
250 LOG(INFO) << "EULA : no collection";
251 GoogleUpdateSettings::SetCollectStatsConsent(false);
252 } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) {
253 LOG(INFO) << "EULA : collection consent";
254 GoogleUpdateSettings::SetCollectStatsConsent(true);
255 }
232 } 256 }
233 } 257 }
234 258
235 FilePath user_prefs = FilePath::FromWStringHack( 259 FilePath user_prefs = FilePath::FromWStringHack(
236 GetDefaultPrefFilePath(true, user_data_dir.ToWStringHack())); 260 GetDefaultPrefFilePath(true, user_data_dir.ToWStringHack()));
237 if (user_prefs.empty()) 261 if (user_prefs.empty())
238 return true; 262 return true;
239 263
240 // The master prefs are regular prefs so we can just copy the file 264 // The master prefs are regular prefs so we can just copy the file
241 // to the default place and they just work. 265 // to the default place and they just work.
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 bool FirstRun::SetShowWelcomePagePref() { 607 bool FirstRun::SetShowWelcomePagePref() {
584 PrefService* local_state = g_browser_process->local_state(); 608 PrefService* local_state = g_browser_process->local_state();
585 if (!local_state) 609 if (!local_state)
586 return false; 610 return false;
587 if (!local_state->IsPrefRegistered(prefs::kShouldShowWelcomePage)) { 611 if (!local_state->IsPrefRegistered(prefs::kShouldShowWelcomePage)) {
588 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); 612 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false);
589 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); 613 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true);
590 } 614 }
591 return true; 615 return true;
592 } 616 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698