Commit 7bba861c authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[ios] Add "Learn More" link to enterprise menu item

Add "Learn More" to enterprise info item in 3-dot menu. When users click
on it, the page will be navigated to chrome://management.

Bug: 1109000
Change-Id: Idf032d4402f918089a03a17d78848f644948597a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337100Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795253}
parent e3649abd
......@@ -1616,10 +1616,10 @@ While in incognito, sites can't use cookies to see your browsing activity across
Passwords
</message>
<message name="IDS_IOS_ENTERPRISE_MANAGED_SETTING_DESC_WITH_COMPANY_NAME" desc="Text displayed to inform the user that the browser is managed by Enterprise policies with company name. [iOS only]">
Managed by <ph name="COMPANY">$1<ex>Google</ex></ph>.
Managed by <ph name="COMPANY">$1<ex>Google</ex></ph>. <ph name="BEGIN_LINK">BEGIN_LINK</ph>Learn more<ph name="END_LINK">END_LINK</ph>
</message>
<message name="IDS_IOS_ENTERPRISE_MANAGED_SETTING_DESC_WITHOUT_COMPANY_NAME" desc="Text displayed to inform the user that the browser is managed by Enterprise policies without company name. [iOS only]">
Managed by your organization.
Managed by your organization. <ph name="BEGIN_LINK">BEGIN_LINK</ph>Learn more<ph name="END_LINK">END_LINK</ph>
</message>
<message name="IDS_IOS_ENTERPRISE_MANAGED_SETTING_MESSAGE" desc="Text displayed to inform the user that the setting is managed by an Enterprise policy. [iOS only]">
This setting is enforced by your administrator.
......
ef37812b8e27c8dc8c5e7f610d1fe90fc73e6330
\ No newline at end of file
9ae016edede31e27044bba22e3c57b3fda5fa294
\ No newline at end of file
73deae28268922683cf1a93aa3200463b7f37a88
\ No newline at end of file
5cd27f4c6fbcaa446840d522c30cefb499a54ab2
\ No newline at end of file
......@@ -13,6 +13,7 @@
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/material_timing.h"
#include "ios/chrome/common/string_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ios/chrome/common/ui/util/constraints_ui_util.h"
......@@ -32,6 +33,9 @@ NSMutableAttributedString* GetAttributedString(NSString* imageName,
// Add a space to have a distance with the leading icon.
NSString* fullText = [@" " stringByAppendingString:message];
NSRange range;
fullText = ParseStringWithLink(fullText, &range);
NSDictionary* generalAttributes = @{
NSForegroundColorAttributeName : [UIColor colorNamed:kTextSecondaryColor],
NSFontAttributeName :
......@@ -42,6 +46,13 @@ NSMutableAttributedString* GetAttributedString(NSString* imageName,
[[NSMutableAttributedString alloc] initWithString:fullText
attributes:generalAttributes];
NSDictionary* linkAttributes = @{
NSForegroundColorAttributeName : [UIColor colorNamed:kBlueColor],
NSFontAttributeName :
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]
};
[attributedString setAttributes:linkAttributes range:range];
// Create the leading enterprise icon.
NSTextAttachment* attachment = [[NSTextAttachment alloc] init];
attachment.image = [UIImage imageNamed:imageName];
......@@ -79,6 +90,7 @@ NSMutableAttributedString* GetAttributedString(NSString* imageName,
- (void)configureCell:(PopupMenuTextCell*)cell
withStyler:(ChromeTableViewStyler*)styler {
[super configureCell:cell withStyler:styler];
cell.userInteractionEnabled = YES;
NSMutableAttributedString* StringOfCell =
GetAttributedString(self.imageName, self.message);
cell.messageAttributedString = StringOfCell;
......@@ -113,7 +125,6 @@ NSMutableAttributedString* GetAttributedString(NSString* imageName,
reuseIdentifier:(NSString*)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.userInteractionEnabled = NO;
UIView* selectedBackgroundView = [[UIView alloc] init];
selectedBackgroundView.backgroundColor =
[UIColor colorNamed:kTableViewRowHighlightColor];
......
......@@ -24,6 +24,7 @@
#import "ios/chrome/browser/ui/popup_menu/public/popup_menu_table_view_controller.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/window_activities/window_activity_helpers.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -32,6 +33,12 @@
using base::RecordAction;
using base::UserMetricsAction;
namespace {
const char kManagementPageURL[] = "chrome://management";
} // namespace
@implementation PopupMenuActionHandler
#pragma mark - PopupMenuTableViewControllerDelegate
......@@ -203,6 +210,9 @@ using base::UserMetricsAction;
break;
}
case PopupMenuActionEnterpriseInfoMessage:
[self.dispatcher
openURLInNewTab:[OpenNewTabCommand commandWithURLFromChrome:
GURL(kManagementPageURL)]];
break;
default:
NOTREACHED() << "Unexpected identifier";
......
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