Commit cdcb232b authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[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: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795470}
parent 5d5bc0f2
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h"
#include "ios/chrome/grit/ios_strings.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.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -61,7 +62,8 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -61,7 +62,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
#pragma mark - AutofillCreditCardTableViewController #pragma mark - AutofillCreditCardTableViewController
@interface AutofillCreditCardTableViewController () < @interface AutofillCreditCardTableViewController () <
PersonalDataManagerObserver> { PersonalDataManagerObserver,
PopoverLabelViewControllerDelegate> {
autofill::PersonalDataManager* _personalDataManager; autofill::PersonalDataManager* _personalDataManager;
Browser* _browser; Browser* _browser;
...@@ -292,6 +294,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -292,6 +294,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView { - (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController = EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil]; [[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
bubbleViewController.delegate = self;
[self presentViewController:bubbleViewController animated:YES completion:nil]; [self presentViewController:bubbleViewController animated:YES completion:nil];
// Disable the button when showing the bubble. // Disable the button when showing the bubble.
...@@ -574,4 +577,11 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -574,4 +577,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
[self setToolbarItems:customToolbarItems animated:YES]; [self setToolbarItems:customToolbarItems animated:YES];
} }
#pragma mark - PopoverLabelViewControllerDelegate
- (void)didTapLinkURL:(NSURL*)URL {
GURL convertedURL = net::GURLWithNSURL(URL);
[self view:nil didTapLinkURL:convertedURL];
}
@end @end
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h"
#include "ios/chrome/grit/ios_strings.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.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -59,7 +60,9 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -59,7 +60,9 @@ typedef NS_ENUM(NSInteger, ItemType) {
#pragma mark - AutofillProfileTableViewController #pragma mark - AutofillProfileTableViewController
@interface AutofillProfileTableViewController () <PersonalDataManagerObserver> { @interface AutofillProfileTableViewController () <
PersonalDataManagerObserver,
PopoverLabelViewControllerDelegate> {
autofill::PersonalDataManager* _personalDataManager; autofill::PersonalDataManager* _personalDataManager;
ChromeBrowserState* _browserState; ChromeBrowserState* _browserState;
...@@ -303,6 +306,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -303,6 +306,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView { - (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController = EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil]; [[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
bubbleViewController.delegate = self;
[self presentViewController:bubbleViewController animated:YES completion:nil]; [self presentViewController:bubbleViewController animated:YES completion:nil];
// Disable the button when showing the bubble. // Disable the button when showing the bubble.
...@@ -498,4 +502,11 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -498,4 +502,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
} }
} }
#pragma mark - PopoverLabelViewControllerDelegate
- (void)didTapLinkURL:(NSURL*)URL {
GURL convertedURL = net::GURLWithNSURL(URL);
[self view:nil didTapLinkURL:convertedURL];
}
@end @end
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_header_footer_item.h" #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/browser/ui/ui_feature_flags.h"
#include "ios/chrome/grit/ios_strings.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.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -50,7 +51,9 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -50,7 +51,9 @@ typedef NS_ENUM(NSInteger, ItemType) {
} // namespace } // namespace
@interface BlockPopupsTableViewController ()<BooleanObserver> { @interface BlockPopupsTableViewController () <
BooleanObserver,
PopoverLabelViewControllerDelegate> {
ChromeBrowserState* _browserState; // weak ChromeBrowserState* _browserState; // weak
// List of url patterns that are allowed to display popups. // List of url patterns that are allowed to display popups.
...@@ -257,6 +260,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -257,6 +260,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView { - (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController = EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil]; [[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
bubbleViewController.delegate = self;
[self presentViewController:bubbleViewController animated:YES completion:nil]; [self presentViewController:bubbleViewController animated:YES completion:nil];
// Disable the button when showing the bubble. // Disable the button when showing the bubble.
...@@ -405,4 +409,11 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -405,4 +409,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
} }
} }
#pragma mark - PopoverLabelViewControllerDelegate
- (void)didTapLinkURL:(NSURL*)URL {
GURL convertedURL = net::GURLWithNSURL(URL);
[self view:nil didTapLinkURL:convertedURL];
}
@end @end
...@@ -228,8 +228,10 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -228,8 +228,10 @@ typedef NS_ENUM(NSInteger, ItemType) {
NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:indexPath]; NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:indexPath];
switch (itemType) { switch (itemType) {
case ItemTypeSettingsBlockPopups: { case ItemTypeSettingsBlockPopups: {
UIViewController* controller = [[BlockPopupsTableViewController alloc] BlockPopupsTableViewController* controller =
initWithBrowserState:_browserState]; [[BlockPopupsTableViewController alloc]
initWithBrowserState:_browserState];
controller.dispatcher = self.dispatcher;
[self.navigationController pushViewController:controller animated:YES]; [self.navigationController pushViewController:controller animated:YES];
break; break;
} }
......
...@@ -21,6 +21,8 @@ namespace { ...@@ -21,6 +21,8 @@ namespace {
NSString* const kEnterpriseIconName = @"enterprise_icon"; NSString* const kEnterpriseIconName = @"enterprise_icon";
NSString* const kChromeManagementURL = @"chrome://management";
NSAttributedString* PrimaryMessage() { NSAttributedString* PrimaryMessage() {
NSString* fullText = NSString* fullText =
l10n_util::GetNSString(IDS_IOS_ENTERPRISE_MANAGED_SETTING_MESSAGE); l10n_util::GetNSString(IDS_IOS_ENTERPRISE_MANAGED_SETTING_MESSAGE);
...@@ -47,6 +49,9 @@ NSAttributedString* SecondaryMessage(NSString* enterpriseName) { ...@@ -47,6 +49,9 @@ NSAttributedString* SecondaryMessage(NSString* enterpriseName) {
// Add a space to have a distanse with the leading icon. // Add a space to have a distanse with the leading icon.
NSString* fullText = [@" " stringByAppendingString:message]; NSString* fullText = [@" " stringByAppendingString:message];
NSRange range;
fullText = ParseStringWithLink(fullText, &range);
NSDictionary* generalAttributes = @{ NSDictionary* generalAttributes = @{
NSForegroundColorAttributeName : [UIColor colorNamed:kTextSecondaryColor], NSForegroundColorAttributeName : [UIColor colorNamed:kTextSecondaryColor],
NSFontAttributeName : NSFontAttributeName :
...@@ -56,8 +61,13 @@ NSAttributedString* SecondaryMessage(NSString* enterpriseName) { ...@@ -56,8 +61,13 @@ NSAttributedString* SecondaryMessage(NSString* enterpriseName) {
[[NSMutableAttributedString alloc] initWithString:fullText [[NSMutableAttributedString alloc] initWithString:fullText
attributes:generalAttributes]; attributes:generalAttributes];
// TODO(crbug.com/1092544): add "Learn more" link when the link page is NSDictionary* linkAttributes = @{
// ready. NSForegroundColorAttributeName : [UIColor colorNamed:kBlueColor],
NSFontAttributeName :
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote],
NSLinkAttributeName : kChromeManagementURL,
};
[attributedString setAttributes:linkAttributes range:range];
// Create the leading enterprise icon. // Create the leading enterprise icon.
NSTextAttachment* attachment = [[NSTextAttachment alloc] init]; NSTextAttachment* attachment = [[NSTextAttachment alloc] init];
......
...@@ -676,6 +676,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -676,6 +676,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView { - (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController = EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil]; [[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
bubbleViewController.delegate = self;
[self presentViewController:bubbleViewController animated:YES completion:nil]; [self presentViewController:bubbleViewController animated:YES completion:nil];
// Disable the button when showing the bubble. // Disable the button when showing the bubble.
......
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
#import "ios/public/provider/chrome/browser/signin/signin_presenter.h" #import "ios/public/provider/chrome/browser/signin/signin_presenter.h"
#import "ios/public/provider/chrome/browser/signin/signin_resources_provider.h" #import "ios/public/provider/chrome/browser/signin/signin_resources_provider.h"
#include "ios/public/provider/chrome/browser/voice/voice_search_prefs.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" #include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -167,6 +168,7 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -167,6 +168,7 @@ NSString* kDevViewSourceKey = @"DevViewSource";
ChromeIdentityServiceObserver, ChromeIdentityServiceObserver,
GoogleServicesSettingsCoordinatorDelegate, GoogleServicesSettingsCoordinatorDelegate,
IdentityManagerObserverBridgeDelegate, IdentityManagerObserverBridgeDelegate,
PopoverLabelViewControllerDelegate,
PrefObserverDelegate, PrefObserverDelegate,
PrivacyCoordinatorDelegate, PrivacyCoordinatorDelegate,
SafetyCheckCoordinatorDelegate, SafetyCheckCoordinatorDelegate,
...@@ -965,6 +967,7 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -965,6 +967,7 @@ NSString* kDevViewSourceKey = @"DevViewSource";
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView { - (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController = EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil]; [[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
bubbleViewController.delegate = self;
// Disable the button when showing the bubble. // Disable the button when showing the bubble.
// The button will be enabled when close the bubble in // The button will be enabled when close the bubble in
...@@ -1475,4 +1478,11 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -1475,4 +1478,11 @@ NSString* kDevViewSourceKey = @"DevViewSource";
base::RecordAction(base::UserMetricsAction("IOSSettingsCloseWithSwipe")); base::RecordAction(base::UserMetricsAction("IOSSettingsCloseWithSwipe"));
} }
#pragma mark - PopoverLabelViewControllerDelegate
- (void)didTapLinkURL:(NSURL*)URL {
GURL convertedURL = net::GURLWithNSURL(URL);
[self view:nil didTapLinkURL:convertedURL];
}
@end @end
...@@ -115,18 +115,24 @@ constexpr CGFloat kVerticalDistance = 24; ...@@ -115,18 +115,24 @@ constexpr CGFloat kVerticalDistance = 24;
[_scrollView addSubview:textView]; [_scrollView addSubview:textView];
UILabel* secondaryLabel = [[UILabel alloc] init]; UITextView* secondaryTextView = [[UITextView alloc] init];
secondaryLabel.numberOfLines = 0; secondaryTextView.scrollEnabled = NO;
secondaryLabel.textColor = [UIColor colorNamed:kTextSecondaryColor]; secondaryTextView.editable = NO;
secondaryLabel.textAlignment = NSTextAlignmentNatural; secondaryTextView.delegate = self;
secondaryLabel.adjustsFontForContentSizeCategory = YES; secondaryTextView.backgroundColor = [UIColor clearColor];
secondaryTextView.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
secondaryTextView.adjustsFontForContentSizeCategory = YES;
secondaryTextView.translatesAutoresizingMaskIntoConstraints = NO;
secondaryTextView.textColor = [UIColor colorNamed:kTextSecondaryColor];
secondaryTextView.linkTextAttributes =
@{NSForegroundColorAttributeName : [UIColor colorNamed:kBlueColor]};
if (self.secondaryAttributedString) { if (self.secondaryAttributedString) {
secondaryLabel.attributedText = self.secondaryAttributedString; secondaryTextView.attributedText = self.secondaryAttributedString;
} }
secondaryLabel.translatesAutoresizingMaskIntoConstraints = NO;
secondaryLabel.font = [_scrollView addSubview:secondaryTextView];
[UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
[_scrollView addSubview:secondaryLabel];
NSLayoutConstraint* heightConstraint = [_scrollView.heightAnchor NSLayoutConstraint* heightConstraint = [_scrollView.heightAnchor
constraintEqualToAnchor:_scrollView.contentLayoutGuide.heightAnchor constraintEqualToAnchor:_scrollView.contentLayoutGuide.heightAnchor
...@@ -139,9 +145,9 @@ constexpr CGFloat kVerticalDistance = 24; ...@@ -139,9 +145,9 @@ constexpr CGFloat kVerticalDistance = 24;
heightConstraint.active = YES; heightConstraint.active = YES;
CGFloat verticalOffset = CGFloat verticalOffset =
(secondaryLabel.attributedText) ? -kVerticalDistance : 0; (secondaryTextView.attributedText) ? -kVerticalDistance : 0;
NSLayoutConstraint* verticalConstraint = NSLayoutConstraint* verticalConstraint =
[textView.bottomAnchor constraintEqualToAnchor:secondaryLabel.topAnchor [textView.bottomAnchor constraintEqualToAnchor:secondaryTextView.topAnchor
constant:verticalOffset]; constant:verticalOffset];
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
...@@ -151,19 +157,19 @@ constexpr CGFloat kVerticalDistance = 24; ...@@ -151,19 +157,19 @@ constexpr CGFloat kVerticalDistance = 24;
constraintEqualToAnchor:textView.leadingAnchor constraintEqualToAnchor:textView.leadingAnchor
constant:-kHorizontalInsetValue], constant:-kHorizontalInsetValue],
[textContainerView.leadingAnchor [textContainerView.leadingAnchor
constraintEqualToAnchor:secondaryLabel.leadingAnchor constraintEqualToAnchor:secondaryTextView.leadingAnchor
constant:-kHorizontalInsetValue], constant:-kHorizontalInsetValue],
[textContainerView.trailingAnchor [textContainerView.trailingAnchor
constraintEqualToAnchor:textView.trailingAnchor constraintEqualToAnchor:textView.trailingAnchor
constant:kHorizontalInsetValue], constant:kHorizontalInsetValue],
[textContainerView.trailingAnchor [textContainerView.trailingAnchor
constraintEqualToAnchor:secondaryLabel.trailingAnchor constraintEqualToAnchor:secondaryTextView.trailingAnchor
constant:kHorizontalInsetValue], constant:kHorizontalInsetValue],
verticalConstraint, verticalConstraint,
[textContainerView.topAnchor constraintEqualToAnchor:textView.topAnchor [textContainerView.topAnchor constraintEqualToAnchor:textView.topAnchor
constant:-kVerticalInsetValue], constant:-kVerticalInsetValue],
[textContainerView.bottomAnchor [textContainerView.bottomAnchor
constraintEqualToAnchor:secondaryLabel.bottomAnchor constraintEqualToAnchor:secondaryTextView.bottomAnchor
constant:kVerticalInsetValue], constant:kVerticalInsetValue],
]]; ]];
} }
......
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