1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

fix breaking changes caused by PM-27081

This commit is contained in:
John Harrington
2025-12-04 20:10:10 -07:00
parent e75dfe55ec
commit 13547d5af0
6 changed files with 28 additions and 7 deletions

View File

@@ -76,7 +76,18 @@ impl InstalledBrowserRetriever for DefaultInstalledBrowserRetriever {
} }
} }
pub fn get_available_profiles(browser_name: &str) -> Result<Vec<ProfileInfo>> { pub async fn get_available_profiles(
browser_name: &str,
mas_build: bool,
) -> Result<Vec<ProfileInfo>> {
// MAS builds need to resume security-scoped access before reading browser files
#[cfg(target_os = "macos")]
let _access = if mas_build {
Some(platform::sandbox::ScopedBrowserAccess::resume(browser_name).await?)
} else {
None
};
let (_, local_state) = load_local_state_for_browser(browser_name)?; let (_, local_state) = load_local_state_for_browser(browser_name)?;
Ok(get_profile_info(&local_state)) Ok(get_profile_info(&local_state))
} }

View File

@@ -61,12 +61,18 @@ pub mod sandbox {
.find(|b| b.name == browser_name) .find(|b| b.name == browser_name)
.ok_or_else(|| anyhow!("Unsupported browser: {}", browser_name))?; .ok_or_else(|| anyhow!("Unsupported browser: {}", browser_name))?;
// For macOS, data_dir is always a single-element array
let relative_path = config
.data_dir
.first()
.ok_or_else(|| anyhow!("No data directory configured for browser"))?;
let input = CommandInput { let input = CommandInput {
namespace: "chromium_importer".to_string(), namespace: "chromium_importer".to_string(),
command: "request_access".to_string(), command: "request_access".to_string(),
params: serde_json::json!({ params: serde_json::json!({
"browserName": browser_name, "browserName": browser_name,
"relativePath": config.data_dir, "relativePath": relative_path,
}), }),
}; };

View File

@@ -254,7 +254,7 @@ export declare namespace chromium_importer {
} }
/** Returns OS aware metadata describing supported Chromium based importers as a JSON string. */ /** Returns OS aware metadata describing supported Chromium based importers as a JSON string. */
export function getMetadata(masBuild: boolean): Record<string, NativeImporterMetadata> export function getMetadata(masBuild: boolean): Record<string, NativeImporterMetadata>
export function getAvailableProfiles(browser: string): Array<ProfileInfo> export function getAvailableProfiles(browser: string, masBuild: boolean): Promise<Array<ProfileInfo>>
export function importLogins(browser: string, profileId: string, masBuild: boolean): Promise<Array<LoginImportResult>> export function importLogins(browser: string, profileId: string, masBuild: boolean): Promise<Array<LoginImportResult>>
export function requestBrowserAccess(browser: string, masBuild: boolean): Promise<void> export function requestBrowserAccess(browser: string, masBuild: boolean): Promise<void>
} }

View File

@@ -1168,8 +1168,12 @@ pub mod chromium_importer {
} }
#[napi] #[napi]
pub fn get_available_profiles(browser: String) -> napi::Result<Vec<ProfileInfo>> { pub async fn get_available_profiles(
chromium_importer::chromium::get_available_profiles(&browser) browser: String,
mas_build: bool,
) -> napi::Result<Vec<ProfileInfo>> {
chromium_importer::chromium::get_available_profiles(&browser, mas_build)
.await
.map(|profiles| profiles.into_iter().map(ProfileInfo::from).collect()) .map(|profiles| profiles.into_iter().map(ProfileInfo::from).collect())
.map_err(|e| napi::Error::from_reason(e.to_string())) .map_err(|e| napi::Error::from_reason(e.to_string()))
} }

View File

@@ -33,7 +33,7 @@
browserName, browserPath.path]; browserName, browserPath.path];
openPanel.prompt = @"Grant Access"; openPanel.prompt = @"Grant Access";
openPanel.allowsMultipleSelection = NO; openPanel.allowsMultipleSelection = NO;
openPanel.canChooseDirectories = NO; openPanel.canChooseDirectories = YES;
openPanel.canChooseFiles = NO; openPanel.canChooseFiles = NO;
openPanel.directoryURL = browserPath; openPanel.directoryURL = browserPath;

View File

@@ -20,7 +20,7 @@ export class ChromiumImporterService {
}); });
ipcMain.handle("chromium_importer.getAvailableProfiles", async (event, browser: string) => { ipcMain.handle("chromium_importer.getAvailableProfiles", async (event, browser: string) => {
return await chromium_importer.getAvailableProfiles(browser); return await chromium_importer.getAvailableProfiles(browser, isMacAppStore());
}); });
ipcMain.handle( ipcMain.handle(