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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/first_run.cc
===================================================================
--- chrome/browser/first_run.cc (revision 11718)
+++ chrome/browser/first_run.cc (working copy)
@@ -32,6 +32,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_service.h"
+#include "chrome/common/resource_bundle.h"
#include "chrome/common/result_codes.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
@@ -45,6 +46,9 @@
#include "google_update_idl.h"
+#include "grit/locale_settings.h"
+
+
namespace {
// The kSentinelFile file absence will tell us it is a first run.
@@ -116,7 +120,8 @@
return false;
}
-bool LaunchSetupWithParam(const std::wstring& param, int* ret_code) {
+bool LaunchSetupWithParam(const std::wstring& param, const std::wstring& value,
+ int* ret_code) {
FilePath exe_path;
if (!PathService::Get(base::DIR_MODULE, &exe_path))
return false;
@@ -124,7 +129,7 @@
exe_path = exe_path.Append(installer_util::kSetupExe);
base::ProcessHandle ph;
CommandLine cl(exe_path.ToWStringHack());
- cl.AppendSwitch(param);
+ cl.AppendSwitchWithValue(param, value);
if (!base::LaunchApp(cl, false, false, &ph))
return false;
DWORD wr = ::WaitForSingleObject(ph, INFINITE);
@@ -133,6 +138,18 @@
return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code)));
}
+bool WriteEULAtoTempFile(FilePath* eula_path) {
+ std::string terms =
+ ResourceBundle::GetSharedInstance().GetDataResource(IDR_TERMS_HTML);
+ if (terms.empty())
+ return false;
+ FilePath temp_dir;
+ if (!file_util::GetTempDir(&temp_dir))
+ return false;
+ *eula_path = temp_dir.Append(L"chrome_eula_iframe.html");
+ return (file_util::WriteFile(*eula_path, terms.c_str(), terms.size()) > 0);
+}
+
} // namespace
bool FirstRun::IsChromeFirstRun() {
@@ -217,19 +234,26 @@
// Show the post-installation EULA. This is done by setup.exe and the
// result determines if we continue or not. We wait here until the user
// dismisses the dialog.
- int retcode = 0;
- if (!LaunchSetupWithParam(installer_util::switches::kShowEula, &retcode) ||
- (retcode == installer_util::EULA_REJECTED)) {
- LOG(WARNING) << "EULA rejected. Fast exit.";
- ::ExitProcess(1);
+
+ // The actual eula text is in a resource in chrome. We extract it to
+ // a text file so setup.exe can use it as an inner frame.
+ FilePath inner_html;
+ 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
+ int retcode = 0;
+ const std::wstring& eula = installer_util::switches::kShowEula;
+ if (!LaunchSetupWithParam(eula, inner_html.ToWStringHack(), &retcode) ||
+ (retcode == installer_util::EULA_REJECTED)) {
+ LOG(WARNING) << "EULA rejected. Fast exit.";
+ ::ExitProcess(1);
+ }
+ if (retcode == installer_util::EULA_ACCEPTED) {
+ LOG(INFO) << "EULA : no collection";
+ GoogleUpdateSettings::SetCollectStatsConsent(false);
+ } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) {
+ LOG(INFO) << "EULA : collection consent";
+ GoogleUpdateSettings::SetCollectStatsConsent(true);
+ }
}
- if (retcode == installer_util::EULA_ACCEPTED) {
- LOG(INFO) << "EULA : no collection";
- GoogleUpdateSettings::SetCollectStatsConsent(false);
- } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) {
- LOG(INFO) << "EULA : collection consent";
- GoogleUpdateSettings::SetCollectStatsConsent(true);
- }
}
FilePath user_prefs = FilePath::FromWStringHack(
« 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