[ios] Add access to management page to settings UI info bubble
When the settings are managed by enterprise policy, a "learn more" link
should be shown in the popup bubble triggered by the information icon
by the end of the settings item. Clicking "Learn More" will navigate to
chrome://management page.
Added access to settings below:
- Settings -> Password -> Save password
- Settings -> Payment Method -> Save and Fill Payment Methods
- Settings -> Address and More -> Save and Fill Addresses
- Settings -> Search Engine
- Settings -> Content Settings -> Block Pop-ups
Bug: 1109002
Change-Id: I4bdba99c1a4d2451a99ddeb8f048af77a2aaa334
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337719
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Reviewed-by: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#795470}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: cdcb232bbf8e2576f84382ab42039783a568bea6
diff --git a/chrome/browser/ui/settings/autofill/autofill_credit_card_table_view_controller.mm b/chrome/browser/ui/settings/autofill/autofill_credit_card_table_view_controller.mm
index a1f6714..db12651 100644
--- a/chrome/browser/ui/settings/autofill/autofill_credit_card_table_view_controller.mm
+++ b/chrome/browser/ui/settings/autofill/autofill_credit_card_table_view_controller.mm
@@ -35,6 +35,7 @@
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#include "ios/chrome/grit/ios_strings.h"
+#import "net/base/mac/url_conversions.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@@ -61,7 +62,8 @@
#pragma mark - AutofillCreditCardTableViewController
@interface AutofillCreditCardTableViewController () <
- PersonalDataManagerObserver> {
+ PersonalDataManagerObserver,
+ PopoverLabelViewControllerDelegate> {
autofill::PersonalDataManager* _personalDataManager;
Browser* _browser;
@@ -292,6 +294,7 @@
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
+ bubbleViewController.delegate = self;
[self presentViewController:bubbleViewController animated:YES completion:nil];
// Disable the button when showing the bubble.
@@ -574,4 +577,11 @@
[self setToolbarItems:customToolbarItems animated:YES];
}
+#pragma mark - PopoverLabelViewControllerDelegate
+
+- (void)didTapLinkURL:(NSURL*)URL {
+ GURL convertedURL = net::GURLWithNSURL(URL);
+ [self view:nil didTapLinkURL:convertedURL];
+}
+
@end
diff --git a/chrome/browser/ui/settings/autofill/autofill_profile_table_view_controller.mm b/chrome/browser/ui/settings/autofill/autofill_profile_table_view_controller.mm
index d6240a2..a848ba5 100644
--- a/chrome/browser/ui/settings/autofill/autofill_profile_table_view_controller.mm
+++ b/chrome/browser/ui/settings/autofill/autofill_profile_table_view_controller.mm
@@ -34,6 +34,7 @@
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#include "ios/chrome/grit/ios_strings.h"
+#import "net/base/mac/url_conversions.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@@ -59,7 +60,9 @@
#pragma mark - AutofillProfileTableViewController
-@interface AutofillProfileTableViewController () <PersonalDataManagerObserver> {
+@interface AutofillProfileTableViewController () <
+ PersonalDataManagerObserver,
+ PopoverLabelViewControllerDelegate> {
autofill::PersonalDataManager* _personalDataManager;
ChromeBrowserState* _browserState;
@@ -303,6 +306,7 @@
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
+ bubbleViewController.delegate = self;
[self presentViewController:bubbleViewController animated:YES completion:nil];
// Disable the button when showing the bubble.
@@ -498,4 +502,11 @@
}
}
+#pragma mark - PopoverLabelViewControllerDelegate
+
+- (void)didTapLinkURL:(NSURL*)URL {
+ GURL convertedURL = net::GURLWithNSURL(URL);
+ [self view:nil didTapLinkURL:convertedURL];
+}
+
@end
diff --git a/chrome/browser/ui/settings/block_popups_table_view_controller.mm b/chrome/browser/ui/settings/block_popups_table_view_controller.mm
index 5022f2d..97fa171 100644
--- a/chrome/browser/ui/settings/block_popups_table_view_controller.mm
+++ b/chrome/browser/ui/settings/block_popups_table_view_controller.mm
@@ -27,6 +27,7 @@
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_header_footer_item.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#include "ios/chrome/grit/ios_strings.h"
+#import "net/base/mac/url_conversions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -50,7 +51,9 @@
} // namespace
-@interface BlockPopupsTableViewController ()<BooleanObserver> {
+@interface BlockPopupsTableViewController () <
+ BooleanObserver,
+ PopoverLabelViewControllerDelegate> {
ChromeBrowserState* _browserState; // weak
// List of url patterns that are allowed to display popups.
@@ -257,6 +260,7 @@
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
+ bubbleViewController.delegate = self;
[self presentViewController:bubbleViewController animated:YES completion:nil];
// Disable the button when showing the bubble.
@@ -405,4 +409,11 @@
}
}
+#pragma mark - PopoverLabelViewControllerDelegate
+
+- (void)didTapLinkURL:(NSURL*)URL {
+ GURL convertedURL = net::GURLWithNSURL(URL);
+ [self view:nil didTapLinkURL:convertedURL];
+}
+
@end
diff --git a/chrome/browser/ui/settings/content_settings_table_view_controller.mm b/chrome/browser/ui/settings/content_settings_table_view_controller.mm
index 7dcfc38..4184664 100644
--- a/chrome/browser/ui/settings/content_settings_table_view_controller.mm
+++ b/chrome/browser/ui/settings/content_settings_table_view_controller.mm
@@ -228,8 +228,10 @@
NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:indexPath];
switch (itemType) {
case ItemTypeSettingsBlockPopups: {
- UIViewController* controller = [[BlockPopupsTableViewController alloc]
- initWithBrowserState:_browserState];
+ BlockPopupsTableViewController* controller =
+ [[BlockPopupsTableViewController alloc]
+ initWithBrowserState:_browserState];
+ controller.dispatcher = self.dispatcher;
[self.navigationController pushViewController:controller animated:YES];
break;
}
diff --git a/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.mm b/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.mm
index bd9480f..d25630b 100644
--- a/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.mm
+++ b/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.mm
@@ -21,6 +21,8 @@
NSString* const kEnterpriseIconName = @"enterprise_icon";
+NSString* const kChromeManagementURL = @"chrome://management";
+
NSAttributedString* PrimaryMessage() {
NSString* fullText =
l10n_util::GetNSString(IDS_IOS_ENTERPRISE_MANAGED_SETTING_MESSAGE);
@@ -47,6 +49,9 @@
// Add a space to have a distanse with the leading icon.
NSString* fullText = [@" " stringByAppendingString:message];
+ NSRange range;
+ fullText = ParseStringWithLink(fullText, &range);
+
NSDictionary* generalAttributes = @{
NSForegroundColorAttributeName : [UIColor colorNamed:kTextSecondaryColor],
NSFontAttributeName :
@@ -56,8 +61,13 @@
[[NSMutableAttributedString alloc] initWithString:fullText
attributes:generalAttributes];
- // TODO(crbug.com/1092544): add "Learn more" link when the link page is
- // ready.
+ NSDictionary* linkAttributes = @{
+ NSForegroundColorAttributeName : [UIColor colorNamed:kBlueColor],
+ NSFontAttributeName :
+ [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote],
+ NSLinkAttributeName : kChromeManagementURL,
+ };
+ [attributedString setAttributes:linkAttributes range:range];
// Create the leading enterprise icon.
NSTextAttachment* attachment = [[NSTextAttachment alloc] init];
diff --git a/chrome/browser/ui/settings/password/passwords_table_view_controller.mm b/chrome/browser/ui/settings/password/passwords_table_view_controller.mm
index 5900752..38351a4 100644
--- a/chrome/browser/ui/settings/password/passwords_table_view_controller.mm
+++ b/chrome/browser/ui/settings/password/passwords_table_view_controller.mm
@@ -676,6 +676,7 @@
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
+ bubbleViewController.delegate = self;
[self presentViewController:bubbleViewController animated:YES completion:nil];
// Disable the button when showing the bubble.
diff --git a/chrome/browser/ui/settings/settings_table_view_controller.mm b/chrome/browser/ui/settings/settings_table_view_controller.mm
index c196a5b..0a99154 100644
--- a/chrome/browser/ui/settings/settings_table_view_controller.mm
+++ b/chrome/browser/ui/settings/settings_table_view_controller.mm
@@ -87,6 +87,7 @@
#import "ios/public/provider/chrome/browser/signin/signin_presenter.h"
#import "ios/public/provider/chrome/browser/signin/signin_resources_provider.h"
#include "ios/public/provider/chrome/browser/voice/voice_search_prefs.h"
+#import "net/base/mac/url_conversions.h"
#include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@@ -167,6 +168,7 @@
ChromeIdentityServiceObserver,
GoogleServicesSettingsCoordinatorDelegate,
IdentityManagerObserverBridgeDelegate,
+ PopoverLabelViewControllerDelegate,
PrefObserverDelegate,
PrivacyCoordinatorDelegate,
SafetyCheckCoordinatorDelegate,
@@ -965,6 +967,7 @@
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
+ bubbleViewController.delegate = self;
// Disable the button when showing the bubble.
// The button will be enabled when close the bubble in
@@ -1475,4 +1478,11 @@
base::RecordAction(base::UserMetricsAction("IOSSettingsCloseWithSwipe"));
}
+#pragma mark - PopoverLabelViewControllerDelegate
+
+- (void)didTapLinkURL:(NSURL*)URL {
+ GURL convertedURL = net::GURLWithNSURL(URL);
+ [self view:nil didTapLinkURL:convertedURL];
+}
+
@end
diff --git a/chrome/common/ui/elements/popover_label_view_controller.mm b/chrome/common/ui/elements/popover_label_view_controller.mm
index 4a75721..1fad0a5 100644
--- a/chrome/common/ui/elements/popover_label_view_controller.mm
+++ b/chrome/common/ui/elements/popover_label_view_controller.mm
@@ -115,18 +115,24 @@
[_scrollView addSubview:textView];
- UILabel* secondaryLabel = [[UILabel alloc] init];
- secondaryLabel.numberOfLines = 0;
- secondaryLabel.textColor = [UIColor colorNamed:kTextSecondaryColor];
- secondaryLabel.textAlignment = NSTextAlignmentNatural;
- secondaryLabel.adjustsFontForContentSizeCategory = YES;
- if (self.secondaryAttributedString) {
- secondaryLabel.attributedText = self.secondaryAttributedString;
- }
- secondaryLabel.translatesAutoresizingMaskIntoConstraints = NO;
- secondaryLabel.font =
+ UITextView* secondaryTextView = [[UITextView alloc] init];
+ secondaryTextView.scrollEnabled = NO;
+ secondaryTextView.editable = NO;
+ secondaryTextView.delegate = self;
+ secondaryTextView.backgroundColor = [UIColor clearColor];
+ secondaryTextView.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
- [_scrollView addSubview:secondaryLabel];
+ secondaryTextView.adjustsFontForContentSizeCategory = YES;
+ secondaryTextView.translatesAutoresizingMaskIntoConstraints = NO;
+ secondaryTextView.textColor = [UIColor colorNamed:kTextSecondaryColor];
+ secondaryTextView.linkTextAttributes =
+ @{NSForegroundColorAttributeName : [UIColor colorNamed:kBlueColor]};
+
+ if (self.secondaryAttributedString) {
+ secondaryTextView.attributedText = self.secondaryAttributedString;
+ }
+
+ [_scrollView addSubview:secondaryTextView];
NSLayoutConstraint* heightConstraint = [_scrollView.heightAnchor
constraintEqualToAnchor:_scrollView.contentLayoutGuide.heightAnchor
@@ -139,9 +145,9 @@
heightConstraint.active = YES;
CGFloat verticalOffset =
- (secondaryLabel.attributedText) ? -kVerticalDistance : 0;
+ (secondaryTextView.attributedText) ? -kVerticalDistance : 0;
NSLayoutConstraint* verticalConstraint =
- [textView.bottomAnchor constraintEqualToAnchor:secondaryLabel.topAnchor
+ [textView.bottomAnchor constraintEqualToAnchor:secondaryTextView.topAnchor
constant:verticalOffset];
[NSLayoutConstraint activateConstraints:@[
@@ -151,19 +157,19 @@
constraintEqualToAnchor:textView.leadingAnchor
constant:-kHorizontalInsetValue],
[textContainerView.leadingAnchor
- constraintEqualToAnchor:secondaryLabel.leadingAnchor
+ constraintEqualToAnchor:secondaryTextView.leadingAnchor
constant:-kHorizontalInsetValue],
[textContainerView.trailingAnchor
constraintEqualToAnchor:textView.trailingAnchor
constant:kHorizontalInsetValue],
[textContainerView.trailingAnchor
- constraintEqualToAnchor:secondaryLabel.trailingAnchor
+ constraintEqualToAnchor:secondaryTextView.trailingAnchor
constant:kHorizontalInsetValue],
verticalConstraint,
[textContainerView.topAnchor constraintEqualToAnchor:textView.topAnchor
constant:-kVerticalInsetValue],
[textContainerView.bottomAnchor
- constraintEqualToAnchor:secondaryLabel.bottomAnchor
+ constraintEqualToAnchor:secondaryTextView.bottomAnchor
constant:kVerticalInsetValue],
]];
}