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:
@@ -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)?;
|
||||
Ok(get_profile_info(&local_state))
|
||||
}
|
||||
|
||||
@@ -61,12 +61,18 @@ pub mod sandbox {
|
||||
.find(|b| b.name == 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 {
|
||||
namespace: "chromium_importer".to_string(),
|
||||
command: "request_access".to_string(),
|
||||
params: serde_json::json!({
|
||||
"browserName": browser_name,
|
||||
"relativePath": config.data_dir,
|
||||
"relativePath": relative_path,
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
2
apps/desktop/desktop_native/napi/index.d.ts
vendored
2
apps/desktop/desktop_native/napi/index.d.ts
vendored
@@ -254,7 +254,7 @@ export declare namespace chromium_importer {
|
||||
}
|
||||
/** Returns OS aware metadata describing supported Chromium based importers as a JSON string. */
|
||||
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 requestBrowserAccess(browser: string, masBuild: boolean): Promise<void>
|
||||
}
|
||||
|
||||
@@ -1168,8 +1168,12 @@ pub mod chromium_importer {
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn get_available_profiles(browser: String) -> napi::Result<Vec<ProfileInfo>> {
|
||||
chromium_importer::chromium::get_available_profiles(&browser)
|
||||
pub async fn get_available_profiles(
|
||||
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_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
browserName, browserPath.path];
|
||||
openPanel.prompt = @"Grant Access";
|
||||
openPanel.allowsMultipleSelection = NO;
|
||||
openPanel.canChooseDirectories = NO;
|
||||
openPanel.canChooseDirectories = YES;
|
||||
openPanel.canChooseFiles = NO;
|
||||
openPanel.directoryURL = browserPath;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export class ChromiumImporterService {
|
||||
});
|
||||
|
||||
ipcMain.handle("chromium_importer.getAvailableProfiles", async (event, browser: string) => {
|
||||
return await chromium_importer.getAvailableProfiles(browser);
|
||||
return await chromium_importer.getAvailableProfiles(browser, isMacAppStore());
|
||||
});
|
||||
|
||||
ipcMain.handle(
|
||||
|
||||
Reference in New Issue
Block a user