From 15eb077b1e6bbb0a4060b8ac402a2a447d7825ae Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 1 May 2019 22:15:38 +0300 Subject: [PATCH] Fix Theia loading inside iframe Fix loading Theia in the iframe launched with protected connection for Google Chrome Signed-off-by: Oleksandr Andriienko --- .../keyboard/browser-keyboard-layout-provider.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/core/src/browser/keyboard/browser-keyboard-layout-provider.ts b/packages/core/src/browser/keyboard/browser-keyboard-layout-provider.ts index 958be1ac29a0b..74320b043b5f6 100644 --- a/packages/core/src/browser/keyboard/browser-keyboard-layout-provider.ts +++ b/packages/core/src/browser/keyboard/browser-keyboard-layout-provider.ts @@ -54,11 +54,21 @@ export class BrowserKeyboardLayoutProvider implements KeyboardLayoutProvider, Ke } } - getNativeLayout(): Promise { + async getNativeLayout(): Promise { const keyboard = (navigator as NavigatorExtension).keyboard; if (keyboard && keyboard.getLayoutMap) { - return keyboard.getLayoutMap().then(layoutMap => this.getFromLayoutMap(layoutMap)); - } else if (navigator.language) { + try { + const layoutMap = await keyboard.getLayoutMap(); + return this.getFromLayoutMap(layoutMap); + } catch (error) { + return this.getLayoutByLanguageOrPlatform(); + } + } + return this.getLayoutByLanguageOrPlatform(); + } + + private getLayoutByLanguageOrPlatform(): Promise { + if (navigator.language) { return Promise.resolve(this.getFromLanguage(navigator.language)); } else { return Promise.resolve(isOSX ? this.macUS : this.winUS);