#include "xwalk/runtime/browser/xwalk_browser_main_parts_android.h"
+#include <string>
+
#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"
#include "content/public/browser/cookie_store_factory.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/result_codes.h"
-#include "grit/net_resources.h"
#include "net/android/network_change_notifier_factory_android.h"
#include "net/base/network_change_notifier.h"
#include "net/base/net_module.h"
#include "net/base/net_util.h"
#include "net/cookies/cookie_monster.h"
#include "net/cookies/cookie_store.h"
+#include "net/grit/net_resources.h"
#include "ui/base/layout.h"
#include "ui/base/l10n/l10n_util_android.h"
#include "ui/base/resource/resource_bundle.h"
#include "xwalk/extensions/common/xwalk_extension.h"
#include "xwalk/extensions/common/xwalk_extension_switches.h"
#include "xwalk/runtime/browser/android/cookie_manager.h"
-#include "xwalk/runtime/browser/runtime_context.h"
#include "xwalk/runtime/browser/xwalk_runner.h"
#include "xwalk/runtime/common/xwalk_runtime_features.h"
+#include "xwalk/runtime/common/xwalk_switches.h"
namespace {
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 {
void XWalkBrowserMainPartsAndroid::PreEarlyInitialization() {
net::NetworkChangeNotifier::SetFactory(
new net::NetworkChangeNotifierFactoryAndroid());
+ // As Crosswalk uses in-process mode, that's easier than Chromium
+ // to reach the default limit(1024) of open files per process on
+ // Android. So increase the limit to 4096 explicitly.
+ base::SetFdLimit(4096);
CommandLine::ForCurrentProcess()->AppendSwitch(
cc::switches::kCompositeToMailbox);
// 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
+#if defined(ENABLE_WEBRTC)
// Disable HW encoding/decoding acceleration for WebRTC on Android.
// FIXME: Remove these switches for Android when Android OS is removed from
// GPU accelerated_video_decode blacklist or we stop ignoring the GPU
// blacklist.
command_line->AppendSwitch(switches::kDisableWebRtcHWDecoding);
command_line->AppendSwitch(switches::kDisableWebRtcHWEncoding);
+#endif
+
+ command_line->AppendSwitch(switches::kEnableViewportMeta);
XWalkBrowserMainParts::PreMainMessageLoopStart();
xwalk_runner_->PreMainMessageLoopRun();
- runtime_context_ = xwalk_runner_->runtime_context();
extension_service_ = xwalk_runner_->extension_service();
// Prepare the cookie store.
if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) {
NOTREACHED() << "Failed to get app data directory for Crosswalk";
}
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ 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"));