From b7710158220315e0f978a655797fd81d267a0b59 Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Fri, 12 Dec 2025 16:25:34 +1030 Subject: [PATCH] Bug 2005405 - add isPrivate to send-tab --- .../java/mozilla/appservices/fxaclient/FxaClient.kt | 6 ++++-- components/fxa-client/src/fxa_client.udl | 7 +++++-- .../fxa-client/src/internal/commands/send_tab.rs | 8 ++++++-- components/fxa-client/src/internal/send_tab.rs | 3 ++- components/fxa-client/src/push.rs | 11 +++++++++-- examples/fxa-client/src/send_tab.rs | 2 +- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/components/fxa-client/android/src/main/java/mozilla/appservices/fxaclient/FxaClient.kt b/components/fxa-client/android/src/main/java/mozilla/appservices/fxaclient/FxaClient.kt index 280c6d0748..c0d8d8e3d1 100644 --- a/components/fxa-client/android/src/main/java/mozilla/appservices/fxaclient/FxaClient.kt +++ b/components/fxa-client/android/src/main/java/mozilla/appservices/fxaclient/FxaClient.kt @@ -525,10 +525,12 @@ class FxaClient(inner: FirefoxAccount, persistCallback: PersistCallback?) : Auto * @param targetDeviceId The target Device ID * @param title The document title of the tab being sent * @param url The url of the tab being sent + * @param isPrivate Whether the tab is open as a private tab. Has a default value to help with progressive + * implementation of this new attribute, but the default should be removed at some point. */ - fun sendSingleTab(targetDeviceId: String, title: String, url: String) { + fun sendSingleTab(targetDeviceId: String, title: String, url: String, isPrivate: Boolean = false) { withMetrics { - this.inner.sendSingleTab(targetDeviceId, title, url) + this.inner.sendSingleTab(targetDeviceId, title, url, isPrivate) } } diff --git a/components/fxa-client/src/fxa_client.udl b/components/fxa-client/src/fxa_client.udl index a6d6e65056..3c00b22015 100644 --- a/components/fxa-client/src/fxa_client.udl +++ b/components/fxa-client/src/fxa_client.udl @@ -552,7 +552,7 @@ interface FirefoxAccount { /// granted the `https:///identity.mozilla.com/apps/oldsync` scope. /// [Throws=FxaError] - void send_single_tab([ByRef] string target_device_id, [ByRef] string title, [ByRef] string url ); + void send_single_tab([ByRef] string target_device_id, [ByRef] string title, [ByRef] string url, optional boolean is_private = false ); /// Use device commands to close one or more tabs on another device. @@ -929,11 +929,14 @@ dictionary CloseTabsPayload { sequence urls; }; -/// An individual entry in the navigation history of a sent tab. +/// A received tab. Mis-named as the original intent was to keep +/// the full "back" history for a tab, where this would be one such +/// entry - but that never happened. /// dictionary TabHistoryEntry { string title; string url; + boolean is_private; }; /// A client connected to the user's account. diff --git a/components/fxa-client/src/internal/commands/send_tab.rs b/components/fxa-client/src/internal/commands/send_tab.rs index 4d0588fd9d..1a4cd15947 100644 --- a/components/fxa-client/src/internal/commands/send_tab.rs +++ b/components/fxa-client/src/internal/commands/send_tab.rs @@ -38,13 +38,14 @@ impl From for crate::SendTabPayload { } impl SendTabPayload { - pub fn single_tab(title: &str, url: &str) -> (Self, telemetry::SentCommand) { + pub fn single_tab(title: &str, url: &str, private: bool) -> (Self, telemetry::SentCommand) { let sent_telemetry: telemetry::SentCommand = telemetry::SentCommand::for_send_tab(); ( SendTabPayload { entries: vec![TabHistoryEntry { title: title.to_string(), url: url.to_string(), + private, }], flow_id: sent_telemetry.flow_id.clone(), stream_id: sent_telemetry.stream_id.clone(), @@ -58,6 +59,7 @@ impl SendTabPayload { pub struct TabHistoryEntry { pub title: String, pub url: String, + pub private: bool, } impl From for crate::TabHistoryEntry { @@ -65,6 +67,7 @@ impl From for crate::TabHistoryEntry { crate::TabHistoryEntry { title: e.title, url: e.url, + is_private: e.private, } } } @@ -82,7 +85,7 @@ mod tests { #[test] fn test_payload() { - let (payload, telem) = SendTabPayload::single_tab("title", "http://example.com"); + let (payload, telem) = SendTabPayload::single_tab("title", "http://example.com", true); let json = serde_json::to_string(&payload).expect("should work"); assert_eq!(telem.flow_id.len(), 12); assert_eq!(telem.stream_id.len(), 12); @@ -90,6 +93,7 @@ mod tests { let p2: SendTabPayload = serde_json::from_str(&json).expect("should work"); // no 'PartialEq' derived so check each field individually... assert_eq!(payload.entries[0].url, "http://example.com".to_string()); + assert!(payload.entries[0].private); assert_eq!(payload.flow_id, p2.flow_id); assert_eq!(payload.stream_id, p2.stream_id); } diff --git a/components/fxa-client/src/internal/send_tab.rs b/components/fxa-client/src/internal/send_tab.rs index 3267843fbb..7bd5b5d642 100644 --- a/components/fxa-client/src/internal/send_tab.rs +++ b/components/fxa-client/src/internal/send_tab.rs @@ -43,13 +43,14 @@ impl FirefoxAccount { target_device_id: &str, title: &str, url: &str, + private: bool, ) -> Result<()> { let devices = self.get_devices(false)?; let target = devices .iter() .find(|d| d.id == target_device_id) .ok_or_else(|| Error::UnknownTargetDevice(target_device_id.to_owned()))?; - let (payload, sent_telemetry) = SendTabPayload::single_tab(title, url); + let (payload, sent_telemetry) = SendTabPayload::single_tab(title, url, private); let oldsync_key = self.get_scoped_key(scopes::OLD_SYNC)?; let command_payload = encrypt_command(oldsync_key, target, send_tab::COMMAND_NAME, &payload)?; diff --git a/components/fxa-client/src/push.rs b/components/fxa-client/src/push.rs index 2570d2765f..c8718da425 100644 --- a/components/fxa-client/src/push.rs +++ b/components/fxa-client/src/push.rs @@ -95,10 +95,16 @@ impl FirefoxAccount { /// - Device commands functionality is only available to applications that have been /// granted the `https://identity.mozilla.com/apps/oldsync` scope. #[handle_error(Error)] - pub fn send_single_tab(&self, target_device_id: &str, title: &str, url: &str) -> ApiResult<()> { + pub fn send_single_tab( + &self, + target_device_id: &str, + title: &str, + url: &str, + private: bool, + ) -> ApiResult<()> { self.internal .lock() - .send_single_tab(target_device_id, title, url) + .send_single_tab(target_device_id, title, url, private) } /// Use device commands to close one or more tabs on another device. @@ -240,4 +246,5 @@ pub struct CloseTabsPayload { pub struct TabHistoryEntry { pub title: String, pub url: String, + pub is_private: bool, } diff --git a/examples/fxa-client/src/send_tab.rs b/examples/fxa-client/src/send_tab.rs index 8cfd4cd9dd..f19284f7ad 100644 --- a/examples/fxa-client/src/send_tab.rs +++ b/examples/fxa-client/src/send_tab.rs @@ -68,7 +68,7 @@ fn poll(account: &FirefoxAccount) -> Result<()> { } fn send(account: &FirefoxAccount, device_id: String, title: String, url: String) -> Result<()> { - account.send_single_tab(&device_id, &title, &url)?; + account.send_single_tab(&device_id, &title, &url, false)?; println!("Tab sent!"); Ok(()) }