1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be found 3 // in the LICENSE file. 4 5 #include "libcef/browser/views/view_util.h" 6 7 #include "ui/aura/window.h" 8 #include "ui/aura/window_tree_host.h" 9 #include "ui/views/widget/widget.h" 10 11 namespace view_util { 12 GetNativeWindow(views::Widget * widget)13gfx::NativeWindow GetNativeWindow(views::Widget* widget) { 14 if (widget) { 15 aura::Window* window = widget->GetNativeWindow(); 16 if (window) 17 return window->GetRootWindow(); 18 } 19 return nullptr; 20 } 21 GetNativeView(views::Widget * widget)22gfx::NativeView GetNativeView(views::Widget* widget) { 23 return GetNativeWindow(widget); 24 } 25 GetWindowHandle(views::Widget * widget)26CefWindowHandle GetWindowHandle(views::Widget* widget) { 27 // Same implementation as views::HWNDForView() but cross-platform. 28 if (widget) { 29 aura::Window* window = widget->GetNativeWindow(); 30 if (window && window->GetRootWindow()) 31 return window->GetHost()->GetAcceleratedWidget(); 32 } 33 return kNullWindowHandle; 34 } 35 36 } // namespace view_util 37