Skip to content

Commit

Permalink
Merge branch 'main' into sabrina/update-fe-onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaTardio committed Oct 18, 2024
2 parents 1bdecb2 + de7be54 commit bfc49cf
Show file tree
Hide file tree
Showing 44 changed files with 1,730 additions and 240 deletions.
2 changes: 1 addition & 1 deletion Configuration/BuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 281
CURRENT_PROJECT_VERSION = 284
56 changes: 44 additions & 12 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"branch" : "sabrina/update-css-dependency",
"revision" : "12f9131bef1ce88b67becdd84af78f72d9032c10"
"revision" : "f6d44525c81213fa970f06d173fc5f490d060bf2"
}
},
{
Expand All @@ -42,7 +42,7 @@
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"branch" : "pr-releases/pr-1059",
"revision" : "3ea12cf94ab83b85c7ff06740e3a033b3be0ef92"
"revision" : "5156cce3b54ee55efb9e28a66ff831840b2ab82d"
}
},
{
Expand Down
77 changes: 77 additions & 0 deletions DuckDuckGo/AIChat/AIChatMenuVisibilityConfigurable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// AIChatMenuVisibilityConfigurable.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Combine

protocol AIChatMenuVisibilityConfigurable {
var shouldDisplayApplicationMenuShortcut: Bool { get }
var shouldDisplayToolbarShortcut: Bool { get }
var shortcutURL: URL { get }
var valuesChangedPublisher: PassthroughSubject<Void, Never> { get }
}

final class AIChatMenuConfiguration: AIChatMenuVisibilityConfigurable {
var valuesChangedPublisher = PassthroughSubject<Void, Never>()
private var cancellables = Set<AnyCancellable>()
private let preferences: AIChatPreferences

enum ShortcutType {
case applicationMenu
case toolbar
}

// MARK: - Public

var shouldDisplayApplicationMenuShortcut: Bool {
return isFeatureEnabledFor(shortcutType: .applicationMenu) && preferences.showShortcutInApplicationMenu
}

var shouldDisplayToolbarShortcut: Bool {
return isFeatureEnabledFor(shortcutType: .toolbar) && preferences.showShortcutInToolbar
}

var shortcutURL: URL {
URL(string: "https://duckduckgo.com/?q=DuckDuckGo+AI+Chat&ia=chat&duckai=2")!
}

init(preferences: AIChatPreferences = .shared) {
self.preferences = preferences
subscribeToValueChanges()
}

// MARK: - Private

private func subscribeToValueChanges() {
preferences.$showShortcutInToolbar
.merge(with: preferences.$showShortcutInApplicationMenu)
.dropFirst()
.sink { [weak self] _ in
self?.valuesChangedPublisher.send(())
}
.store(in: &cancellables)
}

private func isFeatureEnabledFor(shortcutType: ShortcutType) -> Bool {
switch shortcutType {
case .applicationMenu:
return true
case .toolbar:
return true
}
}
}
23 changes: 23 additions & 0 deletions DuckDuckGo/AIChat/AIChatTabOpener.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// AIChatTabOpener.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

struct AIChatTabOpener {
@MainActor static func openAIChatTab() {
WindowControllersManager.shared.showTab(with: .url(AIChatMenuConfiguration().shortcutURL, credential: nil, source: .ui))
}
}
3 changes: 2 additions & 1 deletion DuckDuckGo/Application/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ final class Application: NSApplication {

let mainMenu = MainMenu(featureFlagger: delegate.featureFlagger,
bookmarkManager: delegate.bookmarksManager,
faviconManager: FaviconManager.shared)
faviconManager: FaviconManager.shared,
aiChatMenuConfig: AIChatMenuConfiguration())
self.mainMenu = mainMenu

// Makes sure Spotlight search is part of Help menu
Expand Down
Binary file not shown.
15 changes: 15 additions & 0 deletions DuckDuckGo/Assets.xcassets/Images/AIChat.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "AIChat.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "AiChatPreferences.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/AutoconsentUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ extension AutoconsentUserScript {
}
let remoteConfig = self.config.settings(for: .autoconsent)
let disabledCMPs = remoteConfig["disabledCMPs"] as? [String] ?? []
let isFilterListExperimentEnabled = config.isSubfeatureEnabled(AutoconsentSubfeature.filterlistExperiment)
let isFilterListExperimentEnabled = config.isSubfeatureEnabled(AutoconsentSubfeature.filterlistExperiment2)
let enableFilterList = isFilterListExperimentEnabled && AutoconsentFilterlistExperiment.cohort == AutoconsentFilterlistExperiment.test

replyHandler([
Expand Down
80 changes: 40 additions & 40 deletions DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions DuckDuckGo/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ extension URL {
return nil
}

let privacyConfigurationManager = ContentBlocking.shared.privacyConfigurationManager
let isFilterListExperimentEnabled = privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(AutoconsentSubfeature.filterlistExperiment2)
var url = Self.duckDuckGo.appendingParameter(name: DuckDuckGoParameters.search.rawValue, value: trimmedQuery)
if isFilterListExperimentEnabled {
url = url.appendingParameter(name: "cpme", value: AutoconsentFilterlistExperiment.cohort == AutoconsentFilterlistExperiment.test ? "1" : "0")
}

// Add experimental atb parameter to SERP queries for internal users to display Privacy Reminder
// https://app.asana.com/0/1199230911884351/1205979030848528/f
Expand Down
12 changes: 12 additions & 0 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,17 @@ struct UserText {

// Misc

// AI Chat
static let aiChatShowInToolbarToggle = NSLocalizedString("ai-chat.show-in-toolbar.toggle", value: "Show AI Chat shortcut in browser toolbar", comment: "Show AI Chat in toolbar")

static let aiChatShowInApplicationMenuToggle = NSLocalizedString("ai-chat.show-in-application-menu.toggle", value: "Show “New AI Chat” in File and application menus", comment: "Show AI Chat in application menus")

static let aiChatPreferencesCaption = NSLocalizedString("ai-chat.preferences.caption", value: "Launch AI Chat faster by adding shortcuts to your browser toolbar or menu", comment: "Ai Chat preferences explanation")
static let aiChatPreferencesLearnMoreButton = NSLocalizedString("ai-chat.preferences.learn-more", value: "Learn More", comment: "AI Chat preferences button to learn more about it")

static let newAIChatMenuItem = NSLocalizedString("ai-chat.menu.new", value: "New AI Chat", comment: "Menu item to launch AI Chat")

// Duck Player Preferences
static let duckPlayerSettingsTitle = NSLocalizedString("duck-player.title", value: "Duck Player", comment: "Private YouTube Player settings title")
static let duckPlayerAlwaysOpenInPlayer = NSLocalizedString("duck-player.always-open-in-player", value: "Always open YouTube videos in Duck Player", comment: "Private YouTube Player option")
static let duckPlayerShowPlayerButtons = NSLocalizedString("duck-player.show-buttons", value: "Show option to use Duck Player over YouTube previews on hover", comment: "Private YouTube Player option")
Expand Down Expand Up @@ -614,6 +625,7 @@ struct UserText {
static let vpn = NSLocalizedString("preferences.vpn", value: "VPN", comment: "Title of the option to show the VPN preferences")
static let duckPlayer = NSLocalizedString("preferences.duck-player", value: "Duck Player", comment: "Title of the option to show the Duck Player browser preferences")
static let about = NSLocalizedString("preferences.about", value: "About", comment: "Title of the option to show the About screen")
static let aiChat = NSLocalizedString("preferences.ai-chat", value: "AI Chat", comment: "Title of the option to show AI Chat in preferences")

static let accessibility = NSLocalizedString("preferences.accessibility", value: "Accessibility", comment: "Title of the option to show the Accessibility browser preferences")
static let cookiePopUpProtection = NSLocalizedString("preferences.cookie-pop-up-protection", value: "Cookie Pop-Up Protection", comment: "Title of the option to show the Cookie Pop-Up Protection preferences")
Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,6 @@
<string>$(DISTRIBUTED_NOTIFICATIONS_PREFIX)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSMultipleInstancesProhibited</key>
<true/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
Expand Down
Loading

0 comments on commit bfc49cf

Please sign in to comment.