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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordReauthentication.java

Issue 2067323004: Allow copying and viewing account credentials in PasswordEntryEditor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add junit test for reauthentication 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: chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordReauthentication.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordReauthentication.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordReauthentication.java
new file mode 100644
index 0000000000000000000000000000000000000000..f234229abac18f626d020b39dc5ac8f421714eaf
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordReauthentication.java
@@ -0,0 +1,74 @@
+// 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.
+
+package org.chromium.chrome.browser.preferences.password;
+
+import android.annotation.TargetApi;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.KeyguardManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build.VERSION_CODES;
+import android.os.Bundle;
+import android.widget.LinearLayout;
+
+import org.chromium.chrome.R;
+
+/** Show the lock screen confirmation and lock the screen. */
+public class PasswordReauthentication extends Fragment {
Bernhard Bauer 2016/08/16 23:37:35 Maybe call this ...Fragment? (You could shorten "R
dozsa 2016/08/17 10:40:26 Done.
+
+ private static final int CONFIRM_DEVICE_CREDENTIAL_REQUEST_CODE = 2;
+
+ private LinearLayout mLayout;
+
+ private boolean mTesting = false;
+
+ private FragmentManager mFragmentManager;
+
+ public boolean hello;
Bernhard Bauer 2016/08/16 23:37:35 https://boptopop.files.wordpress.com/2011/03/l9kph
dozsa 2016/08/17 10:40:27 hahaha, sorry, used that to test something and for
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ hello = true;
+ mFragmentManager = getFragmentManager();
+ if (!mTesting) {
+ lockDevice();
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == CONFIRM_DEVICE_CREDENTIAL_REQUEST_CODE) {
+ if (resultCode == getActivity().RESULT_OK) {
+ SavePasswordsPreferences.setLastReauthTimeMillis(System.currentTimeMillis());
+ mFragmentManager.popBackStack();
+ }
+ }
+ }
+
+ public void setTesting(boolean testing) {
Bernhard Bauer 2016/08/16 23:37:35 Add a Javadoc comment. It would also make sense to
dozsa 2016/08/17 10:40:27 Done.
+ mTesting = testing;
+ }
+
+ /**
+ * Should only be called on Lollipop or above devices.
+ */
+ @TargetApi(VERSION_CODES.LOLLIPOP)
+ public void lockDevice() {
+ KeyguardManager keyguardManager = (KeyguardManager) getActivity()
+ .getSystemService(Context.KEYGUARD_SERVICE);
+ Intent intent = keyguardManager.createConfirmDeviceCredentialIntent(
+ null /* title */,
+ getString(R.string.lockscreen_description) /* description */);
+ if (intent != null) {
+ startActivityForResult(intent, CONFIRM_DEVICE_CREDENTIAL_REQUEST_CODE);
+ return;
+ }
+ /*FragmentManager fragmentManager = getFragmentManager();*/
Bernhard Bauer 2016/08/16 23:37:35 Remove this comment.
dozsa 2016/08/17 10:40:27 Done.
+ mFragmentManager.popBackStackImmediate();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698