Commit e033ca47 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Add Safe Browsing opt out setting.

Bug: none
Change-Id: Iaf328b22a6fba65a1d9a6deb837f379cd9405b5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088187
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751135}
parent ff49f990
...@@ -782,6 +782,12 @@ locale. The strings in this file are specific to iOS. ...@@ -782,6 +782,12 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_TEXT" desc="Feature title in the settings for the user to enable/disable, to have autocomplete searches and URLs. Text related to 'Sends searches from the address bar and search box, and some cookies to your default search engine' [iOS only]"> <message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_TEXT" desc="Feature title in the settings for the user to enable/disable, to have autocomplete searches and URLs. Text related to 'Sends searches from the address bar and search box, and some cookies to your default search engine' [iOS only]">
Autocomplete Searches and URLs Autocomplete Searches and URLs
</message> </message>
<message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_DETAIL" desc="Feature detail text in the setting to enable/disable safe browsing">
Sends URLs of some pages you visit to Google, when your security is at risk
</message>
<message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_TEXT" desc="The section title of 'Protects you and your device from dangerous sites'">
Safe Browsing (protects you and your device from dangerous sites)
</message>
<message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_DETAIL" desc="Detail text for a feature in the settings for the user to enable/disable, to make searches andn browsing better. Related to 'Make searches and browsing better'. [iOS only]"> <message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_DETAIL" desc="Detail text for a feature in the settings for the user to enable/disable, to make searches andn browsing better. Related to 'Make searches and browsing better'. [iOS only]">
Sends URLs of pages you visit to Google. Sends URLs of pages you visit to Google.
</message> </message>
......
8d5ac95eb4a3f7d3ef575f237309e1f8c7a50bae
\ No newline at end of file
...@@ -82,6 +82,7 @@ source_set("browser_prefs") { ...@@ -82,6 +82,7 @@ source_set("browser_prefs") {
"//ios/chrome/browser/voice:prefs", "//ios/chrome/browser/voice:prefs",
"//ios/chrome/browser/web", "//ios/chrome/browser/web",
"//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser",
"//ios/web/common:features",
"//ui/base", "//ui/base",
] ]
} }
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#include "ios/chrome/browser/voice/voice_search_prefs_registration.h" #include "ios/chrome/browser/voice/voice_search_prefs_registration.h"
#import "ios/chrome/browser/web/font_size_tab_helper.h" #import "ios/chrome/browser/web/font_size_tab_helper.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/web/common/features.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
......
...@@ -40,6 +40,8 @@ source_set("google_services") { ...@@ -40,6 +40,8 @@ source_set("google_services") {
"//components/metrics", "//components/metrics",
"//components/password_manager/core/common", "//components/password_manager/core/common",
"//components/prefs", "//components/prefs",
"//components/safe_browsing/core:features",
"//components/safe_browsing/core/common:safe_browsing_prefs",
"//components/signin/public/identity_manager", "//components/signin/public/identity_manager",
"//components/signin/public/identity_manager/objc", "//components/signin/public/identity_manager/objc",
"//components/strings", "//components/strings",
...@@ -74,6 +76,7 @@ source_set("google_services") { ...@@ -74,6 +76,7 @@ source_set("google_services") {
"//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/images", "//ios/public/provider/chrome/browser/images",
"//ios/public/provider/chrome/browser/signin", "//ios/public/provider/chrome/browser/signin",
"//ios/web/common:features",
"//ui/base", "//ui/base",
] ]
allow_circular_includes_from = [ allow_circular_includes_from = [
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "components/password_manager/core/common/password_manager_features.h" #include "components/password_manager/core/common/password_manager_features.h"
#include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/password_manager/core/common/password_manager_pref_names.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/features.h"
#import "components/signin/public/identity_manager/objc/identity_manager_observer_bridge.h" #import "components/signin/public/identity_manager/objc/identity_manager_observer_bridge.h"
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "components/ukm/ios/features.h" #include "components/ukm/ios/features.h"
...@@ -44,6 +46,7 @@ ...@@ -44,6 +46,7 @@
#endif #endif
using l10n_util::GetNSString; using l10n_util::GetNSString;
using safe_browsing::kSafeBrowsingAvailableOnIOS;
typedef NSArray<TableViewItem*>* ItemArray; typedef NSArray<TableViewItem*>* ItemArray;
...@@ -80,6 +83,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -80,6 +83,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
ManageSyncItemType, ManageSyncItemType,
// NonPersonalizedSectionIdentifier section. // NonPersonalizedSectionIdentifier section.
AutocompleteSearchesAndURLsItemType, AutocompleteSearchesAndURLsItemType,
SafeBrowsingItemType,
ImproveChromeItemType, ImproveChromeItemType,
BetterSearchAndBrowsingItemType, BetterSearchAndBrowsingItemType,
ItemTypePasswordLeakCheckSwitch, ItemTypePasswordLeakCheckSwitch,
...@@ -135,6 +139,9 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -135,6 +139,9 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
// Preference value for the "Autocomplete searches and URLs" feature. // Preference value for the "Autocomplete searches and URLs" feature.
@property(nonatomic, strong, readonly) @property(nonatomic, strong, readonly)
PrefBackedBoolean* autocompleteSearchPreference; PrefBackedBoolean* autocompleteSearchPreference;
// Preference value for the "Safe Browsing" feature.
@property(nonatomic, strong, readonly)
PrefBackedBoolean* safeBrowsingPreference;
// Preference value for the "Help improve Chromium's features" feature. // Preference value for the "Help improve Chromium's features" feature.
@property(nonatomic, strong, readonly) @property(nonatomic, strong, readonly)
PrefBackedBoolean* sendDataUsagePreference; PrefBackedBoolean* sendDataUsagePreference;
...@@ -179,6 +186,12 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -179,6 +186,12 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
initWithPrefService:userPrefService initWithPrefService:userPrefService
prefName:prefs::kSearchSuggestEnabled]; prefName:prefs::kSearchSuggestEnabled];
_autocompleteSearchPreference.observer = self; _autocompleteSearchPreference.observer = self;
if (base::FeatureList::IsEnabled(kSafeBrowsingAvailableOnIOS)) {
_safeBrowsingPreference = [[PrefBackedBoolean alloc]
initWithPrefService:userPrefService
prefName:prefs::kSafeBrowsingEnabled];
_safeBrowsingPreference.observer = self;
}
_sendDataUsagePreference = [[PrefBackedBoolean alloc] _sendDataUsagePreference = [[PrefBackedBoolean alloc]
initWithPrefService:localPrefService initWithPrefService:localPrefService
prefName:metrics::prefs::kMetricsReportingEnabled]; prefName:metrics::prefs::kMetricsReportingEnabled];
...@@ -510,6 +523,9 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -510,6 +523,9 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
case AutocompleteSearchesAndURLsItemType: case AutocompleteSearchesAndURLsItemType:
switchItem.on = self.autocompleteSearchPreference.value; switchItem.on = self.autocompleteSearchPreference.value;
break; break;
case SafeBrowsingItemType:
switchItem.on = self.safeBrowsingPreference.value;
break;
case ImproveChromeItemType: case ImproveChromeItemType:
switchItem.on = self.sendDataUsagePreference.value; switchItem.on = self.sendDataUsagePreference.value;
break; break;
...@@ -563,13 +579,26 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -563,13 +579,26 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
- (ItemArray)nonPersonalizedItems { - (ItemArray)nonPersonalizedItems {
if (!_nonPersonalizedItems) { if (!_nonPersonalizedItems) {
SyncSwitchItem* autocompleteSearchesAndURLsItem = [self NSMutableArray* items = [NSMutableArray array];
SyncSwitchItem* autocompleteItem = [self
switchItemWithItemType:AutocompleteSearchesAndURLsItemType switchItemWithItemType:AutocompleteSearchesAndURLsItemType
textStringID: textStringID:
IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_TEXT IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_TEXT
detailStringID: detailStringID:
IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_DETAIL IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_DETAIL
dataType:0]; dataType:0];
[items addObject:autocompleteItem];
if (base::FeatureList::IsEnabled(kSafeBrowsingAvailableOnIOS)) {
SyncSwitchItem* safeBrowsingItem = [self
switchItemWithItemType:SafeBrowsingItemType
textStringID:
IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_TEXT
detailStringID:
IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_DETAIL
dataType:0];
[items addObject:safeBrowsingItem];
}
[items addObject:self.passwordLeakCheckItem];
SyncSwitchItem* improveChromeItem = SyncSwitchItem* improveChromeItem =
[self switchItemWithItemType:ImproveChromeItemType [self switchItemWithItemType:ImproveChromeItemType
textStringID: textStringID:
...@@ -577,19 +606,18 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -577,19 +606,18 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
detailStringID: detailStringID:
IDS_IOS_GOOGLE_SERVICES_SETTINGS_IMPROVE_CHROME_DETAIL IDS_IOS_GOOGLE_SERVICES_SETTINGS_IMPROVE_CHROME_DETAIL
dataType:0]; dataType:0];
[items addObject:improveChromeItem];
SyncSwitchItem* betterSearchAndBrowsingItemType = [self SyncSwitchItem* betterSearchAndBrowsingItemType = [self
switchItemWithItemType:BetterSearchAndBrowsingItemType switchItemWithItemType:BetterSearchAndBrowsingItemType
textStringID: textStringID:
IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_TEXT IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_TEXT
detailStringID: detailStringID:
IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_DETAIL IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_DETAIL
dataType:0]; dataType:0];
betterSearchAndBrowsingItemType.accessibilityIdentifier = betterSearchAndBrowsingItemType.accessibilityIdentifier =
kBetterSearchAndBrowsingItemAccessibilityID; kBetterSearchAndBrowsingItemAccessibilityID;
_nonPersonalizedItems = @[ [items addObject:betterSearchAndBrowsingItemType];
autocompleteSearchesAndURLsItem, self.passwordLeakCheckItem, _nonPersonalizedItems = items;
improveChromeItem, betterSearchAndBrowsingItemType
];
} }
return _nonPersonalizedItems; return _nonPersonalizedItems;
} }
...@@ -732,6 +760,9 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -732,6 +760,9 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
case AutocompleteSearchesAndURLsItemType: case AutocompleteSearchesAndURLsItemType:
self.autocompleteSearchPreference.value = value; self.autocompleteSearchPreference.value = value;
break; break;
case SafeBrowsingItemType:
self.safeBrowsingPreference.value = value;
break;
case ImproveChromeItemType: case ImproveChromeItemType:
self.sendDataUsagePreference.value = value; self.sendDataUsagePreference.value = value;
// Don't set value if sendDataUsageWifiOnlyPreference has not been // Don't set value if sendDataUsageWifiOnlyPreference has not been
...@@ -810,6 +841,7 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -810,6 +841,7 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
case SyncDisabledByAdministratorErrorItemType: case SyncDisabledByAdministratorErrorItemType:
case SyncSettingsNotCofirmedErrorItemType: case SyncSettingsNotCofirmedErrorItemType:
case AutocompleteSearchesAndURLsItemType: case AutocompleteSearchesAndURLsItemType:
case SafeBrowsingItemType:
case ItemTypePasswordLeakCheckSwitch: case ItemTypePasswordLeakCheckSwitch:
case ImproveChromeItemType: case ImproveChromeItemType:
case BetterSearchAndBrowsingItemType: case BetterSearchAndBrowsingItemType:
......
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