Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / android / java / src / org / chromium / chrome / browser / profiles / Profile.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.chrome.browser.profiles;
6
7 import org.chromium.base.CalledByNative;
8
9 /**
10  * Wrapper that allows passing a Profile reference around in the Java layer.
11  */
12 public class Profile {
13
14     private long mNativeProfileAndroid;
15
16     private Profile(long nativeProfileAndroid) {
17         mNativeProfileAndroid = nativeProfileAndroid;
18     }
19
20     public static Profile getLastUsedProfile() {
21         return (Profile) nativeGetLastUsedProfile();
22     }
23
24     /**
25      * Destroys the Profile.  Destruction is delayed until all associated
26      * renderers have been killed, so the profile might not be destroyed upon returning from
27      * this call.
28      */
29     public void destroyWhenAppropriate() {
30         nativeDestroyWhenAppropriate(mNativeProfileAndroid);
31     }
32
33     public Profile getOriginalProfile() {
34         return (Profile) nativeGetOriginalProfile(mNativeProfileAndroid);
35     }
36
37     public Profile getOffTheRecordProfile() {
38         return (Profile) nativeGetOffTheRecordProfile(mNativeProfileAndroid);
39     }
40
41     public boolean hasOffTheRecordProfile() {
42         return nativeHasOffTheRecordProfile(mNativeProfileAndroid);
43     }
44
45     public boolean isOffTheRecord() {
46         return nativeIsOffTheRecord(mNativeProfileAndroid);
47     }
48
49     @CalledByNative
50     private static Profile create(long nativeProfileAndroid) {
51         return new Profile(nativeProfileAndroid);
52     }
53
54     @CalledByNative
55     private void onNativeDestroyed() {
56         mNativeProfileAndroid = 0;
57     }
58
59     @CalledByNative
60     private long getNativePointer() {
61         return mNativeProfileAndroid;
62     }
63
64     private static native Object nativeGetLastUsedProfile();
65     private native void nativeDestroyWhenAppropriate(long nativeProfileAndroid);
66     private native Object nativeGetOriginalProfile(long nativeProfileAndroid);
67     private native Object nativeGetOffTheRecordProfile(long nativeProfileAndroid);
68     private native boolean nativeHasOffTheRecordProfile(long nativeProfileAndroid);
69     private native boolean nativeIsOffTheRecord(long nativeProfileAndroid);
70 }