Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix FXIOS-10575 Protection panel: Clear Cookies + Site Data / Design QA #23226

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum TrackingProtectionActionType: ActionType {
case tappedShowClearCookiesAlert
case goBack
case updateBlockedTrackerStats
case showCookiesClearedToast
}

final class TrackingProtectionMiddlewareAction: Action { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class TrackingProtectionModel {
let clearCookiesAlertText: String = .Menu.EnhancedTrackingProtection.clearDataAlertText
let clearCookiesAlertButton: String = .Menu.EnhancedTrackingProtection.clearDataAlertButton
let clearCookiesAlertCancelButton: String = .Menu.EnhancedTrackingProtection.clearDataAlertCancelButton
let clearCookiesToastMessage: String = .Menu.EnhancedTrackingProtection.clearDataToastMessage

// MARK: Accessibility Identifiers
let foxImageA11yId: String = AccessibilityIdentifiers.EnhancedTrackingProtection.MainScreen.foxImage
Expand Down Expand Up @@ -169,7 +170,7 @@ class TrackingProtectionModel {
}

func onTapClearCookiesAndSiteData(controller: UIViewController) {
let alertMessage = String(format: clearCookiesAlertText, url.absoluteDisplayString)
let alertMessage = String(format: clearCookiesAlertText, url.baseDomain ?? url.shortDisplayString)
let alert = UIAlertController(
title: clearCookiesAlertTitle,
message: alertMessage,
Expand All @@ -181,15 +182,20 @@ class TrackingProtectionModel {

let confirmAction = UIAlertAction(title: clearCookiesAlertButton,
style: .destructive) { [weak self] _ in
self?.clearCookiesAndSiteData(cookiesClearable: CookiesClearable(), siteDataClearable: SiteDataClearable())
self?.clearCookiesAndSiteData()
self?.selectedTab?.webView?.reload()
guard let windowUUID = self?.selectedTab?.windowUUID else { return }
store.dispatch(
TrackingProtectionAction(windowUUID: windowUUID,
actionType: TrackingProtectionActionType.showCookiesClearedToast)
)
}
alert.addAction(confirmAction)
controller.present(alert, animated: true, completion: nil)
}

func clearCookiesAndSiteData(cookiesClearable: Clearable, siteDataClearable: Clearable) {
_ = cookiesClearable.clear()
_ = siteDataClearable.clear()
func clearCookiesAndSiteData() {
_ = CookiesClearable().clear()
_ = SiteDataClearable().clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
var showsClearCookiesAlert: Bool
var shouldClearCookies: Bool
var shouldUpdateBlockedTrackerStats: Bool
var showCookiesClearedToast: Bool

init(appState: AppState,
uuid: WindowUUID) {
Expand All @@ -40,7 +41,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: trackingProtectionState.showBlockedTrackers,
showsClearCookiesAlert: trackingProtectionState.showsClearCookiesAlert,
shouldClearCookies: trackingProtectionState.shouldClearCookies,
shouldUpdateBlockedTrackerStats: trackingProtectionState.shouldUpdateBlockedTrackerStats
shouldUpdateBlockedTrackerStats: trackingProtectionState.shouldUpdateBlockedTrackerStats,
showCookiesClearedToast: trackingProtectionState.showCookiesClearedToast
)
}

Expand All @@ -57,7 +59,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
}

Expand All @@ -71,7 +74,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: Bool,
showsClearCookiesAlert: Bool,
shouldClearCookies: Bool,
shouldUpdateBlockedTrackerStats: Bool
shouldUpdateBlockedTrackerStats: Bool,
showCookiesClearedToast: Bool
) {
self.windowUUID = windowUUID
self.shouldDismiss = shouldDismiss
Expand All @@ -83,6 +87,7 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
self.showsClearCookiesAlert = showsClearCookiesAlert
self.shouldClearCookies = shouldClearCookies
self.shouldUpdateBlockedTrackerStats = shouldUpdateBlockedTrackerStats
self.showCookiesClearedToast = showCookiesClearedToast
}

static let reducer: Reducer<TrackingProtectionState> = { state, action in
Expand All @@ -103,7 +108,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: true,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
case TrackingProtectionMiddlewareActionType.navigateToSettings:
return TrackingProtectionState(
Expand All @@ -116,7 +122,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
case TrackingProtectionMiddlewareActionType.showTrackingProtectionDetails:
return TrackingProtectionState(
Expand All @@ -129,7 +136,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
case TrackingProtectionMiddlewareActionType.showBlockedTrackersDetails:
return TrackingProtectionState(
Expand All @@ -142,7 +150,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: true,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
case TrackingProtectionActionType.goBack:
return TrackingProtectionState(
Expand All @@ -155,7 +164,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
case TrackingProtectionActionType.updateBlockedTrackerStats:
return TrackingProtectionState(
Expand All @@ -168,7 +178,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: true
shouldUpdateBlockedTrackerStats: true,
showCookiesClearedToast: false
)
case TrackingProtectionMiddlewareActionType.showAlert:
return TrackingProtectionState(
Expand All @@ -181,7 +192,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: true,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
case TrackingProtectionActionType.toggleTrackingProtectionStatus:
return TrackingProtectionState(
Expand All @@ -194,7 +206,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
case TrackingProtectionMiddlewareActionType.dismissTrackingProtection:
return TrackingProtectionState(
Expand All @@ -207,7 +220,22 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
case TrackingProtectionActionType.showCookiesClearedToast:
return TrackingProtectionState(
windowUUID: state.windowUUID,
shouldDismiss: false,
showTrackingProtectionSettings: false,
trackingProtectionEnabled: state.trackingProtectionEnabled,
connectionSecure: state.connectionSecure,
showDetails: false,
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: state.shouldUpdateBlockedTrackerStats,
showCookiesClearedToast: true
)
default:
return defaultState(from: state)
Expand All @@ -225,7 +253,8 @@ struct TrackingProtectionState: StateType, Equatable, ScreenState {
showBlockedTrackers: false,
showsClearCookiesAlert: false,
shouldClearCookies: false,
shouldUpdateBlockedTrackerStats: false
shouldUpdateBlockedTrackerStats: false,
showCookiesClearedToast: false
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class TrackingProtectionViewController: UIViewController,
updateBlockedTrackersCount()
} else if trackingProtectionState.shouldDismiss {
enhancedTrackingProtectionMenuDelegate?.didFinish()
} else if trackingProtectionState.showCookiesClearedToast {
showToast()
}
}

Expand Down Expand Up @@ -544,6 +546,12 @@ class TrackingProtectionViewController: UIViewController,
model.onTapClearCookiesAndSiteData(controller: self)
}

func showToast() {
SimpleToast().showAlertWithText(model.clearCookiesToastMessage,
bottomContainer: view,
theme: self.themeManager.getCurrentTheme(for: self.windowUUID))
}

func clearCookies() {}

// MARK: - Gesture Recognizer
Expand Down