summaryrefslogtreecommitdiffstats
path: root/win8
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 22:39:37 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 22:39:37 +0000
commit0340739ab51d60d65072e94a8c9c2908ddb96e6b (patch)
treed694531709b1b8e2a8e03a9f231a928fbcf3add0 /win8
parent23e2037f82ea0fc407b53e9153abadce8eee5b91 (diff)
downloadchromium_src-0340739ab51d60d65072e94a8c9c2908ddb96e6b.zip
chromium_src-0340739ab51d60d65072e94a8c9c2908ddb96e6b.tar.gz
chromium_src-0340739ab51d60d65072e94a8c9c2908ddb96e6b.tar.bz2
Ensure that metro chrome exits after sending the Alt + F4 key combination to the core window by invoking the ICoreApplicationExit::Exit function in a task.
At times metro chrome does not exit after sending the Alt + F4 key combination to the core window. This occurs at times when tabs are closed via the keyboard. To ensure that chrome exits in this case we invoke the ICoreApplicationExit::Exit function in a background delayed task. Fixes bug https://code.google.com/p/chromium/issues/detail?id=159147 BUG=159147 R=cpu Review URL: https://codereview.chromium.org/11308128 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8')
-rw-r--r--win8/metro_driver/chrome_app_view.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/win8/metro_driver/chrome_app_view.cc b/win8/metro_driver/chrome_app_view.cc
index 9a0c5f8..7ad5364 100644
--- a/win8/metro_driver/chrome_app_view.cc
+++ b/win8/metro_driver/chrome_app_view.cc
@@ -142,19 +142,27 @@ void SendMnemonic(WORD mnemonic_char, Modifier modifiers, bool extended,
}
}
-void MetroExit() {
- if (globals.core_window == ::GetForegroundWindow()) {
+// Helper function to Exit metro chrome cleanly. If we are in the foreground
+// then we try and exit by sending an Alt+F4 key combination to the core
+// window which ensures that the chrome application tile does not show up in
+// the running metro apps list on the top left corner. We have seen cases
+// where this does work. To workaround that we invoke the
+// ICoreApplicationExit::Exit function in a background delayed task which
+// ensures that chrome exits.
+void MetroExit(bool send_alt_f4_mnemonic) {
+ if (send_alt_f4_mnemonic && globals.core_window == ::GetForegroundWindow()) {
DVLOG(1) << "We are in the foreground. Exiting via Alt F4";
SendMnemonic(VK_F4, ALT, false, false);
DWORD core_window_process_id = 0;
DWORD core_window_thread_id = GetWindowThreadProcessId(
globals.core_window, &core_window_process_id);
if (core_window_thread_id != ::GetCurrentThreadId()) {
- // Sleep to give time to the core window thread to get this message.
- Sleep(100);
+ globals.appview_msg_loop->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&MetroExit, false),
+ base::TimeDelta::FromMilliseconds(100));
}
} else {
- DVLOG(1) << "We are not in the foreground. Exiting normally";
globals.app_exit->Exit();
globals.core_window = NULL;
}
@@ -269,7 +277,7 @@ void CloseFrameWindowInternal(HWND hwnd) {
} else {
// time to quit
DVLOG(1) << "Last host window closed. Calling Exit().";
- MetroExit();
+ MetroExit(true);
}
}
@@ -633,7 +641,7 @@ DWORD WINAPI HostMainThreadProc(void*) {
DWORD exit_code = globals.host_main(globals.host_context);
DVLOG(1) << "host thread done, exit_code=" << exit_code;
- MetroExit();
+ MetroExit(true);
return exit_code;
}