Skip to content

Commit

Permalink
Merge branch 'develop' into sam/logins-authentication
Browse files Browse the repository at this point in the history
# By Sam Macbeth (2) and others
# Via GitHub
* develop:
  Top autofill (#432)
  Option to add new notes or edit existing is disabled (#446)
  Use our own autoconsent fork (#444)
  New Feedback Form (#424)
  Update privacy dashboard (#440)
  Fix crash when background tabs trigger cookie popup (#439)
  Update clickToLoadConfig.json (#435)
  rename weakAssign to assign(to:onWeaklyHeld:) (#442)
  Improve Safari favorite importing (#436)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Loading branch information
samsymons committed Feb 25, 2022
2 parents 2987dfe + 2f3aeaa commit 1db7eb0
Show file tree
Hide file tree
Showing 68 changed files with 1,756 additions and 309 deletions.
72 changes: 72 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@
"revision": "6b2aa2748a7881eebb9f84fb10c01293e15b52ca",
"version": "0.5.0"
}
},
{
"package": "TrackerRadarKit",
"repositoryURL": "https://github.com/duckduckgo/TrackerRadarKit.git",
"state": {
"branch": null,
"revision": "5f4caf35b8418700a48c64c7c61eb43308c8dacc",
"version": "1.0.3"
}
}
]
},
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Bookmark-Color-16.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
12 changes: 12 additions & 0 deletions DuckDuckGo/Assets.xcassets/Images/ThankYou.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "ThankYou.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
5 changes: 3 additions & 2 deletions DuckDuckGo/Autoconsent/AutoconsentUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ final class AutoconsentUserScript: NSObject, UserScriptWithAutoconsent {
return
}
let now = Date.init()
guard Self.promptLastShown == nil || now > Self.promptLastShown!.addingTimeInterval(30) else {
guard Self.promptLastShown == nil || now > Self.promptLastShown!.addingTimeInterval(30),
let window = self.webview!.window else {
callback(false)
return
}
Self.promptLastShown = now
let alert = NSAlert.cookiePopup()
alert.beginSheetModal(for: self.webview!.window!, completionHandler: { response in
alert.beginSheetModal(for: window, completionHandler: { response in
switch response {
case .alertFirstButtonReturn:
// User wants to turn on the feature
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Autoconsent/background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global browser */
import AutoConsent from '@cliqz/autoconsent/lib/web'
import * as rules from '@cliqz/autoconsent/rules/rules.json'
import AutoConsent from '@duckduckgo/autoconsent/lib/web'
import * as rules from '@duckduckgo/autoconsent/rules/rules.json'

const consent = new AutoConsent(browser, browser.tabs.sendMessage)

Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/userscript.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import handleContentMessage from '@cliqz/autoconsent/lib/web/content'
import handleContentMessage from '@duckduckgo/autoconsent/lib/web/content'

window.autoconsent = (payload) => {
return handleContentMessage(payload.message, false)
Expand Down
48 changes: 48 additions & 0 deletions DuckDuckGo/Autofill/ContentOverlay.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Window Controller-->
<scene sceneID="Yd1-AJ-Qv8">
<objects>
<windowController storyboardIdentifier="ContentOverlayWindowController" id="AYn-l1-ytb" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hasShadow="NO" visibleAtLaunch="NO" appearanceType="aqua" frameAutosaveName="" animationBehavior="default" titlebarAppearsTransparent="YES" titleVisibility="hidden" id="EcH-Hu-Dez">
<windowStyleMask key="styleMask" fullSizeContentView="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="2022" y="350" width="480" height="270"/>
<rect key="screenRect" x="1728" y="37" width="1920" height="1055"/>
<view key="contentView" id="94y-sJ-ZOB">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
</view>
<connections>
<outlet property="delegate" destination="AYn-l1-ytb" id="Rr5-bI-8Mg"/>
</connections>
</window>
<connections>
<segue destination="von-g3-QJ1" kind="relationship" relationship="window.shadowedContentViewController" id="nWM-ud-rJK"/>
</connections>
</windowController>
<customObject id="e7l-sk-SA9" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-324" y="1"/>
</scene>
<!--Content Overlay View Controller-->
<scene sceneID="ZEN-nM-P55">
<objects>
<viewController storyboardIdentifier="ContentOverlayViewController" id="von-g3-QJ1" customClass="ContentOverlayViewController" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" appearanceType="aqua" id="ct2-uy-dYM">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</viewController>
<customObject id="KjB-z1-VQJ" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="409" y="1"/>
</scene>
</scenes>
</document>
96 changes: 96 additions & 0 deletions DuckDuckGo/Autofill/ContentOverlayPopover.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//
// ContentOverlayPopover.swift
//
// Copyright © 2022 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 Cocoa
import WebKit
import BrowserServicesKit

public final class ContentOverlayPopover {

public var zoomFactor: CGFloat?
public weak var currentTabView: NSView?

public var viewController: ContentOverlayViewController
public var windowController: NSWindowController

public init(currentTabView: NSView) {
let storyboard = NSStoryboard(name: "ContentOverlay", bundle: Bundle.main)
viewController = storyboard.instantiateController(identifier: "ContentOverlayViewController")
windowController = storyboard.instantiateController(identifier: "ContentOverlayWindowController")
windowController.contentViewController = viewController
windowController.window?.hasShadow = true
windowController.window?.acceptsMouseMovedEvents = true
windowController.window?.ignoresMouseEvents = false

viewController.view.wantsLayer = true
if let layer = viewController.view.layer {
layer.masksToBounds = true
layer.cornerRadius = 6
layer.borderWidth = 0.5
layer.borderColor = CGColor.init(gray: 0, alpha: 0.3) // Looks a little lighter than 0.2 in the CSS
}
viewController.view.window?.backgroundColor = .clear
viewController.view.window?.acceptsMouseMovedEvents = true
viewController.view.window?.ignoresMouseEvents = false
self.currentTabView = currentTabView
}

public required init?(coder: NSCoder) {
fatalError("ContentOverlayPopover: Bad initializer")
}
}

// MARK: - WebsiteAutofillUserScriptDelegate
extension ContentOverlayPopover: ContentOverlayUserScriptDelegate {
public func websiteAutofillUserScriptCloseOverlay(_ websiteAutofillUserScript: WebsiteAutofillUserScript?) {
guard let windowController = windowController.window else {
return
}
if !windowController.isVisible { return }
// Reset window size on close to reduce flicker
viewController.requestResizeToSize(CGSize(width: 0, height: 0))
windowController.parent?.removeChildWindow(windowController)
windowController.orderOut(nil)
}

public func websiteAutofillUserScript(_ websiteAutofillUserScript: WebsiteAutofillUserScript,
willDisplayOverlayAtClick: NSPoint,
serializedInputContext: String,
inputPosition: CGRect) {
// Combines native click with offset of JS click.
let y = (willDisplayOverlayAtClick.y - (inputPosition.height - inputPosition.minY))
let x = (willDisplayOverlayAtClick.x - inputPosition.minX)
var rectWidth = inputPosition.width
// If the field is wider we want to left assign the rectangle anchoring
if inputPosition.width > 315 {
rectWidth = 315
}
let rect = NSRect(x: x, y: y, width: rectWidth, height: inputPosition.height)

// On open initialize to default size to reduce flicker
viewController.requestResizeToSize(CGSize(width: 0, height: 0))
viewController.autofillInterfaceToChild = websiteAutofillUserScript
viewController.setType(serializedInputContext: serializedInputContext, zoomFactor: zoomFactor)
if let overlayWindow = windowController.window, let currentTabViewWindow = currentTabView?.window {
currentTabViewWindow.addChildWindow(overlayWindow, ordered: .above)
let outRect = currentTabViewWindow.convertToScreen(rect)
overlayWindow.setFrameTopLeftPoint(NSPoint(x: outRect.minX, y: outRect.minY))
}
}

}
Loading

0 comments on commit 1db7eb0

Please sign in to comment.