1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

adapt chromium_importer to match conventions established by autofill:

• eliminate extern c and unsafe rust from chromium_importer logic (still called in prior napi/lib.rs)
• use CommandInput / CommandResult JSON pattern to call objc methods
• remove usage of libc to cleanup memory and remove this dependency
This commit is contained in:
John Harrington
2025-12-04 11:02:19 -07:00
parent 7beed6eb1e
commit 16a0aad849
19 changed files with 270 additions and 129 deletions

View File

@@ -256,7 +256,7 @@ export declare namespace chromium_importer {
export function getMetadata(masBuild: boolean): Record<string, NativeImporterMetadata>
export function getAvailableProfiles(browser: string): Array<ProfileInfo>
export function importLogins(browser: string, profileId: string, masBuild: boolean): Promise<Array<LoginImportResult>>
export function requestBrowserAccess(browser: string, masBuild: boolean): void
export function requestBrowserAccess(browser: string, masBuild: boolean): Promise<void>
}
export declare namespace autotype {
export function getForegroundWindowTitle(): string

View File

@@ -1195,17 +1195,14 @@ pub mod chromium_importer {
}
#[napi]
pub fn request_browser_access(_browser: String, _mas_build: bool) -> napi::Result<()> {
pub async fn request_browser_access(_browser: String, _mas_build: bool) -> napi::Result<()> {
#[cfg(target_os = "macos")]
{
chromium_importer::chromium::request_browser_access(&_browser, _mas_build)
.map_err(|e| napi::Error::from_reason(e.to_string()))
}
return chromium_importer::chromium::request_browser_access(&_browser, _mas_build)
.await
.map_err(|e| napi::Error::from_reason(e.to_string()));
#[cfg(not(target_os = "macos"))]
{
// No-op outside of Mac OS
Ok(())
}
Ok(())
}
}