1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "xwalk/runtime/app/android/xwalk_main_delegate_android.h"
9 #include "base/command_line.h"
11 #include "base/file_util.h"
12 #include "base/files/file_path.h"
13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/base_paths_android.h"
16 #include "base/path_service.h"
17 #include "base/platform_file.h"
18 #include "base/posix/global_descriptors.h"
19 #include "content/public/browser/browser_main_runner.h"
20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/base/ui_base_paths.h"
22 #include "ui/base/ui_base_switches.h"
23 #include "xwalk/runtime/common/android/xwalk_globals_android.h"
24 #include "xwalk/runtime/common/xwalk_content_client.h"
28 XWalkMainDelegateAndroid::XWalkMainDelegateAndroid() {
31 XWalkMainDelegateAndroid::~XWalkMainDelegateAndroid() {
34 bool XWalkMainDelegateAndroid::BasicStartupComplete(int* exit_code) {
35 content_client_.reset(new XWalkContentClient);
36 content::SetContentClient(content_client_.get());
40 void XWalkMainDelegateAndroid::PreSandboxStartup() {
41 #if defined(ARCH_CPU_ARM_FAMILY)
42 // Create an instance of the CPU class to parse /proc/cpuinfo and cache
43 // cpu_brand info for ARM platform.
49 int XWalkMainDelegateAndroid::RunProcess(
50 const std::string& process_type,
51 const content::MainFunctionParams& main_function_params) {
52 if (process_type.empty()) {
53 browser_runner_.reset(content::BrowserMainRunner::Create());
54 int exit_code = browser_runner_->Initialize(main_function_params);
55 DCHECK_LT(exit_code, 0);
62 void XWalkMainDelegateAndroid::InitResourceBundle() {
63 base::FilePath pak_file;
64 base::FilePath pak_dir;
65 bool got_path = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_dir);
67 pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks"));
68 pak_file = pak_dir.Append(FILE_PATH_LITERAL(kXWalkPakFilePath));
69 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);