diff --git a/shell/browser/ui/cocoa/electron_ns_window.mm b/shell/browser/ui/cocoa/electron_ns_window.mm index 7156fa9864..9e83e6b02d 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.mm +++ b/shell/browser/ui/cocoa/electron_ns_window.mm @@ -285,6 +285,19 @@ void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) { return base::SysUTF8ToNSString(shell_ ? shell_->GetTitle() : ""); } +- (NSString*)accessibilityDocument { + // Prefer representedFilename set via Electron's setRepresentedFilename API. + // This works around a Chromium change (https://crrev.com/c/6187085) where + // NativeWidgetMacNSWindow's accessibilityDocument override doesn't fall back + // to NSWindow's default behavior of returning the representedFilename. + NSString* representedFilename = [self representedFilename]; + if (representedFilename.length > 0) { + return [[NSURL fileURLWithPath:representedFilename] absoluteString]; + } + // Fall back to Chromium's implementation for web content URLs. + return [super accessibilityDocument]; +} + - (BOOL)canBecomeMainWindow { return !self.disableKeyOrMainWindow; }