Commit e887fc7f authored by harrisonsean's avatar harrisonsean Committed by Commit Bot

[iOS][Safety Check] Add UI support for update check

Add UI for the update check, and support for base error and
offline for the update check.  Actual update check logic will be
added later after addition of support for ad-hoc queries to the service.

Bug: 1078782
Change-Id: I78a5a5b1713a8a040dde638cfbcdecbb313bbd5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352907
Commit-Queue: Sean Harrison <harrisonsean@chromium.org>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802375}
parent ee1ae00d
...@@ -328,6 +328,36 @@ locale. The strings in this file are specific to iOS. ...@@ -328,6 +328,36 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_PAGE_HEADER" desc="Informational header at the top of the safety check page"> <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. Chromium can help keep you safe from data breaches, unsafe websites and more.
</message> </message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_CHANNEL_CANARY_DESC" desc="Description text for when the app is on Canary and unable to run the check">
Not supported on Chromium Canary
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_CHANNEL_BETA_DESC" desc="Description text for when the app is on Beta and unable to run the check">
Not supported on Chromium Beta
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_UP_TO_DATE_DESC" desc="Description text for when Chromium is up to date">
Chromium is up to date
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OUT_OF_DATE_DESC" desc="Description text for when Chromium is out of date">
Chromium is out of date
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OFFLINE_DESC" desc="Description text for when updates can't be checked because the user is offline">
Offline, Chromium can't check for updates
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OFFLINE_INFO" desc="Text inside popover which is shown when the user wants to see detailed information about the error. [iOS only]" meaning="The user has no internet connection and can't check for updates.">
Chromium couldn't check for updates. Try checking your internet connection.
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_ERROR_DESC" desc="Description text for when updates can't be checked because there was an issue with the check">
Chromium can't check for updates
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_ERROR_INFO" desc="Text inside popover which is shown when the user wants to see detailed information about the error. [iOS only]" meaning="An error occured while performing the update check.">
Chromium couldn't check for updates. Try again later.
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_UNABLE_DESC" desc="Description text for when the device is not able to update to the newest version">
Chromium can't update
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_UNABLE_INFO" desc="Text inside popover which is shown when the user wants to see detailed information about the error. [iOS only]" meaning="The device is not able to update to the newest version.">
Chromium is out of date. If no update is available in the <ph name="BEGIN_LINK">BEGIN_LINK</ph>App Store<ph name="END_LINK">END_LINK</ph>, it's possible that your device doesn't support new versions of Chromium anymore.
</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."> <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 Chromium can't check your passwords
</message> </message>
......
...@@ -328,6 +328,36 @@ locale. The strings in this file are specific to iOS. ...@@ -328,6 +328,36 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_PAGE_HEADER" desc="Informational header at the top of the safety check page"> <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. Chrome can help keep you safe from data breaches, unsafe websites and more.
</message> </message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_CHANNEL_CANARY_DESC" desc="Description text for when the app is on Canary and unable to run the check">
Not supported on Chrome Canary
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_CHANNEL_BETA_DESC" desc="Description text for when the app is on Beta and unable to run the check">
Not supported on Chrome Beta
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_UP_TO_DATE_DESC" desc="Description text for when Chrome is up to date">
Google Chrome is up to date
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OUT_OF_DATE_DESC" desc="Description text for when Chrome is out of date">
Google Chrome is out of date
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OFFLINE_DESC" desc="Description text for when updates can't be checked because the user is offline">
Offline, Chrome can't check for updates
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OFFLINE_INFO" desc="Text inside popover which is shown when the user wants to see detailed information about the error. [iOS only]" meaning="The user has no internet connection and can't check for updates.">
Chrome couldn't check for updates. Try checking your internet connection.
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_ERROR_DESC" desc="Description text for when updates can't be checked because there was an issue with the check">
Chrome can't check for updates
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_ERROR_INFO" desc="Text inside popover which is shown when the user wants to see detailed information about the error. [iOS only]" meaning="An error occured while performing the update check.">
Chrome couldn't check for updates. Try again later.
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_UNABLE_DESC" desc="Description text for when the device is not able to update to the newest version">
Chrome can't update
</message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_UNABLE_INFO" desc="Text inside popover which is shown when the user wants to see detailed information about the error. [iOS only]" meaning="The device is not able to update to the newest version.">
Chrome is out of date. If no update is available in the <ph name="BEGIN_LINK">BEGIN_LINK</ph>App Store<ph name="END_LINK">END_LINK</ph>, it's possible that your device doesn't support new versions of Chrome anymore.
</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."> <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 Chrome can't check your passwords
</message> </message>
......
...@@ -1769,6 +1769,9 @@ While in incognito, sites can't use cookies to see your browsing activity across ...@@ -1769,6 +1769,9 @@ While in incognito, sites can't use cookies to see your browsing activity across
<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"> <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 Turned off by your administrator
</message> </message>
<message name="IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_MANAGED_DESC" desc="Description text for when the device has updates managed by an administrator">
Managed 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"> <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. 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>
......
9c8923bfbf2c6be6901c7d6527b11104c227b13f
\ No newline at end of file
...@@ -39,11 +39,13 @@ source_set("safety_check") { ...@@ -39,11 +39,13 @@ source_set("safety_check") {
"//components/prefs", "//components/prefs",
"//components/safe_browsing/core:features", "//components/safe_browsing/core:features",
"//components/safe_browsing/core/common:safe_browsing_prefs", "//components/safe_browsing/core/common:safe_browsing_prefs",
"//components/version_info",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/content_settings", "//ios/chrome/browser/content_settings",
"//ios/chrome/browser/main:public", "//ios/chrome/browser/main:public",
"//ios/chrome/browser/omaha",
"//ios/chrome/browser/passwords", "//ios/chrome/browser/passwords",
"//ios/chrome/browser/signin", "//ios/chrome/browser/signin",
"//ios/chrome/browser/sync", "//ios/chrome/browser/sync",
...@@ -60,9 +62,12 @@ source_set("safety_check") { ...@@ -60,9 +62,12 @@ source_set("safety_check") {
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//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/browser/upgrade",
"//ios/chrome/browser/upgrade:public",
"//ios/chrome/common", "//ios/chrome/common",
"//ios/chrome/common/ui/colors", "//ios/chrome/common/ui/colors",
"//ios/chrome/common/ui/elements:popover_label_view_controller", "//ios/chrome/common/ui/elements:popover_label_view_controller",
"//ios/web/common",
"//ui/base", "//ui/base",
] ]
frameworks = [ "UIKit.framework" ] frameworks = [ "UIKit.framework" ]
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/main/browser.h" #include "ios/chrome/browser/main/browser.h"
#include "ios/chrome/browser/passwords/ios_chrome_password_check_manager.h" #include "ios/chrome/browser/passwords/ios_chrome_password_check_manager.h"
...@@ -99,6 +101,7 @@ ...@@ -99,6 +101,7 @@
self.browser->GetBrowserState()) self.browser->GetBrowserState())
syncService:SyncSetupServiceFactory::GetForBrowserState( syncService:SyncSetupServiceFactory::GetForBrowserState(
self.browser->GetBrowserState())]; self.browser->GetBrowserState())];
self.mediator.consumer = self.viewController; self.mediator.consumer = self.viewController;
self.mediator.handler = self; self.mediator.handler = self;
self.viewController.serviceDelegate = self.mediator; self.viewController.serviceDelegate = self.mediator;
...@@ -174,8 +177,8 @@ ...@@ -174,8 +177,8 @@
completion:nil]; completion:nil];
} }
- (void)showUpdateOnAppStorePage { - (void)showUpdateAtLocation:(NSString*)location {
// TODO(crbug.com/1078782): Add navigation to App Store Chrome page. // TODO(crbug.com/1078782): Add navigation to various app update locations.
} }
- (void)showSafeBrowsingPreferencePage { - (void)showSafeBrowsingPreferencePage {
......
...@@ -30,6 +30,8 @@ class SyncSetupService; ...@@ -30,6 +30,8 @@ class SyncSetupService;
// |userPrefService|: Preference service to access safe browsing state. // |userPrefService|: Preference service to access safe browsing state.
// |passwordCheckManager|: Password check manager to enable use of the password // |passwordCheckManager|: Password check manager to enable use of the password
// check service. // check service.
// |authService|: Authentication service to check users authentication status.
// |syncService|: Sync service to check sync and sync encryption status.
- (instancetype)initWithUserPrefService:(PrefService*)userPrefService - (instancetype)initWithUserPrefService:(PrefService*)userPrefService
passwordCheckManager: passwordCheckManager:
(scoped_refptr<IOSChromePasswordCheckManager>) (scoped_refptr<IOSChromePasswordCheckManager>)
......
...@@ -8,11 +8,15 @@ ...@@ -8,11 +8,15 @@
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/version.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h" #include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "components/password_manager/core/common/password_manager_features.h" #include "components/password_manager/core/common/password_manager_features.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h" #include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/safe_browsing/core/features.h" #include "components/safe_browsing/core/features.h"
#include "components/version_info/version_info.h"
#include "ios/chrome/browser/application_context.h"
#import "ios/chrome/browser/omaha/omaha_service.h"
#include "ios/chrome/browser/passwords/ios_chrome_password_check_manager.h" #include "ios/chrome/browser/passwords/ios_chrome_password_check_manager.h"
#include "ios/chrome/browser/passwords/ios_chrome_password_check_manager_factory.h" #include "ios/chrome/browser/passwords/ios_chrome_password_check_manager_factory.h"
#include "ios/chrome/browser/passwords/password_check_observer_bridge.h" #include "ios/chrome/browser/passwords/password_check_observer_bridge.h"
...@@ -26,17 +30,23 @@ ...@@ -26,17 +30,23 @@
#import "ios/chrome/browser/ui/settings/safety_check/safety_check_table_view_controller.h" #import "ios/chrome/browser/ui/settings/safety_check/safety_check_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/utils/observable_boolean.h" #import "ios/chrome/browser/ui/settings/utils/observable_boolean.h"
#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/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_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_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/browser/upgrade/upgrade_recommended_details.h"
#include "ios/chrome/browser/upgrade/upgrade_utils.h"
#include "ios/chrome/common/channel_info.h"
#import "ios/chrome/common/string_util.h" #import "ios/chrome/common/string_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"
#include "ios/chrome/grit/ios_chromium_strings.h" #include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/web/common/url_scheme_util.h"
#import "net/base/mac/url_conversions.h" #import "net/base/mac/url_conversions.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -75,6 +85,14 @@ typedef NS_ENUM(NSInteger, UpdateCheckRowStates) { ...@@ -75,6 +85,14 @@ typedef NS_ENUM(NSInteger, UpdateCheckRowStates) {
UpdateCheckRowStateManaged, UpdateCheckRowStateManaged,
// When the check is running. // When the check is running.
UpdateCheckRowStateRunning, UpdateCheckRowStateRunning,
// When Omaha encountered an error.
UpdateCheckRowStateOmahaError,
// When there is a connectivity issue.
UpdateCheckRowStateNetError,
// When the device is too old and no longer able to update.
UpdateCheckRowStateUnableUpdate,
// When the device is on a non-supported channel.
UpdateCheckRowStateChannel,
}; };
// Enum with all possible states of the password check. // Enum with all possible states of the password check.
...@@ -225,6 +243,14 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -225,6 +243,14 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
_updateCheckItem.infoButtonHidden = YES; _updateCheckItem.infoButtonHidden = YES;
_updateCheckItem.trailingImage = nil; _updateCheckItem.trailingImage = nil;
// Show unsafe state if user already ran update check and the app is out of
// date.
// TODO(crbug.com/1078782): Add aditional check to make sure check has been
// run at least once.
if (!IsAppUpToDate()) {
_updateCheckRowState = UpdateCheckRowStateOutOfDate;
}
_passwordCheckRowState = PasswordCheckRowStateDefault; _passwordCheckRowState = PasswordCheckRowStateDefault;
_passwordCheckItem = _passwordCheckItem =
[[SettingsCheckItem alloc] initWithType:PasswordItemType]; [[SettingsCheckItem alloc] initWithType:PasswordItemType];
...@@ -242,6 +268,8 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -242,6 +268,8 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
// Show unsafe state if user already ran password check and there are // Show unsafe state if user already ran password check and there are
// compromised credentials. // compromised credentials.
// TODO(crbug.com/1078782): Add aditional check to make sure check has been
// run at least once.
if (!_passwordCheckManager->GetCompromisedCredentials().empty()) { if (!_passwordCheckManager->GetCompromisedCredentials().empty()) {
_passwordCheckRowState = PasswordCheckRowStateUnSafe; _passwordCheckRowState = PasswordCheckRowStateUnSafe;
} }
...@@ -282,16 +310,25 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -282,16 +310,25 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
[_consumer setSafetyCheckHeaderItem:self.headerItem]; [_consumer setSafetyCheckHeaderItem:self.headerItem];
[_consumer setCheckStartItem:self.checkStartItem]; [_consumer setCheckStartItem:self.checkStartItem];
// Need to reconfigure the |passwordCheckItem| to an unsafe state if there are // Need to reconfigure the safety check items if there are remaining issues
// remaining password issues. // from the last check ran.
[self reconfigurePasswordCheckItem]; [self reconfigurePasswordCheckItem];
[self reconfigureUpdateCheckItem];
[self reconfigureSafeBrowsingCheckItem];
} }
#pragma mark - PasswordCheckObserver #pragma mark - PasswordCheckObserver
- (void)passwordCheckStateDidChange:(PasswordCheckState)state { - (void)passwordCheckStateDidChange:(PasswordCheckState)state {
if (state == self.currentPasswordCheckState) if (state == self.currentPasswordCheckState) {
return; return;
}
// If password check reports the device is offline, propogate this information
// to the update check.
if (state == PasswordCheckState::kOffline) {
[self handleUpdateCheckOffline];
}
self.passwordCheckRowState = [self computePasswordCheckRowState:state]; self.passwordCheckRowState = [self computePasswordCheckRowState:state];
// Push update to the display. // Push update to the display.
...@@ -312,32 +349,37 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -312,32 +349,37 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
- (void)didSelectItem:(TableViewItem*)item { - (void)didSelectItem:(TableViewItem*)item {
ItemType type = static_cast<ItemType>(item.type); ItemType type = static_cast<ItemType>(item.type);
switch (type) { switch (type) {
// Few selections are handled here explicitly, but all states are laid out
// to have one location that shows all actions that are taken from the
// safety check page.
// i tap: tap on the info i handled by infoButtonWasTapped.
case UpdateItemType: { case UpdateItemType: {
switch (self.updateCheckRowState) { switch (self.updateCheckRowState) {
case UpdateCheckRowStateDefault: // No tap action. case UpdateCheckRowStateDefault: // No tap action.
case UpdateCheckRowStateRunning: // No tap action. case UpdateCheckRowStateRunning: // No tap action.
case UpdateCheckRowStateUpToDate: // No tap action. case UpdateCheckRowStateUpToDate: // No tap action.
case UpdateCheckRowStateChannel: // No tap action.
case UpdateCheckRowStateManaged: // i tap: Managed state popover.
case UpdateCheckRowStateOmahaError: // i tap: Show error popover.
case UpdateCheckRowStateNetError: // i tap: Show error popover.
case UpdateCheckRowStateUnableUpdate: // i tap: Show error popover.
break; break;
case UpdateCheckRowStateManaged: // Managed state popover handled by case UpdateCheckRowStateOutOfDate: // i tap: Go to app store.
// coordinator.
break;
case UpdateCheckRowStateOutOfDate: // Link to app store.
break; break;
} }
break; break;
} }
case PasswordItemType: { case PasswordItemType: {
switch (self.passwordCheckRowState) { switch (self.passwordCheckRowState) {
case PasswordCheckRowStateDefault: // No tap action. case PasswordCheckRowStateDefault: // No tap action.
case PasswordCheckRowStateRunning: // No tap action. case PasswordCheckRowStateRunning: // No tap action.
case PasswordCheckRowStateSafe: // No tap action. case PasswordCheckRowStateSafe: // No tap action.
case PasswordCheckRowStateDisabled: // i tap: Show error popover.
case PasswordCheckRowStateError: // i tap: Show error popover.
break; break;
case PasswordCheckRowStateUnSafe: case PasswordCheckRowStateUnSafe: // Go to password issues page.
[self.handler showPasswordIssuesPage]; [self.handler showPasswordIssuesPage];
break; break;
case PasswordCheckRowStateDisabled: // Popover handled by coordinator.
case PasswordCheckRowStateError: // Popover handled by coordinator.
break;
} }
break; break;
} }
...@@ -346,17 +388,15 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -346,17 +388,15 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
case SafeBrowsingCheckRowStateDefault: // No tap action. case SafeBrowsingCheckRowStateDefault: // No tap action.
case SafeBrowsingCheckRowStateRunning: // No tap action. case SafeBrowsingCheckRowStateRunning: // No tap action.
case SafeBrowsingCheckRowStateSafe: // No tap action. case SafeBrowsingCheckRowStateSafe: // No tap action.
break; case SafeBrowsingCheckRowStateManaged: // i tap: Managed state popover.
case SafeBrowsingCheckRowStateManaged: // Managed state popover handled case SafeBrowsingCheckRowStateUnsafe: // i tap: Show error popover with
// by coordinator. // link to Safe Browsing toggle
break; // page.
case SafeBrowsingCheckRowStateUnsafe:
[self.handler showSafeBrowsingPreferencePage];
break; break;
} }
break; break;
} }
case CheckStartItemType: { case CheckStartItemType: { // Start or stop a safety check.
[self checkStartOrCancel]; [self checkStartOrCancel];
break; break;
} }
...@@ -373,10 +413,18 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -373,10 +413,18 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
- (void)infoButtonWasTapped:(UIButton*)buttonView - (void)infoButtonWasTapped:(UIButton*)buttonView
usingItemType:(NSInteger)itemType { usingItemType:(NSInteger)itemType {
// Show the managed popover if needed. // Show the managed popover if needed.
if (self.safeBrowsingCheckRowState == SafeBrowsingCheckRowStateManaged) { if (itemType == SafeBrowsingItemType &&
self.safeBrowsingCheckRowState == SafeBrowsingCheckRowStateManaged) {
[self.handler showManagedInfoFrom:buttonView];
return;
}
if (itemType == UpdateItemType &&
self.updateCheckRowState == UpdateCheckRowStateManaged) {
[self.handler showManagedInfoFrom:buttonView]; [self.handler showManagedInfoFrom:buttonView];
return; return;
} }
// If not managed compute error info to show in popover, if available.
NSAttributedString* info = [self getPopoverInfoForType:itemType]; NSAttributedString* info = [self getPopoverInfoForType:itemType];
// If |info| is empty there is no popover to display. // If |info| is empty there is no popover to display.
...@@ -410,6 +458,7 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -410,6 +458,7 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
return [self attributedStringWithText:message link:safeBrowsingURL]; return [self attributedStringWithText:message link:safeBrowsingURL];
} }
case UpdateItemType: case UpdateItemType:
return [self updateCheckErrorInfoString];
case CheckStartItemType: case CheckStartItemType:
case HeaderItem: case HeaderItem:
return nil; return nil;
...@@ -417,7 +466,7 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -417,7 +466,7 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
} }
// Computes the appropriate display state of the password check row based on // Computes the appropriate display state of the password check row based on
// currentPasswordCheckState. // |currentPasswordCheckState|.
- (PasswordCheckRowStates)computePasswordCheckRowState: - (PasswordCheckRowStates)computePasswordCheckRowState:
(PasswordCheckState)newState { (PasswordCheckState)newState {
BOOL wasRunning = BOOL wasRunning =
...@@ -451,6 +500,34 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -451,6 +500,34 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
} }
} }
// Computes the appropriate error info to be displayed in the updates popover.
- (NSAttributedString*)updateCheckErrorInfoString {
NSString* message;
GURL linkURL;
switch (self.updateCheckRowState) {
case UpdateCheckRowStateDefault:
case UpdateCheckRowStateRunning:
case UpdateCheckRowStateUpToDate:
case UpdateCheckRowStateOutOfDate:
case UpdateCheckRowStateManaged:
return nil;
case UpdateCheckRowStateOmahaError:
message = l10n_util::GetNSString(
IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_ERROR_INFO);
break;
case UpdateCheckRowStateNetError:
message = l10n_util::GetNSString(
IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OFFLINE_INFO);
break;
case UpdateCheckRowStateUnableUpdate:
return nil;
case UpdateCheckRowStateChannel:
break;
}
return [self attributedStringWithText:message link:linkURL];
}
// Computes the appropriate error info to be displayed in the passwords popover. // Computes the appropriate error info to be displayed in the passwords popover.
- (NSAttributedString*)passwordCheckErrorInfo { - (NSAttributedString*)passwordCheckErrorInfo {
if (!self.passwordCheckManager->GetCompromisedCredentials().empty()) if (!self.passwordCheckManager->GetCompromisedCredentials().empty())
...@@ -591,11 +668,24 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -591,11 +668,24 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
if (self.checksRemaining) if (self.checksRemaining)
[self checkAndReconfigureSafeBrowsingState]; [self checkAndReconfigureSafeBrowsingState];
}); });
[self performUpdateCheck];
}
return;
}
// Updates |updateCheckItem| to reflect the device being offline if the check
// was running.
- (void)handleUpdateCheckOffline {
if (self.updateCheckRowState == UpdateCheckRowStateRunning) {
self.updateCheckRowState = UpdateCheckRowStateNetError;
[self reconfigureUpdateCheckItem];
} }
} }
// Checks if any of the safety checks are still running, resets |checkStartItem| // Checks if any of the safety checks are still running, resets |checkStartItem|
// if all checks have finished.. // if all checks have finished.
- (void)resetsCheckStartItemIfNeeded { - (void)resetsCheckStartItemIfNeeded {
if (self.checksRemaining) { if (self.checksRemaining) {
return; return;
...@@ -617,6 +707,30 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -617,6 +707,30 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
return updateCheckRunning || passwordCheckRunning || safeBrowsingCheckRunning; return updateCheckRunning || passwordCheckRunning || safeBrowsingCheckRunning;
} }
// Verifies if the Omaha service returned an answer, if not sets
// |updateCheckItem| to an Omaha error state.
- (void)verifyUpdateCheckComplete {
// If still in running state assume Omaha error.
if (self.updateCheckRowState == UpdateCheckRowStateRunning) {
self.updateCheckRowState = UpdateCheckRowStateOmahaError;
[self reconfigureUpdateCheckItem];
}
return;
}
// Performs the update check and triggers the display update to
// |updateCheckItem|.
- (void)performUpdateCheck {
__weak __typeof__(self) weakSelf = self;
// TODO(crbug.com/1078782): Add Omaha support after refactor.
// If after 30 seconds the Omaha server has not responded, assume Omaha error.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(30 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
[weakSelf verifyUpdateCheckComplete];
});
}
// Performs the Safe Browsing check and triggers the display update/ // Performs the Safe Browsing check and triggers the display update/
- (void)checkAndReconfigureSafeBrowsingState { - (void)checkAndReconfigureSafeBrowsingState {
if (!self.safeBrowsingPreferenceManaged) { if (!self.safeBrowsingPreferenceManaged) {
...@@ -631,7 +745,6 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -631,7 +745,6 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
// See if this was the last test. // See if this was the last test.
[self resetsCheckStartItemIfNeeded]; [self resetsCheckStartItemIfNeeded];
// Update |safeBrowsingCheckItem| display.
[self reconfigureSafeBrowsingCheckItem]; [self reconfigureSafeBrowsingCheckItem];
} }
...@@ -645,8 +758,9 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -645,8 +758,9 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
self.updateCheckItem.detailText = nil; self.updateCheckItem.detailText = nil;
self.updateCheckItem.trailingImage = nil; self.updateCheckItem.trailingImage = nil;
self.updateCheckItem.trailingImageTintColor = nil; self.updateCheckItem.trailingImageTintColor = nil;
self.updateCheckItem.accessoryType = UITableViewCellAccessoryNone;
// On any item update, see if any checks are still running. // On any item update, see if |checkStartItem| should be updated.
[self resetsCheckStartItemIfNeeded]; [self resetsCheckStartItemIfNeeded];
switch (self.updateCheckRowState) { switch (self.updateCheckRowState) {
...@@ -656,10 +770,70 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -656,10 +770,70 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
self.updateCheckItem.indicatorHidden = NO; self.updateCheckItem.indicatorHidden = NO;
break; break;
} }
case UpdateCheckRowStateManaged: case UpdateCheckRowStateUpToDate: {
case UpdateCheckRowStateUpToDate: UIImage* safeIconImage = [[UIImage imageNamed:@"settings_safe_state"]
case UpdateCheckRowStateOutOfDate: imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
self.updateCheckItem.trailingImage = safeIconImage;
self.updateCheckItem.trailingImageTintColor =
[UIColor colorNamed:kGreenColor];
self.updateCheckItem.detailText =
GetNSString(IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_UP_TO_DATE_DESC);
break; break;
}
case UpdateCheckRowStateOutOfDate: {
UIImage* unSafeIconImage = [[UIImage imageNamed:@"settings_unsafe_state"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
self.updateCheckItem.trailingImage = unSafeIconImage;
self.updateCheckItem.trailingImageTintColor =
[UIColor colorNamed:kRedColor];
self.updateCheckItem.detailText =
GetNSString(IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OUT_OF_DATE_DESC);
self.updateCheckItem.accessoryType =
UITableViewCellAccessoryDisclosureIndicator;
break;
}
case UpdateCheckRowStateManaged: {
self.updateCheckItem.infoButtonHidden = NO;
self.updateCheckItem.detailText =
GetNSString(IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_MANAGED_DESC);
break;
}
case UpdateCheckRowStateOmahaError: {
self.updateCheckItem.infoButtonHidden = NO;
self.updateCheckItem.detailText =
GetNSString(IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_ERROR_DESC);
break;
}
case UpdateCheckRowStateNetError: {
self.updateCheckItem.infoButtonHidden = NO;
self.updateCheckItem.detailText =
GetNSString(IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OFFLINE_DESC);
break;
}
case UpdateCheckRowStateUnableUpdate: {
self.updateCheckItem.infoButtonHidden = NO;
self.updateCheckItem.detailText =
GetNSString(IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_OUT_OF_DATE_DESC);
break;
}
case UpdateCheckRowStateChannel: {
switch (::GetChannel()) {
case version_info::Channel::STABLE:
case version_info::Channel::DEV:
break;
case version_info::Channel::BETA: {
self.updateCheckItem.detailText = GetNSString(
IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_CHANNEL_BETA_DESC);
break;
}
case version_info::Channel::CANARY:
case version_info::Channel::UNKNOWN: {
self.updateCheckItem.detailText = GetNSString(
IDS_IOS_SETTINGS_SAFETY_CHECK_UPDATES_CHANNEL_CANARY_DESC);
break;
}
}
}
} }
[self.consumer reconfigureCellsForItems:@[ self.updateCheckItem ]]; [self.consumer reconfigureCellsForItems:@[ self.updateCheckItem ]];
...@@ -677,7 +851,7 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -677,7 +851,7 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
self.passwordCheckItem.trailingImageTintColor = nil; self.passwordCheckItem.trailingImageTintColor = nil;
self.passwordCheckItem.accessoryType = UITableViewCellAccessoryNone; self.passwordCheckItem.accessoryType = UITableViewCellAccessoryNone;
// On any item update, see if any checks are still running. // On any item update, see if |checkStartItem| should be updated.
[self resetsCheckStartItemIfNeeded]; [self resetsCheckStartItemIfNeeded];
switch (self.passwordCheckRowState) { switch (self.passwordCheckRowState) {
...@@ -735,8 +909,9 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -735,8 +909,9 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
self.safeBrowsingCheckItem.detailText = nil; self.safeBrowsingCheckItem.detailText = nil;
self.safeBrowsingCheckItem.trailingImage = nil; self.safeBrowsingCheckItem.trailingImage = nil;
self.safeBrowsingCheckItem.trailingImageTintColor = nil; self.safeBrowsingCheckItem.trailingImageTintColor = nil;
self.safeBrowsingCheckItem.accessoryType = UITableViewCellAccessoryNone;
// On any item update, see if any checks are still running. // On any item update, see if |checkStartItem| should be updated.
[self resetsCheckStartItemIfNeeded]; [self resetsCheckStartItemIfNeeded];
switch (self.safeBrowsingCheckRowState) { switch (self.safeBrowsingCheckRowState) {
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
// Shows password issues page. // Shows password issues page.
- (void)showPasswordIssuesPage; - (void)showPasswordIssuesPage;
// Opens Chrome page in App Store for updates. // Opens update page at |location|.
- (void)showUpdateOnAppStorePage; - (void)showUpdateAtLocation:(NSString*)location;
// Shows page with Safe Browsing preference toggle. // Shows page with Safe Browsing preference toggle.
- (void)showSafeBrowsingPreferencePage; - (void)showSafeBrowsingPreferencePage;
......
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