chrome: Support usage of the Chrome toolbar from Views (see issue #2969)

This commit is contained in:
Marshall Greenblatt 2021-04-11 16:10:11 -04:00
parent 9c82785077
commit a4603c6f1a
55 changed files with 1057 additions and 156 deletions

View File

@ -1068,6 +1068,10 @@ static_library("libcef_static") {
"libcef/browser/chrome/views/chrome_browser_frame.h",
"libcef/browser/chrome/views/chrome_browser_view.cc",
"libcef/browser/chrome/views/chrome_browser_view.h",
"libcef/browser/chrome/views/toolbar_view_impl.cc",
"libcef/browser/chrome/views/toolbar_view_impl.h",
"libcef/browser/chrome/views/toolbar_view_view.cc",
"libcef/browser/chrome/views/toolbar_view_view.h",
"libcef/browser/native/window_delegate_view.cc",
"libcef/browser/native/window_delegate_view.h",
"libcef/browser/views/basic_label_button_impl.cc",

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=0fbd582ed5d0231550840ebf3eed2e488ac546d4$
// $hash=3e4eb9ed3a0cb28ae0459a50f20c8405c7722437$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
@ -65,6 +65,17 @@ typedef struct _cef_browser_view_t {
struct _cef_browser_t*(CEF_CALLBACK* get_browser)(
struct _cef_browser_view_t* self);
///
// Returns the Chrome toolbar associated with this BrowserView. Only supported
// when using the Chrome runtime. The cef_browser_view_delegate_t::
// get_chrome_toolbar_type() function must return a value other than
// CEF_CTT_NONE and the toolbar will not be available until after this
// BrowserView is added to a cef_window_t and
// cef_view_delegate_t::on_window_changed() has been called.
///
struct _cef_view_t*(CEF_CALLBACK* get_chrome_toolbar)(
struct _cef_browser_view_t* self);
///
// Sets whether accelerators registered with cef_window_t::SetAccelerator are
// triggered before or after the event is sent to the cef_browser_t. If

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=37bbfadf761b3a1996276885d593d27d3fed5f8d$
// $hash=220a126af3682f716f10b9019e8d1461702aa7c9$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
@ -112,6 +112,14 @@ typedef struct _cef_browser_view_delegate_t {
struct _cef_browser_view_t* browser_view,
struct _cef_browser_view_t* popup_browser_view,
int is_devtools);
///
// Returns the Chrome toolbar type that will be available via
// cef_browser_view_t::get_chrome_toolbar(). See that function for related
// documentation.
///
cef_chrome_toolbar_type_t(CEF_CALLBACK* get_chrome_toolbar_type)(
struct _cef_browser_view_delegate_t* self);
} cef_browser_view_delegate_t;
#ifdef __cplusplus

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=8bd92dd03af4f5cf8c359c45a2d6d013565c2ead$
// $hash=a060cb3c53317d758e7f6b4a275288cd08f086e7$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
@ -114,6 +114,13 @@ typedef struct _cef_view_delegate_t {
int added,
struct _cef_view_t* child);
///
// Called when |view| is added or removed from the cef_window_t.
///
void(CEF_CALLBACK* on_window_changed)(struct _cef_view_delegate_t* self,
struct _cef_view_t* view,
int added);
///
// Called when |view| gains focus.
///

View File

@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "09fa2caf6574279a82c1293ab731add98d6124fd"
#define CEF_API_HASH_UNIVERSAL "0468b890ed1832b3763cb5f16c7b007219964b06"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "1cf8e3e6d8163fc9f600b919bec62dbd3687a481"
#define CEF_API_HASH_PLATFORM "dbe7a5bb3fa66b97a57175575d870a003ce632fe"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "74b89a1b187e5bb5ecd4b97aa21d4abc80d3dcbe"
#define CEF_API_HASH_PLATFORM "f1f736e3e19916d0f3f11de71deff8448dc3a35f"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "b78332272b672f9d3db77a83af92857b226bb294"
#define CEF_API_HASH_PLATFORM "de19204124690a84b9b24102f3bd41991781e044"
#endif
#ifdef __cplusplus

View File

@ -3214,6 +3214,15 @@ typedef enum {
CEF_TFC_SELECT_ALL,
} cef_text_field_commands_t;
///
// Supported Chrome toolbar types.
///
typedef enum {
CEF_CTT_NONE = 1,
CEF_CTT_NORMAL,
CEF_CTT_LOCATION,
} cef_chrome_toolbar_type_t;
#ifdef __cplusplus
}
#endif

View File

@ -80,6 +80,17 @@ class CefBrowserView : public CefView {
/*--cef()--*/
virtual CefRefPtr<CefBrowser> GetBrowser() = 0;
///
// Returns the Chrome toolbar associated with this BrowserView. Only supported
// when using the Chrome runtime. The CefBrowserViewDelegate::
// GetChromeToolbarType() method must return a value other than
// CEF_CTT_NONE and the toolbar will not be available until after this
// BrowserView is added to a CefWindow and CefViewDelegate::OnWindowChanged()
// has been called.
///
/*--cef()--*/
virtual CefRefPtr<CefView> GetChromeToolbar() = 0;
///
// Sets whether accelerators registered with CefWindow::SetAccelerator are
// triggered before or after the event is sent to the CefBrowser. If

View File

@ -52,6 +52,8 @@ class CefBrowserView;
/*--cef(source=client)--*/
class CefBrowserViewDelegate : public CefViewDelegate {
public:
typedef cef_chrome_toolbar_type_t ChromeToolbarType;
///
// Called when |browser| associated with |browser_view| is created. This
// method will be called after CefLifeSpanHandler::OnAfterCreated() is called
@ -104,6 +106,14 @@ class CefBrowserViewDelegate : public CefViewDelegate {
bool is_devtools) {
return false;
}
///
// Returns the Chrome toolbar type that will be available via
// CefBrowserView::GetChromeToolbar(). See that method for related
// documentation.
///
/*--cef(default_retval=CEF_CTT_NONE)--*/
virtual ChromeToolbarType GetChromeToolbarType() { return CEF_CTT_NONE; }
};
#endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_

View File

@ -105,6 +105,12 @@ class CefViewDelegate : public virtual CefBaseRefCounted {
bool added,
CefRefPtr<CefView> child) {}
///
// Called when |view| is added or removed from the CefWindow.
///
/*--cef(optional_param=window)--*/
virtual void OnWindowChanged(CefRefPtr<CefView> view, bool added) {}
///
// Called when |view| gains focus.
///

View File

@ -68,9 +68,12 @@ content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
// May return nullptr for omnibox navigations.
auto frame = browser()->GetFrame(params.frame_tree_node_id);
if (!frame)
frame = browser()->GetMainFrame();
cancel = handler->OnOpenURLFromTab(
browser(), browser()->GetFrame(params.frame_tree_node_id),
params.url.spec(),
browser(), frame, params.url.spec(),
static_cast<cef_window_open_disposition_t>(params.disposition),
params.user_gesture);
}

View File

@ -34,7 +34,7 @@ void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) {
if (cache_path_ == user_data_dir) {
// Use the default disk-based profile.
auto profile = profile_manager->GetActiveUserProfile();
auto profile = profile_manager->GetPrimaryUserProfile();
ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_CREATED);
ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_INITIALIZED);
return;
@ -63,7 +63,7 @@ void ChromeBrowserContext::Shutdown() {
// |g_browser_process| may be nullptr during shutdown.
if (should_destroy_ && g_browser_process) {
g_browser_process->profile_manager()
->GetActiveUserProfile()
->GetPrimaryUserProfile()
->DestroyOffTheRecordProfile(profile_);
}
profile_ = nullptr;
@ -83,7 +83,7 @@ void ChromeBrowserContext::ProfileCreated(Profile* profile,
// new/unique OffTheRecord profile instead.
const auto& profile_id = Profile::OTRProfileID::CreateUniqueForCEF();
parent_profile =
g_browser_process->profile_manager()->GetActiveUserProfile();
g_browser_process->profile_manager()->GetPrimaryUserProfile();
profile_ = parent_profile->GetOffTheRecordProfile(profile_id);
otr_profile = static_cast<OffTheRecordProfileImpl*>(profile_);
status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED;

View File

@ -68,3 +68,31 @@ void ChromeBrowserView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
ParentClass::OnBoundsChanged(previous_bounds);
browser_view_delegate_->OnBoundsChanged();
}
ToolbarView* ChromeBrowserView::OverrideCreateToolbar(
Browser* browser,
BrowserView* browser_view) {
if (cef_delegate()) {
auto toolbar_type = cef_delegate()->GetChromeToolbarType();
base::Optional<ToolbarView::DisplayMode> display_mode;
switch (toolbar_type) {
case CEF_CTT_NORMAL:
display_mode = ToolbarView::DisplayMode::NORMAL;
break;
case CEF_CTT_LOCATION:
display_mode = ToolbarView::DisplayMode::LOCATION;
break;
default:
break;
}
if (display_mode) {
cef_toolbar_ = CefToolbarViewImpl::Create(nullptr, browser, browser_view,
display_mode);
// Ownership will be taken by BrowserView.
view_util::PassOwnership(cef_toolbar_).release();
return cef_toolbar_->root_view();
}
}
return nullptr;
}

View File

@ -8,6 +8,7 @@
#include "include/views/cef_browser_view.h"
#include "include/views/cef_browser_view_delegate.h"
#include "libcef/browser/chrome/views/toolbar_view_impl.h"
#include "libcef/browser/views/browser_view_view.h"
#include "libcef/browser/views/view_view.h"
@ -42,6 +43,12 @@ class ChromeBrowserView
void AddedToWidget() override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
// BrowserView methods:
ToolbarView* OverrideCreateToolbar(Browser* browser,
BrowserView* browser_view) override;
CefRefPtr<CefToolbarViewImpl> cef_toolbar() const { return cef_toolbar_; }
private:
// Not owned by this object.
Delegate* browser_view_delegate_;
@ -51,6 +58,8 @@ class ChromeBrowserView
bool destroyed_ = false;
CefRefPtr<CefToolbarViewImpl> cef_toolbar_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserView);
};

