summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/chrome_constants.cc5
-rw-r--r--chrome/common/chrome_paths_internal.h5
-rw-r--r--chrome/common/chrome_paths_linux.cc10
-rw-r--r--chrome/common/chrome_paths_mac.mm13
-rw-r--r--chrome/common/chrome_paths_win.cc11
-rw-r--r--chrome/installer/setup/uninstall.cc20
-rw-r--r--chrome_frame/chrome_frame_automation.cc9
-rw-r--r--chrome_frame/test/net/fake_external_tab.cc15
-rw-r--r--chrome_frame/test/net/fake_external_tab.h2
-rw-r--r--chrome_frame/test/perf/chrome_frame_perftest.cc9
-rw-r--r--chrome_frame/utils.cc27
-rw-r--r--chrome_frame/utils.h3
12 files changed, 73 insertions, 56 deletions
diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc
index cd21474..6a6ad28 100644
--- a/chrome/common/chrome_constants.cc
+++ b/chrome/common/chrome_constants.cc
@@ -50,10 +50,7 @@ const FilePath::CharType kHelperProcessExecutablePath[] =
const FilePath::CharType kFrameworkName[] =
FPL(PRODUCT_STRING " Framework.framework");
#endif // OS_MACOSX
-#if defined(CHROME_FRAME_BUILD)
-const wchar_t kBrowserAppName[] = L"ChromeFrame";
-const char kStatsFilename[] = "ChromeFrameStats2";
-#elif defined(GOOGLE_CHROME_BUILD)
+#if defined(GOOGLE_CHROME_BUILD)
const wchar_t kBrowserAppName[] = L"Chrome";
const char kStatsFilename[] = "ChromeStats2";
#else
diff --git a/chrome/common/chrome_paths_internal.h b/chrome/common/chrome_paths_internal.h
index 83ae638..4dc4e0f 100644
--- a/chrome/common/chrome_paths_internal.h
+++ b/chrome/common/chrome_paths_internal.h
@@ -14,6 +14,11 @@ namespace chrome {
// DIR_USER_DATA has been overridden by a command-line option.
bool GetDefaultUserDataDirectory(FilePath* result);
+// 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.
+bool GetChromeFrameUserDataDirectory(FilePath* result);
+
#if defined(OS_LINUX)
// Get the path to the user's cache directory.
bool GetUserCacheDirectory(FilePath* result);
diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc
index abc7f8d..71cb03f 100644
--- a/chrome/common/chrome_paths_linux.cc
+++ b/chrome/common/chrome_paths_linux.cc
@@ -72,6 +72,16 @@ bool GetDefaultUserDataDirectory(FilePath* result) {
return true;
}
+bool GetChromeFrameUserDataDirectory(FilePath* result) {
+ FilePath config_dir(GetXDGDirectory("XDG_CONFIG_HOME", ".config"));
+#if defined(GOOGLE_CHROME_BUILD)
+ *result = config_dir.Append("google-chrome-frame");
+#else
+ *result = config_dir.Append("chrome-frame");
+#endif
+ return true;
+}
+
// See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
// for a spec on where cache files go. The net effect for most
// systems is we use ~/.cache/chromium/ for Chromium and
diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm
index 3fdcfdf..f401751 100644
--- a/chrome/common/chrome_paths_mac.mm
+++ b/chrome/common/chrome_paths_mac.mm
@@ -27,6 +27,19 @@ bool GetDefaultUserDataDirectory(FilePath* result) {
return success;
}
+bool GetChromeFrameUserDataDirectory(FilePath* result) {
+ bool success = false;
+ if (result && PathService::Get(base::DIR_APP_DATA, result)) {
+#if defined(GOOGLE_CHROME_BUILD)
+ *result = result->Append("Google").Append("Chrome Frame");
+#else
+ *result = result->Append("Chrome Frame");
+#endif
+ success = true;
+ }
+ return success;
+}
+
bool GetUserDocumentsDirectory(FilePath* result) {
bool success = false;
NSArray* docArray =
diff --git a/chrome/common/chrome_paths_win.cc b/chrome/common/chrome_paths_win.cc
index 257d5bb..5a860b9 100644
--- a/chrome/common/chrome_paths_win.cc
+++ b/chrome/common/chrome_paths_win.cc
@@ -25,6 +25,17 @@ bool GetDefaultUserDataDirectory(FilePath* result) {
return true;
}
+bool GetChromeFrameUserDataDirectory(FilePath* result) {
+ if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result))
+ return false;
+#if defined(GOOGLE_CHROME_BUILD)
+ *result = result->Append(FILE_PATH_LITERAL("Google"));
+#endif
+ *result = result->Append(L"Chrome Frame");
+ *result = result->Append(chrome::kUserDataDirname);
+ return true;
+}
+
bool GetUserDocumentsDirectory(FilePath* result) {
wchar_t path_buf[MAX_PATH];
if (FAILED(SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL,
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 2ad8cf2..1a99803 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -176,17 +176,27 @@ DeleteResult DeleteFilesAndFolders(const std::wstring& exe_path,
file_util::Move(setup_exe_path, temp_file);
}
- // Move the browser's persisted local state
+ // Obtain the location of the user profile data. Chrome Frame needs to
+ // build this path manually since it doesn't use the Chrome default dir.
FilePath user_local_state;
- if (chrome::GetDefaultUserDataDirectory(&user_local_state)) {
+#if defined(CHROME_FRAME_BUILD)
+ bool got_local_state =
+ chrome::GetChromeFrameUserDataDirectory(&user_local_state);
+#else // if !defined(CHROME_FRAME_BUILD)
+ bool got_local_state = chrome::GetDefaultUserDataDirectory(&user_local_state);
+#endif
+
+ // Move the browser's persisted local state
+ if (got_local_state) {
FilePath user_local_file(
user_local_state.Append(chrome::kLocalStateFilename));
-
FilePath path = FilePath::FromWStringHack(*local_state_path);
if (!file_util::CreateTemporaryFile(&path))
LOG(ERROR) << "Failed to create temporary file for Local State.";
else
file_util::CopyFile(user_local_file, path);
+ } else {
+ LOG(ERROR) << "Could not retrieve user's profile directory.";
}
DeleteResult result = DELETE_SUCCEEDED;
@@ -210,7 +220,7 @@ DeleteResult DeleteFilesAndFolders(const std::wstring& exe_path,
#endif
}
- if (delete_profile) {
+ if (delete_profile && got_local_state) {
LOG(INFO) << "Deleting user profile" << user_local_state.value();
if (!file_util::Delete(user_local_state, true)) {
LOG(ERROR) << "Failed to delete user profile dir: "
@@ -521,4 +531,4 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
file_util::Delete(local_state_path, false);
return ret;
-}
+} \ No newline at end of file
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index e02173d..5286f773 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -17,6 +17,7 @@
#include "chrome/app/client_util.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome_frame/chrome_launcher.h"
@@ -251,11 +252,11 @@ void ProxyFactory::CreateProxy(ProxyFactory::ProxyCacheEntry* entry,
// Place the profile directory in
// "<chrome_exe_path>\..\User Data\<profile-name>"
if (!entry->profile_name.empty()) {
- std::wstring profile_path;
- if (GetUserProfileBaseDirectory(&profile_path)) {
- file_util::AppendToPath(&profile_path, entry->profile_name);
+ FilePath profile_path;
+ if (chrome::GetChromeFrameUserDataDirectory(&profile_path)) {
+ profile_path = profile_path.Append(entry->profile_name);
command_line->AppendSwitchWithValue(switches::kUserDataDir,
- profile_path);
+ profile_path.value());
} else {
// Can't get the profile dir :-( We need one to work, so fail.
// We have no code for launch failure.
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc
index ab3437b..78430fe 100644
--- a/chrome_frame/test/net/fake_external_tab.cc
+++ b/chrome_frame/test/net/fake_external_tab.cc
@@ -21,11 +21,12 @@
#include "chrome/browser/browser_prefs.h"
#include "chrome/browser/process_singleton.h"
#include "chrome/browser/profile_manager.h"
+#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
-#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome_frame/utils.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
@@ -68,7 +69,7 @@ bool PromptAfterSetup() {
FakeExternalTab::FakeExternalTab() {
PathService::Get(chrome::DIR_USER_DATA, &overridden_user_dir_);
- user_data_dir_ = FilePath::FromWStringHack(GetProfilePath());
+ GetProfilePath(&user_data_dir_);
PathService::Override(chrome::DIR_USER_DATA, user_data_dir_);
process_singleton_.reset(new ProcessSingleton(user_data_dir_));
}
@@ -83,11 +84,11 @@ std::wstring FakeExternalTab::GetProfileName() {
return L"iexplore";
}
-std::wstring FakeExternalTab::GetProfilePath() {
- std::wstring path;
- GetUserProfileBaseDirectory(&path);
- file_util::AppendToPath(&path, GetProfileName());
- return path;
+bool FakeExternalTab::GetProfilePath(FilePath* path) {
+ if (!chrome::GetChromeFrameUserDataDirectory(path))
+ return false;
+ *path = path->Append(GetProfileName());
+ return true;
}
void FakeExternalTab::Initialize() {
diff --git a/chrome_frame/test/net/fake_external_tab.h b/chrome_frame/test/net/fake_external_tab.h
index 79e45cf..bd67a7f 100644
--- a/chrome_frame/test/net/fake_external_tab.h
+++ b/chrome_frame/test/net/fake_external_tab.h
@@ -28,7 +28,7 @@ class FakeExternalTab {
virtual std::wstring GetProfileName();
- virtual std::wstring GetProfilePath();
+ virtual bool GetProfilePath(FilePath* path);
virtual void Initialize();
virtual void Shutdown();
diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc
index c896fa4..215f076 100644
--- a/chrome_frame/test/perf/chrome_frame_perftest.cc
+++ b/chrome_frame/test/perf/chrome_frame_perftest.cc
@@ -20,6 +20,7 @@
#include "base/time.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_paths_internal.h"
#include "chrome/test/chrome_process_util.h"
#include "chrome/test/perf/mem_usage.h"
#include "chrome/test/ui/ui_test.h"
@@ -638,13 +639,11 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase {
void InitiateNextNavigation() {
if (browser_pid_ == 0) {
- std::wstring profile_directory;
- if (GetUserProfileBaseDirectory(&profile_directory)) {
- file_util::AppendToPath(&profile_directory,
- GetHostProcessName(false));
+ FilePath profile_directory;
+ if (chrome::GetChromeFrameUserDataDirectory(&user_data_dir_)) {
+ user_data_dir_ = user_data_dir_.Append(GetHostProcessName(false));
}
- user_data_dir_ = FilePath::FromWStringHack(profile_directory);
browser_pid_ = ChromeBrowserProcessId(user_data_dir_);
}
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc
index fdcb7c7..746a260 100644
--- a/chrome_frame/utils.cc
+++ b/chrome_frame/utils.cc
@@ -14,8 +14,6 @@
#include "base/registry.h"
#include "base/scoped_comptr_win.h"
#include "base/string_util.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/installer/util/google_update_constants.h"
#include "googleurl/src/gurl.h"
#include "grit/chrome_frame_resources.h"
#include "chrome_frame/resource.h"
@@ -548,28 +546,3 @@ bool IsValidUrlScheme(const std::wstring& url, bool is_privileged) {
return false;
}
-
-// TODO(robertshield): Register and use Chrome's PathProviders.
-// - Note that this function is used by unit tests as well to override
-// PathService paths, so please test when addressing todo.
-bool GetUserProfileBaseDirectory(std::wstring* path) {
- DCHECK(path);
- wchar_t path_buffer[MAX_PATH * 4];
- path_buffer[0] = 0;
- // TODO(robertshield): Ideally we should use SHGetFolderLocation and then
- // get a path via PIDL.
- HRESULT hr = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL,
- SHGFP_TYPE_CURRENT, path_buffer);
-
- if (SUCCEEDED(hr)) {
- *path = path_buffer;
-#if defined(GOOGLE_CHROME_BUILD)
- file_util::AppendToPath(path, FILE_PATH_LITERAL("Google"));
-#endif
- file_util::AppendToPath(path, chrome::kBrowserAppName);
- file_util::AppendToPath(path, chrome::kUserDataDirname);
- return true;
- }
-
- return false;
-}
diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h
index 2f79013..fa6bec9 100644
--- a/chrome_frame/utils.h
+++ b/chrome_frame/utils.h
@@ -196,9 +196,6 @@ HRESULT GetUrlFromMoniker(IMoniker* moniker, IBindCtx* bind_context,
// When is_privileged is true, chrome extension URLs will be considered valid.
bool IsValidUrlScheme(const std::wstring& url, bool is_privileged);
-// This returns the base directory in which to store user profiles.
-bool GetUserProfileBaseDirectory(std::wstring* path);
-
// See COM_INTERFACE_BLIND_DELEGATE below for details.
template <class T>
STDMETHODIMP CheckOutgoingInterface(void* obj, REFIID iid, void** ret,