#include "base/android/path_utils.h"
#include "base/base_paths_android.h"
#include "base/files/file_path.h"
-#include "base/file_util.h"
+#include "base/files/file_util.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/threading/sequenced_worker_pool.h"
return base::StringPiece();
}
+void MoveUserDataDirIfNecessary(const base::FilePath& user_data_dir,
+ const base::FilePath& profile) {
+ if (base::DirectoryExists(profile))
+ return;
+
+ if (!base::CreateDirectory(profile))
+ return;
+
+ const char* possible_data_dir_names[] = {
+ "Cache",
+ "Cookies",
+ "Cookies-journal",
+ "Local Storage",
+ };
+ for (int i = 0; i < 4; i++) {
+ base::FilePath dir = user_data_dir.Append(possible_data_dir_names[i]);
+ if (base::PathExists(dir)) {
+ if (!base::Move(dir, profile.Append(possible_data_dir_names[i]))) {
+ NOTREACHED() << "Failed to import previous user data: "
+ << possible_data_dir_names[i];
+ }
+ }
+ }
+}
+
} // namespace
namespace xwalk {
// Only force to enable WebGL for Android for IA platforms because
// we've tested the WebGL conformance test. For other platforms, just
// follow up the behavior defined by Chromium upstream.
-#if defined(ARCH_CPU_X86)
+#if defined(ARCH_CPU_X86) || defined(ARCH_CPU_X86_64)
command_line->AppendSwitch(switches::kIgnoreGpuBlacklist);
#endif
NOTREACHED() << "Failed to get app data directory for Crosswalk";
}
CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kXWalkProfileName))
- user_data_dir = user_data_dir.Append(
+ if (command_line->HasSwitch(switches::kXWalkProfileName)) {
+ base::FilePath profile = user_data_dir.Append(
command_line->GetSwitchValuePath(switches::kXWalkProfileName));
+ MoveUserDataDirIfNecessary(user_data_dir, profile);
+ user_data_dir = profile;
+ }
base::FilePath cookie_store_path = user_data_dir.Append(
FILE_PATH_LITERAL("Cookies"));