Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 #include "blimp/client/core/settings/android/blimp_settings_android.h" | |
| 6 | |
| 7 #include "blimp/client/core/session/identity_source.h" | |
| 8 #include "blimp/client/public/blimp_client_context.h" | |
| 9 #include "jni/AboutBlimpPreferences_jni.h" | |
| 10 | |
| 11 namespace blimp { | |
| 12 namespace client { | |
| 13 | |
| 14 // static | |
| 15 bool BlimpSettingsAndroid::RegisterJni(JNIEnv* env) { | |
| 16 return RegisterNativesImpl(env); | |
| 17 } | |
| 18 | |
| 19 static jlong Init(JNIEnv* env, | |
| 20 const base::android::JavaParamRef<jobject>& jobj) { | |
| 21 return reinterpret_cast<intptr_t>(new BlimpSettingsAndroid(env, jobj)); | |
| 22 } | |
| 23 | |
| 24 BlimpSettingsAndroid::BlimpSettingsAndroid(JNIEnv* env, jobject jobj) | |
| 25 : identity_source_(nullptr) { | |
| 26 java_obj_.Reset(env, jobj); | |
| 27 } | |
| 28 | |
| 29 BlimpSettingsAndroid::~BlimpSettingsAndroid() {} | |
| 30 | |
| 31 void BlimpSettingsAndroid::Destroy( | |
| 32 JNIEnv* env, | |
| 33 const base::android::JavaParamRef<jobject>& jobj) { | |
| 34 identity_source_->RemoveObserver(this); | |
|
David Trainor- moved to gerrit
2016/08/29 05:12:24
DCHECK(identity_source_)?
xingliu
2016/08/30 04:47:42
Done.
| |
| 35 delete this; | |
| 36 } | |
| 37 | |
| 38 void BlimpSettingsAndroid::SetIdentitySource(IdentitySource* identity_source) { | |
|
David Trainor- moved to gerrit
2016/08/29 05:12:24
We actually want to call RemoveObserver on the old
xingliu
2016/08/30 04:47:42
This code is just to avoid SetIdentitySource calle
David Trainor- moved to gerrit
2016/08/30 20:46:29
I think the remove call is safe unless we add DCHE
xingliu
2016/08/30 22:27:36
Oh, I understand now. Added this before changing i
| |
| 39 identity_source_ = identity_source; | |
| 40 DCHECK(identity_source_); | |
| 41 | |
| 42 // Listen to sign in state change. | |
| 43 identity_source->RemoveObserver(this); | |
| 44 identity_source->AddObserver(this); | |
| 45 } | |
| 46 | |
| 47 void BlimpSettingsAndroid::OnSignedOut() { | |
| 48 Java_AboutBlimpPreferences_onSignedOut(base::android::AttachCurrentThread(), | |
| 49 java_obj_); | |
| 50 } | |
| 51 | |
| 52 void BlimpSettingsAndroid::OnSignedIn() { | |
| 53 Java_AboutBlimpPreferences_onSignedIn(base::android::AttachCurrentThread(), | |
| 54 java_obj_); | |
| 55 } | |
| 56 | |
| 57 void BlimpSettingsAndroid::OnActiveAccountLogout() { | |
| 58 OnSignedOut(); | |
|
David Trainor- moved to gerrit
2016/08/29 05:12:24
How much of this do we want to share with Linux?
xingliu
2016/08/30 04:47:42
The code here is only for UX, I'll expose the iden
David Trainor- moved to gerrit
2016/08/30 20:46:29
Acknowledged.
| |
| 59 } | |
| 60 | |
| 61 void BlimpSettingsAndroid::OnActiveAccountLogin() { | |
| 62 OnSignedIn(); | |
| 63 } | |
| 64 | |
| 65 } // namespace client | |
| 66 } // namespace blimp | |
| OLD | NEW |