summaryrefslogtreecommitdiffstats
path: root/chrome_elf
diff options
context:
space:
mode:
authorcaitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-07 21:59:10 +0000
committercaitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-07 21:59:10 +0000
commita8eab3bb4993c6db09e963a436a305d07e327e1e (patch)
treeabc17b2eecb42d425c855160e3374c1511cb9bdc /chrome_elf
parent69c355d4f8883f4504fb7752f658918d528f55df (diff)
downloadchromium_src-a8eab3bb4993c6db09e963a436a305d07e327e1e.zip
chromium_src-a8eab3bb4993c6db09e963a436a305d07e327e1e.tar.gz
chromium_src-a8eab3bb4993c6db09e963a436a305d07e327e1e.tar.bz2
Make redirects work on canary by looking in the correct profile
BUG=334379 Review URL: https://codereview.chromium.org/156103004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249806 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_elf')
-rw-r--r--chrome_elf/chrome_elf_constants.cc9
-rw-r--r--chrome_elf/chrome_elf_constants.h3
-rw-r--r--chrome_elf/create_file/chrome_create_file.cc14
-rw-r--r--chrome_elf/create_file/chrome_create_file.h4
-rw-r--r--chrome_elf/create_file/chrome_create_file_unittest.cc6
5 files changed, 30 insertions, 6 deletions
diff --git a/chrome_elf/chrome_elf_constants.cc b/chrome_elf/chrome_elf_constants.cc
index b3f0ab5..cd60763 100644
--- a/chrome_elf/chrome_elf_constants.cc
+++ b/chrome_elf/chrome_elf_constants.cc
@@ -4,12 +4,13 @@
#include "chrome_elf/chrome_elf_constants.h"
-const wchar_t kUserDataDirName[] = L"User Data";
-const wchar_t kPreferencesFilename[] = L"Preferences";
-const wchar_t kLocalStateFilename[] = L"Local State";
-
#if defined(GOOGLE_CHROME_BUILD)
const wchar_t kAppDataDirName[] = L"Google\\Chrome";
#else
const wchar_t kAppDataDirName[] = L"Chromium";
#endif
+const wchar_t kCanaryAppDataDirName[] = L"Google\\Chrome SxS";
+const wchar_t kLocalStateFilename[] = L"Local State";
+const wchar_t kPreferencesFilename[] = L"Preferences";
+const wchar_t kUserDataDirName[] = L"User Data";
+
diff --git a/chrome_elf/chrome_elf_constants.h b/chrome_elf/chrome_elf_constants.h
index a24e0f7..fcfbc25 100644
--- a/chrome_elf/chrome_elf_constants.h
+++ b/chrome_elf/chrome_elf_constants.h
@@ -9,8 +9,9 @@
// directory names
extern const wchar_t kAppDataDirName[];
-extern const wchar_t kPreferencesFilename[];
+extern const wchar_t kCanaryAppDataDirName[];
extern const wchar_t kLocalStateFilename[];
+extern const wchar_t kPreferencesFilename[];
extern const wchar_t kUserDataDirName[];
#endif // CHROME_ELF_CHROME_ELF_CONSTANTS_H_
diff --git a/chrome_elf/create_file/chrome_create_file.cc b/chrome_elf/create_file/chrome_create_file.cc
index a39cd3e..f1cd599 100644
--- a/chrome_elf/create_file/chrome_create_file.cc
+++ b/chrome_elf/create_file/chrome_create_file.cc
@@ -243,6 +243,11 @@ HANDLE CreateFileNTDLL(
return file_handle;
}
+bool IsCanary(LPWSTR exe_path) {
+ wchar_t* found = wcsstr(exe_path, L"Google\\Chrome SxS");
+ return !!found;
+}
+
bool ShouldBypass(LPCWSTR file_path) {
// If the shell functions are not present, forward the call to kernel32.
if (!PopulateShellFunctions())
@@ -259,10 +264,17 @@ bool ShouldBypass(LPCWSTR file_path) {
HRESULT appdata_result = g_get_folder_func(
NULL, CSIDL_LOCAL_APPDATA, NULL, 0, local_appdata_path);
+ wchar_t buffer[MAX_PATH] = {};
+ if (!GetModuleFileNameW(NULL, buffer, MAX_PATH))
+ return false;
+
+ bool is_canary = IsCanary(buffer);
+
// If getting the %LOCALAPPDATA% path or appending to it failed, then forward
// the call to kernel32.
if (!SUCCEEDED(appdata_result) ||
- !g_path_append_func(local_appdata_path, kAppDataDirName) ||
+ !g_path_append_func(local_appdata_path, is_canary ?
+ kCanaryAppDataDirName : kAppDataDirName) ||
!g_path_append_func(local_appdata_path, kUserDataDirName)) {
return false;
}
diff --git a/chrome_elf/create_file/chrome_create_file.h b/chrome_elf/create_file/chrome_create_file.h
index dac93af..df38986 100644
--- a/chrome_elf/create_file/chrome_create_file.h
+++ b/chrome_elf/create_file/chrome_create_file.h
@@ -35,4 +35,8 @@ HANDLE CreateFileNTDLL(
// system version (only uses ours if we're writing to the user data directory).
bool ShouldBypass(LPCWSTR file_name);
+// Returns true if |exe_path| points to a Chrome installed in a SxS
+// installation.
+bool IsCanary(LPWSTR exe_path);
+
#endif // CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_
diff --git a/chrome_elf/create_file/chrome_create_file_unittest.cc b/chrome_elf/create_file/chrome_create_file_unittest.cc
index e25b159..1d5800a 100644
--- a/chrome_elf/create_file/chrome_create_file_unittest.cc
+++ b/chrome_elf/create_file/chrome_create_file_unittest.cc
@@ -343,6 +343,12 @@ TEST_F(ChromeCreateFileTest, CheckParams_FILE_FLAG_OPEN_NO_RECALL) {
ResetNtCreateFileCalls();
}
+TEST_F(ChromeCreateFileTest, CanaryTest) {
+ EXPECT_TRUE(IsCanary(L"C:\\Users\\user\\AppData\\Local\\Google\\Chrome SxS"));
+ EXPECT_FALSE(IsCanary(L"C:\\Users\\user\\AppData\\Local\\Google\\Chrome"));
+ EXPECT_FALSE(IsCanary(L"C:\\Users\\user\\AppData\\Local\\Chromium"));
+}
+
TEST_F(ChromeCreateFileTest, BypassTest) {
std::wstring UNC_filepath_file(L"\\\\.\\some_file.txt");