Commit 2be350d5 authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Use GetShownOriginAndLinkUrl in iOS password settings

GetShownOriginAndLinkUrl was recently updated to handle Android credentials correctly, by replacing the android:// URIs with a human-readable Play Store name for display and a Play Store web URL for linking to the app description. Android credentials are credentials stored in Android apps and uploaded to Chrome Sync. They can be used for filling on affiliated websites, so they are important on iOS as well.

The change affects Android credentials as described above, but also web credentials, by changing slightly the presentation of the web origin (e.g., https:// prefix is removed). The new state is consistent with Chrome settings on desktop and soon also on Android.

Screenshots with before and after are at https://crbug.com/628988#c19.

Bug: 628988
Change-Id: Ib0f8219ed0eb652196aaa1717f075a14ee47db3d
Reviewed-on: https://chromium-review.googlesource.com/571227
Commit-Queue: Louis Romero <lpromero@chromium.org>
Reviewed-by: default avatarLouis Romero <lpromero@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487033}
parent fc66d403
......@@ -10,9 +10,9 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/sys_string_conversions.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/android_affiliation/affiliation_utils.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/password_ui_utils.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
......@@ -126,11 +126,11 @@ reauthenticationModule:(id<ReauthenticationProtocol>)reauthenticationModule {
base::SysUTF8ToNSString(_passwordForm.federation_origin.host());
}
}
_site = base::SysUTF8ToNSString(_passwordForm.origin.spec());
auto name_and_link =
password_manager::GetShownOriginAndLinkUrl(_passwordForm);
_site = base::SysUTF8ToNSString(name_and_link.second.spec());
self.title = [PasswordDetailsCollectionViewController
simplifyOrigin:base::SysUTF8ToNSString(
password_manager::GetHumanReadableOrigin(
_passwordForm))];
simplifyOrigin:base::SysUTF8ToNSString(name_and_link.first)];
self.collectionViewAccessibilityIdentifier =
@"PasswordDetailsCollectionViewController";
NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
......
......@@ -258,7 +258,7 @@ TEST_F(PasswordDetailsCollectionViewControllerTest, SimplifyOrigin) {
{GURL("android://"
"Qllt1FacrB0NYCeSFvmudHvssWBPFfC54EbtHTpFxukvw2wClI1rafcVB3kQOMxfJg"
"xbVAkGXvC_A52kbPL1EQ==@com.parkingpanda.mobile/"),
@"com.parkingpanda.mobile"}};
@"mobile.parkingpanda.com"}};
for (const auto& data : test_data) {
origin_ = base::SysUTF8ToNSString(data.origin.spec());
......
......@@ -396,8 +396,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self tapDone];
// Inspect "password details" view.
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
......@@ -419,8 +418,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
MockReauthenticationModule* mock_reauthentication_module =
......@@ -473,8 +471,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
// Check the snackbar.
......@@ -508,8 +505,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
// Check the snackbar.
......@@ -544,8 +540,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
// Tap the Delete... button.
......@@ -575,8 +570,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
nullptr)] assertWithMatcher:grey_notNil()];
// Also verify that the removed password is no longer in the list.
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
assertWithMatcher:grey_not(grey_sufficientlyVisible())];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
......@@ -594,8 +588,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
// Tap the Delete... button.
......@@ -625,8 +618,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
// list.
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
......@@ -647,8 +639,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self tapEdit];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
// Check that the current view is not the detail view, by failing to locate
......@@ -674,7 +665,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey selectElementWithMatcher:Entry(@"https://example.com")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com")]
performAction:grey_tap()];
// Check that the Site section is there as well as the Delete button.
......@@ -712,8 +703,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
// Tap the site cell to display the context menu.
......@@ -755,8 +745,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
// Tap the username cell to display the context menu.
......@@ -799,8 +788,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
// Tap the password cell to display the context menu.
......@@ -850,8 +838,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(@"https://example.com, concrete username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, concrete username")]
performAction:grey_tap()];
// Tap the password cell to display the context menu.
......@@ -923,9 +910,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[self openPasswordSettings];
[[EarlGrey
selectElementWithMatcher:Entry(
@"https://example.com, federated username")]
[[EarlGrey selectElementWithMatcher:Entry(@"example.com, federated username")]
performAction:grey_tap()];
// Check that the Site, Username, Federation and Delete Saved Password
......
......@@ -15,10 +15,10 @@
#include "components/autofill/core/common/password_form.h"
#include "components/google/core/browser/google_util.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/password_manager/core/browser/android_affiliation/affiliation_utils.h"
#include "components/password_manager/core/browser/password_manager_constants.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
#include "components/password_manager/core/browser/password_ui_utils.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
......@@ -260,8 +260,8 @@ void SavePasswordsConsumer::OnGetPasswordStoreResults(
- (SavedFormContentItem*)savedFormItemWithForm:(autofill::PasswordForm*)form {
SavedFormContentItem* passwordItem =
[[SavedFormContentItem alloc] initWithType:ItemTypeSavedPassword];
passwordItem.text =
base::SysUTF8ToNSString(password_manager::GetHumanReadableOrigin(*form));
passwordItem.text = base::SysUTF8ToNSString(
password_manager::GetShownOriginAndLinkUrl(*form).first);
passwordItem.detailText = base::SysUTF16ToNSString(form->username_value);
if (experimental_flags::IsViewCopyPasswordsEnabled()) {
passwordItem.accessibilityTraits |= UIAccessibilityTraitButton;
......@@ -275,8 +275,8 @@ void SavePasswordsConsumer::OnGetPasswordStoreResults(
(autofill::PasswordForm*)form {
BlacklistedFormContentItem* passwordItem =
[[BlacklistedFormContentItem alloc] initWithType:ItemTypeBlacklisted];
passwordItem.text =
base::SysUTF8ToNSString(password_manager::GetHumanReadableOrigin(*form));
passwordItem.text = base::SysUTF8ToNSString(
password_manager::GetShownOriginAndLinkUrl(*form).first);
if (experimental_flags::IsViewCopyPasswordsEnabled()) {
passwordItem.accessibilityTraits |= UIAccessibilityTraitButton;
passwordItem.accessoryType =
......
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