View File

@ -0,0 +1,40 @@
// Copyright 2021 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/chrome/views/toolbar_view_impl.h"
// static
CefRefPtr<CefToolbarViewImpl> CefToolbarViewImpl::Create(
CefRefPtr<CefViewDelegate> delegate,
Browser* browser,
BrowserView* browser_view,
base::Optional<ToolbarView::DisplayMode> display_mode) {
CEF_REQUIRE_UIT_RETURN(nullptr);
CefRefPtr<CefToolbarViewImpl> view =
new CefToolbarViewImpl(delegate, browser, browser_view, display_mode);
view->Initialize();
return view;
}
// static
const char* const CefToolbarViewImpl::kTypeString = "ToolbarView";
CefToolbarViewImpl::CefToolbarViewImpl(
CefRefPtr<CefViewDelegate> delegate,
Browser* browser,
BrowserView* browser_view,
base::Optional<ToolbarView::DisplayMode> display_mode)
: ParentClass(delegate),
browser_(browser),
browser_view_(browser_view),
display_mode_(display_mode) {}
CefToolbarViewView* CefToolbarViewImpl::CreateRootView() {
return new CefToolbarViewView(delegate(), browser_, browser_view_,
display_mode_);
}
void CefToolbarViewImpl::InitializeRootView() {
static_cast<CefToolbarViewView*>(root_view())->Initialize();
}

View File

@ -0,0 +1,55 @@
// Copyright 2021 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.
#ifndef CEF_LIBCEF_BROWSER_CHROME_VIEWS_TOOLBAR_VIEW_IMPL_H_
#define CEF_LIBCEF_BROWSER_CHROME_VIEWS_TOOLBAR_VIEW_IMPL_H_
#pragma once
#include "include/views/cef_view_delegate.h"
#include "libcef/browser/chrome/views/toolbar_view_view.h"
#include "libcef/browser/views/view_impl.h"
class Browser;
class BrowserView;
class CefToolbarViewImpl
: public CefViewImpl<CefToolbarViewView, CefView, CefViewDelegate> {
public:
typedef CefViewImpl<CefToolbarViewView, CefView, CefViewDelegate> ParentClass;
// Create a new CefToolbarViewImpl instance. |delegate| may be nullptr.
static CefRefPtr<CefToolbarViewImpl> Create(
CefRefPtr<CefViewDelegate> delegate,
Browser* browser,
BrowserView* browser_view,
base::Optional<ToolbarView::DisplayMode> display_mode);
static const char* const kTypeString;
// CefViewAdapter methods:
std::string GetDebugType() override { return kTypeString; }
private:
// Create a new implementation object.
// Always call Initialize() after creation.
// |delegate| may be nullptr.
CefToolbarViewImpl(CefRefPtr<CefViewDelegate> delegate,
Browser* browser,
BrowserView* browser_view,
base::Optional<ToolbarView::DisplayMode> display_mode);
// CefViewImpl methods:
CefToolbarViewView* CreateRootView() override;
void InitializeRootView() override;
Browser* const browser_;
BrowserView* const browser_view_;
base::Optional<ToolbarView::DisplayMode> const display_mode_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefToolbarViewImpl);
DISALLOW_COPY_AND_ASSIGN(CefToolbarViewImpl);
};
#endif // CEF_LIBCEF_BROWSER_VIEWS_SCROLL_VIEW_IMPL_H_

View File

@ -0,0 +1,11 @@
// Copyright 2021 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/chrome/views/toolbar_view_view.h"
CefToolbarViewView::CefToolbarViewView(CefViewDelegate* cef_delegate,
Browser* browser,
BrowserView* browser_view,
base::Optional<DisplayMode> display_mode)
: ParentClass(cef_delegate, browser, browser_view, display_mode) {}

View File

@ -0,0 +1,27 @@
// Copyright 2021 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.
#ifndef CEF_LIBCEF_BROWSER_CHROME_VIEWS_TOOLBAR_VIEW_VIEW_H_
#define CEF_LIBCEF_BROWSER_CHROME_VIEWS_TOOLBAR_VIEW_VIEW_H_
#pragma once
#include "libcef/browser/views/view_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
class CefToolbarViewView : public CefViewView<ToolbarView, CefViewDelegate> {
public:
typedef CefViewView<ToolbarView, CefViewDelegate> ParentClass;
// |cef_delegate| may be nullptr.
explicit CefToolbarViewView(CefViewDelegate* cef_delegate,
Browser* browser,
BrowserView* browser_view,
base::Optional<DisplayMode> display_mode);
private:
DISALLOW_COPY_AND_ASSIGN(CefToolbarViewView);
};
#endif // CEF_LIBCEF_BROWSER_CHROME_VIEWS_TOOLBAR_VIEW_VIEW_H_

View File

@ -123,6 +123,15 @@ CefRefPtr<CefBrowser> CefBrowserViewImpl::GetBrowser() {
return browser_;
}
CefRefPtr<CefView> CefBrowserViewImpl::GetChromeToolbar() {
CEF_REQUIRE_VALID_RETURN(nullptr);
if (cef::IsChromeRuntimeEnabled()) {
return static_cast<ChromeBrowserView*>(root_view())->cef_toolbar();
}
return nullptr;
}
void CefBrowserViewImpl::SetPreferAccelerators(bool prefer_accelerators) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (web_view())

View File

@ -53,6 +53,7 @@ class CefBrowserViewImpl
// CefBrowserView methods:
CefRefPtr<CefBrowser> GetBrowser() override;
CefRefPtr<CefView> GetChromeToolbar() override;
void SetPreferAccelerators(bool prefer_accelerators) override;
// CefView methods:

View File

