-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SEBWIN-841: Implemented focus handler API in attempt to resolve issue…
… (without success).
- Loading branch information
Showing
11 changed files
with
204 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2024 ETH Zürich, IT Services | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
using CefSharp; | ||
using SafeExamBrowser.Logging.Contracts; | ||
|
||
namespace SafeExamBrowser.Browser.Handlers | ||
{ | ||
internal class FocusHandler : IFocusHandler | ||
{ | ||
private readonly ILogger logger; | ||
|
||
internal FocusHandler(ILogger logger) | ||
{ | ||
this.logger = logger; | ||
} | ||
|
||
public void OnGotFocus(IWebBrowser webBrowser, IBrowser browser) | ||
{ | ||
} | ||
|
||
public bool OnSetFocus(IWebBrowser webBrowser, IBrowser browser, CefFocusSource source) | ||
{ | ||
return true; | ||
} | ||
|
||
public void OnTakeFocus(IWebBrowser webBrowser, IBrowser browser, bool next) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
SafeExamBrowser.Browser/Wrapper/Events/GotFocusEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2024 ETH Zürich, IT Services | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
using CefSharp; | ||
|
||
namespace SafeExamBrowser.Browser.Wrapper.Events | ||
{ | ||
internal delegate void GotFocusEventHandler(IWebBrowser webBrowser, IBrowser browser); | ||
} |
14 changes: 14 additions & 0 deletions
14
SafeExamBrowser.Browser/Wrapper/Events/SetFocusEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2024 ETH Zürich, IT Services | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
using CefSharp; | ||
|
||
namespace SafeExamBrowser.Browser.Wrapper.Events | ||
{ | ||
internal delegate void SetFocusEventHandler(IWebBrowser webBrowser, IBrowser browser, CefFocusSource source, GenericEventArgs args); | ||
} |
14 changes: 14 additions & 0 deletions
14
SafeExamBrowser.Browser/Wrapper/Events/TakeFocusEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2024 ETH Zürich, IT Services | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
using CefSharp; | ||
|
||
namespace SafeExamBrowser.Browser.Wrapper.Events | ||
{ | ||
internal delegate void TakeFocusEventHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, bool next); | ||
} |
70 changes: 70 additions & 0 deletions
70
SafeExamBrowser.Browser/Wrapper/Handlers/FocusHandlerSwitch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2024 ETH Zürich, IT Services | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
using CefSharp; | ||
using CefSharp.WinForms; | ||
using CefSharp.WinForms.Host; | ||
using SafeExamBrowser.Browser.Wrapper.Events; | ||
|
||
namespace SafeExamBrowser.Browser.Wrapper.Handlers | ||
{ | ||
internal class FocusHandlerSwitch : IFocusHandler | ||
{ | ||
public void OnGotFocus(IWebBrowser webBrowser, IBrowser browser) | ||
{ | ||
if (browser.IsPopup) | ||
{ | ||
var control = ChromiumHostControl.FromBrowser(browser) as CefSharpPopupControl; | ||
|
||
control?.OnGotFocus(webBrowser, browser); | ||
} | ||
else | ||
{ | ||
var control = ChromiumWebBrowser.FromBrowser(browser) as CefSharpBrowserControl; | ||
|
||
control?.OnGotFocus(webBrowser, browser); | ||
} | ||
} | ||
|
||
public bool OnSetFocus(IWebBrowser webBrowser, IBrowser browser, CefFocusSource source) | ||
{ | ||
var args = new GenericEventArgs { Value = false }; | ||
|
||
if (browser.IsPopup) | ||
{ | ||
var control = ChromiumHostControl.FromBrowser(browser) as CefSharpPopupControl; | ||
|
||
control?.OnSetFocus(webBrowser, browser, source, args); | ||
} | ||
else | ||
{ | ||
var control = ChromiumWebBrowser.FromBrowser(browser) as CefSharpBrowserControl; | ||
|
||
control?.OnSetFocus(webBrowser, browser, source, args); | ||
} | ||
|
||
return args.Value; | ||
} | ||
|
||
public void OnTakeFocus(IWebBrowser webBrowser, IBrowser browser, bool next) | ||
{ | ||
if (browser.IsPopup) | ||
{ | ||
var control = ChromiumHostControl.FromBrowser(browser) as CefSharpPopupControl; | ||
|
||
control?.OnTakeFocus(webBrowser, browser, next); | ||
} | ||
else | ||
{ | ||
var control = ChromiumWebBrowser.FromBrowser(browser) as CefSharpBrowserControl; | ||
|
||
control?.OnTakeFocus(webBrowser, browser, next); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters