Commit 8c6277bf authored by harrisonsean's avatar harrisonsean Committed by Commit Bot

[iOS][Safety Check] Add support for Safe Browsing Check

Add support for Safe Browsing check

Including adding managed state popover

Add header to safety check page

Bug: 1078782
Change-Id: I26dab9d679c5ecc14779d52bc3b4b13c52586ce4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346805Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Sean Harrison <harrisonsean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799020}
parent a1e402ac
......@@ -328,6 +328,9 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_UPGRADE_AVAILABLE" desc="Text to inform the user of the presence of a new version of the application">
Chromium just got better! A new version is available.
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_PAGE_HEADER" desc="Informational header at the top of the safety check page">
Chromium can help keep you safe from data breaches, unsafe websites and more.
</message>
<message name="IDS_IOS_PASSWORD_CHECK_ERROR" desc="Description of the password check cell, explaining that Password Check failed. [iOS only]" meaning="Password Check failed due to some error.">
Chromium can't check your passwords
</message>
......
28a503a39c906bc31debe24cd73ee1100fb1fe45
\ No newline at end of file
......@@ -328,6 +328,9 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_UPGRADE_AVAILABLE" desc="Text to inform the user of the presence of a new version of the application">
Chrome just got better! A new version is available.
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_PAGE_HEADER" desc="Informational header at the top of the safety check page">
Chrome can help keep you safe from data breaches, unsafe websites and more.
</message>
<message name="IDS_IOS_PASSWORD_CHECK_ERROR" desc="Description of the password check cell, explaining that Password Check failed. [iOS only]" meaning="Password Check failed due to some error.">
Chrome can't check your passwords
</message>
......
......@@ -1742,6 +1742,18 @@ While in incognito, sites can't use cookies to see your browsing activity across
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_SAFE_BROWSING_TITLE" desc="Title for the safe browsing element of safety check" meaning="Row title to display the user's safe browsing status [CHAR_LIMIT=20]">
Safe Browsing
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_SAFE_BROWSING_DISABLED_DESC" desc="Detail text for the Safe Browsing check if the user has Safe Browsing disabled">
Off - Not recommended
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_SAFE_BROWSING_ENABLED_DESC" desc="Detail text for the Safe Browsing check if the user has Safe Browsing enabled">
Safe Browsing is on
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_SAFE_BROWSING_MANAGED_DESC" desc="Detail text for the Safe Browsing check if the user's Safe Browsing setting is managed by their administrator and disabled">
Turned off by your administrator
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_SAFE_BROWSING_DISABLED_INFO" desc="String in the popover for the Safe Browsing check to direct the user to the Sync and Google Services page if Safe Browsing is disabled">
To turn on Safe Browsing, open <ph name="BEGIN_LINK">BEGIN_LINK</ph>Sync and Google Services<ph name="END_LINK">END_LINK</ph> and tap Safe Browsing.
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_TITLE" desc="Title for the updates element of safety check" meaning="Row title to display the user's Chrome update status, and access upates [CHAR_LIMIT=20]">
Updates
</message>
......
......@@ -53,6 +53,8 @@ source_set("safety_check") {
"//ios/chrome/browser/ui/settings:settings_root",
"//ios/chrome/browser/ui/settings/cells",
"//ios/chrome/browser/ui/settings/cells:public",
"//ios/chrome/browser/ui/settings/elements:enterprise_info_popover_view_controller",
"//ios/chrome/browser/ui/settings/google_services",
"//ios/chrome/browser/ui/settings/password",
"//ios/chrome/browser/ui/settings/utils",
"//ios/chrome/browser/ui/table_view",
......
......@@ -7,6 +7,7 @@
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_consumer.h"
#import "ios/chrome/browser/ui/table_view/table_view_model.h"
......@@ -16,6 +17,9 @@
// Initializes the check types section with |items|.
- (void)setCheckItems:(NSArray<TableViewItem*>*)items;
// Initializes the safety check header with |item|.
- (void)setSafetyCheckHeaderItem:(TableViewLinkHeaderFooterItem*)item;
// Initializes the check start section with |item|.
- (void)setCheckStartItem:(TableViewItem*)item;
......
......@@ -18,19 +18,26 @@
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.h"
#import "ios/chrome/browser/ui/settings/google_services/google_services_settings_coordinator.h"
#import "ios/chrome/browser/ui/settings/password/password_issues_coordinator.h"
#import "ios/chrome/browser/ui/settings/safety_check/safety_check_mediator.h"
#import "ios/chrome/browser/ui/settings/safety_check/safety_check_navigation_commands.h"
#import "ios/chrome/browser/ui/settings/safety_check/safety_check_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/chrome/common/ui/elements/popover_label_view_controller.h"
#import "net/base/mac/url_conversions.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface SafetyCheckCoordinator () <
GoogleServicesSettingsCoordinatorDelegate,
PasswordIssuesCoordinatorDelegate,
PopoverLabelViewControllerDelegate,
SafetyCheckNavigationCommands,
SafetyCheckTableViewControllerPresentationDelegate>
......@@ -47,6 +54,14 @@
// Dispatcher which can handle changing passwords on sites.
@property(nonatomic, strong) id<ApplicationCommands> handler;
// Coordinator for the Google Services screen (SafeBrowsing toggle location).
@property(nonatomic, strong)
GoogleServicesSettingsCoordinator* googleServicesSettingsCoordinator;
// Popover view controller with error information.
@property(nonatomic, strong)
PopoverLabelViewController* errorInfoPopoverViewController;
@end
@implementation SafetyCheckCoordinator
......@@ -102,6 +117,28 @@
[self.delegate safetyCheckCoordinatorDidRemove:self];
}
#pragma mark - PopoverLabelViewControllerDelegate
- (void)didTapLinkURL:(NSURL*)URL {
GURL convertedURL = net::GURLWithNSURL(URL);
const GURL safeBrowsingURL(kSafeBrowsingStringURL);
// Take the user to Sync and Google Services page in Bling instead of desktop
// settings.
if (convertedURL == safeBrowsingURL) {
[self.errorInfoPopoverViewController
dismissViewControllerAnimated:YES
completion:^{
[self showSafeBrowsingPreferencePage];
}];
return;
}
OpenNewTabCommand* command =
[OpenNewTabCommand commandWithURLFromChrome:convertedURL];
[self.handler closeSettingsUIAndOpenURL:command];
}
#pragma mark - SafetyCheckNavigationCommands
- (void)showPasswordIssuesPage {
......@@ -120,15 +157,19 @@
- (void)showErrorInfoFrom:(UIButton*)buttonView
withText:(NSAttributedString*)text {
PopoverLabelViewController* errorInfoPopover =
self.errorInfoPopoverViewController =
[[PopoverLabelViewController alloc] initWithPrimaryAttributedString:text
secondaryAttributedString:nil];
errorInfoPopover.popoverPresentationController.sourceView = buttonView;
errorInfoPopover.popoverPresentationController.sourceRect = buttonView.bounds;
errorInfoPopover.popoverPresentationController.permittedArrowDirections =
UIPopoverArrowDirectionAny;
[self.viewController presentViewController:errorInfoPopover
self.errorInfoPopoverViewController.delegate = self;
self.errorInfoPopoverViewController.popoverPresentationController.sourceView =
buttonView;
self.errorInfoPopoverViewController.popoverPresentationController.sourceRect =
buttonView.bounds;
self.errorInfoPopoverViewController.popoverPresentationController
.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self.viewController presentViewController:self.errorInfoPopoverViewController
animated:YES
completion:nil];
}
......@@ -138,7 +179,36 @@
}
- (void)showSafeBrowsingPreferencePage {
// TODO(crbug.com/1078782): Add navigation to Safe Browsing preference page.
DCHECK(!self.googleServicesSettingsCoordinator);
self.googleServicesSettingsCoordinator =
[[GoogleServicesSettingsCoordinator alloc]
initWithBaseNavigationController:self.baseNavigationController
browser:self.browser
mode:GoogleServicesSettingsModeSettings];
self.googleServicesSettingsCoordinator.handler = self.handler;
self.googleServicesSettingsCoordinator.delegate = self;
[self.googleServicesSettingsCoordinator start];
}
- (void)showManagedInfoFrom:(UIButton*)buttonView {
EnterpriseInfoPopoverViewController* bubbleViewController =
[[EnterpriseInfoPopoverViewController alloc] initWithEnterpriseName:nil];
[self.viewController presentViewController:bubbleViewController
animated:YES
completion:nil];
// Disable the button when showing the bubble.
// The button will be enabled when close the bubble in
// (void)popoverPresentationControllerDidDismissPopover: of
// EnterpriseInfoPopoverViewController.
buttonView.enabled = NO;
// Set the anchor and arrow direction of the bubble.
bubbleViewController.popoverPresentationController.sourceView = buttonView;
bubbleViewController.popoverPresentationController.sourceRect =
buttonView.bounds;
bubbleViewController.popoverPresentationController.permittedArrowDirections =
UIPopoverArrowDirectionAny;
}
#pragma mark - PasswordIssuesCoordinatorDelegate
......@@ -155,4 +225,14 @@
return NO;
}
#pragma mark - GoogleServicesSettingsCoordinatorDelegate
- (void)googleServicesSettingsCoordinatorDidRemove:
(GoogleServicesSettingsCoordinator*)coordinator {
DCHECK_EQ(_googleServicesSettingsCoordinator, coordinator);
[self.googleServicesSettingsCoordinator stop];
self.googleServicesSettingsCoordinator.delegate = nil;
self.googleServicesSettingsCoordinator = nil;
}
@end
......@@ -11,6 +11,9 @@
#import <UIKit/UIKit.h>
// Webpage with safe browsing toggle.
extern const char kSafeBrowsingStringURL[];
class AuthenticationService;
class IOSChromePasswordCheckManager;
class PrefService;
......
......@@ -22,6 +22,10 @@
- (void)showErrorInfoFrom:(UIButton*)buttonView
withText:(NSAttributedString*)text;
// Called when the user clicks on the information button of the managed
// setting's UI. Shows a textual bubble with the information of the enterprise.
- (void)showManagedInfoFrom:(UIButton*)buttonView;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_SAFETY_CHECK_SAFETY_CHECK_NAVIGATION_COMMANDS_H_
......@@ -10,7 +10,9 @@
#import "ios/chrome/browser/ui/settings/safety_check/safety_check_navigation_commands.h"
#import "ios/chrome/browser/ui/settings/safety_check/safety_check_service_delegate.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -34,6 +36,10 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) {
// Current state of array of items that form the safety check.
@property(nonatomic, strong) NSArray<TableViewItem*>* checkTypesItems;
// Header for the safety check page.
@property(nonatomic, strong)
TableViewLinkHeaderFooterItem* safetyCheckHeaderItem;
// Current display state of the check start item.
@property(nonatomic, strong) TableViewItem* checkStartItem;
......@@ -55,6 +61,11 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) {
[self reloadData];
}
- (void)setSafetyCheckHeaderItem:(TableViewLinkHeaderFooterItem*)item {
_safetyCheckHeaderItem = item;
[self reloadData];
}
- (void)setCheckStartItem:(TableViewItem*)item {
_checkStartItem = item;
[self reloadData];
......@@ -71,6 +82,10 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) {
[self.tableViewModel addItem:item
toSectionWithIdentifier:SectionIdentifierCheckTypes];
}
if (self.safetyCheckHeaderItem) {
[self.tableViewModel setHeader:self.safetyCheckHeaderItem
forSectionWithIdentifier:SectionIdentifierCheckTypes];
}
}
if (self.checkStartItem) {
......
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