@ -28,8 +28,9 @@ CEF_BUTTON_VIEW_T class CefButtonView : public CEF_VIEW_VIEW_D {
typedef CEF_VIEW_VIEW_D ParentClass;
// |cef_delegate| may be nullptr.
explicit CefButtonView(CefViewDelegateClass* cef_delegate)
: ParentClass(cef_delegate) {}
template <typename... Args>
explicit CefButtonView(CefViewDelegateClass* cef_delegate, Args... args)
: ParentClass(cef_delegate, args...) {}
// Returns the CefButton associated with this view. See comments on
// CefViewView::GetCefView.

View File

@ -25,8 +25,9 @@ CEF_LABEL_BUTTON_VIEW_T class CefLabelButtonView : public CEF_BUTTON_VIEW_D {
typedef CEF_BUTTON_VIEW_D ParentClass;
// |cef_delegate| may be nullptr.
explicit CefLabelButtonView(CefViewDelegateClass* cef_delegate)
: ParentClass(cef_delegate) {}
template <typename... Args>
explicit CefLabelButtonView(CefViewDelegateClass* cef_delegate, Args... args)
: ParentClass(cef_delegate, args...) {}
void Initialize() override {
ParentClass::Initialize();

View File

@ -113,12 +113,14 @@ CEF_PANEL_IMPL_T void CEF_PANEL_IMPL_D::AddChildView(CefRefPtr<CefView> view) {
CEF_REQUIRE_VALID_RETURN_VOID();
DCHECK(view.get());
DCHECK(view->IsValid());
DCHECK(!view->IsAttached());
if (!view.get() || !view->IsValid() || view->IsAttached())
if (!view.get() || !view->IsValid())
return;
std::unique_ptr<views::View> view_ptr = view_util::PassOwnership(view);
ParentClass::content_view()->AddChildView(view_ptr.release());
auto* view_ptr = view->IsAttached()
? view_util::GetFor(view)
: view_util::PassOwnership(view).release();
DCHECK(view_ptr);
ParentClass::content_view()->AddChildView(view_ptr);
}
CEF_PANEL_IMPL_T void CEF_PANEL_IMPL_D::AddChildViewAt(CefRefPtr<CefView> view,
@ -126,18 +128,20 @@ CEF_PANEL_IMPL_T void CEF_PANEL_IMPL_D::AddChildViewAt(CefRefPtr<CefView> view,
CEF_REQUIRE_VALID_RETURN_VOID();
DCHECK(view.get());
DCHECK(view->IsValid());
DCHECK(!view->IsAttached());
DCHECK_GE(index, 0);
DCHECK_LE(static_cast<unsigned int>(index),
ParentClass::content_view()->children().size());
if (!view.get() || !view->IsValid() || view->IsAttached() || index < 0 ||
if (!view.get() || !view->IsValid() || index < 0 ||
(static_cast<unsigned int>(index) >
ParentClass::content_view()->children().size())) {
return;
}
std::unique_ptr<views::View> view_ptr = view_util::PassOwnership(view);
ParentClass::content_view()->AddChildViewAt(view_ptr.release(), index);
auto* view_ptr = view->IsAttached()
? view_util::GetFor(view)
: view_util::PassOwnership(view).release();
DCHECK(view_ptr);
ParentClass::content_view()->AddChildViewAt(view_ptr, index);
}
CEF_PANEL_IMPL_T void CEF_PANEL_IMPL_D::ReorderChildView(

View File

@ -26,8 +26,9 @@ CEF_PANEL_VIEW_T class CefPanelView : public CEF_VIEW_VIEW_D {
typedef CEF_VIEW_VIEW_D ParentClass;
// |cef_delegate| may be nullptr.
explicit CefPanelView(CefViewDelegateClass* cef_delegate)
: ParentClass(cef_delegate) {}
template <typename... Args>
explicit CefPanelView(CefViewDelegateClass* cef_delegate, Args... args)
: ParentClass(cef_delegate, args...) {}
// Returns the CefPanel associated with this view. See comments on
// CefViewView::GetCefView.

View File

@ -4,6 +4,7 @@
#include "libcef/browser/views/view_adapter.h"
#include "libcef/browser/chrome/views/toolbar_view_impl.h"
#include "libcef/browser/views/basic_label_button_impl.h"
#include "libcef/browser/views/basic_panel_impl.h"
#include "libcef/browser/views/browser_view_impl.h"
@ -40,6 +41,9 @@ CefViewAdapter* CefViewAdapter::GetFor(CefRefPtr<CefView> view) {
adapter = static_cast<CefScrollViewImpl*>(view->AsScrollView().get());
} else if (view->AsTextfield()) {
adapter = static_cast<CefTextfieldImpl*>(view->AsTextfield().get());
} else if (view->GetTypeString().ToString() ==
CefToolbarViewImpl::kTypeString) {
adapter = static_cast<CefToolbarViewImpl*>(view.get());
}
DCHECK(adapter);

View File

@ -34,8 +34,9 @@ CEF_VIEW_VIEW_T class CefViewView : public ViewsViewClass {
// Do not call complex views::View-derived methods from a CefViewView-derived
// constructor as they may attempt to call back into CefViewImpl before
// registration has been performed. |cef_delegate| may be nullptr.
explicit CefViewView(CefViewDelegateClass* cef_delegate)
: cef_delegate_(cef_delegate) {}
template <typename... Args>
explicit CefViewView(CefViewDelegateClass* cef_delegate, Args... args)
: ParentClass(args...), cef_delegate_(cef_delegate) {}
// Should be called from InitializeRootView() in the CefViewImpl-derived
// class that created this object. This method will be called after
@ -70,6 +71,8 @@ CEF_VIEW_VIEW_T class CefViewView : public ViewsViewClass {
void Layout() override;
void ViewHierarchyChanged(
const views::ViewHierarchyChangedDetails& details) override;
void AddedToWidget() override;
void RemovedFromWidget() override;
void OnFocus() override;
void OnBlur() override;
@ -84,7 +87,7 @@ CEF_VIEW_VIEW_T class CefViewView : public ViewsViewClass {
const views::ViewHierarchyChangedDetails& details);
// Not owned by this object.
CefViewDelegateClass* cef_delegate_;
CefViewDelegateClass* const cef_delegate_;
};
CEF_VIEW_VIEW_T gfx::Size CEF_VIEW_VIEW_D::CalculatePreferredSize() const {
@ -162,6 +165,18 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::ViewHierarchyChanged(
ParentClass::ViewHierarchyChanged(details);
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::AddedToWidget() {
ParentClass::AddedToWidget();
if (cef_delegate())
cef_delegate()->OnWindowChanged(GetCefView(), /*added=*/true);
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::RemovedFromWidget() {
if (cef_delegate())
cef_delegate()->OnWindowChanged(GetCefView(), /*added=*/false);
ParentClass::RemovedFromWidget();
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnFocus() {
if (cef_delegate())
cef_delegate()->OnFocus(GetCefView());

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=d69aae0b968db9610e29d956d629f1789eca922d$
// $hash=312985bb5cc971d1fe9d77af1f985f6a544e9db5$
//
#include "libcef_dll/cpptoc/views/browser_view_cpptoc.h"
@ -102,6 +102,24 @@ browser_view_get_browser(struct _cef_browser_view_t* self) {
return CefBrowserCppToC::Wrap(_retval);
}
struct _cef_view_t* CEF_CALLBACK
browser_view_get_chrome_toolbar(struct _cef_browser_view_t* self) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefView> _retval =
CefBrowserViewCppToC::Get(self)->GetChromeToolbar();
// Return type: refptr_same
return CefViewCppToC::Wrap(_retval);
}
void CEF_CALLBACK
browser_view_set_prefer_accelerators(struct _cef_browser_view_t* self,
int prefer_accelerators) {
@ -1075,6 +1093,7 @@ int CEF_CALLBACK browser_view_convert_point_from_view(struct _cef_view_t* self,
CefBrowserViewCppToC::CefBrowserViewCppToC() {
GetStruct()->get_browser = browser_view_get_browser;
GetStruct()->get_chrome_toolbar = browser_view_get_chrome_toolbar;
GetStruct()->set_prefer_accelerators = browser_view_set_prefer_accelerators;
GetStruct()->base.as_browser_view = browser_view_as_browser_view;
GetStruct()->base.as_button = browser_view_as_button;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=dceaf28fbed0456dce3c34fcbc8177f3c2537cec$
// $hash=8e8daae6a8ed718582045ea42e16906813b77337$
//
#include "libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.h"
@ -149,6 +149,25 @@ int CEF_CALLBACK browser_view_delegate_on_popup_browser_view_created(
return _retval;
}
cef_chrome_toolbar_type_t CEF_CALLBACK
browser_view_delegate_get_chrome_toolbar_type(
struct _cef_browser_view_delegate_t* self) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CEF_CTT_NONE;
// Execute
cef_chrome_toolbar_type_t _retval =
CefBrowserViewDelegateCppToC::Get(self)->GetChromeToolbarType();
// Return type: simple
return _retval;
}
cef_size_t CEF_CALLBACK
browser_view_delegate_get_preferred_size(struct _cef_view_delegate_t* self,
cef_view_t* view) {
@ -302,6 +321,28 @@ browser_view_delegate_on_child_view_changed(struct _cef_view_delegate_t* self,
CefViewCToCpp::Wrap(child));
}
void CEF_CALLBACK
browser_view_delegate_on_window_changed(struct _cef_view_delegate_t* self,
cef_view_t* view,
int added) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: view; type: refptr_diff
DCHECK(view);
if (!view)
return;
// Execute
CefBrowserViewDelegateCppToC::Get(
reinterpret_cast<cef_browser_view_delegate_t*>(self))
->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false);
}
void CEF_CALLBACK
browser_view_delegate_on_focus(struct _cef_view_delegate_t* self,
cef_view_t* view) {
@ -356,6 +397,8 @@ CefBrowserViewDelegateCppToC::CefBrowserViewDelegateCppToC() {
browser_view_delegate_get_delegate_for_popup_browser_view;
GetStruct()->on_popup_browser_view_created =
browser_view_delegate_on_popup_browser_view_created;
GetStruct()->get_chrome_toolbar_type =
browser_view_delegate_get_chrome_toolbar_type;
GetStruct()->base.get_preferred_size =
browser_view_delegate_get_preferred_size;
GetStruct()->base.get_minimum_size = browser_view_delegate_get_minimum_size;
@ -366,6 +409,7 @@ CefBrowserViewDelegateCppToC::CefBrowserViewDelegateCppToC() {
browser_view_delegate_on_parent_view_changed;
GetStruct()->base.on_child_view_changed =
browser_view_delegate_on_child_view_changed;
GetStruct()->base.on_window_changed = browser_view_delegate_on_window_changed;
GetStruct()->base.on_focus = browser_view_delegate_on_focus;
GetStruct()->base.on_blur = browser_view_delegate_on_blur;
}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=0fa0f3d240a017c67e65fc7e965c9b8c61e64649$
// $hash=52a0deb8b7ae62e474acb1474cf922c3e9a04f14$
//
#include "libcef_dll/cpptoc/views/button_delegate_cpptoc.h"
@ -213,6 +213,27 @@ button_delegate_on_child_view_changed(struct _cef_view_delegate_t* self,
CefViewCToCpp::Wrap(child));
}
void CEF_CALLBACK
button_delegate_on_window_changed(struct _cef_view_delegate_t* self,
cef_view_t* view,
int added) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: view; type: refptr_diff
DCHECK(view);
if (!view)
return;
// Execute
CefButtonDelegateCppToC::Get(reinterpret_cast<cef_button_delegate_t*>(self))
->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false);
}
void CEF_CALLBACK button_delegate_on_focus(struct _cef_view_delegate_t* self,
cef_view_t* view) {
shutdown_checker::AssertNotShutdown();
@ -267,6 +288,7 @@ CefButtonDelegateCppToC::CefButtonDelegateCppToC() {
button_delegate_on_parent_view_changed;
GetStruct()->base.on_child_view_changed =
button_delegate_on_child_view_changed;
GetStruct()->base.on_window_changed = button_delegate_on_window_changed;
GetStruct()->base.on_focus = button_delegate_on_focus;
GetStruct()->base.on_blur = button_delegate_on_blur;
}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=8c598c348857748e3eca7629326f2eff46e7c06c$
// $hash=2fcd1d4d2126285209e1fa782beccbb363693bf3$
//
#include "libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.h"
@ -252,6 +252,28 @@ menu_button_delegate_on_child_view_changed(struct _cef_view_delegate_t* self,
CefViewCToCpp::Wrap(child));
}
void CEF_CALLBACK
menu_button_delegate_on_window_changed(struct _cef_view_delegate_t* self,
cef_view_t* view,
int added) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: view; type: refptr_diff
DCHECK(view);
if (!view)
return;
// Execute
CefMenuButtonDelegateCppToC::Get(
reinterpret_cast<cef_menu_button_delegate_t*>(self))
->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false);
}
void CEF_CALLBACK
menu_button_delegate_on_focus(struct _cef_view_delegate_t* self,
cef_view_t* view) {
@ -316,6 +338,8 @@ CefMenuButtonDelegateCppToC::CefMenuButtonDelegateCppToC() {
menu_button_delegate_on_parent_view_changed;
GetStruct()->base.base.on_child_view_changed =
menu_button_delegate_on_child_view_changed;
GetStruct()->base.base.on_window_changed =
menu_button_delegate_on_window_changed;
GetStruct()->base.base.on_focus = menu_button_delegate_on_focus;
GetStruct()->base.base.on_blur = menu_button_delegate_on_blur;
}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=e3a1c9fc1175aef66bd4f2c2c9a11263502977ff$
// $hash=dd29f2990766a766a27dece7e39501eb11a296fd$
//
#include "libcef_dll/cpptoc/views/panel_delegate_cpptoc.h"
@ -172,6 +172,27 @@ panel_delegate_on_child_view_changed(struct _cef_view_delegate_t* self,
CefViewCToCpp::Wrap(child));
}
void CEF_CALLBACK
panel_delegate_on_window_changed(struct _cef_view_delegate_t* self,
cef_view_t* view,
int added) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: view; type: refptr_diff
DCHECK(view);
if (!view)
return;
// Execute
CefPanelDelegateCppToC::Get(reinterpret_cast<cef_panel_delegate_t*>(self))
->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false);
}
void CEF_CALLBACK panel_delegate_on_focus(struct _cef_view_delegate_t* self,
cef_view_t* view) {
shutdown_checker::AssertNotShutdown();
@ -223,6 +244,7 @@ CefPanelDelegateCppToC::CefPanelDelegateCppToC() {
panel_delegate_on_parent_view_changed;
GetStruct()->base.on_child_view_changed =
panel_delegate_on_child_view_changed;
GetStruct()->base.on_window_changed = panel_delegate_on_window_changed;
GetStruct()->base.on_focus = panel_delegate_on_focus;
GetStruct()->base.on_blur = panel_delegate_on_blur;
}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=2762af8abc72d877fd2a44a07701861face6013d$
// $hash=e35b635ec442c8910b02aca64d48760b1360c868$
//
#include "libcef_dll/cpptoc/views/textfield_delegate_cpptoc.h"
@ -227,6 +227,28 @@ textfield_delegate_on_child_view_changed(struct _cef_view_delegate_t* self,
CefViewCToCpp::Wrap(child));
}
void CEF_CALLBACK
textfield_delegate_on_window_changed(struct _cef_view_delegate_t* self,
cef_view_t* view,
int added) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: view; type: refptr_diff
DCHECK(view);
if (!view)
return;
// Execute
CefTextfieldDelegateCppToC::Get(
reinterpret_cast<cef_textfield_delegate_t*>(self))
->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false);
}
void CEF_CALLBACK textfield_delegate_on_focus(struct _cef_view_delegate_t* self,
cef_view_t* view) {
shutdown_checker::AssertNotShutdown();
@ -283,6 +305,7 @@ CefTextfieldDelegateCppToC::CefTextfieldDelegateCppToC() {
textfield_delegate_on_parent_view_changed;
GetStruct()->base.on_child_view_changed =
textfield_delegate_on_child_view_changed;
GetStruct()->base.on_window_changed = textfield_delegate_on_window_changed;
GetStruct()->base.on_focus = textfield_delegate_on_focus;
GetStruct()->base.on_blur = textfield_delegate_on_blur;
}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=918764cb2b4346405ddfb1f4eeb26f3042d93bb9$
// $hash=7c6283658d49420281d02b4793f65f478f261461$
//
#include "libcef_dll/cpptoc/views/view_delegate_cpptoc.h"
@ -173,6 +173,27 @@ view_delegate_on_child_view_changed(struct _cef_view_delegate_t* self,
CefViewCToCpp::Wrap(child));
}
void CEF_CALLBACK
view_delegate_on_window_changed(struct _cef_view_delegate_t* self,
cef_view_t* view,
int added) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: view; type: refptr_diff
DCHECK(view);
if (!view)
return;
// Execute
CefViewDelegateCppToC::Get(self)->OnWindowChanged(CefViewCToCpp::Wrap(view),
added ? true : false);
}
void CEF_CALLBACK view_delegate_on_focus(struct _cef_view_delegate_t* self,
cef_view_t* view) {
shutdown_checker::AssertNotShutdown();
@ -220,6 +241,7 @@ CefViewDelegateCppToC::CefViewDelegateCppToC() {
GetStruct()->get_height_for_width = view_delegate_get_height_for_width;
GetStruct()->on_parent_view_changed = view_delegate_on_parent_view_changed;
GetStruct()->on_child_view_changed = view_delegate_on_child_view_changed;
GetStruct()->on_window_changed = view_delegate_on_window_changed;
GetStruct()->on_focus = view_delegate_on_focus;
GetStruct()->on_blur = view_delegate_on_blur;
}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=041bb67146f8e803a9eeb7790528441f2f8ceb28$
// $hash=a201b988556a825fffe39f58e378664b93795c72$
//
#include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h"
@ -452,6 +452,27 @@ window_delegate_on_child_view_changed(struct _cef_view_delegate_t* self,
CefViewCToCpp::Wrap(child));
}
void CEF_CALLBACK
window_delegate_on_window_changed(struct _cef_view_delegate_t* self,
cef_view_t* view,
int added) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: view; type: refptr_diff
DCHECK(view);
if (!view)
return;
// Execute
CefWindowDelegateCppToC::Get(reinterpret_cast<cef_window_delegate_t*>(self))
->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false);
}
void CEF_CALLBACK window_delegate_on_focus(struct _cef_view_delegate_t* self,
cef_view_t* view) {
shutdown_checker::AssertNotShutdown();
@ -516,6 +537,7 @@ CefWindowDelegateCppToC::CefWindowDelegateCppToC() {
window_delegate_on_parent_view_changed;
GetStruct()->base.base.on_child_view_changed =
window_delegate_on_child_view_changed;
GetStruct()->base.base.on_window_changed = window_delegate_on_window_changed;
GetStruct()->base.base.on_focus = window_delegate_on_focus;
GetStruct()->base.base.on_blur = window_delegate_on_blur;
}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=60dd60fe326607167c50e97f55a673151c1dcc69$
// $hash=912a0807db8bc1405188d61961545cc8e540aacf$
//
#include "libcef_dll/ctocpp/views/browser_view_ctocpp.h"
@ -93,6 +93,23 @@ CefRefPtr<CefBrowser> CefBrowserViewCToCpp::GetBrowser() {
return CefBrowserCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefView> CefBrowserViewCToCpp::GetChromeToolbar() {
shutdown_checker::AssertNotShutdown();
cef_browser_view_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_chrome_toolbar))
return nullptr;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_view_t* _retval = _struct->get_chrome_toolbar(_struct);
// Return type: refptr_same
return CefViewCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
void CefBrowserViewCToCpp::SetPreferAccelerators(bool prefer_accelerators) {
shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=b9bb98216be4ad0a91215e146dfd330ebe790721$
// $hash=f17d395c61d650a824016d14bc06d0cb9db9a6e6$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BROWSER_VIEW_CTOCPP_H_
@ -35,6 +35,7 @@ class CefBrowserViewCToCpp : public CefCToCppRefCounted<CefBrowserViewCToCpp,
// CefBrowserView methods.
CefRefPtr<CefBrowser> GetBrowser() OVERRIDE;
CefRefPtr<CefView> GetChromeToolbar() OVERRIDE;
void SetPreferAccelerators(bool prefer_accelerators) OVERRIDE;
// CefView methods.

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=902dae801096930c473e8cd7c86945fc0e703a98$
// $hash=9aed01b6014f1c22815e7847eba321d75dbfa45d$
//
#include "libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h"
@ -75,11 +75,12 @@ void CefBrowserViewDelegateCToCpp::OnBrowserDestroyed(
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefBrowserViewDelegate> CefBrowserViewDelegateCToCpp::
GetDelegateForPopupBrowserView(CefRefPtr<CefBrowserView> browser_view,
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
bool is_devtools) {
CefRefPtr<CefBrowserViewDelegate>
CefBrowserViewDelegateCToCpp::GetDelegateForPopupBrowserView(
CefRefPtr<CefBrowserView> browser_view,
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
bool is_devtools) {
shutdown_checker::AssertNotShutdown();
cef_browser_view_delegate_t* _struct = GetStruct();
@ -139,8 +140,26 @@ bool CefBrowserViewDelegateCToCpp::OnPopupBrowserViewCreated(
}
NO_SANITIZE("cfi-icall")
CefSize
CefBrowserViewDelegateCToCpp::GetPreferredSize(CefRefPtr<CefView> view) {
CefBrowserViewDelegate::ChromeToolbarType
CefBrowserViewDelegateCToCpp::GetChromeToolbarType() {
shutdown_checker::AssertNotShutdown();
cef_browser_view_delegate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_chrome_toolbar_type))
return CEF_CTT_NONE;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_chrome_toolbar_type_t _retval = _struct->get_chrome_toolbar_type(_struct);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
CefSize CefBrowserViewDelegateCToCpp::GetPreferredSize(
CefRefPtr<CefView> view) {
shutdown_checker::AssertNotShutdown();
cef_view_delegate_t* _struct =
@ -292,6 +311,27 @@ void CefBrowserViewDelegateCToCpp::OnChildViewChanged(
CefViewCppToC::Wrap(child));
}
NO_SANITIZE("cfi-icall")
void CefBrowserViewDelegateCToCpp::OnWindowChanged(CefRefPtr<CefView> view,
bool added) {
shutdown_checker::AssertNotShutdown();
cef_view_delegate_t* _struct =
reinterpret_cast<cef_view_delegate_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, on_window_changed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: view; type: refptr_diff
DCHECK(view.get());
if (!view.get())
return;
// Execute
_struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added);
}
NO_SANITIZE("cfi-icall")
void CefBrowserViewDelegateCToCpp::OnFocus(CefRefPtr<CefView> view) {
shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=83b4092b1523348b483a411ad80d64fa8b9db63d$
// $hash=20b067cabc4baa4c9edecaffb38a2ebb28524ccc$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BROWSER_VIEW_DELEGATE_CTOCPP_H_
@ -51,6 +51,7 @@ class CefBrowserViewDelegateCToCpp
bool OnPopupBrowserViewCreated(CefRefPtr<CefBrowserView> browser_view,
CefRefPtr<CefBrowserView> popup_browser_view,
bool is_devtools) override;
ChromeToolbarType GetChromeToolbarType() override;
// CefViewDelegate methods.
CefSize GetPreferredSize(CefRefPtr<CefView> view) override;
@ -63,6 +64,7 @@ class CefBrowserViewDelegateCToCpp
void OnChildViewChanged(CefRefPtr<CefView> view,
bool added,
CefRefPtr<CefView> child) override;
void OnWindowChanged(CefRefPtr<CefView> view, bool added) override;
void OnFocus(CefRefPtr<CefView> view) override;
void OnBlur(CefRefPtr<CefView> view) override;
};

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=3dcc24823032b36d6566eea42fd3ccdcee286e92$
// $hash=fc962d2832eeb3dee99e9a201f234d4a4b4d6f0f$
//
#include "libcef_dll/ctocpp/views/button_delegate_ctocpp.h"
@ -210,6 +210,27 @@ void CefButtonDelegateCToCpp::OnChildViewChanged(CefRefPtr<CefView> view,
CefViewCppToC::Wrap(child));
}
NO_SANITIZE("cfi-icall")
void CefButtonDelegateCToCpp::OnWindowChanged(CefRefPtr<CefView> view,
bool added) {
shutdown_checker::AssertNotShutdown();
cef_view_delegate_t* _struct =
reinterpret_cast<cef_view_delegate_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, on_window_changed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: view; type: refptr_diff
DCHECK(view.get());
if (!view.get())
return;
// Execute
_struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added);
}
NO_SANITIZE("cfi-icall")
void CefButtonDelegateCToCpp::OnFocus(CefRefPtr<CefView> view) {
shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=532ee88167e55b11e3bce9330b93f33fa382e24a$
// $hash=6a72a71a9becd6103d44719ed88b000d576d95eb$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BUTTON_DELEGATE_CTOCPP_H_
@ -51,6 +51,7 @@ class CefButtonDelegateCToCpp
void OnChildViewChanged(CefRefPtr<CefView> view,
bool added,
CefRefPtr<CefView> child) override;
void OnWindowChanged(CefRefPtr<CefView> view, bool added) override;
void OnFocus(CefRefPtr<CefView> view) override;
void OnBlur(CefRefPtr<CefView> view) override;
};

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c4cdaa3fa15fb7559a199e37448fec7fe9d81711$
// $hash=9ecd07954f90dc14ddf36072285c942f2ee8082f$
//
#include "libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h"
@ -242,6 +242,27 @@ void CefMenuButtonDelegateCToCpp::OnChildViewChanged(CefRefPtr<CefView> view,
CefViewCppToC::Wrap(child));
}
NO_SANITIZE("cfi-icall")
void CefMenuButtonDelegateCToCpp::OnWindowChanged(CefRefPtr<CefView> view,
bool added) {
shutdown_checker::AssertNotShutdown();
cef_view_delegate_t* _struct =
reinterpret_cast<cef_view_delegate_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, on_window_changed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: view; type: refptr_diff
DCHECK(view.get());
if (!view.get())
return;
// Execute
_struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added);
}
NO_SANITIZE("cfi-icall")
void CefMenuButtonDelegateCToCpp::OnFocus(CefRefPtr<CefView> view) {
shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=1bbd5144528b748527fb1ef3fe49e29e84a642de$
// $hash=7836ec7b53349057b1d1d75c6ba8506620bed53d$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_DELEGATE_CTOCPP_H_
@ -57,6 +57,7 @@ class CefMenuButtonDelegateCToCpp
void OnChildViewChanged(CefRefPtr<CefView> view,
bool added,
CefRefPtr<CefView> child) override;
void OnWindowChanged(CefRefPtr<CefView> view, bool added) override;
void OnFocus(CefRefPtr<CefView> view) override;
void OnBlur(CefRefPtr<CefView> view) override;
};

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=785b996793338a2ac1918b48d2046954c58a6237$
// $hash=4bffffc0fe09523839a08109aef1e3de90f6e25c$
//
#include "libcef_dll/ctocpp/views/panel_delegate_ctocpp.h"
@ -170,6 +170,27 @@ void CefPanelDelegateCToCpp::OnChildViewChanged(CefRefPtr<CefView> view,
CefViewCppToC::Wrap(child));
}
NO_SANITIZE("cfi-icall")
void CefPanelDelegateCToCpp::OnWindowChanged(CefRefPtr<CefView> view,
bool added) {
shutdown_checker::AssertNotShutdown();
cef_view_delegate_t* _struct =
reinterpret_cast<cef_view_delegate_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, on_window_changed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: view; type: refptr_diff
DCHECK(view.get());
if (!view.get())
return;
// Execute
_struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added);
}
NO_SANITIZE("cfi-icall")
void CefPanelDelegateCToCpp::OnFocus(CefRefPtr<CefView> view) {
shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=88ff4d04d59ca5e3b5add12c0360750844f0263f$
// $hash=d508126f22cba29931a4d53aecbdaaca7dd39b9d$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_PANEL_DELEGATE_CTOCPP_H_
@ -47,6 +47,7 @@ class CefPanelDelegateCToCpp
void OnChildViewChanged(CefRefPtr<CefView> view,
bool added,
CefRefPtr<CefView> child) override;
void OnWindowChanged(CefRefPtr<CefView> view, bool added) override;
void OnFocus(CefRefPtr<CefView> view) override;
void OnBlur(CefRefPtr<CefView> view) override;
};

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=042f9e7c31678915a88af146b06a34c842a8796f$
// $hash=8582eda62f90bab166d04bb6a2f8783a98fabe15$
//
#include "libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h"
@ -215,6 +215,27 @@ void CefTextfieldDelegateCToCpp::OnChildViewChanged(CefRefPtr<CefView> view,
CefViewCppToC::Wrap(child));
}
NO_SANITIZE("cfi-icall")
void CefTextfieldDelegateCToCpp::OnWindowChanged(CefRefPtr<CefView> view,
bool added) {
shutdown_checker::AssertNotShutdown();
cef_view_delegate_t* _struct =
reinterpret_cast<cef_view_delegate_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, on_window_changed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: view; type: refptr_diff
DCHECK(view.get());
if (!view.get())
return;
// Execute
_struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added);
}
NO_SANITIZE("cfi-icall")
void CefTextfieldDelegateCToCpp::OnFocus(CefRefPtr<CefView> view) {
shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=5e71b48999ec32b734dad95bfe8ce37e29a02537$
// $hash=3a83b906a29ba302874b73804e457680d2b7251e$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_TEXTFIELD_DELEGATE_CTOCPP_H_
@ -52,6 +52,7 @@ class CefTextfieldDelegateCToCpp
void OnChildViewChanged(CefRefPtr<CefView> view,
bool added,
CefRefPtr<CefView> child) override;
void OnWindowChanged(CefRefPtr<CefView> view, bool added) override;
void OnFocus(CefRefPtr<CefView> view) override;
void OnBlur(CefRefPtr<CefView> view) override;
};

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=2d7b3c7d174f5669f039e25c93da73e6f29de471$
// $hash=7a6d2ca91509c2e6c510d5c9585a74c2fe10499b$
//
#include "libcef_dll/ctocpp/views/view_delegate_ctocpp.h"
@ -169,6 +169,26 @@ void CefViewDelegateCToCpp::OnChildViewChanged(CefRefPtr<CefView> view,
CefViewCppToC::Wrap(child));
}
NO_SANITIZE("cfi-icall")
void CefViewDelegateCToCpp::OnWindowChanged(CefRefPtr<CefView> view,
bool added) {
shutdown_checker::AssertNotShutdown();
cef_view_delegate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_window_changed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: view; type: refptr_diff
DCHECK(view.get());
if (!view.get())
return;
// Execute
_struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added);
}
NO_SANITIZE("cfi-icall")
void CefViewDelegateCToCpp::OnFocus(CefRefPtr<CefView> view) {
shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=ae050ad2368c8741e90ee0653f8bc6c6e1be4ad8$
// $hash=f049a053042a00be15899439f324a376ee309dbb$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_VIEW_DELEGATE_CTOCPP_H_
@ -46,6 +46,7 @@ class CefViewDelegateCToCpp : public CefCToCppRefCounted<CefViewDelegateCToCpp,
void OnChildViewChanged(CefRefPtr<CefView> view,
bool added,
CefRefPtr<CefView> child) override;
void OnWindowChanged(CefRefPtr<CefView> view, bool added) override;
void OnFocus(CefRefPtr<CefView> view) override;
void OnBlur(CefRefPtr<CefView> view) override;
};

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c15191d56329def4089fb5d3944e2991b55876ca$
// $hash=dda345b957ac58c71770da1cf4813ce16ea568b8$
//
#include "libcef_dll/ctocpp/views/window_delegate_ctocpp.h"
@ -436,6 +436,27 @@ void CefWindowDelegateCToCpp::OnChildViewChanged(CefRefPtr<CefView> view,
CefViewCppToC::Wrap(child));
}
NO_SANITIZE("cfi-icall")
void CefWindowDelegateCToCpp::OnWindowChanged(CefRefPtr<CefView> view,
bool added) {
shutdown_checker::AssertNotShutdown();
cef_view_delegate_t* _struct =
reinterpret_cast<cef_view_delegate_t*>(GetStruct());
if (CEF_MEMBER_MISSING(_struct, on_window_changed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: view; type: refptr_diff
DCHECK(view.get());
if (!view.get())
return;
// Execute
_struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added);
}
NO_SANITIZE("cfi-icall")
void CefWindowDelegateCToCpp::OnFocus(CefRefPtr<CefView> view) {
shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=22e538be2af31decaefcfc0b3e2879586530ad71$
// $hash=4e5e470d6aa929b3b2d4286eb4bcdc90dba052dc$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_
@ -65,6 +65,7 @@ class CefWindowDelegateCToCpp
void OnChildViewChanged(CefRefPtr<CefView> view,
bool added,
CefRefPtr<CefView> child) override;
void OnWindowChanged(CefRefPtr<CefView> view, bool added) override;
void OnFocus(CefRefPtr<CefView> view) override;
void OnBlur(CefRefPtr<CefView> view) override;
};

View File

@ -200,7 +200,7 @@ index f225525e74eb..2f3d13b087b0 100644
void Browser::CloseFrame() {
diff --git chrome/browser/ui/browser.h chrome/browser/ui/browser.h
index 3a0202c2139b..700de9a44461 100644
index 3a0202c2139b..5b950c1146d0 100644
--- chrome/browser/ui/browser.h
+++ chrome/browser/ui/browser.h
@@ -22,6 +22,7 @@
@ -234,7 +234,21 @@ index 3a0202c2139b..700de9a44461 100644
private:
friend class Browser;
friend class WindowSizerChromeOSTest;
@@ -403,6 +413,12 @@ class Browser : public TabStripModelObserver,
@@ -345,6 +355,13 @@ class Browser : public TabStripModelObserver,
bool is_focus_mode() const { return is_focus_mode_; }
+ // Return true if CEF will expose the toolbar to the client. This value is
+ // used to selectively enable toolbar behaviors such as command processing
+ // and omnibox focus without also including the toolbar in BrowserView layout
+ // calculations.
+ void set_toolbar_overridden(bool val) { toolbar_overridden_ = val; }
+ bool toolbar_overridden() const { return toolbar_overridden_; }
+
// Accessors ////////////////////////////////////////////////////////////////
const CreateParams& create_params() const { return create_params_; }
@@ -403,6 +420,12 @@ class Browser : public TabStripModelObserver,
base::WeakPtr<Browser> AsWeakPtr();
@ -247,7 +261,7 @@ index 3a0202c2139b..700de9a44461 100644
// Get the FindBarController for this browser, creating it if it does not
// yet exist.
FindBarController* GetFindBarController();
@@ -783,6 +799,11 @@ class Browser : public TabStripModelObserver,
@@ -783,6 +806,11 @@ class Browser : public TabStripModelObserver,
void SetContentsBounds(content::WebContents* source,
const gfx::Rect& bounds) override;
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
@ -259,7 +273,16 @@ index 3a0202c2139b..700de9a44461 100644
void ContentsMouseEvent(content::WebContents* source,
bool motion,
bool exited) override;
@@ -1242,6 +1263,10 @@ class Browser : public TabStripModelObserver,
@@ -1182,6 +1210,8 @@ class Browser : public TabStripModelObserver,
const std::string initial_workspace_;
bool initial_visible_on_all_workspaces_state_;
+ bool toolbar_overridden_ = false;
+
// Tracks when this browser is being created by session restore.
bool is_session_restore_;
@@ -1242,6 +1272,10 @@ class Browser : public TabStripModelObserver,
extension_browser_window_helper_;
#endif

View File

@ -1,3 +1,35 @@
diff --git chrome/browser/ui/browser_command_controller.cc chrome/browser/ui/browser_command_controller.cc
index 8faaa9afc1e6..4dd8937fdc7b 100644
--- chrome/browser/ui/browser_command_controller.cc
+++ chrome/browser/ui/browser_command_controller.cc
@@ -354,8 +354,10 @@ bool BrowserCommandController::ExecuteCommandWithDisposition(
// CommandUpdaterDelegate and CommandUpdater declare this function so we
// choose to not implement CommandUpdaterDelegate inside this class and
// therefore command_updater_ doesn't have the delegate set).
- if (!SupportsCommand(id) || !IsCommandEnabled(id))
+ if (!SupportsCommand(id) || !IsCommandEnabled(id)) {
+ LOG(WARNING) << "Invalid/disabled command " << id;
return false;
+ }
// No commands are enabled if there is not yet any selected tab.
// TODO(pkasting): It seems like we should not need this, because either
@@ -952,11 +954,13 @@ void BrowserCommandController::TabRestoreServiceLoaded(
// BrowserCommandController, private:
bool BrowserCommandController::IsShowingMainUI() {
- return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
+ return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ||
+ browser_->toolbar_overridden();
}
bool BrowserCommandController::IsShowingLocationBar() {
- return browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
+ return browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR) ||
+ browser_->toolbar_overridden();
}
void BrowserCommandController::InitCommandState() {
diff --git chrome/browser/ui/views/frame/browser_frame.cc chrome/browser/ui/views/frame/browser_frame.cc
index 7c0229c202ca..67320e907526 100644
--- chrome/browser/ui/views/frame/browser_frame.cc
@ -88,7 +120,7 @@ index 050c0e05e4e3..0bbcf4af9a92 100644
// Initialize the frame (creates the underlying native window).
diff --git chrome/browser/ui/views/frame/browser_view.cc chrome/browser/ui/views/frame/browser_view.cc
index 7d93faeadd2c..9b10c7f86c5c 100644
index 7d93faeadd2c..8208964c4a88 100644
--- chrome/browser/ui/views/frame/browser_view.cc
+++ chrome/browser/ui/views/frame/browser_view.cc
@@ -557,11 +557,22 @@ class BrowserView::AccessibilityModeObserver : public ui::AXModeObserver {
@ -123,7 +155,25 @@ index 7d93faeadd2c..9b10c7f86c5c 100644
// Top container holds tab strip region and toolbar and lives at the front of
// the view hierarchy.
@@ -1368,6 +1378,8 @@ bool BrowserView::ShouldHideUIForFullscreen() const {
@@ -619,8 +629,15 @@ BrowserView::BrowserView(std::unique_ptr<Browser> browser)
contents_container->SetLayoutManager(std::make_unique<ContentsLayoutManager>(
devtools_web_view_, contents_web_view_));
- toolbar_ = top_container_->AddChildView(
- std::make_unique<ToolbarView>(browser_.get(), this));
+ toolbar_ = OverrideCreateToolbar(browser_.get(), this);
+ if (!toolbar_) {
+ toolbar_ = new ToolbarView(browser_.get(), this, base::nullopt);
+ } else {
+ browser_->set_toolbar_overridden(true);
+ // Update state that depends on the above flag.
+ browser_->command_controller()->FullscreenStateChanged();
+ }
+ top_container_->AddChildView(base::WrapUnique(toolbar_));
contents_separator_ =
top_container_->AddChildView(std::make_unique<ContentsSeparator>());
@@ -1368,6 +1385,8 @@ bool BrowserView::ShouldHideUIForFullscreen() const {
if (immersive_mode_controller_->IsEnabled())
return false;
@ -132,7 +182,7 @@ index 7d93faeadd2c..9b10c7f86c5c 100644
return frame_->GetFrameView()->ShouldHideTopUIForFullscreen();
}
@@ -2393,7 +2405,8 @@ BrowserView::GetNativeViewHostsForTopControlsSlide() const {
@@ -2393,7 +2412,8 @@ BrowserView::GetNativeViewHostsForTopControlsSlide() const {
}
void BrowserView::ReparentTopContainerForEndOfImmersive() {
@ -142,19 +192,40 @@ index 7d93faeadd2c..9b10c7f86c5c 100644
top_container()->DestroyLayer();
AddChildViewAt(top_container(), 0);
EnsureFocusOrder();
@@ -2841,7 +2854,8 @@ void BrowserView::Layout() {
@@ -2840,8 +2860,10 @@ void BrowserView::Layout() {
// TODO(jamescook): Why was this in the middle of layout code?
toolbar_->location_bar()->omnibox_view()->SetFocusBehavior(
IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER);
- IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER);
- frame()->GetFrameView()->UpdateMinimumSize();
+ (IsToolbarVisible() || browser_->toolbar_overridden()) ?
+ FocusBehavior::ALWAYS : FocusBehavior::NEVER);
+ if (frame()->GetFrameView())
+ frame()->GetFrameView()->UpdateMinimumSize();
// Some of the situations when the BrowserView is laid out are:
// - Enter/exit immersive fullscreen mode.
@@ -2944,7 +2958,8 @@ void BrowserView::AddedToWidget() {
SetToolbarButtonProvider(toolbar_);
@@ -2898,6 +2920,11 @@ void BrowserView::AddedToWidget() {
SetThemeProfileForWindow(GetNativeWindow(), browser_->profile());
#endif
+ // This browser view may already have a custom button provider set (e.g the
+ // hosted app frame).
+ if (!toolbar_button_provider_)
+ SetToolbarButtonProvider(toolbar_);
+
toolbar_->Init();
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -2938,13 +2965,9 @@ void BrowserView::AddedToWidget() {
EnsureFocusOrder();
- // This browser view may already have a custom button provider set (e.g the
- // hosted app frame).
- if (!toolbar_button_provider_)
- SetToolbarButtonProvider(toolbar_);
-
frame_->OnBrowserViewInitViewsComplete();
- frame_->GetFrameView()->UpdateMinimumSize();
+ if (frame_->GetFrameView())
@ -163,7 +234,7 @@ index 7d93faeadd2c..9b10c7f86c5c 100644
MaybeInitializeWebUITabStrip();
diff --git chrome/browser/ui/views/frame/browser_view.h chrome/browser/ui/views/frame/browser_view.h
index e4955ccbb929..e678754ee361 100644
index e4955ccbb929..51a4133ba8d1 100644
--- chrome/browser/ui/views/frame/browser_view.h
+++ chrome/browser/ui/views/frame/browser_view.h
@@ -114,7 +114,9 @@ class BrowserView : public BrowserWindow,
@ -176,6 +247,36 @@ index e4955ccbb929..e678754ee361 100644
BrowserView(const BrowserView&) = delete;
BrowserView& operator=(const BrowserView&) = delete;
~BrowserView() override;
@@ -617,6 +619,12 @@ class BrowserView : public BrowserWindow,
return accessibility_focus_highlight_.get();
}
+ protected:
+ virtual ToolbarView* OverrideCreateToolbar(Browser* browser,
+ BrowserView* browser_view) {
+ return nullptr;
+ }
+
private:
// Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
// interface to keep these two classes decoupled and testable.
diff --git chrome/browser/ui/views/frame/browser_view_layout.cc chrome/browser/ui/views/frame/browser_view_layout.cc
index 1f790b4d87da..782d132ccac2 100644
--- chrome/browser/ui/views/frame/browser_view_layout.cc
+++ chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -402,6 +402,12 @@ int BrowserViewLayout::LayoutWebUITabStrip(int top) {
int BrowserViewLayout::LayoutToolbar(int top) {
TRACE_EVENT0("ui", "BrowserViewLayout::LayoutToolbar");
+ if (toolbar_->parent() && toolbar_->parent()->GetLayoutManager() != this &&
+ toolbar_->parent()->GetLayoutManager() != nullptr) {
+ // CEF may take ownership of the toolbar. Early exit to avoid the DCHECK
+ // in LayoutManager::SetViewVisibility().
+ return top;
+ }
int browser_view_width = vertical_layout_rect_.width();
bool toolbar_visible = delegate_->IsToolbarVisible();
int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0;
diff --git chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
index 975817e079eb..f77c24d294bc 100644
--- chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
@ -234,3 +335,46 @@ index 975817e079eb..f77c24d294bc 100644
return GetFrameView()->GetCustomBackgroundId(active_state);
}
diff --git chrome/browser/ui/views/toolbar/toolbar_view.cc chrome/browser/ui/views/toolbar/toolbar_view.cc
index 54ba2047729f..b288d841f7eb 100644
--- chrome/browser/ui/views/toolbar/toolbar_view.cc
+++ chrome/browser/ui/views/toolbar/toolbar_view.cc
@@ -150,12 +150,13 @@ auto& GetViewCommandMap() {
////////////////////////////////////////////////////////////////////////////////
// ToolbarView, public:
-ToolbarView::ToolbarView(Browser* browser, BrowserView* browser_view)
+ToolbarView::ToolbarView(Browser* browser, BrowserView* browser_view,
+ base::Optional<DisplayMode> display_mode)
: AnimationDelegateViews(this),
browser_(browser),
browser_view_(browser_view),
app_menu_icon_controller_(browser->profile(), this),
- display_mode_(GetDisplayMode(browser)) {
+ display_mode_(display_mode ? *display_mode : GetDisplayMode(browser)) {
SetID(VIEW_ID_TOOLBAR);
UpgradeDetector::GetInstance()->AddObserver(this);
@@ -181,7 +182,7 @@ ToolbarView::~ToolbarView() {
void ToolbarView::Init() {
auto location_bar = std::make_unique<LocationBarView>(
browser_, browser_->profile(), browser_->command_controller(), this,
- display_mode_ != DisplayMode::NORMAL);
+ display_mode_ != DisplayMode::NORMAL && !browser_->toolbar_overridden());
// Make sure the toolbar shows by default.
size_animation_.Reset(1);
diff --git chrome/browser/ui/views/toolbar/toolbar_view.h chrome/browser/ui/views/toolbar/toolbar_view.h
index 0b3492e04542..81e819582cb6 100644
--- chrome/browser/ui/views/toolbar/toolbar_view.h
+++ chrome/browser/ui/views/toolbar/toolbar_view.h
@@ -88,7 +88,8 @@ class ToolbarView : public views::AccessiblePaneView,
// needs to be displayed.
};
- ToolbarView(Browser* browser, BrowserView* browser_view);
+ ToolbarView(Browser* browser, BrowserView* browser_view,
+ base::Optional<DisplayMode> display_mode);
ToolbarView(const ToolbarView&) = delete;
ToolbarView& operator=(const ToolbarView&) = delete;
~ToolbarView() override;

View File

@ -11,6 +11,7 @@
#include "include/cef_app.h"
#include "include/views/cef_box_layout.h"
#include "include/wrapper/cef_helpers.h"
#include "tests/cefclient/browser/main_context.h"
#include "tests/cefclient/browser/resource.h"
#include "tests/cefclient/browser/views_style.h"
#include "tests/shared/browser/extension_util.h"
@ -235,7 +236,7 @@ void ViewsWindow::SetLoadingState(bool isLoading,
bool canGoBack,
bool canGoForward) {
CEF_REQUIRE_UI_THREAD();
if (!window_ || !with_controls_)
if (!window_ || !with_controls_ || chrome_toolbar_type_ == CEF_CTT_NORMAL)
return;
EnableView(ID_BACK_BUTTON, canGoBack);
@ -274,8 +275,12 @@ void ViewsWindow::TakeFocus(bool next) {
if (!window_ || !with_controls_)
return;
// Give focus to the URL textfield.
window_->GetViewForID(ID_URL_TEXTFIELD)->RequestFocus();
if (chrome_toolbar_type_ == CEF_CTT_NORMAL) {
top_toolbar_->RequestFocus();
} else {
// Give focus to the URL textfield.
location_->RequestFocus();
}
}
void ViewsWindow::OnBeforeContextMenu(CefRefPtr<CefMenuModel> model) {
@ -362,6 +367,10 @@ bool ViewsWindow::OnPopupBrowserViewCreated(
return true;
}
CefBrowserViewDelegate::ChromeToolbarType ViewsWindow::GetChromeToolbarType() {
return chrome_toolbar_type_;
}
void ViewsWindow::OnButtonPressed(CefRefPtr<CefButton> button) {
CEF_REQUIRE_UI_THREAD();
DCHECK(with_controls_);
@ -665,6 +674,120 @@ void ViewsWindow::OnBlur(CefRefPtr<CefView> view) {
}
}
void ViewsWindow::OnWindowChanged(CefRefPtr<CefView> view, bool added) {
if (!with_controls_ || !added)
return;
const int view_id = view->GetID();
if (view_id != ID_BROWSER_VIEW)
return;
// Build the remainder of the UI now that the BrowserView has been added to
// the CefWindow. This is a requirement to use Chrome toolbars.
CefRefPtr<CefPanel> top_menu_panel;
if (top_menu_bar_)
top_menu_panel = top_menu_bar_->GetMenuPanel();
LabelButtons browse_buttons;
CefRefPtr<CefMenuButton> menu_button;
if (chrome_toolbar_type_ == CEF_CTT_NORMAL) {
// Chrome will provide a normal toolbar with location, menu, etc.
top_toolbar_ = browser_view_->GetChromeToolbar();
DCHECK(top_toolbar_);
}
if (!top_toolbar_) {
// Create the browse buttons.
browse_buttons.push_back(CreateBrowseButton("Back", ID_BACK_BUTTON));
browse_buttons.push_back(CreateBrowseButton("Forward", ID_FORWARD_BUTTON));
browse_buttons.push_back(CreateBrowseButton("Reload", ID_RELOAD_BUTTON));
browse_buttons.push_back(CreateBrowseButton("Stop", ID_STOP_BUTTON));
if (chrome_toolbar_type_ == CEF_CTT_LOCATION) {
// Chrome will provide a minimal location bar.
location_ = browser_view_->GetChromeToolbar();
DCHECK(location_);
}
if (!location_) {
// Create the URL textfield.
CefRefPtr<CefTextfield> url_textfield =
CefTextfield::CreateTextfield(this);
url_textfield->SetID(ID_URL_TEXTFIELD);
url_textfield->SetEnabled(false); // Disabled by default.
views_style::ApplyTo(url_textfield);
location_ = url_textfield;
}
// Create the menu button.
menu_button = CefMenuButton::CreateMenuButton(this, CefString());
menu_button->SetID(ID_MENU_BUTTON);
menu_button->SetImage(
CEF_BUTTON_STATE_NORMAL,
delegate_->GetImageCache()->GetCachedImage("menu_icon"));
views_style::ApplyTo(menu_button.get());
menu_button->SetInkDropEnabled(true);
// Override the default minimum size.
menu_button->SetMinimumSize(CefSize(0, 0));
// Create the top panel.
CefRefPtr<CefPanel> top_panel = CefPanel::CreatePanel(nullptr);
// Use a horizontal box layout for |top_panel|.
CefBoxLayoutSettings top_panel_layout_settings;
top_panel_layout_settings.horizontal = true;
CefRefPtr<CefBoxLayout> top_panel_layout =
top_panel->SetToBoxLayout(top_panel_layout_settings);
// Add the buttons and URL textfield to |top_panel|.
for (size_t i = 0U; i < browse_buttons.size(); ++i)
top_panel->AddChildView(browse_buttons[i]);
top_panel->AddChildView(location_);
UpdateExtensionControls();
DCHECK(extensions_panel_);
top_panel->AddChildView(extensions_panel_);
top_panel->AddChildView(menu_button);
views_style::ApplyTo(top_panel);
// Allow |location| to grow and fill any remaining space.
top_panel_layout->SetFlexForView(location_, 1);
top_toolbar_ = top_panel;
}
// Add the top panel and browser view to |window|.
int top_index = 0;
if (top_menu_panel)
window_->AddChildViewAt(top_menu_panel, top_index++);
window_->AddChildViewAt(top_toolbar_, top_index);
// Lay out |window| so we can get the default button sizes.
window_->Layout();
int min_width = 200;
if (!browse_buttons.empty()) {
// Make all browse buttons the same size.
MakeButtonsSameSize(browse_buttons);
// Lay out |window| again with the new button sizes.
window_->Layout();
// Minimum window width is the size of all buttons plus some extra.
min_width = browse_buttons[0]->GetBounds().width * 4 +
menu_button->GetBounds().width + 100;
}
// Minimum window height is the hight of the top toolbar plus some extra.
int min_height = top_toolbar_->GetBounds().height + 100;
if (top_menu_panel)
min_height += top_menu_panel->GetBounds().height;
minimum_window_size_ = CefSize(min_width, min_height);
}
void ViewsWindow::MenuBarExecuteCommand(CefRefPtr<CefMenuModel> menu_model,
int command_id,
cef_event_flags_t event_flags) {
@ -686,6 +809,20 @@ ViewsWindow::ViewsWindow(Delegate* delegate,
frameless_ = command_line->HasSwitch(switches::kHideFrame) ||
delegate_->WithExtension();
if (MainContext::Get()->UseChromeRuntime()) {
const std::string& toolbar_type =
command_line->GetSwitchValue(switches::kShowChromeToolbar);
if (toolbar_type == "none") {
chrome_toolbar_type_ = CEF_CTT_NONE;
} else if (toolbar_type == "location") {
chrome_toolbar_type_ = CEF_CTT_LOCATION;
} else {
chrome_toolbar_type_ = CEF_CTT_NORMAL;
}
} else {
chrome_toolbar_type_ = CEF_CTT_NONE;
}
#if !defined(OS_MAC)
// On Mac we don't show a top menu on the window. The options are available in
// the app menu instead.
@ -736,59 +873,6 @@ void ViewsWindow::AddControls() {
// Create the MenuModel that will be displayed via the menu button.
CreateMenuModel();
CefRefPtr<CefPanel> top_menu_panel;
if (top_menu_bar_)
top_menu_panel = top_menu_bar_->GetMenuPanel();
// Create the browse buttons.
LabelButtons browse_buttons;
browse_buttons.push_back(CreateBrowseButton("Back", ID_BACK_BUTTON));
browse_buttons.push_back(CreateBrowseButton("Forward", ID_FORWARD_BUTTON));
browse_buttons.push_back(CreateBrowseButton("Reload", ID_RELOAD_BUTTON));
browse_buttons.push_back(CreateBrowseButton("Stop", ID_STOP_BUTTON));
// Create the URL textfield.
CefRefPtr<CefTextfield> url_textfield = CefTextfield::CreateTextfield(this);
url_textfield->SetID(ID_URL_TEXTFIELD);
url_textfield->SetEnabled(false); // Disabled by default.
views_style::ApplyTo(url_textfield);
// Create the menu button.
CefRefPtr<CefMenuButton> menu_button =
CefMenuButton::CreateMenuButton(this, CefString());
menu_button->SetID(ID_MENU_BUTTON);
menu_button->SetImage(
CEF_BUTTON_STATE_NORMAL,
delegate_->GetImageCache()->GetCachedImage("menu_icon"));
views_style::ApplyTo(menu_button.get());
menu_button->SetInkDropEnabled(true);
// Override the default minimum size.
menu_button->SetMinimumSize(CefSize(0, 0));
// Create the top panel.
CefRefPtr<CefPanel> top_panel = CefPanel::CreatePanel(nullptr);
// Use a horizontal box layout for |top_panel|.
CefBoxLayoutSettings top_panel_layout_settings;
top_panel_layout_settings.horizontal = true;
CefRefPtr<CefBoxLayout> top_panel_layout =
top_panel->SetToBoxLayout(top_panel_layout_settings);
// Add the buttons and URL textfield to |top_panel|.
for (size_t i = 0U; i < browse_buttons.size(); ++i)
top_panel->AddChildView(browse_buttons[i]);
top_panel->AddChildView(url_textfield);
UpdateExtensionControls();
DCHECK(extensions_panel_);
top_panel->AddChildView(extensions_panel_);
top_panel->AddChildView(menu_button);
views_style::ApplyTo(top_panel);
// Allow |url_textfield| to grow and fill any remaining space.
top_panel_layout->SetFlexForView(url_textfield, 1);
// Use a vertical box layout for |window|.
CefBoxLayoutSettings window_layout_settings;
window_layout_settings.horizontal = false;
@ -796,33 +880,14 @@ void ViewsWindow::AddControls() {
CefRefPtr<CefBoxLayout> window_layout =
window_->SetToBoxLayout(window_layout_settings);
// Add the top panel and browser view to |window|.
if (top_menu_panel)
window_->AddChildView(top_menu_panel);
window_->AddChildView(top_panel);
window_->AddChildView(browser_view_);
// Allow |browser_view_| to grow and fill any remaining space.
window_layout->SetFlexForView(browser_view_, 1);
// Lay out |window| so we can get the default button sizes.
window_->Layout();
// Make all browse buttons the same size.
MakeButtonsSameSize(browse_buttons);
// Lay out |window| again with the new button sizes.
window_->Layout();
// Minimum window width is the size of all buttons plus some extra.
const int min_width = browse_buttons[0]->GetBounds().width * 4 +
menu_button->GetBounds().width + 100;
// Minimum window height is the hight of the top toolbar plus some extra.
int min_height = top_panel->GetBounds().height + 100;
if (top_menu_panel)
min_height += top_menu_panel->GetBounds().height;
minimum_window_size_ = CefSize(min_width, min_height);
// Remaining setup will be performed in OnWindowChanged after the BrowserView
// is added to the CefWindow. This is necessary because Chrome toolbars are
// only available after the BrowserView is added.
}
void ViewsWindow::AddAccelerators() {
@ -864,12 +929,10 @@ void ViewsWindow::ShowTopControls(bool show) {
if (!window_ || !with_controls_)
return;
// Change the visibility of the panel that contains the buttons.
CefRefPtr<CefView> parent_view =
window_->GetViewForID(ID_BACK_BUTTON)->GetParentView();
if (parent_view->IsVisible() != show) {
parent_view->SetVisible(show);
parent_view->InvalidateLayout();
// Change the visibility of the top toolbar.
if (top_toolbar_->IsVisible() != show) {
top_toolbar_->SetVisible(show);
top_toolbar_->InvalidateLayout();
}
}

View File

@ -128,6 +128,7 @@ class ViewsWindow : public CefBrowserViewDelegate,
bool OnPopupBrowserViewCreated(CefRefPtr<CefBrowserView> browser_view,
CefRefPtr<CefBrowserView> popup_browser_view,
bool is_devtools) OVERRIDE;
ChromeToolbarType GetChromeToolbarType() override;
// CefButtonDelegate methods:
void OnButtonPressed(CefRefPtr<CefButton> button) OVERRIDE;
@ -164,6 +165,7 @@ class ViewsWindow : public CefBrowserViewDelegate,
CefSize GetMinimumSize(CefRefPtr<CefView> view) OVERRIDE;
void OnFocus(CefRefPtr<CefView> view) OVERRIDE;
void OnBlur(CefRefPtr<CefView> view) OVERRIDE;
void OnWindowChanged(CefRefPtr<CefView> view, bool added) OVERRIDE;
// ViewsMenuBar::Delegate methods:
void MenuBarExecuteCommand(CefRefPtr<CefMenuModel> menu_model,
@ -208,10 +210,13 @@ class ViewsWindow : public CefBrowserViewDelegate,
CefRefPtr<CefBrowserView> browser_view_;
bool frameless_;
bool with_controls_;
ChromeToolbarType chrome_toolbar_type_;
CefRefPtr<CefWindow> window_;
CefRefPtr<CefMenuModel> button_menu_model_;
CefRefPtr<ViewsMenuBar> top_menu_bar_;
CefRefPtr<CefView> top_toolbar_;
CefRefPtr<CefView> location_;
bool menu_has_focus_;
int last_focused_view_;

View File

@ -45,6 +45,7 @@ const char kCRLSetsPath[] = "crl-sets-path";
const char kLoadExtension[] = "load-extension";
const char kNoActivate[] = "no-activate";
const char kEnableChromeRuntime[] = "enable-chrome-runtime";
const char kShowChromeToolbar[] = "show-chrome-toolbar";
} // namespace switches
} // namespace client

View File

@ -39,6 +39,7 @@ extern const char kCRLSetsPath[];
extern const char kLoadExtension[];
extern const char kNoActivate[];
extern const char kEnableChromeRuntime[];
extern const char kShowChromeToolbar[];
} // namespace switches
} // namespace client