fix(autofill): page tenue eveillee dans le tray et au retour de veille
Premier autofill apres des heures cachee : la page mettait 3 a 5 s a repondre, alors que les drapeaux anti-gel de Chromium etaient appliques. Un ExecuteJavaScript trivial toutes les 5 min, et tout de suite a la sortie de veille ou au deverrouillage de session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -109,6 +109,7 @@ type
|
|||||||
// WinEvent hook that watches every foreground change in the session.
|
// WinEvent hook that watches every foreground change in the session.
|
||||||
FForegroundHook: THandle;
|
FForegroundHook: THandle;
|
||||||
FOnSystemLock: TProc;
|
FOnSystemLock: TProc;
|
||||||
|
FOnSystemResume: TProc;
|
||||||
// Set TRUE the moment Windows tells us the session is ending
|
// Set TRUE the moment Windows tells us the session is ending
|
||||||
// (WM_QUERYENDSESSION / WM_ENDSESSION). FormCloseQuery checks this
|
// (WM_QUERYENDSESSION / WM_ENDSESSION). FormCloseQuery checks this
|
||||||
// to bypass the "minimize to tray" intercept so the form closes
|
// to bypass the "minimize to tray" intercept so the form closes
|
||||||
@@ -296,6 +297,8 @@ type
|
|||||||
property AutofillTotpActive: Boolean read FAutofillTotpActive;
|
property AutofillTotpActive: Boolean read FAutofillTotpActive;
|
||||||
// Fired on main thread when Windows locks the session (WTS_SESSION_LOCK).
|
// Fired on main thread when Windows locks the session (WTS_SESSION_LOCK).
|
||||||
property OnSystemLock: TProc read FOnSystemLock write FOnSystemLock;
|
property OnSystemLock: TProc read FOnSystemLock write FOnSystemLock;
|
||||||
|
// Sortie de veille ou session deverrouillee : de quoi reveiller la page.
|
||||||
|
property OnSystemResume: TProc read FOnSystemResume write FOnSystemResume;
|
||||||
// True once WM_QUERYENDSESSION (or WM_ENDSESSION) has been received.
|
// True once WM_QUERYENDSESSION (or WM_ENDSESSION) has been received.
|
||||||
// FormCloseQuery uses this to allow normal close during shutdown.
|
// FormCloseQuery uses this to allow normal close during shutdown.
|
||||||
property ShutdownPending: Boolean read FShutdownPending;
|
property ShutdownPending: Boolean read FShutdownPending;
|
||||||
@@ -406,6 +409,7 @@ const
|
|||||||
const
|
const
|
||||||
WM_WTSSESSION_CHANGE = $02B1;
|
WM_WTSSESSION_CHANGE = $02B1;
|
||||||
WTS_SESSION_LOCK = 7;
|
WTS_SESSION_LOCK = 7;
|
||||||
|
WTS_SESSION_UNLOCK = 8;
|
||||||
NOTIFY_FOR_THIS_SESSION = 0;
|
NOTIFY_FOR_THIS_SESSION = 0;
|
||||||
|
|
||||||
// Power management broadcast — sent to all top-level windows when the
|
// Power management broadcast — sent to all top-level windows when the
|
||||||
@@ -1755,6 +1759,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
if AMsg.WParam = WTS_SESSION_LOCK then
|
if AMsg.WParam = WTS_SESSION_LOCK then
|
||||||
if Assigned(FOnSystemLock) then FOnSystemLock();
|
if Assigned(FOnSystemLock) then FOnSystemLock();
|
||||||
|
if AMsg.WParam = WTS_SESSION_UNLOCK then
|
||||||
|
if Assigned(FOnSystemResume) then FOnSystemResume();
|
||||||
end
|
end
|
||||||
|
|
||||||
else if AMsg.Msg = WM_POWERBROADCAST then
|
else if AMsg.Msg = WM_POWERBROADCAST then
|
||||||
@@ -1768,6 +1774,8 @@ begin
|
|||||||
// suspends — fast handler required (no UI prompts, no network).
|
// suspends — fast handler required (no UI prompts, no network).
|
||||||
if AMsg.WParam = PBT_APMSUSPEND then
|
if AMsg.WParam = PBT_APMSUSPEND then
|
||||||
if Assigned(FOnSystemLock) then FOnSystemLock();
|
if Assigned(FOnSystemLock) then FOnSystemLock();
|
||||||
|
if AMsg.WParam = PBT_APMRESUMEAUTOMATIC then
|
||||||
|
if Assigned(FOnSystemResume) then FOnSystemResume();
|
||||||
end
|
end
|
||||||
|
|
||||||
else if (AMsg.Msg = WM_QUERYENDSESSION) or (AMsg.Msg = WM_ENDSESSION) then
|
else if (AMsg.Msg = WM_QUERYENDSESSION) or (AMsg.Msg = WM_ENDSESSION) then
|
||||||
|
|||||||
@@ -98,6 +98,13 @@ type
|
|||||||
FFileSaveChunks: TDictionary<string, TStringBuilder>;
|
FFileSaveChunks: TDictionary<string, TStringBuilder>;
|
||||||
FPendingURL: string;
|
FPendingURL: string;
|
||||||
FNavTimer: TTimer;
|
FNavTimer: TTimer;
|
||||||
|
// REVEIL DE LA PAGE pendant que l'application dort dans le tray. Les
|
||||||
|
// drapeaux --disable-renderer-backgrounding & co sont bien appliques, et
|
||||||
|
// pourtant le premier autofill apres des heures cachee attendait 3 a 5 s
|
||||||
|
// la reponse de la page (mesure : 8 ms coffre tout juste ouvert, 4907 ms
|
||||||
|
// apres une veille). Windows laisse s'endormir un processus que personne
|
||||||
|
// ne sollicite ; une instruction JS triviale toutes les 5 min l'en empeche.
|
||||||
|
FKeepWarmTimer: TTimer;
|
||||||
// Set once WebView2 fires OnInitialized. The nav timer only consumes
|
// Set once WebView2 fires OnInitialized. The nav timer only consumes
|
||||||
// FPendingURL when this is True — otherwise a timer tick that lands
|
// FPendingURL when this is True — otherwise a timer tick that lands
|
||||||
// before the engine is ready would Navigate() into the void AND clear
|
// before the engine is ready would Navigate() into the void AND clear
|
||||||
@@ -163,6 +170,7 @@ type
|
|||||||
procedure UpdateButtons;
|
procedure UpdateButtons;
|
||||||
procedure NavigateToVault;
|
procedure NavigateToVault;
|
||||||
procedure NavTimerTick(Sender: TObject);
|
procedure NavTimerTick(Sender: TObject);
|
||||||
|
procedure KeepWarmTick(Sender: TObject);
|
||||||
// JS↔Delphi bridge
|
// JS↔Delphi bridge
|
||||||
procedure WebBrowserBeforeNavigate(Sender: TObject;
|
procedure WebBrowserBeforeNavigate(Sender: TObject;
|
||||||
var Params: TTMSFNCCustomWebBrowserBeforeNavigateParams);
|
var Params: TTMSFNCCustomWebBrowserBeforeNavigateParams);
|
||||||
@@ -313,6 +321,14 @@ begin
|
|||||||
FBridge := TPMBridge.Create(Self);
|
FBridge := TPMBridge.Create(Self);
|
||||||
FFileSaveChunks := TDictionary<string, TStringBuilder>.Create;
|
FFileSaveChunks := TDictionary<string, TStringBuilder>.Create;
|
||||||
FBridge.OnSystemLock := BridgeSystemLock;
|
FBridge.OnSystemLock := BridgeSystemLock;
|
||||||
|
// Le reveil des 5 min ne tourne pas pendant la veille : on le donne tout de
|
||||||
|
// suite au retour, avant le premier autofill.
|
||||||
|
FBridge.OnSystemResume :=
|
||||||
|
procedure
|
||||||
|
begin
|
||||||
|
LogLine('Windows resumed / unlocked — waking the page');
|
||||||
|
KeepWarmTick(nil);
|
||||||
|
end;
|
||||||
FBridge.OnTrayRestore := BridgeTrayRestore;
|
FBridge.OnTrayRestore := BridgeTrayRestore;
|
||||||
// Changement fait sur la barrette elle-meme : l'onglet se relit (fillbar/get).
|
// Changement fait sur la barrette elle-meme : l'onglet se relit (fillbar/get).
|
||||||
FBridge.OnFillBarChanged :=
|
FBridge.OnFillBarChanged :=
|
||||||
@@ -351,6 +367,10 @@ begin
|
|||||||
FNavTimer.Enabled := False;
|
FNavTimer.Enabled := False;
|
||||||
FNavTimer.OnTimer := NavTimerTick;
|
FNavTimer.OnTimer := NavTimerTick;
|
||||||
|
|
||||||
|
FKeepWarmTimer := TTimer.Create(Self);
|
||||||
|
FKeepWarmTimer.Interval := 5 * 60 * 1000;
|
||||||
|
FKeepWarmTimer.OnTimer := KeepWarmTick;
|
||||||
|
|
||||||
UpdateButtons;
|
UpdateButtons;
|
||||||
LogLine('Password Manager - d backend ready.');
|
LogLine('Password Manager - d backend ready.');
|
||||||
LogLine('Click Start to launch server + embedded web vault.');
|
LogLine('Click Start to launch server + embedded web vault.');
|
||||||
@@ -805,6 +825,12 @@ begin
|
|||||||
FNavTimer.Enabled := True;
|
FNavTimer.Enabled := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.KeepWarmTick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if FBrowserInitialized then
|
||||||
|
WebBrowser.ExecuteJavaScript('window.Bridge&&Bridge.active');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.NavTimerTick(Sender: TObject);
|
procedure TMainForm.NavTimerTick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FNavTimer.Enabled := False;
|
FNavTimer.Enabled := False;
|
||||||
|
|||||||
Reference in New Issue
Block a user