OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "win8/metro_driver/stdafx.h" | 5 #include "win8/metro_driver/stdafx.h" |
6 #include "win8/metro_driver/chrome_app_view_ash.h" | 6 #include "win8/metro_driver/chrome_app_view_ash.h" |
7 | 7 |
8 #include <corewindow.h> | 8 #include <corewindow.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <windows.foundation.h> | 10 #include <windows.foundation.h> |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 NOTREACHED() << "unknown event type: " << event; | 912 NOTREACHED() << "unknown event type: " << event; |
913 return; | 913 return; |
914 } | 914 } |
915 } | 915 } |
916 | 916 |
917 // Function to Exit metro chrome cleanly. If we are in the foreground | 917 // Function to Exit metro chrome cleanly. If we are in the foreground |
918 // then we try and exit by sending an Alt+F4 key combination to the core | 918 // then we try and exit by sending an Alt+F4 key combination to the core |
919 // window which ensures that the chrome application tile does not show up in | 919 // window which ensures that the chrome application tile does not show up in |
920 // the running metro apps list on the top left corner. | 920 // the running metro apps list on the top left corner. |
921 void ChromeAppViewAsh::OnMetroExit(MetroTerminateMethod method) { | 921 void ChromeAppViewAsh::OnMetroExit(MetroTerminateMethod method) { |
922 HWND core_window = core_window_hwnd(); | 922 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
923 if (method == TERMINATE_USING_KEY_SEQUENCE && core_window != NULL && | 923 HWND core_window = core_window_hwnd(); |
924 core_window == ::GetForegroundWindow()) { | 924 if (method == TERMINATE_USING_KEY_SEQUENCE && core_window != NULL && |
925 DVLOG(1) << "We are in the foreground. Exiting via Alt F4"; | 925 core_window == ::GetForegroundWindow()) { |
926 SendKeySequence(VK_F4, ALT); | 926 DVLOG(1) << "We are in the foreground. Exiting via Alt F4"; |
927 if (ui_channel_) | 927 SendKeySequence(VK_F4, ALT); |
928 ui_channel_->Close(); | 928 } |
929 } else { | |
930 globals.app_exit->Exit(); | |
931 } | 929 } |
| 930 if (ui_channel_) |
| 931 ui_channel_->Close(); |
| 932 |
| 933 globals.app_exit->Exit(); |
932 } | 934 } |
933 | 935 |
934 void ChromeAppViewAsh::OnInputSourceChanged() { | 936 void ChromeAppViewAsh::OnInputSourceChanged() { |
935 if (!input_source_) | 937 if (!input_source_) |
936 return; | 938 return; |
937 | 939 |
938 LANGID langid = 0; | 940 LANGID langid = 0; |
939 bool is_ime = false; | 941 bool is_ime = false; |
940 if (!input_source_->GetActiveSource(&langid, &is_ime)) { | 942 if (!input_source_->GetActiveSource(&langid, &is_ime)) { |
941 LOG(ERROR) << "GetActiveSource failed"; | 943 LOG(ERROR) << "GetActiveSource failed"; |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; | 1349 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; |
1348 CheckHR(core_app.As(&app_exit)); | 1350 CheckHR(core_app.As(&app_exit)); |
1349 globals.app_exit = app_exit.Detach(); | 1351 globals.app_exit = app_exit.Detach(); |
1350 } | 1352 } |
1351 | 1353 |
1352 IFACEMETHODIMP | 1354 IFACEMETHODIMP |
1353 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { | 1355 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { |
1354 *view = mswr::Make<ChromeAppViewAsh>().Detach(); | 1356 *view = mswr::Make<ChromeAppViewAsh>().Detach(); |
1355 return (*view) ? S_OK : E_OUTOFMEMORY; | 1357 return (*view) ? S_OK : E_OUTOFMEMORY; |
1356 } | 1358 } |
OLD | NEW |