Commit 41858daf authored by Guillaume Jenkins's avatar Guillaume Jenkins Committed by Chromium LUCI CQ

[iOS Enterprise] BrowserSignin: hide Recent Tabs promo

When browser sign-in is disabled by policy, replaces the sign-in promo
in the "Other devices" section of the Recent Tabs views with a message
indicating that the feature has been disabled by the managing
organization / administrator.

Bug: 1155745
Change-Id: I496e7f7ec53d721748e8a49c9a01228aa9b43548
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575260
Commit-Queue: Guillaume Jenkins <gujen@google.com>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836302}
parent 79a2bd46
...@@ -1610,6 +1610,9 @@ While in incognito, sites can't use cookies to see your browsing activity across ...@@ -1610,6 +1610,9 @@ While in incognito, sites can't use cookies to see your browsing activity across
<message name="IDS_IOS_READING_LIST_UNREAD_HEADER" desc="Header for the list containing the unread reading list entries" meaning="The entries below this header are unread. [Length: 15em]"> <message name="IDS_IOS_READING_LIST_UNREAD_HEADER" desc="Header for the list containing the unread reading list entries" meaning="The entries below this header are unread. [Length: 15em]">
Unread Unread
</message> </message>
<message name="IDS_IOS_RECENT_TABS_DISABLED_BY_ORGANIZATION" desc="This message is shown in the Other Devices section of the Recent Tabs view if browser sign-in is disabled via policy by the device's administrator / organization.">
Turned off by your organization.
</message>
<message name="IDS_IOS_RECENT_TABS_DISCLOSURE_VIEW_COLLAPSED_HINT" desc="The accessibility hint spoken to signify that the given cell expands the given section when tapped."> <message name="IDS_IOS_RECENT_TABS_DISCLOSURE_VIEW_COLLAPSED_HINT" desc="The accessibility hint spoken to signify that the given cell expands the given section when tapped.">
Expands the section. Expands the section.
</message> </message>
......
3cf86b88cafd72542b35c838fed18abbec75f271
\ No newline at end of file
...@@ -74,7 +74,9 @@ source_set("recent_tabs_ui") { ...@@ -74,7 +74,9 @@ source_set("recent_tabs_ui") {
":recent_tabs_ui_constants", ":recent_tabs_ui_constants",
"resources:recent_tabs_other_devices_empty", "resources:recent_tabs_other_devices_empty",
"//base", "//base",
"//components/prefs",
"//components/sessions", "//components/sessions",
"//components/signin/public/base",
"//components/strings", "//components/strings",
"//components/sync", "//components/sync",
"//ios/chrome/app:tests_hook", "//ios/chrome/app:tests_hook",
...@@ -83,6 +85,7 @@ source_set("recent_tabs_ui") { ...@@ -83,6 +85,7 @@ source_set("recent_tabs_ui") {
"//ios/chrome/browser/drag_and_drop", "//ios/chrome/browser/drag_and_drop",
"//ios/chrome/browser/main:public", "//ios/chrome/browser/main:public",
"//ios/chrome/browser/metrics:metrics_internal", "//ios/chrome/browser/metrics:metrics_internal",
"//ios/chrome/browser/policy:feature_flags",
"//ios/chrome/browser/sessions", "//ios/chrome/browser/sessions",
"//ios/chrome/browser/sessions:serialisation", "//ios/chrome/browser/sessions:serialisation",
"//ios/chrome/browser/sync", "//ios/chrome/browser/sync",
......
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
#include "base/notreached.h" #include "base/notreached.h"
#import "base/numerics/safe_conversions.h" #import "base/numerics/safe_conversions.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "components/prefs/pref_service.h"
#include "components/sessions/core/tab_restore_service.h" #include "components/sessions/core/tab_restore_service.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/sync_sessions/open_tabs_ui_delegate.h" #include "components/sync_sessions/open_tabs_ui_delegate.h"
#include "components/sync_sessions/session_sync_service.h" #include "components/sync_sessions/session_sync_service.h"
...@@ -22,6 +24,7 @@ ...@@ -22,6 +24,7 @@
#import "ios/chrome/browser/drag_and_drop/table_view_url_drag_drop_handler.h" #import "ios/chrome/browser/drag_and_drop/table_view_url_drag_drop_handler.h"
#import "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/metrics/new_tab_page_uma.h" #import "ios/chrome/browser/metrics/new_tab_page_uma.h"
#include "ios/chrome/browser/policy/policy_features.h"
#include "ios/chrome/browser/sessions/live_tab_context_browser_agent.h" #include "ios/chrome/browser/sessions/live_tab_context_browser_agent.h"
#include "ios/chrome/browser/sessions/session_util.h" #include "ios/chrome/browser/sessions/session_util.h"
#include "ios/chrome/browser/sync/session_sync_service_factory.h" #include "ios/chrome/browser/sync/session_sync_service_factory.h"
...@@ -97,6 +100,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -97,6 +100,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeSessionHeader, ItemTypeSessionHeader,
ItemTypeSessionTabData, ItemTypeSessionTabData,
ItemTypeShowFullHistory, ItemTypeShowFullHistory,
ItemTypeSigninDisabled,
}; };
// Key for saving whether the Other Device section is collapsed. // Key for saving whether the Other Device section is collapsed.
...@@ -494,7 +498,18 @@ API_AVAILABLE(ios(13.0)) ...@@ -494,7 +498,18 @@ API_AVAILABLE(ios(13.0))
[self.tableViewModel sectionIsCollapsed:SectionIdentifierOtherDevices]; [self.tableViewModel sectionIsCollapsed:SectionIdentifierOtherDevices];
} }
if (base::FeatureList::IsEnabled(kIllustratedEmptyStates)) { if (ShouldInstallBrowserSigninPolicyHandler() &&
!self.browserState->GetPrefs()->GetBoolean(prefs::kSigninAllowed)) {
// If sign-in is disabled, don't show an illustration or a sign-in promo.
TableViewTextItem* disabledByOrganizationText =
[[TableViewTextItem alloc] initWithType:ItemTypeSigninDisabled];
disabledByOrganizationText.text =
l10n_util::GetNSString(IDS_IOS_RECENT_TABS_DISABLED_BY_ORGANIZATION);
disabledByOrganizationText.textColor =
[UIColor colorNamed:kTextSecondaryColor];
[self.tableViewModel addItem:disabledByOrganizationText
toSectionWithIdentifier:SectionIdentifierOtherDevices];
} else if (base::FeatureList::IsEnabled(kIllustratedEmptyStates)) {
ItemType itemType; ItemType itemType;
NSString* itemSubtitle; NSString* itemSubtitle;
NSString* itemButtonText; NSString* itemButtonText;
...@@ -816,6 +831,7 @@ API_AVAILABLE(ios(13.0)) ...@@ -816,6 +831,7 @@ API_AVAILABLE(ios(13.0))
case ItemTypeOtherDevicesSyncOff: case ItemTypeOtherDevicesSyncOff:
case ItemTypeOtherDevicesNoSessions: case ItemTypeOtherDevicesNoSessions:
case ItemTypeOtherDevicesSigninPromo: case ItemTypeOtherDevicesSigninPromo:
case ItemTypeSigninDisabled:
break; break;
} }
} }
...@@ -860,8 +876,10 @@ API_AVAILABLE(ios(13.0)) ...@@ -860,8 +876,10 @@ API_AVAILABLE(ios(13.0))
itemTypeSelected == ItemTypeSessionTabData) { itemTypeSelected == ItemTypeSessionTabData) {
[self loadFaviconForCell:cell indexPath:indexPath]; [self loadFaviconForCell:cell indexPath:indexPath];
} }
// ItemTypeOtherDevicesNoSessions should not be selectable. // ItemTypeOtherDevicesNoSessions and ItemTypeSigninDisabled should not be
if (itemTypeSelected == ItemTypeOtherDevicesNoSessions) { // selectable.
if (itemTypeSelected == ItemTypeOtherDevicesNoSessions ||
itemTypeSelected == ItemTypeSigninDisabled) {
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
} }
// Set button action method for ItemTypeOtherDevicesSyncOff. // Set button action method for ItemTypeOtherDevicesSyncOff.
...@@ -997,6 +1015,7 @@ API_AVAILABLE(ios(13.0)) ...@@ -997,6 +1015,7 @@ API_AVAILABLE(ios(13.0))
case ItemTypeOtherDevicesSyncInProgressHeader: case ItemTypeOtherDevicesSyncInProgressHeader:
case ItemTypeSessionHeader: case ItemTypeSessionHeader:
case ItemTypeShowFullHistory: case ItemTypeShowFullHistory:
case ItemTypeSigninDisabled:
break; break;
} }
return nil; return nil;
......
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