summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-16 03:45:24 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-16 03:45:24 +0000
commitf8ec0d584c9b476d7dcb919e769a9e66fc666e62 (patch)
tree8bb1120ea4a735f6c382a43d78e1c02e0e63ce7e /chrome
parentcf9e57411d02f9328328ea4f4ec81741076891bc (diff)
downloadchromium_src-f8ec0d584c9b476d7dcb919e769a9e66fc666e62.zip
chromium_src-f8ec0d584c9b476d7dcb919e769a9e66fc666e62.tar.gz
chromium_src-f8ec0d584c9b476d7dcb919e769a9e66fc666e62.tar.bz2
Do not show the EULA if it has already been accepted by the user in another user data dir.
BUG=131033 TEST=install system-level chrome with require_eula in master prefs and eulaaccepted=0 in the ClientState key. nuke all user data dirs (including the metro one). now launch desktop chrome and accept the eula. make chrome the default browser and launch into metro. notice that it works. Review URL: https://chromiumcodereview.appspot.com/10539153 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142576 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/first_run/first_run_win.cc23
-rw-r--r--chrome/common/chrome_paths.cc9
-rw-r--r--chrome/common/chrome_paths.h4
-rw-r--r--chrome/common/chrome_paths_internal.h6
-rw-r--r--chrome/common/chrome_paths_unittest.cc22
-rw-r--r--chrome/common/chrome_paths_win.cc18
6 files changed, 76 insertions, 6 deletions
diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc
index a66fd8c..31461fa 100644
--- a/chrome/browser/first_run/first_run_win.cc
+++ b/chrome/browser/first_run/first_run_win.cc
@@ -171,6 +171,25 @@ bool LaunchSetupWithParam(const std::string& param,
return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code)));
}
+// Returns true if the EULA is required but has not been accepted by this user.
+// The EULA is considered having been accepted if the user has gotten past
+// first run in the "other" environment (desktop or metro).
+bool IsEulaNotAccepted(installer::MasterPreferences* install_prefs) {
+ bool value = false;
+ if (install_prefs->GetBool(installer::master_preferences::kRequireEula,
+ &value) && value) {
+ // Check for a first run sentinel in the alternate user data dir.
+ FilePath alt_user_data_dir;
+ if (!PathService::Get(chrome::DIR_ALT_USER_DATA, &alt_user_data_dir) ||
+ !file_util::DirectoryExists(alt_user_data_dir) ||
+ !file_util::PathExists(alt_user_data_dir.AppendASCII(
+ first_run::internal::kSentinelFile))) {
+ return true;
+ }
+ }
+ return false;
+}
+
// Writes the EULA to a temporary file, returned in |*eula_path|, and returns
// true if successful.
bool WriteEULAtoTempFile(FilePath* eula_path) {
@@ -188,9 +207,7 @@ bool WriteEULAtoTempFile(FilePath* eula_path) {
}
void ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) {
- bool value = false;
- if (install_prefs->GetBool(installer::master_preferences::kRequireEula,
- &value) && value) {
+ if (IsEulaNotAccepted(install_prefs)) {
// 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.
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index edeb082..1228838 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -148,6 +148,15 @@ bool PathProvider(int key, FilePath* result) {
}
create_dir = true;
break;
+#if defined(OS_WIN)
+ case chrome::DIR_ALT_USER_DATA:
+ if (!GetAlternateUserDataDirectory(&cur)) {
+ NOTREACHED();
+ return false;
+ }
+ create_dir = false;
+ break;
+#endif // OS_WIN
case chrome::DIR_USER_DOCUMENTS:
if (!GetUserDocumentsDirectory(&cur))
return false;
diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h
index a3991c6..61cee75 100644
--- a/chrome/common/chrome_paths.h
+++ b/chrome/common/chrome_paths.h
@@ -19,6 +19,10 @@ enum {
DIR_APP = PATH_START, // Directory where dlls and data reside.
DIR_LOGS, // Directory where logs should be written.
DIR_USER_DATA, // Directory where user data can be written.
+#if defined(OS_WIN)
+ DIR_ALT_USER_DATA, // Directory of the desktop or metro user data
+ // (the one that isn't in use).
+#endif
DIR_CRASH_DUMPS, // Directory where crash dumps are written.
DIR_USER_DESKTOP, // Directory that correspond to the desktop.
DIR_RESOURCES, // Directory containing separate file resources
diff --git a/chrome/common/chrome_paths_internal.h b/chrome/common/chrome_paths_internal.h
index 2eb1557..23784aa 100644
--- a/chrome/common/chrome_paths_internal.h
+++ b/chrome/common/chrome_paths_internal.h
@@ -26,6 +26,12 @@ namespace chrome {
// DIR_USER_DATA has been overridden by a command-line option.
bool GetDefaultUserDataDirectory(FilePath* result);
+#if defined(OS_WIN)
+// Gets the path to the user data directory for the alternate environment to
+// the one in use (metro or desktop).
+bool GetAlternateUserDataDirectory(FilePath *result);
+#endif
+
// This returns the base directory in which Chrome Frame stores user profiles.
// Note that this cannot be wrapped in a preprocessor define since
// CF and Google Chrome want to share the same binaries.
diff --git a/chrome/common/chrome_paths_unittest.cc b/chrome/common/chrome_paths_unittest.cc
index 23bc7d4..98f9882 100644
--- a/chrome/common/chrome_paths_unittest.cc
+++ b/chrome/common/chrome_paths_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,6 +9,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "chrome/common/chrome_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
// Test the behavior of chrome::GetUserCacheDirectory.
@@ -42,3 +43,22 @@ TEST(ChromePaths, UserCacheDir) {
chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir);
EXPECT_EQ(test_profile_dir.value(), cache_dir.value());
}
+
+#if defined(OS_WINDOWS)
+TEST(ChromePaths, AlternateUserDataDir) {
+ FilePath current_dir;
+ FilePath alternate_dir;
+
+ ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, current_dir));
+
+ // Check that we can get the alternate dir.
+ EXPECT_TRUE(PathService::Get(chrome::DIR_ALT_USER_DATA, alternate_dir));
+
+ // And that it's not the same as the current dir.
+ EXPECTE_NE(current_dir.value(), alternate_dir.value());
+
+ // And that it's the metro dir.
+ EXPECT_EQ(FilePath::StringType(kMetroChromeUserDataSubDir),
+ alternate_dir.DirName().BaseName().value());
+}
+#endif
diff --git a/chrome/common/chrome_paths_win.cc b/chrome/common/chrome_paths_win.cc
index dc2502f..21d9a35 100644
--- a/chrome/common/chrome_paths_win.cc
+++ b/chrome/common/chrome_paths_win.cc
@@ -20,17 +20,31 @@
namespace chrome {
-bool GetDefaultUserDataDirectory(FilePath* result) {
+namespace {
+
+// Gets the default user data directory for either the current environment
+// (desktop or metro) or for the other one (metro or desktop).
+bool GetUserDataDirectoryForEnvironment(bool current, FilePath* result) {
if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result))
return false;
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
*result = result->Append(dist->GetInstallSubDir());
- if (base::win::GetMetroModule())
+ if (base::win::GetMetroModule() ? current : !current)
*result = result->Append(kMetroChromeUserDataSubDir);
*result = result->Append(chrome::kUserDataDirname);
return true;
}
+} // namespace
+
+bool GetDefaultUserDataDirectory(FilePath* result) {
+ return GetUserDataDirectoryForEnvironment(true, result);
+}
+
+bool GetAlternateUserDataDirectory(FilePath *result) {
+ return GetUserDataDirectoryForEnvironment(false, result);
+}
+
bool GetChromeFrameUserDataDirectory(FilePath* result) {
if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result))
return false;