summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-27 00:52:17 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-27 00:52:17 +0000
commit64fcca73ef6067346597989f641488ada57ba1ea (patch)
tree55239f769b7238627673881368ba57896c0855a4
parentcd3414054bcd0f6590342f89c43f8da676e377ae (diff)
downloadchromium_src-64fcca73ef6067346597989f641488ada57ba1ea.zip
chromium_src-64fcca73ef6067346597989f641488ada57ba1ea.tar.gz
chromium_src-64fcca73ef6067346597989f641488ada57ba1ea.tar.bz2
Wire the eula and the dialog display code
- html, css and js to live in the installer as resources. The right combo of resources is selected based on system lang - currently the approach is to have chrome show the eula by spawing setup.exe --show-eula BUG=1468838 Review URL: http://codereview.chromium.org/18732 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8690 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/installer/setup/eula/oem.css52
-rw-r--r--chrome/installer/setup/eula/oem.js18
-rw-r--r--chrome/installer/setup/eula/oem_en.html53
-rwxr-xr-xchrome/installer/setup/main.cc44
-rw-r--r--chrome/installer/setup/setup.rc26
-rw-r--r--chrome/installer/util/html_dialog_impl.cc4
-rw-r--r--chrome/installer/util/l10n_string_util.cc31
-rw-r--r--chrome/installer/util/l10n_string_util.h6
-rwxr-xr-xchrome/installer/util/util_constants.cc3
-rwxr-xr-xchrome/installer/util/util_constants.h5
10 files changed, 223 insertions, 19 deletions
diff --git a/chrome/installer/setup/eula/oem.css b/chrome/installer/setup/eula/oem.css
new file mode 100644
index 0000000..3d30301
--- /dev/null
+++ b/chrome/installer/setup/eula/oem.css
@@ -0,0 +1,52 @@
+html {
+ overflow:auto;
+}
+body, td {
+ overflow:auto;
+ margin:0px;
+ font-family:arial;
+ font-size:84%;
+}
+.header {
+ background-color:#d8dfea;
+ padding:10px 10px 10px 8px;
+}
+.icontext {
+ text-align:center;
+ font-family:tahoma;
+ font-size:11px;
+ padding:1px 0px 0px 2px;
+}
+.title {
+ font-size:115%;
+ font-weight:bold;
+}
+.desc {
+ display:block;
+ padding-top:5px;
+}
+.main {
+ margin:17px 13px 0px 14px;
+}
+.eula {
+ margin:5px 10px 0px 5px;
+}
+iframe {
+ border:1px solid #999999;
+}
+.footer {
+ position:absolute;
+ bottom:0px;
+ padding:5px 5px 5px 5px;
+}
+form {
+ margin:0px;
+ padding:0px;
+}
+.labelcell {
+ padding-top:2px;
+}
+.buttons {
+ margin:8px 5px 0px 5px;
+ text-align:right;
+} \ No newline at end of file
diff --git a/chrome/installer/setup/eula/oem.js b/chrome/installer/setup/eula/oem.js
new file mode 100644
index 0000000..2b0bcbd
--- /dev/null
+++ b/chrome/installer/setup/eula/oem.js
@@ -0,0 +1,18 @@
+function checkAccept(f) {
+ if (f.accept.checked) {
+ window.returnValue = 1;
+ } else {
+ window.returnValue = 2;
+ }
+ window.close();
+}
+
+function resize() {
+ var ifr = document.getElementById('ifr');
+ var footer = document.getElementById('footer');
+
+ ifr.height = footer.offsetTop - ifr.offsetTop;
+}
+
+window.onresize = resize;
+window.onload = resize; \ No newline at end of file
diff --git a/chrome/installer/setup/eula/oem_en.html b/chrome/installer/setup/eula/oem_en.html
new file mode 100644
index 0000000..d331d3a
--- /dev/null
+++ b/chrome/installer/setup/eula/oem_en.html
@@ -0,0 +1,53 @@
+<html>
+<head>
+<title>Google Chrome OEM EULA</title>
+<link rel="stylesheet" type="text/css" href="res://setup.exe/IDR_EULA_CSS.CSS" />
+<script type="text/javascript" src="res://setup.exe/IDR_EULA_JSC.JS"></script>
+</head>
+<body>
+<div class="header">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td valign="top" width="48" align="center">
+ <img class="icon" src="res://setup.exe/EULA/IDR_EULA_ICO.PNG" width="32" height="32" />
+ <div class="icontext">Google Chrome</div>
+ </td>
+ <td width="10">&nbsp;</td>
+ <td>
+ <span class="title">Surf the web with Google Chrome</span><br />
+ <span class="desc">Using the internet is faster, safer and easier
+ with Google Chrome, the web browser installed on your PC</span>
+ </td>
+ </tr>
+ </table>
+</div>
+<div class="main">
+ Accept the Google Chrome Terms of Service to start using Google Chrome:
+</div>
+<div class="eula">
+ <iframe id="ifr" src="res://setup.exe/IDR_TERMS_EN.HTML" width="100%" height="354" frameborder="0"></iframe>
+</div>
+<div id="footer" class="footer">
+ <form method="post" action="" onsubmit="checkAccept(this); return false;">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td valign="top">
+ <input type="checkbox" name="accept" id="accept" />&nbsp;
+ </td>
+ <td valign="top" class="labelcell">
+ <label for="accept"><b>Optional:</b> Help make Google Chrome
+ better by automatically sending usage statistics and crash reports
+ to Google.
+ <a href="http://www.google.com/support/chrome/bin/answer.py?answer=96817&hl=en">Learn more</a>
+ </label>
+ </td>
+ </tr>
+ </table>
+ <div class="buttons">
+ <input type="submit" name="submit" value="Accept and Run" />
+ <input type="submit" name="cancel" value="Cancel" />
+ </div>
+ </form>
+</div>
+</body>
+</html> \ No newline at end of file
diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc
index 8f57e06..925d49a 100755
--- a/chrome/installer/setup/main.cc
+++ b/chrome/installer/setup/main.cc
@@ -23,6 +23,7 @@
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/html_dialog.h"
#include "chrome/installer/util/install_util.h"
+#include "chrome/installer/util/l10n_string_util.h"
#include "chrome/installer/util/logging_installer.h"
#include "chrome/installer/util/lzma_util.h"
#include "chrome/installer/util/google_update_constants.h"
@@ -226,6 +227,10 @@ int GetInstallOptions(const CommandLine& cmd_line) {
if ((preferences & installer_util::MASTER_PROFILE_ERROR) == 0)
options |= installer_util::MASTER_PROFILE_VALID;
}
+ // While there is a --show-eula command line flag, we don't process
+ // it in this function because it requires special handling.
+ if (preferences & installer_util::MASTER_PROFILE_REQUIRE_EULA)
+ options |= installer_util::MASTER_PROFILE_REQUIRE_EULA;
}
if (preferences & installer_util::MASTER_PROFILE_CREATE_ALL_SHORTCUTS ||
@@ -247,7 +252,7 @@ int GetInstallOptions(const CommandLine& cmd_line) {
if (preferences & installer_util::MASTER_PROFILE_VERBOSE_LOGGING ||
cmd_line.HasSwitch(installer_util::switches::kVerboseLogging))
options |= installer_util::VERBOSE_LOGGING;
-
+
return options;
}
@@ -439,16 +444,19 @@ installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line,
*version, remove_all, force);
}
-// This function is temporary and meant to live while we get our eula dialogs
-// looking sharp. If the cmd line has --eula-test=path then the eula dialog
-// will be shown and no matter what the selection is the installer will exit.
-bool HandleEULADialog(const CommandLine& cmdline) {
- std:: wstring eula_path(cmdline.GetSwitchValue(L"eula-test"));
- if (eula_path.empty())
- return true;
+bool ShowEULADialog() {
+ LOG(INFO) << "About to show EULA";
+ std::wstring eula_path = installer_util::GetLocalizedEulaResource();
+ if (eula_path.empty()) {
+ LOG(ERROR) << "No EULA path available";
+ return false;
+ }
installer::EulaHTMLDialog dlg(eula_path);
- dlg.ShowModal();
- return false;
+ if (!dlg.ShowModal()) {
+ LOG(ERROR) << "EULA rejected or EULA failure";
+ return false;
+ }
+ return true;
}
} // namespace
@@ -467,9 +475,6 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0;
LOG(INFO) << "system install is " << system_install;
- if (!HandleEULADialog(parsed_command_line))
- return 0;
-
// Check to make sure current system is WinXP or later. If not, log
// error message and get out.
if (!InstallUtil::IsOSSupported()) {
@@ -489,6 +494,19 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
return installer_util::OS_ERROR;
}
+ // Check if we need to show the EULA. There are two cases:
+ // 1- If it is passed as a command line (--show-eula), then the dialog is
+ // shown and regardless of the outcome setup exits here.
+ // 2- If it is found in the installerdata file then the eula is shown
+ // and the installation proceeds if the user acepts.
+ if (parsed_command_line.HasSwitch(installer_util::switches::kShowEula)) {
+ return (ShowEULADialog() ?
+ installer_util::EULA_ACCEPTED : installer_util::EULA_REJECTED);
+ } else if (installer_util::MASTER_PROFILE_REQUIRE_EULA & options) {
+ if (!ShowEULADialog())
+ return installer_util::EULA_REJECTED;
+ }
+
// If --register-chrome-browser option is specified, register all
// Chrome protocol/file associations as well as register it as a valid
// browser for StarMenu->Internet shortcut. This option should only
diff --git a/chrome/installer/setup/setup.rc b/chrome/installer/setup/setup.rc
index f844d43..0f1b7c3 100644
--- a/chrome/installer/setup/setup.rc
+++ b/chrome/installer/setup/setup.rc
@@ -57,6 +57,30 @@ IDI_SETUP ICON "setup.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
+#if defined(GOOGLE_CHROME_BUILD)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// EULA
+//
+IDR_EULA_ICO.PNG EULA "..\\..\\app\\theme\\google_chrome\\eula_icon.png"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// HTML
+//
+
+IDR_EULA_CSS.CSS HTML "eula\\oem.css"
+IDR_EULA_JSC.JS HTML "eula\\oem.js"
+
+IDR_OEMPG_EN.HTML HTML "eula\\oem_en.html"
+
+IDR_TERMS_EN.HTML HTML "..\\..\\app\\resources\\terms\\terms_en.html"
+IDR_TERMS_ES.HTML HTML "..\\..\\app\\resources\\terms\\terms_es.html"
+IDR_TERMS_FR.HTML HTML "..\\..\\app\\resources\\terms\\terms_fr.html"
+IDR_TERMS_BR.HTML HTML "..\\..\\app\\resources\\terms\\terms_pt-BR.html"
+
+#endif // defined(GOOGLE_CHROME_BUILD)
/////////////////////////////////////////////////////////////////////////////
//
@@ -64,7 +88,6 @@ IDI_SETUP ICON "setup.ico"
//
#include "installer_util_strings.rc"
-
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
@@ -72,7 +95,6 @@ IDI_SETUP ICON "setup.ico"
//
#include "setup_exe_version.rc"
-
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
diff --git a/chrome/installer/util/html_dialog_impl.cc b/chrome/installer/util/html_dialog_impl.cc
index 197cebb..80fb112 100644
--- a/chrome/installer/util/html_dialog_impl.cc
+++ b/chrome/installer/util/html_dialog_impl.cc
@@ -173,8 +173,8 @@ EulaHTMLDialog::~EulaHTMLDialog() {
bool EulaHTMLDialog::ShowModal() {
Customizer customizer;
- dialog_->ShowModal(NULL, &customizer);
- return false;
+ HTMLDialog::DialogResult dr = dialog_->ShowModal(NULL, &customizer);
+ return (HTMLDialog::HTML_DLG_ACCEPT == dr);
}
} // namespace installer
diff --git a/chrome/installer/util/l10n_string_util.cc b/chrome/installer/util/l10n_string_util.cc
index a7c636d..343a474 100644
--- a/chrome/installer/util/l10n_string_util.cc
+++ b/chrome/installer/util/l10n_string_util.cc
@@ -1,4 +1,5 @@
#include <atlbase.h>
+#include <shlwapi.h>
#include <map>
@@ -152,4 +153,34 @@ std::wstring GetLocalizedString(int base_message_id) {
return localized_string;
}
+// Here we generate the url spec with the Microsoft res:// scheme which is
+// explained here : http://support.microsoft.com/kb/220830
+std::wstring GetLocalizedEulaResource() {
+ wchar_t full_exe_path[MAX_PATH];
+ int len = ::GetModuleFileNameW(NULL, full_exe_path, MAX_PATH);
+ if (len <= 0 && len >= MAX_PATH)
+ return L"";
+ // The default language is English, but we also support Spanish,French and
+ // Portuguese.
+ std::wstring language = GetSystemLanguage();
+ const wchar_t* resource = L"IDR_OEMPG_EN.HTML";
+ if (language == L"fr")
+ resource = L"IDR_OEMPG_FR.HTML";
+ else if (language == L"es")
+ resource = L"IDR_OEMPG_ES.HTML";
+ else if (language == L"pt-br")
+ resource = L"IDR_OEMPG_BR.HTML";
+ // Spaces and DOS paths must be url encoded.
+ std::wstring url_path =
+ StringPrintf(L"res://%ls/#23/%ls", full_exe_path, resource);
+ DWORD count = url_path.size() * 3;
+ scoped_ptr<wchar_t> url_canon(new wchar_t[count]);
+ HRESULT hr = ::UrlCanonicalizeW(url_path.c_str(), url_canon.get(),
+ &count, URL_ESCAPE_UNSAFE);
+ if (SUCCEEDED(hr))
+ return std::wstring(url_canon.get());
+ return url_path;
+}
+
} // namespace installer_util
+
diff --git a/chrome/installer/util/l10n_string_util.h b/chrome/installer/util/l10n_string_util.h
index aa04447..bea5344 100644
--- a/chrome/installer/util/l10n_string_util.h
+++ b/chrome/installer/util/l10n_string_util.h
@@ -22,7 +22,11 @@ namespace installer_util {
// desktop.
std::wstring GetLocalizedString(int base_message_id);
-}
+// Given the system language, return a url that points to the localized eula.
+// The empty string is returned on failure.
+std::wstring GetLocalizedEulaResource();
+
+} // namespace installer_util.
#endif // CHROME_INSTALLER_UTIL_L10N_STRING_UTIL_H_
diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc
index e6147c5..3fdace4 100755
--- a/chrome/installer/util/util_constants.cc
+++ b/chrome/installer/util/util_constants.cc
@@ -66,6 +66,9 @@ const wchar_t kUninstall[] = L"uninstall";
// Enable verbose logging (info level).
const wchar_t kVerboseLogging[] = L"verbose-logging";
+// Show the embedded EULA dialog.
+const wchar_t kShowEula[] = L"show-eula";
+
} // namespace switches
const wchar_t kInstallBinaryDir[] = L"Application";
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index 657c558..0ad2ed1 100755
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -33,7 +33,9 @@ enum InstallStatus {
UNINSTALL_CANCELLED, // User cancelled Chrome uninstallation
UNKNOWN_STATUS, // Unknown status (this should never happen)
RENAME_SUCCESSFUL, // Rename of new_chrome.exe to chrome.exe worked
- RENAME_FAILED // Rename of new_chrome.exe failed
+ RENAME_FAILED, // Rename of new_chrome.exe failed
+ EULA_REJECTED, // EULA dialog was not accepted by user.
+ EULA_ACCEPTED // EULA dialog was accepted by user.
};
// These are distibution related install options specified through command
@@ -74,6 +76,7 @@ extern const wchar_t kRunAsAdmin[];
extern const wchar_t kSystemLevel[];
extern const wchar_t kUninstall[];
extern const wchar_t kVerboseLogging[];
+extern const wchar_t kShowEula[];
} // namespace switches
extern const wchar_t kInstallBinaryDir[];