Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / mojo / shell / android / apk / src / org / chromium / mojo_shell_apk / MojoMain.java
1 // Copyright 2013 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 package org.chromium.mojo_shell_apk;
6
7 import android.content.Context;
8
9 import org.chromium.base.JNINamespace;
10
11 /**
12  * A placeholder class to call native functions.
13  **/
14 @JNINamespace("mojo")
15 public class MojoMain {
16     /**
17      * A guard flag for calling nativeInit() only once.
18      **/
19     private static boolean sInitialized = false;
20
21     /**
22      * Initializes the native system.
23      **/
24     public static void ensureInitialized(Context context) {
25         if (sInitialized)
26             return;
27         nativeInit(context);
28         sInitialized = true;
29     }
30
31     /**
32      * Starts the specified application in the specified context.
33      **/
34     public static void start(final String appUrl) {
35         nativeStart(appUrl);
36     }
37
38     /**
39      * Initializes the native system. This API should be called only once per process.
40      **/
41     private static native void nativeInit(Context context);
42     private static native void nativeStart(String appUrl);
43 };