OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. 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. |
| 4 |
| 5 #include "chrome/app/android/chrome_main_delegate_android.h" |
| 6 |
| 7 #include "base/android/jni_android.h" |
| 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" |
| 10 #include "chrome/browser/android/chrome_jni_registrar.h" |
| 11 #include "chrome/browser/android/chrome_startup_flags.h" |
| 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "content/public/browser/browser_main_runner.h" |
| 14 |
| 15 // ChromeMainDelegateAndroid is created when the library is loaded. It is always |
| 16 // done in the process's main Java thread. But for non browser process, e.g. |
| 17 // renderer process, it is not the native Chrome's main thread. |
| 18 ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() { |
| 19 } |
| 20 |
| 21 ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() { |
| 22 } |
| 23 |
| 24 void ChromeMainDelegateAndroid::SandboxInitialized( |
| 25 const std::string& process_type) { |
| 26 ChromeMainDelegate::SandboxInitialized(process_type); |
| 27 } |
| 28 |
| 29 int ChromeMainDelegateAndroid::RunProcess( |
| 30 const std::string& process_type, |
| 31 const content::MainFunctionParams& main_function_params) { |
| 32 if (process_type.empty()) { |
| 33 JNIEnv* env = base::android::AttachCurrentThread(); |
| 34 RegisterApplicationNativeMethods(env); |
| 35 |
| 36 browser_runner_.reset(content::BrowserMainRunner::Create()); |
| 37 int exit_code = browser_runner_->Initialize(main_function_params); |
| 38 DCHECK(exit_code < 0); |
| 39 |
| 40 // Return 0 so that we do NOT trigger the default behavior. On Android, the |
| 41 // UI message loop is managed by the Java application. |
| 42 return 0; |
| 43 } |
| 44 |
| 45 return ChromeMainDelegate::RunProcess(process_type, main_function_params); |
| 46 } |
| 47 |
| 48 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { |
| 49 SetChromeSpecificCommandLineFlags(); |
| 50 return ChromeMainDelegate::BasicStartupComplete(exit_code); |
| 51 } |
| 52 |
| 53 bool ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(JNIEnv* env) { |
| 54 return chrome::android::RegisterJni(env); |
| 55 } |
OLD | NEW |