Commit 6c53e238 authored by Ioana Pandele's avatar Ioana Pandele Committed by Commit Bot

Change "Manage passwords" entry points to use the same logic as in Settings

This ensures that the same UI surface that is shown when going to
Settings > Passwords will also be shown when selecting one of the
following:
- The option to "Manage passwords" in the accessory sheet
- The option to "Manage passwords" the autofill dropdown
- A link pointing to where the generated password is
saved, in the GeneratedPasswordSavedInfobar

Bug: 903249
Change-Id: I0c718be6b6b3b6c70a96e860f434f88eebfe8777
Reviewed-on: https://chromium-review.googlesource.com/c/1337333Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Ioana Pandele <ioanap@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609308}
parent c101dcd6
......@@ -18,6 +18,7 @@ public class ManagePasswordsUIProvider {
* @param activity the activity from which to launch the settings page.
*/
public void showManagePasswordsUI(Activity activity) {
if (activity == null) return;
// Launch preference activity with SavePasswordsPreferences fragment.
PreferencesLauncher.launchSettingsPage(activity, SavePasswordsPreferences.class);
}
......
......@@ -11,13 +11,13 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.preferences.autofill.AutofillPaymentMethodsFragment;
import org.chromium.chrome.browser.preferences.autofill.AutofillProfilesFragment;
import org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences;
import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.WindowAndroid;
import java.lang.ref.WeakReference;
......@@ -100,8 +100,12 @@ public class PreferencesLauncher {
}
@CalledByNative
private static void showPasswordSettings() {
launchSettingsPage(ContextUtils.getApplicationContext(), SavePasswordsPreferences.class);
private static void showPasswordSettings(WebContents webContents) {
WindowAndroid window = webContents.getTopLevelNativeWindow();
if (window == null) return;
WeakReference<Activity> currentActivity = window.getActivity();
AppHooks.get().createManagePasswordsUIProvider().showManagePasswordsUI(
currentActivity.get());
}
private static void showSettingSubpage(
......
......@@ -24,9 +24,10 @@ void PreferencesLauncher::ShowAutofillCreditCardSettings(
base::android::AttachCurrentThread(), web_contents->GetJavaWebContents());
}
void PreferencesLauncher::ShowPasswordSettings() {
void PreferencesLauncher::ShowPasswordSettings(
content::WebContents* web_contents) {
Java_PreferencesLauncher_showPasswordSettings(
base::android::AttachCurrentThread());
base::android::AttachCurrentThread(), web_contents->GetJavaWebContents());
}
} // namespace android
......
......@@ -24,7 +24,7 @@ class PreferencesLauncher {
content::WebContents* web_contents);
// Opens the password settings page.
static void ShowPasswordSettings();
static void ShowPasswordSettings(content::WebContents* web_contents);
private:
PreferencesLauncher() {}
......
......@@ -8,6 +8,8 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/android/android_theme_resources.h"
#include "chrome/browser/android/preferences/preferences_launcher.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/grit/generated_resources.h"
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobar_manager.h"
......@@ -21,9 +23,8 @@ GeneratedPasswordSavedInfoBarDelegateAndroid::
~GeneratedPasswordSavedInfoBarDelegateAndroid() {}
void GeneratedPasswordSavedInfoBarDelegateAndroid::OnInlineLinkClicked() {
GURL dashboard_link(l10n_util::GetStringUTF16(IDS_PASSWORDS_WEB_LINK));
infobar()->owner()->OpenURL(dashboard_link,
WindowOpenDisposition::NEW_FOREGROUND_TAB);
chrome::android::PreferencesLauncher::ShowPasswordSettings(
InfoBarService::WebContentsFromInfoBar(infobar()));
}
GeneratedPasswordSavedInfoBarDelegateAndroid::
......
......@@ -279,7 +279,7 @@ void PasswordAccessoryController::OnOptionSelected(
UMA_HISTOGRAM_ENUMERATION("KeyboardAccessory.AccessoryActionSelected",
metrics::AccessoryAction::MANAGE_PASSWORDS,
metrics::AccessoryAction::COUNT);
chrome::android::PreferencesLauncher::ShowPasswordSettings();
chrome::android::PreferencesLauncher::ShowPasswordSettings(web_contents_);
}
}
......
......@@ -530,7 +530,7 @@ void ChromeAutofillClient::ExecuteCommand(int id) {
chrome::FindBrowserWithWebContents(web_contents()),
chrome::kPasswordManagerSubPage);
#else
chrome::android::PreferencesLauncher::ShowPasswordSettings();
chrome::android::PreferencesLauncher::ShowPasswordSettings(web_contents());
#endif
} else if (id == autofill::POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO) {
#if defined(OS_ANDROID)
......
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