Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #752: Add HTTPSE file version preference to be upgradable with app
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson authored and Joel Reis committed Jan 18, 2019
1 parent 23b1355 commit 3fe6b52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions BraveShared/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extension Preferences {
}
public final class BlockFileVersion {
public static let adblock = Option<String?>(key: "blockfile.adblock", default: nil)
public static let httpse = Option<String?>(key: "blockfile.httpse", default: nil)
}
}

Expand Down
12 changes: 8 additions & 4 deletions Client/Frontend/ContentBlocker/BlocklistName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ class BlocklistName: Hashable, CustomStringConvertible, ContentBlocker {
return "<\(type(of: self)): \(self.filename)>"
}

private static let blocklistFileVersionMap: [BlocklistName: Preferences.Option<String?>] = [
BlocklistName.ad: Preferences.BlockFileVersion.adblock,
BlocklistName.https: Preferences.BlockFileVersion.httpse
]

lazy var fileVersionPref: Preferences.Option<String?>? = {
let prefMap = [BlocklistName.ad: Preferences.BlockFileVersion.adblock]
return prefMap[self]
return BlocklistName.blocklistFileVersionMap[self]
}()

lazy var fileVersion: String? = {
let adVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
return self == .ad ? adVersion : nil
guard let _ = BlocklistName.blocklistFileVersionMap[self] else { return nil }
return Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
}()

static func blocklists(forDomain domain: Domain) -> (on: Set<BlocklistName>, off: Set<BlocklistName>) {
Expand Down

0 comments on commit 3fe6b52

Please sign in to comment.