| 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.h" | 6 #include "win8/metro_driver/chrome_app_view.h" |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <windows.applicationModel.datatransfer.h> | 9 #include <windows.applicationModel.datatransfer.h> |
| 10 #include <windows.foundation.h> | 10 #include <windows.foundation.h> |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 DVLOG(1) << __FUNCTION__ << ", hwnd=" << LONG_PTR(hwnd); | 211 DVLOG(1) << __FUNCTION__ << ", hwnd=" << LONG_PTR(hwnd); |
| 212 | 212 |
| 213 HWND current_top_frame = | 213 HWND current_top_frame = |
| 214 !globals.host_windows.empty() ? globals.host_windows.front().first : NULL; | 214 !globals.host_windows.empty() ? globals.host_windows.front().first : NULL; |
| 215 if (hwnd != current_top_frame && IsWindow(current_top_frame)) { | 215 if (hwnd != current_top_frame && IsWindow(current_top_frame)) { |
| 216 DVLOG(1) << "Hiding current top window, hwnd=" | 216 DVLOG(1) << "Hiding current top window, hwnd=" |
| 217 << LONG_PTR(current_top_frame); | 217 << LONG_PTR(current_top_frame); |
| 218 ::ShowWindow(current_top_frame, SW_HIDE); | 218 ::ShowWindow(current_top_frame, SW_HIDE); |
| 219 } | 219 } |
| 220 | 220 |
| 221 // If chrome opens a url in a foreground tab, it may call SetFrameWindow | 221 std::list<std::pair<HWND, bool> >::iterator index = |
| 222 // again. Ensure that we don't have dups. | 222 std::find_if(globals.host_windows.begin(), globals.host_windows.end(), |
| 223 globals.host_windows.remove_if([hwnd](std::pair<HWND, bool>& item) { | 223 [hwnd](std::pair<HWND, bool>& item) { |
| 224 return (item.first == hwnd); | 224 return (item.first == hwnd); |
| 225 }); | 225 }); |
| 226 | 226 |
| 227 globals.host_windows.push_front(std::make_pair(hwnd, false)); | 227 if (index == globals.host_windows.end()) { |
| 228 | 228 globals.host_windows.push_front(std::make_pair(hwnd, false)); |
| 229 AdjustFrameWindowStyleForMetro(hwnd); | 229 AdjustFrameWindowStyleForMetro(hwnd); |
| 230 } |
| 230 } | 231 } |
| 231 | 232 |
| 232 void CloseFrameWindowInternal(HWND hwnd) { | 233 void CloseFrameWindowInternal(HWND hwnd) { |
| 233 DVLOG(1) << __FUNCTION__ << ", hwnd=" << LONG_PTR(hwnd); | 234 DVLOG(1) << __FUNCTION__ << ", hwnd=" << LONG_PTR(hwnd); |
| 234 | 235 |
| 235 globals.host_windows.remove_if([hwnd](std::pair<HWND, bool>& item) { | 236 globals.host_windows.remove_if([hwnd](std::pair<HWND, bool>& item) { |
| 236 return (item.first == hwnd); | 237 return (item.first == hwnd); |
| 237 }); | 238 }); |
| 238 | 239 |
| 239 if (globals.host_windows.size() > 0) { | 240 if (globals.host_windows.size() > 0) { |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 CheckHR(core_app.As(&app_exit)); | 1180 CheckHR(core_app.As(&app_exit)); |
| 1180 globals.app_exit = app_exit.Detach(); | 1181 globals.app_exit = app_exit.Detach(); |
| 1181 } | 1182 } |
| 1182 | 1183 |
| 1183 IFACEMETHODIMP | 1184 IFACEMETHODIMP |
| 1184 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { | 1185 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { |
| 1185 globals.view = mswr::Make<ChromeAppView>().Detach(); | 1186 globals.view = mswr::Make<ChromeAppView>().Detach(); |
| 1186 *view = globals.view; | 1187 *view = globals.view; |
| 1187 return (*view) ? S_OK : E_OUTOFMEMORY; | 1188 return (*view) ? S_OK : E_OUTOFMEMORY; |
| 1188 } | 1189 } |
| OLD | NEW |