Commit 0073a6f1 authored by tedchoc's avatar tedchoc Committed by Commit bot

Revert of Redirect users without sync passphrase to passwords.google.com...

Revert of Redirect users without sync passphrase to passwords.google.com (patchset #50 id:980001 of https://codereview.chromium.org/2092723002/ )

Reason for revert:
The tests are checking their expectations on the wrong thread.

https://uberchromegw.corp.google.com/i/chromium.linux/builders/Android%20Tests%20%28dbg%29/builds/35372/steps/chrome_public_test_apk/logs/stdio

I  703.521s run_tests_on_device(0ca41989032f9f23)    java.lang.AssertionError
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at org.chromium.base.ThreadUtils.assertOnUiThread(ThreadUtils.java:192)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at org.chromium.chrome.browser.sync.ProfileSyncService.get(ProfileSyncService.java:104)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at org.chromium.chrome.browser.preferences.PasswordViewingTypeTest.testUserRedirectSyncSettings(PasswordViewingTypeTest.java:133)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at java.lang.reflect.Method.invokeNative(Native Method)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at org.chromium.base.test.BaseTestResult.run(BaseTestResult.java:129)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
I  703.521s run_tests_on_device(0ca41989032f9f23)    	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)

Original issue's description:
> Redirect syncing users without sync passphrase to passwords.google.com
>
> This CL redirects syncing users without a sync passphrase to https://passwords.google.com instead of natively displaying passwords. The changes created in this CL are hidden behind the ViewPasswords feature.
>
> BUG=623488
>
> Committed: https://crrev.com/13085d446efc3b8cd2c26338738c04a7516953a8
> Cr-Commit-Position: refs/heads/master@{#406823}

TBR=vabr@chromium.org,bauerb@chromium.org,dozsa@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=623488

Review-Url: https://codereview.chromium.org/2165333002
Cr-Commit-Position: refs/heads/master@{#406885}
parent a39093e4
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
android:key="autofill_settings" android:key="autofill_settings"
android:title="@string/prefs_autofill" /> android:title="@string/prefs_autofill" />
<org.chromium.chrome.browser.preferences.ChromeBasePreference <org.chromium.chrome.browser.preferences.ChromeBasePreference
android:key="saved_passwords"/> android:fragment="org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences"
android:key="saved_passwords"
android:title="@string/prefs_saved_passwords" />
<Preference <Preference
android:fragment="org.chromium.chrome.browser.preferences.HomepagePreferences" android:fragment="org.chromium.chrome.browser.preferences.HomepagePreferences"
android:key="homepage" android:key="homepage"
......
...@@ -4,32 +4,24 @@ ...@@ -4,32 +4,24 @@
package org.chromium.chrome.browser.preferences; package org.chromium.chrome.browser.preferences;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.PasswordUIView; import org.chromium.chrome.browser.PasswordUIView;
import org.chromium.chrome.browser.autofill.PersonalDataManager; import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
import org.chromium.chrome.browser.partnercustomizations.HomepageManager; import org.chromium.chrome.browser.partnercustomizations.HomepageManager;
import org.chromium.chrome.browser.preferences.datareduction.DataReductionPreferences; import org.chromium.chrome.browser.preferences.datareduction.DataReductionPreferences;
import org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences;
import org.chromium.chrome.browser.signin.SigninManager; import org.chromium.chrome.browser.signin.SigninManager;
import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver;
import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.sync.AndroidSyncSettings;
/** /**
* The main settings screen, shown when the user first opens Settings. * The main settings screen, shown when the user first opens Settings.
*/ */
public class MainPreferences extends PreferenceFragment implements SignInStateObserver, public class MainPreferences extends PreferenceFragment implements SignInStateObserver {
Preference.OnPreferenceClickListener {
public static final String PREF_SIGN_IN = "sign_in"; public static final String PREF_SIGN_IN = "sign_in";
public static final String PREF_SEARCH_ENGINE = "search_engine"; public static final String PREF_SEARCH_ENGINE = "search_engine";
...@@ -42,11 +34,6 @@ public class MainPreferences extends PreferenceFragment implements SignInStateOb ...@@ -42,11 +34,6 @@ public class MainPreferences extends PreferenceFragment implements SignInStateOb
public static final String ACCOUNT_PICKER_DIALOG_TAG = "account_picker_dialog_tag"; public static final String ACCOUNT_PICKER_DIALOG_TAG = "account_picker_dialog_tag";
public static final String EXTRA_SHOW_SEARCH_ENGINE_PICKER = "show_search_engine_picker"; public static final String EXTRA_SHOW_SEARCH_ENGINE_PICKER = "show_search_engine_picker";
public static final String PREF_MANAGE_ACCOUNT_LINK = "manage_account_link";
@VisibleForTesting
public static final String VIEW_PASSWORDS = "view-passwords";
private SignInPreference mSignInPreference; private SignInPreference mSignInPreference;
private ManagedPreferenceDelegate mManagedPreferenceDelegate; private ManagedPreferenceDelegate mManagedPreferenceDelegate;
...@@ -90,16 +77,6 @@ public class MainPreferences extends PreferenceFragment implements SignInStateOb ...@@ -90,16 +77,6 @@ public class MainPreferences extends PreferenceFragment implements SignInStateOb
clearSignInPref(); clearSignInPref();
} }
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse(PasswordUIView.getAccountDashboardURL()));
intent.setPackage(getActivity().getPackageName());
getActivity().startActivity(intent);
return true;
}
private void updatePreferences() { private void updatePreferences() {
if (getPreferenceScreen() != null) getPreferenceScreen().removeAll(); if (getPreferenceScreen() != null) getPreferenceScreen().removeAll();
addPreferencesFromResource(R.xml.main_preferences); addPreferencesFromResource(R.xml.main_preferences);
...@@ -111,31 +88,13 @@ public class MainPreferences extends PreferenceFragment implements SignInStateOb ...@@ -111,31 +88,13 @@ public class MainPreferences extends PreferenceFragment implements SignInStateOb
ChromeBasePreference passwordsPref = ChromeBasePreference passwordsPref =
(ChromeBasePreference) findPreference(PREF_SAVED_PASSWORDS); (ChromeBasePreference) findPreference(PREF_SAVED_PASSWORDS);
if (PasswordUIView.shouldUseSmartLockBranding()) {
ProfileSyncService syncService = ProfileSyncService.get(); passwordsPref.setTitle(getResources().getString(
R.string.prefs_smart_lock_for_passwords));
if (AndroidSyncSettings.isSyncEnabled(getActivity().getApplicationContext())
&& syncService.isBackendInitialized()
&& !syncService.isUsingSecondaryPassphrase()
&& ChromeFeatureList.isEnabled(VIEW_PASSWORDS)) {
passwordsPref.setKey(PREF_MANAGE_ACCOUNT_LINK);
passwordsPref.setTitle(R.string.redirect_to_passwords_text);
passwordsPref.setSummary(R.string.redirect_to_passwords_link);
passwordsPref.setOnPreferenceClickListener(this);
passwordsPref.setManagedPreferenceDelegate(null);
} else {
if (PasswordUIView.shouldUseSmartLockBranding()) {
passwordsPref.setTitle(getResources().getString(
R.string.prefs_smart_lock_for_passwords));
} else {
passwordsPref.setTitle(getResources().getString(
R.string.prefs_saved_passwords));
}
passwordsPref.setFragment(SavePasswordsPreferences.class.getCanonicalName());
setOnOffSummary(passwordsPref,
PrefServiceBridge.getInstance().isRememberPasswordsEnabled());
passwordsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
} }
setOnOffSummary(passwordsPref,
PrefServiceBridge.getInstance().isRememberPasswordsEnabled());
passwordsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
Preference homepagePref = findPreference(PREF_HOMEPAGE); Preference homepagePref = findPreference(PREF_HOMEPAGE);
if (HomepageManager.shouldShowHomepageSetting()) { if (HomepageManager.shouldShowHomepageSetting()) {
......
...@@ -333,12 +333,6 @@ CHAR-LIMIT guidelines: ...@@ -333,12 +333,6 @@ CHAR-LIMIT guidelines:
<message name="IDS_MANAGE_PASSWORDS_TEXT" desc="Text for link to manage passwords on Account Central."> <message name="IDS_MANAGE_PASSWORDS_TEXT" desc="Text for link to manage passwords on Account Central.">
View and manage saved passwords at <ph name="BEGIN_LINK">&lt;link&gt;</ph>passwords.google.com<ph name="END_LINK">&lt;/link&gt;</ph> View and manage saved passwords at <ph name="BEGIN_LINK">&lt;link&gt;</ph>passwords.google.com<ph name="END_LINK">&lt;/link&gt;</ph>
</message> </message>
<message name="IDS_REDIRECT_TO_PASSWORDS_TEXT" desc="Title of password settings entry in main Chrome preferences for users who will be redirected to passwords.google.com to manage their passwords.">
Saved passwords
</message>
<message name="IDS_REDIRECT_TO_PASSWORDS_LINK" desc="Hostname of the site where users will go if they tap the passwords settings in main Chrome preferences.">
passwords.google.com
</message>
<message name="IDS_SAVED_PASSWORDS_NONE_TEXT" desc="Text when there are no saved passwords/exceptions."> <message name="IDS_SAVED_PASSWORDS_NONE_TEXT" desc="Text when there are no saved passwords/exceptions.">
Saved passwords will appear here. Saved passwords will appear here.
</message> </message>
......
...@@ -1199,7 +1199,6 @@ chrome_test_java_sources = [ ...@@ -1199,7 +1199,6 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/precache/PrecacheLauncherTest.java", "javatests/src/org/chromium/chrome/browser/precache/PrecacheLauncherTest.java",
"javatests/src/org/chromium/chrome/browser/precache/PrecacheControllerTest.java", "javatests/src/org/chromium/chrome/browser/precache/PrecacheControllerTest.java",
"javatests/src/org/chromium/chrome/browser/precache/PrecacheUMATest.java", "javatests/src/org/chromium/chrome/browser/precache/PrecacheUMATest.java",
"javatests/src/org/chromium/chrome/browser/preferences/PasswordViewingTypeTest.java",
"javatests/src/org/chromium/chrome/browser/preferences/PreferencesTest.java", "javatests/src/org/chromium/chrome/browser/preferences/PreferencesTest.java",
"javatests/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtilsTest.java", "javatests/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtilsTest.java",
"javatests/src/org/chromium/chrome/browser/preferences/password/SavePasswordsPreferencesTest.java", "javatests/src/org/chromium/chrome/browser/preferences/password/SavePasswordsPreferencesTest.java",
......
// 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;
import android.accounts.Account;
import android.app.Activity;
import android.app.Instrumentation;
import android.content.Context;
import android.content.Intent;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences;
import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.content.browser.test.NativeLibraryTestBase;
import org.chromium.sync.AndroidSyncSettings;
import org.chromium.sync.signin.AccountManagerHelper;
import org.chromium.sync.test.util.AccountHolder;
import org.chromium.sync.test.util.MockAccountManager;
import org.chromium.sync.test.util.MockSyncContentResolverDelegate;
/**
* Tests for verifying whether users are presented with the correct option of viewing
* passwords according to the user group they belong to (syncing with sync passphrase,
* syncing without sync passsphrase, non-syncing).
*/
public class PasswordViewingTypeTest extends NativeLibraryTestBase {
private MainPreferences mMainPreferences;
private ChromeBasePreference mPasswordsPref;
private static final String DEFAULT_ACCOUNT = "test@gmail.com";
private Context mContext;
private MockSyncContentResolverDelegate mSyncContentResolverDelegate;
private String mAuthority;
private Account mAccount;
private MockAccountManager mAccountManager;
@Override
protected void setUp() throws Exception {
mSyncContentResolverDelegate = new MockSyncContentResolverDelegate();
mContext = getInstrumentation().getTargetContext();
mMainPreferences = (MainPreferences) startMainPreferences(getInstrumentation(),
mContext).getFragmentForTest();
mPasswordsPref = (ChromeBasePreference) mMainPreferences.findPreference(
MainPreferences.PREF_SAVED_PASSWORDS);
setupTestAccount(mContext);
AndroidSyncSettings.overrideForTests(mContext, mSyncContentResolverDelegate);
mAuthority = AndroidSyncSettings.getContractAuthority(mContext);
AndroidSyncSettings.updateAccount(mContext, mAccount);
super.setUp();
loadNativeLibraryAndInitBrowserProcess();
}
private void setupTestAccount(Context context) {
mAccountManager = new MockAccountManager(context, context);
AccountManagerHelper.overrideAccountManagerHelperForTests(context, mAccountManager);
mAccount = AccountManagerHelper.createAccountFromName("account@example.com");
AccountHolder.Builder accountHolder =
AccountHolder.create().account(mAccount).password("password").alwaysAccept(true);
mAccountManager.addAccountHolderExplicitly(accountHolder.build());
}
/**
* Launches the main preferences.
*/
private static Preferences startMainPreferences(Instrumentation instrumentation,
final Context mContext) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage(mContext,
MainPreferences.class.getName());
Activity activity = (Preferences) instrumentation.startActivitySync(intent);
return (Preferences) activity;
}
/**
* Override ProfileSyncService using FakeProfileSyncService.
*/
private void overrideProfileSyncService(final boolean usingPassphrase) {
class FakeProfileSyncService extends ProfileSyncService {
@Override
public boolean isUsingSecondaryPassphrase() {
return usingPassphrase;
}
@Override
public boolean isBackendInitialized() {
return true;
}
}
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
ProfileSyncService.overrideForTests(new FakeProfileSyncService());
}
});
}
/**
* Turn syncability on/off.
*/
private void setSyncability(boolean syncState) throws InterruptedException {
// Turn on syncability
mSyncContentResolverDelegate.setMasterSyncAutomatically(syncState);
mSyncContentResolverDelegate.waitForLastNotificationCompleted();
// First sync
mSyncContentResolverDelegate.setIsSyncable(mAccount, mAuthority, (syncState) ? 1 : 0);
mSyncContentResolverDelegate.waitForLastNotificationCompleted();
if (syncState) {
mSyncContentResolverDelegate.setSyncAutomatically(mAccount, mAuthority, syncState);
mSyncContentResolverDelegate.waitForLastNotificationCompleted();
}
}
/**
* Verifies that sync settings are being set up correctly in the case of redirecting users.
*/
@SmallTest
@CommandLineFlags.Add("enable-features=" + MainPreferences.VIEW_PASSWORDS)
@Feature({"Sync"})
public void testUserRedirectSyncSettings() throws InterruptedException {
setSyncability(true);
overrideProfileSyncService(false);
assertTrue(AndroidSyncSettings.isSyncEnabled(mContext));
assertTrue(ProfileSyncService.get().isBackendInitialized());
assertFalse(ProfileSyncService.get().isUsingSecondaryPassphrase());
}
/**
* Verifies that syncing users with a custom passphrase are allowed to
* natively view passwords.
*/
@SmallTest
public void testSyncingNativePasswordView() throws InterruptedException {
setSyncability(true);
overrideProfileSyncService(true);
assertEquals(SavePasswordsPreferences.class.getCanonicalName(),
mPasswordsPref.getFragment());
assertNotNull(mMainPreferences.getActivity().getIntent());
}
/**
* Verifies that non-syncing users are allowed to natively view passwords.
*/
@SmallTest
public void testNonSyncingNativePasswordView() throws InterruptedException {
setSyncability(false);
assertEquals(SavePasswordsPreferences.class.getCanonicalName(),
mPasswordsPref.getFragment());
}
}
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "components/offline_pages/offline_page_feature.h" #include "components/offline_pages/offline_page_feature.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "content/public/common/content_features.h" #include "content/public/common/content_features.h"
#include "jni/ChromeFeatureList_jni.h" #include "jni/ChromeFeatureList_jni.h"
...@@ -47,7 +46,6 @@ const base::Feature* kFeaturesExposedToJava[] = { ...@@ -47,7 +46,6 @@ const base::Feature* kFeaturesExposedToJava[] = {
&kTabReparenting, &kTabReparenting,
&offline_pages::kOfflinePagesBackgroundLoadingFeature, &offline_pages::kOfflinePagesBackgroundLoadingFeature,
&offline_pages::kOfflinePagesCTFeature, // See crbug.com/620421. &offline_pages::kOfflinePagesCTFeature, // See crbug.com/620421.
&password_manager::features::kViewPasswords,
}; };
} // namespace } // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment