Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(913)

Side by Side Diff: chrome/browser/profiles/profile_android.cc

Issue 556083004: Add hooks to get incognito profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/profiles/profile_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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> ProfileAndroid::GetOriginalProfile(
67 JNIEnv* env, jobject obj) {
68 ProfileAndroid* original_profile = ProfileAndroid::FromProfile(
69 profile_->GetOriginalProfile());
70 DCHECK(original_profile);
71 return original_profile->GetJavaObject();
72 }
73
74 base::android::ScopedJavaLocalRef<jobject>
75 ProfileAndroid::GetOffTheRecordProfile(JNIEnv* env, jobject obj) {
76 ProfileAndroid* otr_profile = ProfileAndroid::FromProfile(
77 profile_->GetOffTheRecordProfile());
78 DCHECK(otr_profile);
79 return otr_profile->GetJavaObject();
80 }
81
82 jboolean ProfileAndroid::HasOffTheRecordProfile(JNIEnv* env, jobject obj) {
83 return profile_->HasOffTheRecordProfile();
84 }
85
86 jboolean ProfileAndroid::IsOffTheRecord(JNIEnv* env, jobject obj) {
87 return profile_->IsOffTheRecord();
88 }
89
66 // static 90 // static
67 jobject GetLastUsedProfile(JNIEnv* env, jclass clazz) { 91 jobject GetLastUsedProfile(JNIEnv* env, jclass clazz) {
68 return ProfileAndroid::GetLastUsedProfile(env, clazz); 92 return ProfileAndroid::GetLastUsedProfile(env, clazz);
69 } 93 }
70 94
71 ProfileAndroid::ProfileAndroid(Profile* profile) 95 ProfileAndroid::ProfileAndroid(Profile* profile)
72 : profile_(profile) { 96 : profile_(profile) {
73 JNIEnv* env = AttachCurrentThread(); 97 JNIEnv* env = AttachCurrentThread();
74 base::android::ScopedJavaLocalRef<jobject> jprofile = 98 base::android::ScopedJavaLocalRef<jobject> jprofile =
75 Java_Profile_create(env, reinterpret_cast<intptr_t>(this)); 99 Java_Profile_create(env, reinterpret_cast<intptr_t>(this));
76 obj_.Reset(env, jprofile.obj()); 100 obj_.Reset(env, jprofile.obj());
77
78 } 101 }
79 102
80 ProfileAndroid::~ProfileAndroid() { 103 ProfileAndroid::~ProfileAndroid() {
81 Java_Profile_destroy(AttachCurrentThread(), obj_.obj()); 104 Java_Profile_destroy(AttachCurrentThread(), obj_.obj());
82 } 105 }
83 106
84 base::android::ScopedJavaLocalRef<jobject> ProfileAndroid::GetJavaObject() { 107 base::android::ScopedJavaLocalRef<jobject> ProfileAndroid::GetJavaObject() {
85 return base::android::ScopedJavaLocalRef<jobject>(obj_); 108 return base::android::ScopedJavaLocalRef<jobject>(obj_);
86 } 109 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698