Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/profiles/profile_android.h" | 5 #include "chrome/browser/profiles/profile_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "jni/Profile_jni.h" | 10 #include "jni/Profile_jni.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 | 56 |
| 57 ProfileAndroid* profile_android = ProfileAndroid::FromProfile(profile); | 57 ProfileAndroid* profile_android = ProfileAndroid::FromProfile(profile); |
| 58 if (profile_android == NULL) { | 58 if (profile_android == NULL) { |
| 59 NOTREACHED() << "ProfileAndroid not found."; | 59 NOTREACHED() << "ProfileAndroid not found."; |
| 60 return NULL; | 60 return NULL; |
| 61 } | 61 } |
| 62 | 62 |
| 63 return profile_android->obj_.obj(); | 63 return profile_android->obj_.obj(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 base::android::ScopedJavaLocalRef<jobject> | |
| 67 ProfileAndroid::GetOffTheRecordProfile(JNIEnv* env, jobject obj) { | |
| 68 Profile* profile = ProfileManager::GetPrimaryUserProfile(); | |
|
Ted C
2014/09/10 17:08:10
This shouldn't be using this anymore. It should b
Maria
2014/09/10 17:17:54
Done.
| |
| 69 if (!profile) { | |
| 70 NOTREACHED() << "Profile not found."; | |
| 71 return base::android::ScopedJavaLocalRef<jobject>(); | |
| 72 } | |
| 73 | |
| 74 Profile* otr_profile = profile->GetOffTheRecordProfile(); | |
| 75 DCHECK(otr_profile); | |
| 76 | |
| 77 ProfileAndroid* profile_android = ProfileAndroid::FromProfile(otr_profile); | |
| 78 if (!profile_android) { | |
| 79 NOTREACHED() << "ProfileAndroid not found."; | |
| 80 return base::android::ScopedJavaLocalRef<jobject>(); | |
| 81 } | |
| 82 return profile_android->GetJavaObject(); | |
| 83 } | |
| 84 | |
| 85 jboolean ProfileAndroid::HasOffTheRecordProfile(JNIEnv* env, jobject obj) { | |
| 86 Profile* profile = ProfileManager::GetPrimaryUserProfile(); | |
| 87 if (!profile) { | |
| 88 NOTREACHED() << "Profile not found."; | |
| 89 return false; | |
| 90 } | |
| 91 | |
| 92 return profile->HasOffTheRecordProfile(); | |
|
Ted C
2014/09/10 17:08:10
and this should be profile_->HasOffTheRecordProfil
Maria
2014/09/10 17:17:54
Done.
| |
| 93 } | |
| 94 | |
| 66 // static | 95 // static |
| 67 jobject GetLastUsedProfile(JNIEnv* env, jclass clazz) { | 96 jobject GetLastUsedProfile(JNIEnv* env, jclass clazz) { |
| 68 return ProfileAndroid::GetLastUsedProfile(env, clazz); | 97 return ProfileAndroid::GetLastUsedProfile(env, clazz); |
| 69 } | 98 } |
| 70 | 99 |
| 71 ProfileAndroid::ProfileAndroid(Profile* profile) | 100 ProfileAndroid::ProfileAndroid(Profile* profile) |
| 72 : profile_(profile) { | 101 : profile_(profile) { |
| 73 JNIEnv* env = AttachCurrentThread(); | 102 JNIEnv* env = AttachCurrentThread(); |
| 74 base::android::ScopedJavaLocalRef<jobject> jprofile = | 103 base::android::ScopedJavaLocalRef<jobject> jprofile = |
| 75 Java_Profile_create(env, reinterpret_cast<intptr_t>(this)); | 104 Java_Profile_create(env, reinterpret_cast<intptr_t>(this)); |
| 76 obj_.Reset(env, jprofile.obj()); | 105 obj_.Reset(env, jprofile.obj()); |
| 77 | |
| 78 } | 106 } |
| 79 | 107 |
| 80 ProfileAndroid::~ProfileAndroid() { | 108 ProfileAndroid::~ProfileAndroid() { |
| 81 Java_Profile_destroy(AttachCurrentThread(), obj_.obj()); | 109 Java_Profile_destroy(AttachCurrentThread(), obj_.obj()); |
| 82 } | 110 } |
| 83 | 111 |
| 84 base::android::ScopedJavaLocalRef<jobject> ProfileAndroid::GetJavaObject() { | 112 base::android::ScopedJavaLocalRef<jobject> ProfileAndroid::GetJavaObject() { |
| 85 return base::android::ScopedJavaLocalRef<jobject>(obj_); | 113 return base::android::ScopedJavaLocalRef<jobject>(obj_); |
| 86 } | 114 } |
| OLD | NEW |