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

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

Issue 2900173002: Copy and view saved passwords. (Closed)
Patch Set: . Created 3 years, 7 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/PasswordReauthenticationFragment.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordReauthenticationFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordReauthenticationFragment.java
new file mode 100644
index 0000000000000000000000000000000000000000..2723636591900066beebf39c772a86188a61bbbe
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/password/PasswordReauthenticationFragment.java
@@ -0,0 +1,68 @@
+// Copyright 2017 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 org.chromium.chrome.R;
+
+/** Show the lock screen confirmation and lock the screen. */
+public class PasswordReauthenticationFragment extends Fragment {
+ public static final int CONFIRM_DEVICE_CREDENTIAL_REQUEST_CODE = 2;
gone 2017/06/01 20:46:37 does this have to be public? can it just be packa
melandory 2017/06/09 15:09:27 Done.
+
+ private boolean mPreventLockDevice = false;
gone 2017/06/01 20:46:37 booleans are false by default
melandory 2017/06/09 15:09:27 Done.
+
+ private FragmentManager mFragmentManager;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mFragmentManager = getFragmentManager();
+ if (!mPreventLockDevice) {
+ 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();
+ }
+ }
+ }
+
+ /**
+ * Prevent calling the {@link lockDevice} method in {@link onCreate}
gone 2017/06/01 20:46:37 1) {@link #lockDevice} 2) {@link #onCreate} 3) f
melandory 2017/06/09 15:09:27 Done.
+ */
+ public void preventLockingForTesting(boolean preventLockDevice) {
+ mPreventLockDevice = preventLockDevice;
+ }
+
+ /**
+ * Should only be called on Lollipop or above devices.
gone 2017/06/01 20:46:37 1) assert this, too 2) Does this have to be public
melandory 2017/06/09 15:09:27 Done.
+ */
+ @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;
+ }
+ mFragmentManager.popBackStackImmediate();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698