Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / ui / base / win / hidden_window.cc
blobd04f2a3f7fad918ad428103b7e181a30b34d4ed2
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
3 // found in the LICENSE file.
5 #include "ui/base/win/hidden_window.h"
7 #include "ui/gfx/win/window_impl.h"
9 namespace ui {
11 namespace {
13 // We need to have a parent window for the compositing code to work correctly.
15 // A tab will not have a parent HWND whenever it is not active in its
16 // host window - for example at creation time and when it's in the
17 // background, so we provide a default widget to host them.
19 // It may be tempting to use GetDesktopWindow() instead, but this is
20 // problematic as the shell sends messages to children of the desktop
21 // window that interact poorly with us.
23 // See: http://crbug.com/16476
24 class TempParent : public gfx::WindowImpl {
25 public:
26 static TempParent* Get() {
27 static TempParent* g_temp_parent;
28 if (!g_temp_parent) {
29 g_temp_parent = new TempParent();
31 g_temp_parent->set_window_style(WS_POPUP);
32 g_temp_parent->set_window_ex_style(WS_EX_TOOLWINDOW);
33 g_temp_parent->Init(GetDesktopWindow(), gfx::Rect());
34 EnableWindow(g_temp_parent->hwnd(), FALSE);
36 return g_temp_parent;
39 private:
40 // Explicitly do nothing in Close. We do this as some external apps may get a
41 // handle to this window and attempt to close it.
42 void OnClose() {
45 CR_BEGIN_MSG_MAP_EX(WebContentsViewWin)
46 CR_MSG_WM_CLOSE(OnClose)
47 CR_END_MSG_MAP()
50 } // namespace
52 HWND GetHiddenWindow() {
53 return TempParent::Get()->hwnd();
56 } // namespace ui