2024-03-29 12:48:33 -04:00
|
|
|
// Copyright 2024 The Chromium Embedded Framework Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found
|
|
|
|
// in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser/views/widget.h"
|
|
|
|
|
|
|
|
#include "libcef/browser/chrome/views/chrome_browser_frame.h"
|
2024-04-17 12:01:26 -04:00
|
|
|
#include "libcef/browser/views/view_util.h"
|
2024-03-29 12:48:33 -04:00
|
|
|
#include "libcef/browser/views/widget_impl.h"
|
2024-04-17 12:01:26 -04:00
|
|
|
#include "libcef/browser/views/window_impl.h"
|
2024-03-29 12:48:33 -04:00
|
|
|
|
|
|
|
// static
|
|
|
|
CefWidget* CefWidget::Create(CefWindowView* window_view) {
|
2024-04-17 12:01:26 -04:00
|
|
|
if (window_view->IsChromeStyle()) {
|
2024-03-29 12:48:33 -04:00
|
|
|
return new ChromeBrowserFrame(window_view);
|
|
|
|
}
|
|
|
|
return new CefWidgetImpl(window_view);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
CefWidget* CefWidget::GetForWidget(views::Widget* widget) {
|
2024-04-17 12:01:26 -04:00
|
|
|
if (auto window = view_util::GetWindowFor(widget)) {
|
|
|
|
if (auto* window_view =
|
|
|
|
static_cast<CefWindowImpl*>(window.get())->cef_window_view()) {
|
|
|
|
if (window_view->IsChromeStyle()) {
|
|
|
|
return static_cast<ChromeBrowserFrame*>(widget);
|
|
|
|
}
|
|
|
|
return static_cast<CefWidgetImpl*>(widget);
|
|
|
|
}
|
2024-03-29 12:48:33 -04:00
|
|
|
}
|
2024-04-17 12:01:26 -04:00
|
|
|
return nullptr;
|
2024-03-29 12:48:33 -04:00
|
|
|
}
|