Chromium Code Reviews| 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_startup_flags.h" | |
| 11 #include "chrome/common/chrome_switches.h" | |
| 12 #include "content/public/browser/browser_main_runner.h" | |
| 13 | |
| 14 // ChromeMainDelegateAndroid is created when the library is loaded. It is always | |
| 15 // done in the process's main Java thread. But for non browser process, e.g. | |
| 16 // renderer process, it is not the native Chrome's main thread. | |
| 17 ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() { | |
| 18 } | |
| 19 | |
| 20 ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() { | |
| 21 } | |
| 22 | |
| 23 void ChromeMainDelegateAndroid::SandboxInitialized( | |
| 24 const std::string& process_type) { | |
| 25 if (process_type.empty()) { | |
| 26 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 27 RegisterApplicationNativeMethods(env); | |
| 28 } | |
| 29 | |
| 30 ChromeMainDelegate::SandboxInitialized(process_type); | |
| 31 } | |
| 32 | |
| 33 int ChromeMainDelegateAndroid::RunProcess( | |
| 34 const std::string& process_type, | |
| 35 const content::MainFunctionParams& main_function_params) { | |
| 36 if (process_type.empty()) { | |
| 37 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 38 RegisterApplicationNativeMethods(env); | |
| 39 | |
| 40 browser_runner_.reset(content::BrowserMainRunner::Create()); | |
| 41 int exit_code = browser_runner_->Initialize(main_function_params); | |
| 42 DCHECK(exit_code < 0); | |
| 43 | |
| 44 // Return 0 so that we do NOT trigger the default behavior. On Android, the | |
| 45 // UI message loop is managed by the Java application. | |
| 46 return 0; | |
| 47 } | |
| 48 | |
| 49 return ChromeMainDelegate::RunProcess(process_type, main_function_params); | |
| 50 } | |
| 51 | |
| 52 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { | |
| 53 SetChromeSpecificCommandLineFlags(); | |
| 54 return ChromeMainDelegate::BasicStartupComplete(exit_code); | |
| 55 } | |
| 56 | |
| 57 bool ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(JNIEnv* env) { | |
| 58 return true; | |
|
Yaron
2012/09/07 20:53:43
I think you should move chrome::android::RegisterJ
David Trainor- moved to gerrit
2012/09/10 18:09:13
Yeah that should work. It looks like the registra
| |
| 59 } | |
| OLD | NEW |