From 0f1f7085c555779e37accaaf47ab6cd4427bcc5b Mon Sep 17 00:00:00 2001 From: "gcasto@chromium.org" Date: Sat, 9 Aug 2014 05:56:01 +0000 Subject: [PATCH] [Password Manager] Add accessor for account dashboard URL to Android. Also include a field trial and flags to enable/disable showing this link. BUG=398617 Review URL: https://codereview.chromium.org/447153002 Cr-Commit-Position: refs/heads/master@{#288520} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288520 0039d316-1c4b-4281-b951-d872f2087c98 --- .../chromium/chrome/browser/PasswordUIView.java | 12 ++++++++++ chrome/app/generated_resources.grd | 6 +++++ chrome/browser/about_flags.cc | 9 +++++++ chrome/browser/android/password_ui_view_android.cc | 28 ++++++++++++++++++++++ .../core/common/password_manager_switches.cc | 8 +++++++ .../core/common/password_manager_switches.h | 2 ++ 6 files changed, 65 insertions(+) diff --git a/chrome/android/java/src/org/chromium/chrome/browser/PasswordUIView.java b/chrome/android/java/src/org/chromium/chrome/browser/PasswordUIView.java index 7fbc0784ae7e..c1eb3f0b3821 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/PasswordUIView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/PasswordUIView.java @@ -138,6 +138,14 @@ public final class PasswordUIView { nativeHandleRemoveSavedPasswordException(mNativePasswordUIViewAndroid, index); } + public static String getAccountDashboardURL() { + return nativeGetAccountDashboardURL(); + } + + public static boolean shouldDisplayManageAccountLink() { + return nativeShouldDisplayManageAccountLink(); + } + /** * Destroy the native object. */ @@ -168,6 +176,10 @@ public final class PasswordUIView { long nativePasswordUIViewAndroid, int index); + private static native String nativeGetAccountDashboardURL(); + + private static native boolean nativeShouldDisplayManageAccountLink(); + private native void nativeDestroy(long nativePasswordUIViewAndroid); } diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 1ea12558a686..972b475ced43 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6219,6 +6219,12 @@ Keep your key file in a safe place. You will need it to create new versions of y Disable prompting the user for their OS password before revealing passwords on the passwords page. + + Enable remote password management link + + + Show a link in the password manager settings page to manage your synced passwords online. + Enable performance monitoring diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 56e9503f5bff..39f0c0555de9 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1111,6 +1111,15 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(switches::kDisablePasswordManagerReauthentication) }, { + "enable-android-password-link", + IDS_FLAGS_PASSWORD_MANAGER_ANDROID_LINK_NAME, + IDS_FLAGS_PASSWORD_MANAGER_ANDROID_LINK_DESCRIPTION, + kOsAndroid, + ENABLE_DISABLE_VALUE_TYPE( + password_manager::switches::kEnableAndroidPasswordLink, + password_manager::switches::kDisableAndroidPasswordLink) + }, + { "enable-deferred-image-decoding", IDS_FLAGS_ENABLE_DEFERRED_IMAGE_DECODING_NAME, IDS_FLAGS_ENABLE_DEFERRED_IMAGE_DECODING_DESCRIPTION, diff --git a/chrome/browser/android/password_ui_view_android.cc b/chrome/browser/android/password_ui_view_android.cc index e26c552d5949..bb3cb5efc894 100644 --- a/chrome/browser/android/password_ui_view_android.cc +++ b/chrome/browser/android/password_ui_view_android.cc @@ -6,8 +6,12 @@ #include "base/android/jni_string.h" #include "base/android/jni_weak_ref.h" +#include "base/command_line.h" +#include "base/metrics/field_trial.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/common/url_constants.h" #include "components/autofill/core/common/password_form.h" +#include "components/password_manager/core/common/password_manager_switches.h" #include "jni/PasswordUIView_jni.h" using base::android::ConvertUTF16ToJavaString; @@ -93,6 +97,30 @@ void PasswordUIViewAndroid::HandleRemoveSavedPasswordException( password_manager_presenter_.RemovePasswordException(index); } +jstring GetAccountDashboardURL(JNIEnv* env, jclass) { + return ConvertUTF8ToJavaString( + env, chrome::kPasswordManagerAccountDashboardURL).Release(); +} + +static jboolean ShouldDisplayManageAccountLink( + JNIEnv* env, jclass) { + std::string group_name = + base::FieldTrialList::FindFullName("AndroidPasswordLinkInSettings"); + + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch( + password_manager::switches::kDisableAndroidPasswordLink)) { + return false; + } + + if (command_line->HasSwitch( + password_manager::switches::kEnableAndroidPasswordLink)) { + return true; + } + + return group_name == "Enabled"; +} + // static static jlong Init(JNIEnv* env, jobject obj) { PasswordUIViewAndroid* controller = new PasswordUIViewAndroid(env, obj); diff --git a/components/password_manager/core/common/password_manager_switches.cc b/components/password_manager/core/common/password_manager_switches.cc index 25d75f01e210..8ceab0f288f2 100644 --- a/components/password_manager/core/common/password_manager_switches.cc +++ b/components/password_manager/core/common/password_manager_switches.cc @@ -8,6 +8,10 @@ namespace password_manager { namespace switches { +// Disable the link in the password manager settings page that points to account +// central. +const char kDisableAndroidPasswordLink[] = "disable-android-password-link"; + // Disable dropping the credential used to sync passwords. const char kDisableDropSyncCredential[] = "disable-drop-sync-credential"; @@ -16,6 +20,10 @@ const char kDisableDropSyncCredential[] = const char kDisableManagerForSyncSignin[] = "disable-manager-for-sync-signin"; +// Enable the link in the password manager settings page that points to account +// central. +const char kEnableAndroidPasswordLink[] = "enable-android-password-link"; + // Enable dropping the credential used to sync passwords. const char kEnableDropSyncCredential[] = "enable-drop-sync-credential"; diff --git a/components/password_manager/core/common/password_manager_switches.h b/components/password_manager/core/common/password_manager_switches.h index 2520601c771c..995c5cc2a363 100644 --- a/components/password_manager/core/common/password_manager_switches.h +++ b/components/password_manager/core/common/password_manager_switches.h @@ -12,8 +12,10 @@ namespace switches { // All switches in alphabetical order. The switches should be documented // alongside the definition of their values in the .cc file. +extern const char kDisableAndroidPasswordLink[]; extern const char kDisableDropSyncCredential[]; extern const char kDisableManagerForSyncSignin[]; +extern const char kEnableAndroidPasswordLink[]; extern const char kEnableDropSyncCredential[]; extern const char kEnableManagerForSyncSignin[]; extern const char kEnableAutomaticPasswordSaving[]; -- 2.11.4.GIT