2016-01-19 21:09:01 +01:00
|
|
|
// Copyright 2016 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.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/views/view_adapter.h"
|
2016-01-19 21:09:01 +01:00
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/chrome/views/toolbar_view_impl.h"
|
|
|
|
#include "cef/libcef/browser/views/basic_label_button_impl.h"
|
|
|
|
#include "cef/libcef/browser/views/basic_panel_impl.h"
|
|
|
|
#include "cef/libcef/browser/views/browser_view_impl.h"
|
|
|
|
#include "cef/libcef/browser/views/menu_button_impl.h"
|
|
|
|
#include "cef/libcef/browser/views/scroll_view_impl.h"
|
|
|
|
#include "cef/libcef/browser/views/textfield_impl.h"
|
|
|
|
#include "cef/libcef/browser/views/view_util.h"
|
|
|
|
#include "cef/libcef/browser/views/window_impl.h"
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
// static
|
|
|
|
CefViewAdapter* CefViewAdapter::GetFor(CefRefPtr<CefView> view) {
|
|
|
|
CefViewAdapter* adapter = nullptr;
|
|
|
|
if (view->AsBrowserView()) {
|
|
|
|
adapter = static_cast<CefBrowserViewImpl*>(view->AsBrowserView().get());
|
|
|
|
} else if (view->AsButton()) {
|
|
|
|
CefRefPtr<CefButton> button = view->AsButton();
|
|
|
|
if (button->AsLabelButton()) {
|
|
|
|
CefRefPtr<CefLabelButton> label_button = button->AsLabelButton();
|
|
|
|
if (label_button->AsMenuButton()) {
|
2017-05-17 11:29:28 +02:00
|
|
|
adapter =
|
|
|
|
static_cast<CefMenuButtonImpl*>(label_button->AsMenuButton().get());
|
2016-01-19 21:09:01 +01:00
|
|
|
} else {
|
|
|
|
adapter = static_cast<CefBasicLabelButtonImpl*>(label_button.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (view->AsPanel()) {
|
|
|
|
CefRefPtr<CefPanel> panel = view->AsPanel();
|
|
|
|
if (panel->AsWindow()) {
|
|
|
|
adapter = static_cast<CefWindowImpl*>(panel->AsWindow().get());
|
|
|
|
} else {
|
|
|
|
adapter = static_cast<CefBasicPanelImpl*>(panel.get());
|
|
|
|
}
|
|
|
|
} else if (view->AsScrollView()) {
|
|
|
|
adapter = static_cast<CefScrollViewImpl*>(view->AsScrollView().get());
|
|
|
|
} else if (view->AsTextfield()) {
|
|
|
|
adapter = static_cast<CefTextfieldImpl*>(view->AsTextfield().get());
|
2021-04-11 22:10:11 +02:00
|
|
|
} else if (view->GetTypeString().ToString() ==
|
|
|
|
CefToolbarViewImpl::kTypeString) {
|
|
|
|
adapter = static_cast<CefToolbarViewImpl*>(view.get());
|
2016-01-19 21:09:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DCHECK(adapter);
|
|
|
|
return adapter;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
CefViewAdapter* CefViewAdapter::GetFor(views::View* view) {
|
|
|
|
CefRefPtr<CefView> cef_view = view_util::GetFor(view, false);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (cef_view) {
|
2016-01-19 21:09:01 +01:00
|
|
|
return GetFor(cef_view);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|