Commit 83c0ab25 authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[SettingsUI] Add customized item for managed on/off settings

- Add customized item and cell for settings which has a toggle switcher once not managed by policy.
- Apply to "Save Password" setting.
- Add corresponding method to handle click action of the info button.

Screenshot: https://screenshot.googleplex.com/6doUPsk0Dmj

Bug: 1087223
Change-Id: I3140c7cfb99dbaf46f8679c4e675b9ab0002d6c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2219569
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774424}
parent fff41f16
...@@ -1654,9 +1654,6 @@ Handoff must also be enabled in the General section of Settings, and your device ...@@ -1654,9 +1654,6 @@ Handoff must also be enabled in the General section of Settings, and your device
<message name="IDS_IOS_SETTINGS_SWIPE_DOWN_KEEP" desc="Button displayed along with a message alert whenever a user tries to dismiss a Settings screen which is being edited, or information is being added to it. Selecting this option will dismiss the message alert, and will keep displaying the settings screen."> <message name="IDS_IOS_SETTINGS_SWIPE_DOWN_KEEP" desc="Button displayed along with a message alert whenever a user tries to dismiss a Settings screen which is being edited, or information is being added to it. Selecting this option will dismiss the message alert, and will keep displaying the settings screen.">
Keep Editing Keep Editing
</message> </message>
<message name="IDS_IOS_TOGGLE_SETTING_SWITCH_ACCESSIBILITY_HINT" desc="Action hint for any switch in settings. This is spoken by VoiceOver. [iOS only]">
Double tap to toggle setting
</message>
<message name="IDS_IOS_SHARE_BUTTON_LABEL" desc="Label of a button which will initiate a share flow. [iOS only]"> <message name="IDS_IOS_SHARE_BUTTON_LABEL" desc="Label of a button which will initiate a share flow. [iOS only]">
Share... Share...
</message> </message>
...@@ -2038,6 +2035,15 @@ Your data was encrypted with your sync passphrase on <ph name="TIME">$2<ex>Sept ...@@ -2038,6 +2035,15 @@ Your data was encrypted with your sync passphrase on <ph name="TIME">$2<ex>Sept
<message name="IDS_IOS_TEXT_ZOOM_ZOOM_OUT" desc="Accessibility label for a button allowing the user to zoom out." meaning="User is asking page to zoom out"> <message name="IDS_IOS_TEXT_ZOOM_ZOOM_OUT" desc="Accessibility label for a button allowing the user to zoom out." meaning="User is asking page to zoom out">
Zoom Out Zoom Out
</message> </message>
<message name="IDS_IOS_TOGGLE_SETTING_SWITCH_ACCESSIBILITY_HINT" desc="Action hint for any switch in settings. This is spoken by VoiceOver. [iOS only]">
Double tap to toggle setting
</message>
<message name="IDS_IOS_TOGGLE_SETTING_MANAGED_ACCESSIBILITY_HINT" desc="Action hint for any managed switch in settings. This is spoken by VoiceOver. [iOS only]">
This setting is managed
</message>
<message name="IDS_IOS_TOGGLE_SETTING_MANAGED_INFO_BUBBLE_MESSAGE" desc="Text displayed on the textual bubble about settings managed information. [iOS only]">
This setting is enforced by your administrator.
</message>
<message name="IDS_IOS_TOOLBAR_CLOSE_MENU" desc="The accessibility label for the toolbar close settings menu button [iOS only]."> <message name="IDS_IOS_TOOLBAR_CLOSE_MENU" desc="The accessibility label for the toolbar close settings menu button [iOS only].">
Close Menu Close Menu
</message> </message>
......
...@@ -18,6 +18,10 @@ source_set("cells") { ...@@ -18,6 +18,10 @@ source_set("cells") {
"settings_image_detail_text_cell.mm", "settings_image_detail_text_cell.mm",
"settings_image_detail_text_item.h", "settings_image_detail_text_item.h",
"settings_image_detail_text_item.mm", "settings_image_detail_text_item.mm",
"settings_managed_cell.h",
"settings_managed_cell.mm",
"settings_managed_item.h",
"settings_managed_item.mm",
"settings_multiline_detail_item.h", "settings_multiline_detail_item.h",
"settings_multiline_detail_item.mm", "settings_multiline_detail_item.mm",
"settings_switch_cell.h", "settings_switch_cell.h",
......
// Copyright 2020 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.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_MANAGED_CELL_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_MANAGED_CELL_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/table_view/cells/table_view_cell.h"
// SettingsManagedCell implements a TableViewCell subclass containing an icon,
// a text label, a detail text, a status text and an info button.
// If the preferred content size category is an accessibility category, the
// status text is displayed below the detail text, and the info button is
// below the status text. Otherwise, they are on the trailing side.
@interface SettingsManagedCell : TableViewCell
// UILabel displayed next to the leading image icon if there is one, otherwise
// this UILabel will be at the leading position. Corresponding to |text| from
// the item.
@property(nonatomic, readonly, strong) UILabel* textLabel;
// UILabel displayed under the |textLabel| shows the description text.
// Corresponding to |detailText| from the item.
@property(nonatomic, readonly, strong) UILabel* detailTextLabel;
// UILabel displayed at the trailing side of the view, it's trailing anchor
// align with the leading anchor of the |bubbleView| below. It shows the status
// of the setting's row. Mostly show On or Off, but there is use case that shows
// a search engine name. Corresponding to |statusText| from the item.
@property(nonatomic, readonly, strong) UILabel* statusTextLabel;
// UIButton displayed aligned to the trailing of the view.
@property(nonatomic, readonly, strong) UIButton* trailingButton;
// Sets the image that should be displayed at the leading edge of the cell. If
// set to nil, the icon will be hidden and the remaining content will expand to
// fill the full width of the cell.
- (void)setIconImage:(UIImage*)image;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_MANAGED_CELL_H_
// Copyright 2020 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.
#import "ios/chrome/browser/ui/settings/cells/settings_managed_cell.h"
#import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h"
#include "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ios/chrome/common/ui/util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Padding used between the icon and the text labels.
const CGFloat kIconTrailingPadding = 12;
// Size of the icon image.
const CGFloat kIconImageSize = 28;
// Proportion of |textLayoutGuide| and |statusTextLabel|. This guarantees both
// of them at least occupies 20% of the cell.
const CGFloat kCellLabelsWidthProportion = 0.2f;
} // namespace
@interface SettingsManagedCell ()
// The image view for the leading icon.
@property(nonatomic, readonly, strong) UIImageView* iconImageView;
// Constraints that are used when the iconImageView is visible and hidden.
@property(nonatomic, strong) NSLayoutConstraint* iconVisibleConstraint;
@property(nonatomic, strong) NSLayoutConstraint* iconHiddenConstraint;
// Constraints that are used when the preferred content size is an
// "accessibility" category.
@property(nonatomic, strong) NSArray* accessibilityConstraints;
// Constraints that are used when the preferred content size is *not* an
// "accessibility" category.
@property(nonatomic, strong) NSArray* standardConstraints;
@end
@implementation SettingsManagedCell
@synthesize textLabel = _textLabel;
@synthesize detailTextLabel = _detailTextLabel;
- (instancetype)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString*)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.isAccessibilityElement = YES;
_iconImageView = [[UIImageView alloc] init];
_iconImageView.translatesAutoresizingMaskIntoConstraints = NO;
_iconImageView.hidden = YES;
[self.contentView addSubview:_iconImageView];
UILayoutGuide* textLayoutGuide = [[UILayoutGuide alloc] init];
[self.contentView addLayoutGuide:textLayoutGuide];
_textLabel = [[UILabel alloc] init];
_textLabel.translatesAutoresizingMaskIntoConstraints = NO;
_textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_textLabel.adjustsFontForContentSizeCategory = YES;
_textLabel.textColor = UIColor.cr_labelColor;
_textLabel.numberOfLines = 0;
[self.contentView addSubview:_textLabel];
_detailTextLabel = [[UILabel alloc] init];
_detailTextLabel.translatesAutoresizingMaskIntoConstraints = NO;
_detailTextLabel.font =
[UIFont preferredFontForTextStyle:kTableViewSublabelFontStyle];
_detailTextLabel.adjustsFontForContentSizeCategory = YES;
_detailTextLabel.textColor = UIColor.cr_secondaryLabelColor;
[self.contentView addSubview:_detailTextLabel];
_statusTextLabel = [[UILabel alloc] init];
_statusTextLabel.translatesAutoresizingMaskIntoConstraints = NO;
_statusTextLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_statusTextLabel.adjustsFontForContentSizeCategory = YES;
_statusTextLabel.textColor = UIColor.cr_secondaryLabelColor;
[self.contentView addSubview:_statusTextLabel];
_trailingButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
_trailingButton.translatesAutoresizingMaskIntoConstraints = NO;
[_trailingButton
setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh + 1
forAxis:
UILayoutConstraintAxisHorizontal];
[self.contentView addSubview:_trailingButton];
// Set up the constraints assuming that the icon image is hidden.
_iconVisibleConstraint = [textLayoutGuide.leadingAnchor
constraintEqualToAnchor:_iconImageView.trailingAnchor
constant:kIconTrailingPadding];
_iconHiddenConstraint = [textLayoutGuide.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:kTableViewHorizontalSpacing];
// Set the constranits of |textLabel| and |statusTextLabel| to make their
// width >= 20% of the cell to ensure both of them have a space.
NSLayoutConstraint* widthConstraintStatus = [_statusTextLabel.widthAnchor
constraintGreaterThanOrEqualToAnchor:self.contentView.widthAnchor
multiplier:kCellLabelsWidthProportion];
widthConstraintStatus.priority = UILayoutPriorityDefaultHigh + 1;
NSLayoutConstraint* widthConstraintLayoutGuide =
[textLayoutGuide.widthAnchor
constraintGreaterThanOrEqualToAnchor:self.contentView.widthAnchor
multiplier:kCellLabelsWidthProportion];
widthConstraintLayoutGuide.priority = UILayoutPriorityDefaultHigh + 1;
// Set the content hugging property to |statusTextLabel| to wrap the text
// and give other label more space.
[_statusTextLabel
setContentHuggingPriority:UILayoutPriorityDefaultHigh + 2
forAxis:UILayoutConstraintAxisHorizontal];
_standardConstraints = @[
[_statusTextLabel.centerYAnchor
constraintEqualToAnchor:self.contentView.centerYAnchor],
[_statusTextLabel.trailingAnchor
constraintEqualToAnchor:_trailingButton.leadingAnchor
constant:-kTableViewHorizontalSpacing],
[_trailingButton.centerYAnchor
constraintEqualToAnchor:self.contentView.centerYAnchor],
[_trailingButton.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing],
[textLayoutGuide.trailingAnchor
constraintLessThanOrEqualToAnchor:_statusTextLabel.leadingAnchor
constant:-kTableViewHorizontalSpacing],
[textLayoutGuide.centerYAnchor
constraintEqualToAnchor:self.contentView.centerYAnchor],
[textLayoutGuide.widthAnchor
constraintGreaterThanOrEqualToAnchor:self.contentView.widthAnchor
multiplier:kCellLabelsWidthProportion],
widthConstraintStatus,
widthConstraintLayoutGuide,
];
_accessibilityConstraints = @[
[_statusTextLabel.topAnchor
constraintEqualToAnchor:textLayoutGuide.bottomAnchor
constant:kTableViewLargeVerticalSpacing],
[_statusTextLabel.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:kTableViewHorizontalSpacing],
[_statusTextLabel.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing],
[_trailingButton.topAnchor
constraintEqualToAnchor:_statusTextLabel.bottomAnchor
constant:kTableViewLargeVerticalSpacing],
[_trailingButton.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:kTableViewHorizontalSpacing],
[_trailingButton.bottomAnchor
constraintEqualToAnchor:self.contentView.bottomAnchor
constant:-kTableViewLargeVerticalSpacing],
[textLayoutGuide.trailingAnchor
constraintLessThanOrEqualToAnchor:self.contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing],
];
[NSLayoutConstraint activateConstraints:@[
[_iconImageView.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:kTableViewHorizontalSpacing],
[_iconImageView.widthAnchor constraintEqualToConstant:kIconImageSize],
[_iconImageView.heightAnchor constraintEqualToConstant:kIconImageSize],
[_iconImageView.centerYAnchor
constraintEqualToAnchor:textLayoutGuide.centerYAnchor],
_iconHiddenConstraint,
[textLayoutGuide.leadingAnchor
constraintEqualToAnchor:_textLabel.leadingAnchor],
[textLayoutGuide.leadingAnchor
constraintEqualToAnchor:_detailTextLabel.leadingAnchor],
[textLayoutGuide.trailingAnchor
constraintEqualToAnchor:_textLabel.trailingAnchor],
[textLayoutGuide.trailingAnchor
constraintEqualToAnchor:_detailTextLabel.trailingAnchor],
[textLayoutGuide.topAnchor constraintEqualToAnchor:_textLabel.topAnchor],
[textLayoutGuide.bottomAnchor
constraintEqualToAnchor:_detailTextLabel.bottomAnchor],
[_textLabel.bottomAnchor
constraintEqualToAnchor:_detailTextLabel.topAnchor],
]];
if (UIContentSizeCategoryIsAccessibilityCategory(
self.traitCollection.preferredContentSizeCategory)) {
[NSLayoutConstraint activateConstraints:_accessibilityConstraints];
} else {
[NSLayoutConstraint activateConstraints:_standardConstraints];
}
AddOptionalVerticalPadding(self.contentView, textLayoutGuide,
kTableViewOneLabelCellVerticalSpacing);
}
return self;
}
- (void)setIconImage:(UIImage*)image {
BOOL hidden = (image == nil);
self.iconImageView.image = image;
if (hidden == self.iconImageView.hidden)
return;
self.iconImageView.hidden = hidden;
if (hidden) {
self.iconVisibleConstraint.active = NO;
self.iconHiddenConstraint.active = YES;
} else {
self.iconHiddenConstraint.active = NO;
self.iconVisibleConstraint.active = YES;
}
}
#pragma mark - UIView
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
BOOL isCurrentContentSizeAccessibility =
UIContentSizeCategoryIsAccessibilityCategory(
self.traitCollection.preferredContentSizeCategory);
if (UIContentSizeCategoryIsAccessibilityCategory(
previousTraitCollection.preferredContentSizeCategory) !=
isCurrentContentSizeAccessibility) {
if (isCurrentContentSizeAccessibility) {
[NSLayoutConstraint deactivateConstraints:_standardConstraints];
[NSLayoutConstraint activateConstraints:_accessibilityConstraints];
} else {
[NSLayoutConstraint deactivateConstraints:_accessibilityConstraints];
[NSLayoutConstraint activateConstraints:_standardConstraints];
}
}
}
#pragma mark - UITableViewCell
- (void)prepareForReuse {
[super prepareForReuse];
self.textLabel.text = nil;
self.detailTextLabel.text = nil;
self.statusTextLabel.text = nil;
[self setIconImage:nil];
[_trailingButton removeTarget:nil
action:nil
forControlEvents:[_trailingButton allControlEvents]];
}
#pragma mark - UIAccessibility
- (CGPoint)accessibilityActivationPoint {
// Center the activation point over the button.
CGRect buttonFrame = UIAccessibilityConvertFrameToScreenCoordinates(
self.contentView.frame, self);
return CGPointMake(CGRectGetMidX(buttonFrame), CGRectGetMidY(buttonFrame));
}
- (NSString*)accessibilityHint {
return l10n_util::GetNSString(
IDS_IOS_TOGGLE_SETTING_MANAGED_ACCESSIBILITY_HINT);
}
- (NSString*)accessibilityLabel {
if (!self.detailTextLabel.text)
return self.textLabel.text;
return [NSString stringWithFormat:@"%@, %@", self.textLabel.text,
self.detailTextLabel.text];
}
- (NSString*)accessibilityValue {
return self.statusTextLabel.text;
}
@end
// Copyright 2020 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.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_MANAGED_ITEM_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_MANAGED_ITEM_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
// SettingsManagedItem is a model class that uses SettingsManagedCell.
@interface SettingsManagedItem : TableViewItem
// The filename for the leading icon. If empty, no icon will be shown.
@property(nonatomic, copy) NSString* iconImageName;
// The main text string.
@property(nonatomic, copy) NSString* text;
// The detail text string.
@property(nonatomic, copy) NSString* detailText;
// The status text string.
@property(nonatomic, copy) NSString* statusText;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_MANAGED_ITEM_H_
// Copyright 2020 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.
#import "ios/chrome/browser/ui/settings/cells/settings_managed_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_managed_cell.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation SettingsManagedItem
- (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type];
if (self) {
self.cellClass = [SettingsManagedCell class];
}
return self;
}
#pragma mark TableViewItem
- (void)configureCell:(SettingsManagedCell*)cell
withStyler:(ChromeTableViewStyler*)styler {
[super configureCell:cell withStyler:styler];
cell.textLabel.text = self.text;
cell.detailTextLabel.text = self.detailText;
cell.statusTextLabel.text = self.statusText;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// Update the icon image, if one is present.
UIImage* iconImage = nil;
if ([self.iconImageName length]) {
iconImage = [UIImage imageNamed:self.iconImageName];
}
[cell setIconImage:iconImage];
}
@end
...@@ -41,6 +41,7 @@ source_set("password") { ...@@ -41,6 +41,7 @@ source_set("password") {
"//ios/chrome/browser/ui/table_view/cells:cells_constants", "//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common/ui/colors", "//ios/chrome/common/ui/colors",
"//ios/chrome/common/ui/elements:popover_label_view_controller",
"//ios/chrome/common/ui/reauthentication", "//ios/chrome/common/ui/reauthentication",
"//ios/chrome/common/ui/util", "//ios/chrome/common/ui/util",
"//ios/third_party/material_components_ios", "//ios/third_party/material_components_ios",
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#import "ios/chrome/browser/signin/chrome_identity_service_observer_bridge.h" #import "ios/chrome/browser/signin/chrome_identity_service_observer_bridge.h"
#include "ios/chrome/browser/system_flags.h" #include "ios/chrome/browser/system_flags.h"
#import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h" #import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h"
#import "ios/chrome/browser/ui/settings/cells/settings_managed_cell.h"
#import "ios/chrome/browser/ui/settings/cells/settings_managed_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_cell.h" #import "ios/chrome/browser/ui/settings/cells/settings_switch_cell.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h"
#import "ios/chrome/browser/ui/settings/password/password_details_table_view_controller.h" #import "ios/chrome/browser/ui/settings/password/password_details_table_view_controller.h"
...@@ -47,7 +49,6 @@ ...@@ -47,7 +49,6 @@
#import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h"
#import "ios/chrome/browser/ui/settings/utils/settings_utils.h" #import "ios/chrome/browser/ui/settings/utils/settings_utils.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_detail_icon_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_detail_text_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_detail_text_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h"
#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"
...@@ -58,6 +59,7 @@ ...@@ -58,6 +59,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/UIColor+cr_semantic_colors.h" #import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ios/chrome/common/ui/elements/popover_label_view_controller.h"
#import "ios/chrome/common/ui/reauthentication/reauthentication_module.h" #import "ios/chrome/common/ui/reauthentication/reauthentication_module.h"
#import "ios/chrome/common/ui/util/constraints_ui_util.h" #import "ios/chrome/common/ui/util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
...@@ -172,7 +174,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -172,7 +174,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
// The item related to the switch for the password manager setting. // The item related to the switch for the password manager setting.
SettingsSwitchItem* _savePasswordsItem; SettingsSwitchItem* _savePasswordsItem;
// The item related to the enterprise managed save password setting. // The item related to the enterprise managed save password setting.
TableViewDetailIconItem* _managedSavePasswordItem; SettingsManagedItem* _managedSavePasswordItem;
// The item related to the button for exporting passwords. // The item related to the button for exporting passwords.
TableViewTextItem* _exportPasswordsItem; TableViewTextItem* _exportPasswordsItem;
// The interface for getting and manipulating a user's saved passwords. // The interface for getting and manipulating a user's saved passwords.
...@@ -460,17 +462,14 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -460,17 +462,14 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
return savePasswordsItem; return savePasswordsItem;
} }
- (TableViewDetailIconItem*)managedSavePasswordItem { - (SettingsManagedItem*)managedSavePasswordItem {
TableViewDetailIconItem* managedSavePasswordItem = SettingsManagedItem* managedSavePasswordItem =
[[TableViewDetailIconItem alloc] [[SettingsManagedItem alloc] initWithType:ItemTypeManagedSavePasswords];
initWithType:ItemTypeManagedSavePasswords];
managedSavePasswordItem.text = l10n_util::GetNSString(IDS_IOS_SAVE_PASSWORDS); managedSavePasswordItem.text = l10n_util::GetNSString(IDS_IOS_SAVE_PASSWORDS);
NSString* passwordsDetail = [_passwordManagerEnabled value] managedSavePasswordItem.statusText =
? l10n_util::GetNSString(IDS_IOS_SETTING_ON) [_passwordManagerEnabled value]
: l10n_util::GetNSString(IDS_IOS_SETTING_OFF); ? l10n_util::GetNSString(IDS_IOS_SETTING_ON)
managedSavePasswordItem.detailText = passwordsDetail; : l10n_util::GetNSString(IDS_IOS_SETTING_OFF);
managedSavePasswordItem.accessoryType = UITableViewCellAccessoryDetailButton;
managedSavePasswordItem.accessibilityIdentifier = managedSavePasswordItem.accessibilityIdentifier =
@"savePasswordsItem_managed"; @"savePasswordsItem_managed";
return managedSavePasswordItem; return managedSavePasswordItem;
...@@ -541,9 +540,23 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -541,9 +540,23 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
- (void)savePasswordsSwitchChanged:(UISwitch*)switchView { - (void)savePasswordsSwitchChanged:(UISwitch*)switchView {
// Update the setting. // Update the setting.
[_passwordManagerEnabled setValue:switchView.on]; [_passwordManagerEnabled setValue:switchView.on];
}
// Update the item. // Being called when the user clicks on the information button of the managed
_savePasswordsItem.on = [_passwordManagerEnabled value]; // setting's UI. Shows a textual bubble with the information of the enterprise.
- (void)didTapManagedUIInfoButton:(UIButton*)buttonView {
// TODO(crbug.com/1085202): show customized text bubble.
// Now showing a PopoverLabelView as a placeholder.
NSString* text = l10n_util::GetNSString(
IDS_IOS_TOGGLE_SETTING_MANAGED_INFO_BUBBLE_MESSAGE);
PopoverLabelViewController* bubbleViewController =
[[PopoverLabelViewController alloc] initWithMessage:text];
[self presentViewController:bubbleViewController animated:YES completion:nil];
bubbleViewController.popoverPresentationController.sourceView = buttonView;
bubbleViewController.popoverPresentationController.sourceRect =
buttonView.bounds;
bubbleViewController.popoverPresentationController.permittedArrowDirections =
UIPopoverArrowDirectionAny;
} }
#pragma mark - SavePasswordsConsumerDelegate #pragma mark - SavePasswordsConsumerDelegate
...@@ -1013,11 +1026,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -1013,11 +1026,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
SectionIdentifierSavePasswordsSwitch; SectionIdentifierSavePasswordsSwitch;
} }
- (void)tableView:(UITableView*)tableView
accessoryButtonTappedForRowWithIndexPath:(NSIndexPath*)indexPath {
// TODO(crbug.com/1085202): show the text bubble.
}
- (UIView*)tableView:(UITableView*)tableView - (UIView*)tableView:(UITableView*)tableView
viewForHeaderInSection:(NSInteger)section { viewForHeaderInSection:(NSInteger)section {
UIView* view = [super tableView:tableView viewForHeaderInSection:section]; UIView* view = [super tableView:tableView viewForHeaderInSection:section];
...@@ -1065,6 +1073,15 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -1065,6 +1073,15 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
forControlEvents:UIControlEventValueChanged]; forControlEvents:UIControlEventValueChanged];
break; break;
} }
case ItemTypeManagedSavePasswords: {
SettingsManagedCell* managedCell =
base::mac::ObjCCastStrict<SettingsManagedCell>(cell);
[managedCell.trailingButton
addTarget:self
action:@selector(didTapManagedUIInfoButton:)
forControlEvents:UIControlEventTouchUpInside];
break;
}
} }
return cell; return cell;
} }
......
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