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.
5 package org.chromium.chrome.browser.profiles;
7 import org.chromium.base.CalledByNative;
10 * Wrapper that allows passing a Profile reference around in the Java layer.
12 public class Profile {
14 private long mNativeProfileAndroid;
16 private Profile(long nativeProfileAndroid) {
17 mNativeProfileAndroid = nativeProfileAndroid;
20 public static Profile getLastUsedProfile() {
21 return (Profile) nativeGetLastUsedProfile();
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
29 public void destroyWhenAppropriate() {
30 nativeDestroyWhenAppropriate(mNativeProfileAndroid);
33 public Profile getOriginalProfile() {
34 return (Profile) nativeGetOriginalProfile(mNativeProfileAndroid);
37 public Profile getOffTheRecordProfile() {
38 return (Profile) nativeGetOffTheRecordProfile(mNativeProfileAndroid);
41 public boolean hasOffTheRecordProfile() {
42 return nativeHasOffTheRecordProfile(mNativeProfileAndroid);
45 public boolean isOffTheRecord() {
46 return nativeIsOffTheRecord(mNativeProfileAndroid);
50 private static Profile create(long nativeProfileAndroid) {
51 return new Profile(nativeProfileAndroid);
55 private void onNativeDestroyed() {
56 mNativeProfileAndroid = 0;
60 private long getNativePointer() {
61 return mNativeProfileAndroid;
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);