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

android support for toggle report #187

Open
wants to merge 3 commits 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
6 changes: 4 additions & 2 deletions build/app/public/css/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -3939,12 +3939,14 @@ body.environment--macos, body.environment--browser, body.environment--windows, b
visibility: hidden;
}

.environment--ios [data-toggle-report=child] {
.environment--ios [data-toggle-report=child],
.environment--android [data-toggle-report=child] {
opacity: 0;
visibility: hidden;
}

.environment--ios [data-toggle-report=child][data-ready=true] {
.environment--ios [data-toggle-report=child][data-ready=true],
.environment--android [data-toggle-report=child][data-ready=true] {
opacity: 1;
visibility: visible;
}
76 changes: 66 additions & 10 deletions build/app/public/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -14039,12 +14039,12 @@
function privacyDashboardSendToggleReport() {
invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
invariant(window.webkit.messageHandlers.privacyDashboardSendToggleReport, "privacyDashboardSendToggleReport required");
return window.webkit.messageHandlers.privacyDashboardSendToggleReport.postMessage({});
window.webkit.messageHandlers.privacyDashboardSendToggleReport.postMessage({});
}
function privacyDashboardRejectToggleReport() {
invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
invariant(window.webkit.messageHandlers.privacyDashboardRejectToggleReport, "privacyDashboardRejectToggleReport required");
return window.webkit.messageHandlers.privacyDashboardRejectToggleReport.postMessage({});
window.webkit.messageHandlers.privacyDashboardRejectToggleReport.postMessage({});
}
function privacyDashboardSeeWhatIsSent() {
invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
Expand Down Expand Up @@ -14392,7 +14392,6 @@
/**
* {@inheritDoc common.openInNewTab}
* @type {import("./common.js").openInNewTab}
*
* ```js
* const payload = JSON.stringify({
* "url": "https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/"
Expand Down Expand Up @@ -14425,6 +14424,49 @@
invariant(typeof window.PrivacyDashboard?.submitBrokenSiteReport, "window.PrivacyDashboard.submitBrokenSiteReport required");
window.PrivacyDashboard.submitBrokenSiteReport(JSON.stringify(payload));
}
/**
* {@inheritDoc common.getToggleReportOptions}
* @type {import("./common.js").getToggleReportOptions}
* @returns {Promise<import('../../../schema/__generated__/schema.types').ToggleReportScreen>}
*/
getToggleReportOptions() {
invariant(typeof window.PrivacyDashboard?.getToggleReportOptions, "window.PrivacyDashboard.getToggleReportOptions required");
window.PrivacyDashboard.getToggleReportOptions();
return new Promise((resolve) => {
window.onGetToggleReportOptionsResponse = (data) => {
resolve(data);
Reflect.deleteProperty(window, "onGetToggleReportOptionsResponse");
};
});
}
/**
* {@inheritDoc common.sendToggleReport}
* @type {import("./common.js").sendToggleReport}
* @example
* ```js
* window.PrivacyDashboard.sendToggleReport()
* ```
*/
sendToggleReport() {
invariant(window.PrivacyDashboard?.sendToggleReport, "sendToggleReport missing");
window.PrivacyDashboard.sendToggleReport();
}
/**
* {@inheritDoc common.rejectToggleReport}
* @type {import("./common.js").rejectToggleReport}
*/
rejectToggleReport() {
invariant(window.PrivacyDashboard?.rejectToggleReport, "rejectToggleReport missing");
window.PrivacyDashboard.rejectToggleReport();
}
/**
* {@inheritDoc common.seeWhatIsSent}
* @type {import("./common.js").seeWhatIsSent}
*/
seeWhatIsSent() {
invariant(window.PrivacyDashboard?.seeWhatIsSent, "seeWhatIsSent missing");
window.PrivacyDashboard.seeWhatIsSent();
}
};
var privacyDashboardApi;
async function fetchAndroid(message) {
Expand Down Expand Up @@ -14461,6 +14503,18 @@
target: message.target
});
}
if (message instanceof FetchToggleReportOptions) {
return privacyDashboardApi.getToggleReportOptions();
}
if (message instanceof SendToggleBreakageReport) {
return privacyDashboardApi.sendToggleReport();
}
if (message instanceof RejectToggleBreakageReport) {
return privacyDashboardApi.rejectToggleReport();
}
if (message instanceof SeeWhatIsSent) {
return privacyDashboardApi.seeWhatIsSent();
}
console.warn("unhandled message", message);
}
var getBackgroundTabDataAndroid = () => {
Expand Down Expand Up @@ -17053,7 +17107,7 @@
// shared/js/ui/components/toggle-report/use-ios-animation.js
function useIosAnimation(state, dispatch) {
p2(() => {
if (platform.name !== "ios")
if (platform.name !== "ios" && platform.name !== "android")
return;
if (state.value === "animating") {
const child = (
Expand All @@ -17069,7 +17123,7 @@
}
}, [state.value]);
p2(() => {
if (platform.name !== "ios")
if (platform.name !== "ios" && platform.name !== "android")
return;
const child = (
/** @type {HTMLDivElement | null} */
Expand Down Expand Up @@ -17192,7 +17246,8 @@

// shared/js/ui/components/toggle-report.jsx
function ToggleReport() {
const innerGap = platform.name === "ios" ? "24px" : "16px";
const mobile = platform.name === "android" || platform.name === "ios";
const innerGap = mobile ? "24px" : "16px";
const desktop = platform.name === "macos" || platform.name === "windows";
const extension = platform.name === "browser";
const { value, didClickSuccessScreen } = q2(ToggleReportContext);
Expand All @@ -17204,7 +17259,7 @@
if (desktop || extension) {
return /* @__PURE__ */ y(ToggleReportWrapper, { state: state.value }, extension && /* @__PURE__ */ y(SetAutoHeight, null), /* @__PURE__ */ y(Stack, { gap: "40px" }, /* @__PURE__ */ y(Stack, { gap: "24px" }, /* @__PURE__ */ y(Stack, { gap: innerGap }, /* @__PURE__ */ y("div", { className: "medium-icon-container hero-icon--toggle-report" }), /* @__PURE__ */ y(ToggleReportTitle, null, ns.toggleReport("siteNotWorkingTitle.title")), /* @__PURE__ */ y("div", null, /* @__PURE__ */ y("h2", { className: "token-title-3 text--center" }, ns.toggleReport("siteNotWorkingSubTitle.title")), /* @__PURE__ */ y(DesktopRevealText, { state, toggle: () => dispatch("toggle") }))), state.value === "showing" && /* @__PURE__ */ y(Scrollable, null, /* @__PURE__ */ y(ToggleReportDataList, { rows: value.data })), /* @__PURE__ */ y(ToggleReportButtons, { send: () => dispatch("send"), reject: () => dispatch("reject") }))));
}
if (platform.name === "ios") {
if (mobile) {
return /* @__PURE__ */ y(ToggleReportWrapper, { state: state.value }, /* @__PURE__ */ y(Stack, { gap: "40px" }, /* @__PURE__ */ y(Stack, { gap: "24px" }, /* @__PURE__ */ y(Stack, { gap: innerGap }, /* @__PURE__ */ y("div", { className: "medium-icon-container hero-icon--toggle-report" }), /* @__PURE__ */ y(ToggleReportTitle, null, ns.toggleReport("siteNotWorkingTitle.title")), /* @__PURE__ */ y("div", null, /* @__PURE__ */ y("h2", { className: "token-title-3 text--center" }, ns.toggleReport("siteNotWorkingSubTitle.title")))), /* @__PURE__ */ y(ToggleReportButtons, { send: () => dispatch("send"), reject: () => dispatch("reject") }), state.value !== "showing" && /* @__PURE__ */ y(RevealText, { toggle: () => dispatch("toggle-ios") })), state.value === "showing" && /* @__PURE__ */ y("div", { className: "ios-separator" }, /* @__PURE__ */ y(ToggleReportDataList, { rows: value.data }))));
}
return /* @__PURE__ */ y("p", null, "unsupported platform: ", platform.name);
Expand Down Expand Up @@ -17232,9 +17287,10 @@
return null;
}
function ToggleReportButtons({ send, reject }) {
const buttonVariant = platform.name === "ios" ? "ios-secondary" : "macos-standard";
const buttonLayout = platform.name === "ios" ? "vertical" : "horizontal";
const buttonSize = platform.name === "ios" ? "big" : "small";
const mobile = platform.name === "ios" || platform.name === "android";
const buttonVariant = mobile ? "ios-secondary" : "macos-standard";
const buttonLayout = mobile ? "vertical" : "horizontal";
const buttonSize = mobile ? "big" : "small";
return /* @__PURE__ */ y(ButtonBar, { layout: buttonLayout }, /* @__PURE__ */ y(Button, { variant: buttonVariant, btnSize: buttonSize, onClick: reject }, ns.toggleReport("dontSendReport.title")), /* @__PURE__ */ y(Button, { variant: buttonVariant, btnSize: buttonSize, onClick: send }, ns.report("sendReport.title")));
}
function RevealText({ toggle }) {
Expand Down
5 changes: 4 additions & 1 deletion integration-tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export async function playTimeline(page, state, platform) {
if (platform.name === 'windows') {
messages.windowsViewModel = state.toWindowsViewModel()
}
if (platform.name === 'ios' || platform.name === 'macos') {
messages.privacyDashboardGetToggleReportOptions = toggleReportScreen
}
await page.evaluate(mockDataProvider, { state, platform, messages })
return messages
}
Expand All @@ -52,7 +55,7 @@ export function installWindowsMocks(page) {
export async function installWebkitMocks(page, _args) {
await page.waitForFunction(() => typeof window.onChangeRequestData === 'function')
return page.evaluate(webkitMockApis, {
responses: {
messages: {
privacyDashboardGetToggleReportOptions: toggleReportScreen,
},
})
Expand Down
68 changes: 67 additions & 1 deletion shared/js/browser/android-communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import { setupBlurOnLongPress, setupGlobalOpenerListener } from '../ui/views/uti
import {
CheckBrokenSiteReportHandledMessage,
CloseMessage,
FetchToggleReportOptions,
OpenSettingsMessages,
RejectToggleBreakageReport,
SeeWhatIsSent,
SendToggleBreakageReport,
SetListsMessage,
setupColorScheme,
SubmitBrokenSiteReportMessage,
Expand Down Expand Up @@ -287,7 +291,6 @@ export class PrivacyDashboardJavascriptInterface {
/**
* {@inheritDoc common.openInNewTab}
* @type {import("./common.js").openInNewTab}
*
* ```js
* const payload = JSON.stringify({
* "url": "https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/"
Expand Down Expand Up @@ -322,6 +325,53 @@ export class PrivacyDashboardJavascriptInterface {
invariant(typeof window.PrivacyDashboard?.submitBrokenSiteReport, 'window.PrivacyDashboard.submitBrokenSiteReport required')
window.PrivacyDashboard.submitBrokenSiteReport(JSON.stringify(payload))
}

/**
* {@inheritDoc common.getToggleReportOptions}
* @type {import("./common.js").getToggleReportOptions}
* @returns {Promise<import('../../../schema/__generated__/schema.types').ToggleReportScreen>}
*/
getToggleReportOptions() {
invariant(typeof window.PrivacyDashboard?.getToggleReportOptions, 'window.PrivacyDashboard.getToggleReportOptions required')
window.PrivacyDashboard.getToggleReportOptions()
return new Promise((resolve) => {
window.onGetToggleReportOptionsResponse = (data) => {
resolve(data)
Reflect.deleteProperty(window, 'onGetToggleReportOptionsResponse')
}
})
}

/**
* {@inheritDoc common.sendToggleReport}
* @type {import("./common.js").sendToggleReport}
* @example
* ```js
* window.PrivacyDashboard.sendToggleReport()
* ```
*/
sendToggleReport() {
invariant(window.PrivacyDashboard?.sendToggleReport, 'sendToggleReport missing')
window.PrivacyDashboard.sendToggleReport()
}

/**
* {@inheritDoc common.rejectToggleReport}
* @type {import("./common.js").rejectToggleReport}
*/
rejectToggleReport() {
invariant(window.PrivacyDashboard?.rejectToggleReport, 'rejectToggleReport missing')
window.PrivacyDashboard.rejectToggleReport()
}

/**
* {@inheritDoc common.seeWhatIsSent}
* @type {import("./common.js").seeWhatIsSent}
*/
seeWhatIsSent() {
invariant(window.PrivacyDashboard?.seeWhatIsSent, 'seeWhatIsSent missing')
window.PrivacyDashboard.seeWhatIsSent()
}
}

/**
Expand Down Expand Up @@ -375,6 +425,22 @@ async function fetchAndroid(message) {
})
}

if (message instanceof FetchToggleReportOptions) {
return privacyDashboardApi.getToggleReportOptions()
}

if (message instanceof SendToggleBreakageReport) {
return privacyDashboardApi.sendToggleReport()
}

if (message instanceof RejectToggleBreakageReport) {
return privacyDashboardApi.rejectToggleReport()
}

if (message instanceof SeeWhatIsSent) {
return privacyDashboardApi.seeWhatIsSent()
}

console.warn('unhandled message', message)
}

Expand Down
14 changes: 10 additions & 4 deletions shared/js/browser/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,31 +280,37 @@

/**
* Fetch the data needed to display the toggle report screen
* @returns {Promise<import('../../../schema/__generated__/schema.types').ToggleReportScreen>}
*/
export async function getToggleReportOptions() {
throw new Error('base impl')
}

/**
* Send the toggle report
* @returns {Promise<void>}
*/
export async function sendToggleReport() {
export function sendToggleReport() {
throw new Error('base impl')
}

/**
* Reject sending the toggle report
* @returns {Promise<void>}
*/
export async function rejectToggleReport() {
export function rejectToggleReport() {
throw new Error('base impl')
}

/**
* Sent when the user expands the disclosure
*/
export function seeWhatIsSent() {
throw new Error('base impl')
}

/**
* Sent when the user expands the disclosure
*/
export function seeWhatIsSent() {

Check failure on line 313 in shared/js/browser/common.js

View workflow job for this annotation

GitHub Actions / test

'seeWhatIsSent' is already defined
throw new Error('base impl')
}

Expand Down
4 changes: 2 additions & 2 deletions shared/js/browser/macos-communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export function privacyDashboardGetToggleReportOptions() {
export function privacyDashboardSendToggleReport() {
invariant(window.webkit?.messageHandlers, 'webkit.messageHandlers required')
invariant(window.webkit.messageHandlers.privacyDashboardSendToggleReport, 'privacyDashboardSendToggleReport required')
return window.webkit.messageHandlers.privacyDashboardSendToggleReport.postMessage({})
window.webkit.messageHandlers.privacyDashboardSendToggleReport.postMessage({})
}

/**
Expand All @@ -335,7 +335,7 @@ export function privacyDashboardSendToggleReport() {
export function privacyDashboardRejectToggleReport() {
invariant(window.webkit?.messageHandlers, 'webkit.messageHandlers required')
invariant(window.webkit.messageHandlers.privacyDashboardRejectToggleReport, 'privacyDashboardRejectToggleReport required')
return window.webkit.messageHandlers.privacyDashboardRejectToggleReport.postMessage({})
window.webkit.messageHandlers.privacyDashboardRejectToggleReport.postMessage({})
}

/**
Expand Down
Loading
Loading