| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/password_ui_view_android.h" | 5 #include "chrome/browser/android/password_ui_view_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/android/jni_weak_ref.h" | 8 #include "base/android/jni_weak_ref.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "components/autofill/core/common/password_form.h" | 13 #include "components/autofill/core/common/password_form.h" |
| 14 #include "components/password_manager/core/common/experiments.h" |
| 14 #include "components/password_manager/core/common/password_manager_switches.h" | 15 #include "components/password_manager/core/common/password_manager_switches.h" |
| 15 #include "jni/PasswordUIView_jni.h" | 16 #include "jni/PasswordUIView_jni.h" |
| 16 | 17 |
| 17 using base::android::ConvertUTF16ToJavaString; | 18 using base::android::ConvertUTF16ToJavaString; |
| 18 using base::android::ConvertUTF8ToJavaString; | 19 using base::android::ConvertUTF8ToJavaString; |
| 19 using base::android::ScopedJavaLocalRef; | 20 using base::android::ScopedJavaLocalRef; |
| 20 | 21 |
| 21 PasswordUIViewAndroid::PasswordUIViewAndroid(JNIEnv* env, jobject obj) | 22 PasswordUIViewAndroid::PasswordUIViewAndroid(JNIEnv* env, jobject obj) |
| 22 : password_manager_presenter_(this), weak_java_ui_controller_(env, obj) {} | 23 : password_manager_presenter_(this), weak_java_ui_controller_(env, obj) {} |
| 23 | 24 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 password_manager_presenter_.RemovePasswordException(index); | 98 password_manager_presenter_.RemovePasswordException(index); |
| 98 } | 99 } |
| 99 | 100 |
| 100 jstring GetAccountDashboardURL(JNIEnv* env, jclass) { | 101 jstring GetAccountDashboardURL(JNIEnv* env, jclass) { |
| 101 return ConvertUTF8ToJavaString( | 102 return ConvertUTF8ToJavaString( |
| 102 env, chrome::kPasswordManagerAccountDashboardURL).Release(); | 103 env, chrome::kPasswordManagerAccountDashboardURL).Release(); |
| 103 } | 104 } |
| 104 | 105 |
| 105 static jboolean ShouldDisplayManageAccountLink( | 106 static jboolean ShouldDisplayManageAccountLink( |
| 106 JNIEnv* env, jclass) { | 107 JNIEnv* env, jclass) { |
| 107 std::string group_name = | 108 return password_manager::ManageAccountLinkExperimentEnabled(); |
| 108 base::FieldTrialList::FindFullName("AndroidPasswordLinkInSettings"); | |
| 109 | |
| 110 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 111 if (command_line->HasSwitch( | |
| 112 password_manager::switches::kDisableAndroidPasswordLink)) { | |
| 113 return false; | |
| 114 } | |
| 115 | |
| 116 if (command_line->HasSwitch( | |
| 117 password_manager::switches::kEnableAndroidPasswordLink)) { | |
| 118 return true; | |
| 119 } | |
| 120 | |
| 121 return group_name == "Enabled"; | |
| 122 } | 109 } |
| 123 | 110 |
| 124 // static | 111 // static |
| 125 static jlong Init(JNIEnv* env, jobject obj) { | 112 static jlong Init(JNIEnv* env, jobject obj) { |
| 126 PasswordUIViewAndroid* controller = new PasswordUIViewAndroid(env, obj); | 113 PasswordUIViewAndroid* controller = new PasswordUIViewAndroid(env, obj); |
| 127 return reinterpret_cast<intptr_t>(controller); | 114 return reinterpret_cast<intptr_t>(controller); |
| 128 } | 115 } |
| 129 | 116 |
| 130 bool PasswordUIViewAndroid::RegisterPasswordUIViewAndroid(JNIEnv* env) { | 117 bool PasswordUIViewAndroid::RegisterPasswordUIViewAndroid(JNIEnv* env) { |
| 131 return RegisterNativesImpl(env); | 118 return RegisterNativesImpl(env); |
| 132 } | 119 } |
| OLD | NEW |