Commit 5e450e92 authored by Ewann's avatar Ewann Committed by Commit Bot

[iOS] Adds Cookies to privacy screen

 This CL creates the Cookies view controller & coordinator and adds
 Cookies to the Privacy screen. 4 options have also been added to the
 Privacy view controller.

 Bug: 1064961

Change-Id: I48534388d195f15ae199d63ef995668f0b43125b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2129708
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758791}
parent b99c852b
......@@ -1149,6 +1149,30 @@ Handoff must also be enabled in the General section of Settings, and your device
</message>
<message name="IDS_IOS_OPTIONS_PRELOAD_WEBPAGES" desc="Title for opening the setting for if/when to preload webpages. [Length: 20em] [iOS only]">
Preload Webpages
</message>
<message name="IDS_IOS_OPTIONS_PRIVACY_COOKIES" desc="Title on Privacy screen to open Cookies">
Cookies
</message>
<message name="IDS_IOS_OPTIONS_PRIVACY_COOKIES_ALLOW_COOKIES_TITLE" desc="Option title to allow cookies">
Allow Cookies
</message>
<message name="IDS_IOS_OPTIONS_PRIVACY_COOKIES_ALLOW_COOKIES_DETAIL" desc="Option detail to allow cookies">
Sites will work normally
</message>
<message name="IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_ALL_COOKIES_TITLE" desc="Option title to block all cookies">
Block All Cookies (Not recommended)
</message>
<message name="IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_ALL_COOKIES_DETAIL" desc="Option detail to block all cookies">
Features on many sites may break
</message>
<message name="IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_TITLE" desc="Option title to block third party cookies">
Block Third-Party Cookies
</message>
<message name="IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_INCOGNITO_TITLE" desc="Option title to block third party cookies in incognito">
Block Third-Party Cookies in incognito
</message>
<message name="IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_DETAIL" desc="Option detail to block third party cookies">
Features on some sites may break
</message>
<message name="IDS_IOS_OPTIONS_PRIVACY_GOOGLE_SERVICES_FOOTER" desc="Footer to invite the user to open the Sync and Google Services settings.">
For more settings that relate to privacy, security, and data collection, see <ph name="BEGIN_LINK">BEGIN_LINK</ph>Sync and Google Services<ph name="END_LINK">END_LINK</ph>.
......
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c
\ No newline at end of file
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c
\ No newline at end of file
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c
\ No newline at end of file
......@@ -5,6 +5,10 @@
source_set("privacy") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"cookies_coordinator.h",
"cookies_coordinator.mm",
"cookies_view_controller.h",
"cookies_view_controller.mm",
"handoff_table_view_controller.h",
"handoff_table_view_controller.mm",
"privacy_coordinator.h",
......@@ -28,6 +32,7 @@ source_set("privacy") {
"//ios/chrome/browser/ui/colors",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/page_info:features",
"//ios/chrome/browser/ui/settings:constants",
"//ios/chrome/browser/ui/settings:settings_root",
"//ios/chrome/browser/ui/settings/cells",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_COOKIES_COORDINATOR_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_COOKIES_COORDINATOR_H_
#import <Foundation/Foundation.h>
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
@class PrivacyCookiesCoordinator;
// Delegate that allows to dereference the PrivacyCookiesCoordinator.
@protocol PrivacyCookiesCoordinatorDelegate
// Called when the view controller is removed from navigation controller.
- (void)privacyCookiesCoordinatorViewControllerWasRemoved:
(PrivacyCookiesCoordinator*)coordinator;
@end
// The coordinator for the Cookies screen.
@interface PrivacyCookiesCoordinator : ChromeCoordinator
@property(nonatomic, weak) id<PrivacyCookiesCoordinatorDelegate> delegate;
- (instancetype)initWithBaseViewController:(UIViewController*)viewController
NS_UNAVAILABLE;
- (instancetype)initWithBaseViewController:(UIViewController*)viewController
browserState:(ChromeBrowserState*)browserState
NS_UNAVAILABLE;
- (instancetype)initWithBaseViewController:(UIViewController*)viewController
browser:(Browser*)browser NS_UNAVAILABLE;
- (instancetype)initWithBaseNavigationController:
(UINavigationController*)navigationController
browser:(Browser*)browser
NS_DESIGNATED_INITIALIZER;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_COOKIES_COORDINATOR_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/privacy/cookies_coordinator.h"
#include "base/logging.h"
#import "ios/chrome/browser/ui/settings/privacy/cookies_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface PrivacyCookiesCoordinator () <
PrivacyCookiesViewControllerPresentationDelegate>
@property(nonatomic, strong) PrivacyCookiesViewController* viewController;
@end
@implementation PrivacyCookiesCoordinator
@synthesize baseNavigationController = _baseNavigationController;
- (instancetype)initWithBaseNavigationController:
(UINavigationController*)navigationController
browser:(Browser*)browser {
if ([super initWithBaseViewController:navigationController browser:browser]) {
_baseNavigationController = navigationController;
}
return self;
}
#pragma mark - ChromeCoordinator
- (void)start {
self.viewController = [[PrivacyCookiesViewController alloc]
initWithStyle:UITableViewStylePlain];
[self.baseNavigationController pushViewController:self.viewController
animated:YES];
self.viewController.presentationDelegate = self;
}
- (void)stop {
self.viewController = nil;
}
#pragma mark - PrivacyCookiesViewControllerPresentationDelegate
- (void)privacyCookiesViewControllerWasRemoved:
(PrivacyCookiesViewController*)controller {
DCHECK_EQ(self.viewController, controller);
[self.delegate privacyCookiesCoordinatorViewControllerWasRemoved:self];
}
@end
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_COOKIES_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_COOKIES_VIEW_CONTROLLER_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/settings/settings_root_table_view_controller.h"
@class PrivacyCookiesViewController;
// Delegate for presentation events related to
// PrivacyCookiesViewController.
@protocol PrivacyCookiesViewControllerPresentationDelegate
// Called when the view controller is removed from its parent.
- (void)privacyCookiesViewControllerWasRemoved:
(PrivacyCookiesViewController*)controller;
@end
// View Controller for displaying the Cookies screen.
@interface PrivacyCookiesViewController : SettingsRootTableViewController
// Presentation delegate.
@property(nonatomic, weak) id<PrivacyCookiesViewControllerPresentationDelegate>
presentationDelegate;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_COOKIES_VIEW_CONTROLLER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/privacy/cookies_view_controller.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_multi_detail_text_item.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
typedef NS_ENUM(NSInteger, SectionIdentifier) {
SectionIdentifierContent = kSectionIdentifierEnumZero,
};
typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeAllowCookies = kItemTypeEnumZero,
ItemTypeBlockThirdPartyCookiesIncognito,
ItemTypeBlockThirdPartyCookies,
ItemTypeBlockAllCookies,
ItemTypeCookiesDescription,
};
} // namespace
@implementation PrivacyCookiesViewController
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = l10n_util::GetNSString(IDS_IOS_OPTIONS_PRIVACY_COOKIES);
[self loadModel];
// TODO(crbug.com/1064961): Implement this.
}
- (void)didMoveToParentViewController:(UIViewController*)parent {
[super didMoveToParentViewController:parent];
if (!parent) {
[self.presentationDelegate privacyCookiesViewControllerWasRemoved:self];
}
}
#pragma mark - ChromeTableViewController
- (void)loadModel {
[super loadModel];
[self.tableViewModel addSectionWithIdentifier:SectionIdentifierContent];
TableViewMultiDetailTextItem* allowCookies =
[[TableViewMultiDetailTextItem alloc] initWithType:ItemTypeAllowCookies];
allowCookies.text = l10n_util::GetNSString(
IDS_IOS_OPTIONS_PRIVACY_COOKIES_ALLOW_COOKIES_TITLE);
allowCookies.leadingDetailText = l10n_util::GetNSString(
IDS_IOS_OPTIONS_PRIVACY_COOKIES_ALLOW_COOKIES_DETAIL);
[self.tableViewModel addItem:allowCookies
toSectionWithIdentifier:SectionIdentifierContent];
TableViewMultiDetailTextItem* blockThirdPartyCookiesIncognito =
[[TableViewMultiDetailTextItem alloc]
initWithType:ItemTypeBlockThirdPartyCookiesIncognito];
blockThirdPartyCookiesIncognito.text = l10n_util::GetNSString(
IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_INCOGNITO_TITLE);
blockThirdPartyCookiesIncognito.leadingDetailText = l10n_util::GetNSString(
IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_DETAIL);
[self.tableViewModel addItem:blockThirdPartyCookiesIncognito
toSectionWithIdentifier:SectionIdentifierContent];
TableViewMultiDetailTextItem* blockThirdPartyCookies =
[[TableViewMultiDetailTextItem alloc]
initWithType:ItemTypeBlockThirdPartyCookies];
blockThirdPartyCookies.text = l10n_util::GetNSString(
IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_TITLE);
blockThirdPartyCookies.leadingDetailText = l10n_util::GetNSString(
IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_DETAIL);
[self.tableViewModel addItem:blockThirdPartyCookies
toSectionWithIdentifier:SectionIdentifierContent];
TableViewMultiDetailTextItem* blockAllCookies =
[[TableViewMultiDetailTextItem alloc]
initWithType:ItemTypeBlockAllCookies];
blockAllCookies.text = l10n_util::GetNSString(
IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_ALL_COOKIES_TITLE);
blockAllCookies.leadingDetailText = l10n_util::GetNSString(
IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_ALL_COOKIES_DETAIL);
[self.tableViewModel addItem:blockAllCookies
toSectionWithIdentifier:SectionIdentifierContent];
}
@end
......@@ -11,6 +11,7 @@
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_ui_delegate.h"
#import "ios/chrome/browser/ui/settings/privacy/cookies_coordinator.h"
#import "ios/chrome/browser/ui/settings/privacy/handoff_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/privacy/privacy_navigation_commands.h"
#import "ios/chrome/browser/ui/settings/privacy/privacy_table_view_controller.h"
......@@ -22,11 +23,13 @@
@interface PrivacyCoordinator () <
ClearBrowsingDataUIDelegate,
PrivacyCookiesCoordinatorDelegate,
PrivacyNavigationCommands,
PrivacyTableViewControllerPresentationDelegate>
@property(nonatomic, strong) id<ApplicationCommands> handler;
@property(nonatomic, strong) PrivacyTableViewController* viewController;
@property(nonatomic, strong) PrivacyCookiesCoordinator* cookiesCoordinator;
@end
......@@ -63,6 +66,25 @@
- (void)stop {
self.viewController = nil;
[self.cookiesCoordinator stop];
self.cookiesCoordinator = nil;
}
#pragma mark - PrivacyTableViewControllerPresentationDelegate
- (void)privacyTableViewControllerWasRemoved:
(PrivacyTableViewController*)controller {
DCHECK_EQ(self.viewController, controller);
[self.delegate privacyCoordinatorViewControllerWasRemoved:self];
}
#pragma mark - PrivacyCookiesCoordinatorDelegate
- (void)privacyCookiesCoordinatorViewControllerWasRemoved:
(PrivacyCookiesCoordinator*)coordinator {
DCHECK(self.cookiesCoordinator);
[coordinator stop];
coordinator = nil;
}
#pragma mark - PrivacyNavigationCommands
......@@ -86,6 +108,14 @@
animated:YES];
}
- (void)showCookies {
self.cookiesCoordinator = [[PrivacyCookiesCoordinator alloc]
initWithBaseNavigationController:self.baseNavigationController
browser:self.browser];
self.cookiesCoordinator.delegate = self;
[self.cookiesCoordinator start];
}
#pragma mark - PrivacyTableViewControllerPresentationDelegate
- (void)privacyTableViewControllerViewControllerWasRemoved:
......@@ -107,5 +137,4 @@
self.viewController.navigationController);
[navigationController closeSettings];
}
@end
......@@ -15,6 +15,9 @@
// Shows ClearBrowsingData screen.
- (void)showClearBrowsingData;
// Shows Cookies screen.
- (void)showCookies;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PRIVACY_PRIVACY_NAVIGATION_COMMANDS_H_
......@@ -20,7 +20,7 @@ extern NSString* const kPrivacyTableViewId;
@protocol PrivacyTableViewControllerPresentationDelegate
// Called when the view controller is removed from its parent.
- (void)privacyTableViewControllerViewControllerWasRemoved:
- (void)privacyTableViewControllerWasRemoved:
(PrivacyTableViewController*)controller;
@end
......
......@@ -15,6 +15,8 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/browsing_data/browsing_data_features.h"
#import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/page_info/features.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_cell.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h"
#import "ios/chrome/browser/ui/settings/privacy/privacy_navigation_commands.h"
......@@ -39,11 +41,13 @@ namespace {
typedef NS_ENUM(NSInteger, SectionIdentifier) {
SectionIdentifierWebServices = kSectionIdentifierEnumZero,
SectionIndentifierCookies,
SectionIdentifierClearBrowsingData,
};
typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeOtherDevicesHandoff = kItemTypeEnumZero,
ItemTypeCookies,
ItemTypeClearBrowsingDataClear,
// Footer to suggest the user to open Sync and Google services settings.
ItemTypeClearBrowsingDataFooter,
......@@ -112,8 +116,7 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services";
- (void)didMoveToParentViewController:(UIViewController*)parent {
[super didMoveToParentViewController:parent];
if (!parent) {
[self.presentationDelegate
privacyTableViewControllerViewControllerWasRemoved:self];
[self.presentationDelegate privacyTableViewControllerWasRemoved:self];
}
}
......@@ -129,6 +132,13 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services";
[model addItem:[self handoffDetailItem]
toSectionWithIdentifier:SectionIdentifierWebServices];
if (base::FeatureList::IsEnabled(kPageInfoChromeGuard)) {
// Cookies Section
[model addSectionWithIdentifier:SectionIndentifierCookies];
[model addItem:[self cookiesItem]
toSectionWithIdentifier:SectionIndentifierCookies];
}
// Clear Browsing Section
[model addSectionWithIdentifier:SectionIdentifierClearBrowsingData];
[model addItem:[self clearBrowsingDetailItem]
......@@ -166,6 +176,14 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services";
return showClearBrowsingDataFooterItem;
}
// Returns TableViewHeaderFooterItem instance to open Cookies screen.
- (TableViewItem*)cookiesItem {
return [self detailItemWithType:ItemTypeCookies
titleId:IDS_IOS_OPTIONS_PRIVACY_COOKIES
detailText:nil
accessibilityIdentifier:kSettingsCookiesCellId];
}
- (TableViewItem*)clearBrowsingDetailItem {
return [self detailItemWithType:ItemTypeClearBrowsingDataClear
titleId:IDS_IOS_CLEAR_BROWSING_DATA_TITLE
......@@ -214,6 +232,9 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services";
case ItemTypeClearBrowsingDataClear:
[self.handler showClearBrowsingData];
break;
case ItemTypeCookies:
[self.handler showCookies];
break;
default:
break;
}
......
......@@ -79,4 +79,7 @@ extern NSString* const kSettingsClearBrowsingDataCellId;
// The accessibility identifier of the Handoff cell.
extern NSString* const kSettingsHandoffCellId;
// The accessibility identifier of the Cookies cell.
extern NSString* const kSettingsCookiesCellId;
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_SETTINGS_TABLE_VIEW_CONTROLLER_CONSTANTS_H_
......@@ -39,3 +39,4 @@ NSString* const kSettingsAddLanguageCellId = @"kSettingsAddLanguageCellId";
NSString* const kSettingsClearBrowsingDataCellId =
@"kSettingsClearBrowsingDataCellId";
NSString* const kSettingsHandoffCellId = @"kSettingsHandoffCellId";
NSString* const kSettingsCookiesCellId = @"kSettingsCookiesCellId";
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