Remove the Chrome Frame preprocessor define in chrome_constants.cc and deal with resulting fallout.

Also, remove several instances of Chrome Frame using wstrings instead of FilePaths.

The main goal of this patch is to move towards ensuring that Chrome Frame and Google Chrome share binary-identical exes and dlls except for setup.exe and mini_installer.exe.

Review URL: http://codereview.chromium.org/338025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30290 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a28f169
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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 =
......
......@@ -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,
......
......@@ -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
......@@ -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.
......
......@@ -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() {
......
......@@ -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();
......
......@@ -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_);
}
......
......@@ -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;
}
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment