forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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: Gauthier Ambard <gambard@chromium.org> Reviewed-by: Mark Cogan <marq@chromium.org> Cr-Commit-Position: refs/heads/master@{#758791}
- Loading branch information
Ewann
authored and
Commit Bot
committed
Apr 14, 2020
1 parent
b99c852
commit 5e450e9
Showing
20 changed files
with
325 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
ios/chrome/app/strings/ios_strings_grd/IDS_IOS_OPTIONS_PRIVACY_COOKIES.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c |
1 change: 1 addition & 0 deletions
1
...app/strings/ios_strings_grd/IDS_IOS_OPTIONS_PRIVACY_COOKIES_ALLOW_COOKIES_DETAIL.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c |
1 change: 1 addition & 0 deletions
1
.../app/strings/ios_strings_grd/IDS_IOS_OPTIONS_PRIVACY_COOKIES_ALLOW_COOKIES_TITLE.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c |
1 change: 1 addition & 0 deletions
1
...strings/ios_strings_grd/IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_ALL_COOKIES_DETAIL.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c |
1 change: 1 addition & 0 deletions
1
.../strings/ios_strings_grd/IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_ALL_COOKIES_TITLE.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c |
1 change: 1 addition & 0 deletions
1
...ios_strings_grd/IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_DETAIL.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c |
1 change: 1 addition & 0 deletions
1
...gs_grd/IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_INCOGNITO_TITLE.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c |
1 change: 1 addition & 0 deletions
1
.../ios_strings_grd/IDS_IOS_OPTIONS_PRIVACY_COOKIES_BLOCK_THIRD_PARTY_COOKIES_TITLE.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aea330bb9bdf26d2cd5b4fbbf38855d339559e1c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
ios/chrome/browser/ui/settings/privacy/cookies_coordinator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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_ |
56 changes: 56 additions & 0 deletions
56
ios/chrome/browser/ui/settings/privacy/cookies_coordinator.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// 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 |
33 changes: 33 additions & 0 deletions
33
ios/chrome/browser/ui/settings/privacy/cookies_view_controller.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 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_ |
96 changes: 96 additions & 0 deletions
96
ios/chrome/browser/ui/settings/privacy/cookies_view_controller.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.