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

Unified Diff: blimp/client/core/settings/android/blimp_settings_android.cc

Issue 2261273002: Integrate UI with authentication flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Misc fix. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: blimp/client/core/settings/android/blimp_settings_android.cc
diff --git a/blimp/client/core/settings/android/blimp_settings_android.cc b/blimp/client/core/settings/android/blimp_settings_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d7ac5d2b6cb7ee4c77687a7721a558d9b6e33b60
--- /dev/null
+++ b/blimp/client/core/settings/android/blimp_settings_android.cc
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/client/core/settings/android/blimp_settings_android.h"
+
+#include "blimp/client/core/session/identity_source.h"
+#include "blimp/client/public/blimp_client_context.h"
+#include "jni/AboutBlimpPreferences_jni.h"
+
+namespace blimp {
+namespace client {
+
+// static
+bool BlimpSettingsAndroid::RegisterJni(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+static jlong Init(JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jobj) {
+ return reinterpret_cast<intptr_t>(new BlimpSettingsAndroid(env, jobj));
+}
+
+BlimpSettingsAndroid::BlimpSettingsAndroid(JNIEnv* env, jobject jobj)
+ : identity_source_(nullptr) {
+ java_obj_.Reset(env, jobj);
+}
+
+BlimpSettingsAndroid::~BlimpSettingsAndroid() {}
+
+void BlimpSettingsAndroid::Destroy(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jobj) {
+ 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.
+ delete this;
+}
+
+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
+ identity_source_ = identity_source;
+ DCHECK(identity_source_);
+
+ // Listen to sign in state change.
+ identity_source->RemoveObserver(this);
+ identity_source->AddObserver(this);
+}
+
+void BlimpSettingsAndroid::OnSignedOut() {
+ Java_AboutBlimpPreferences_onSignedOut(base::android::AttachCurrentThread(),
+ java_obj_);
+}
+
+void BlimpSettingsAndroid::OnSignedIn() {
+ Java_AboutBlimpPreferences_onSignedIn(base::android::AttachCurrentThread(),
+ java_obj_);
+}
+
+void BlimpSettingsAndroid::OnActiveAccountLogout() {
+ 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.
+}
+
+void BlimpSettingsAndroid::OnActiveAccountLogin() {
+ OnSignedIn();
+}
+
+} // namespace client
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698