Mac: Add Views API support (see issue #1749)

The Chrome browser can now be hosted in a Views-based application on Mac
(see issue #2969).

To launch a fully-featured Chrome window using cefsimple:
$ open cefsimple.app --args --enable-chrome-runtime

To launch a minimally-styled Views-hosted window using cefsimple:
$ open cefsimple.app --args --use-views [--enable-chrome-runtime]

To launch a fully-styled Views-hosted window using cefclient:
$ open cefclient.app --args --use-views [--enable-chrome-runtime]

Known issues:
- Some Views unit tests are currently failing on Mac.
This commit is contained in:
Marshall Greenblatt 2021-02-23 15:08:33 -05:00
parent f93c9c0c5c
commit 1d39ff720e
22 changed files with 264 additions and 190 deletions

155
BUILD.gn
View File

@ -1058,10 +1058,6 @@ static_library("libcef_static") {
}
if (toolkit_views) {
deps += [
"//ui/views",
]
sources += [
"libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc",
"libcef/browser/chrome/views/browser_platform_delegate_chrome_views.h",
@ -1129,84 +1125,106 @@ static_library("libcef_static") {
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/desktop_test_views_delegate.h",
"//ui/views/test/desktop_test_views_delegate_aura.cc",
"//ui/views/test/test_views_delegate.h",
"//ui/views/test/test_views_delegate_aura.cc",
# Support for UI input events.
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls.h",
"//ui/base/test/ui_controls_aura.cc",
"//ui/aura/test/ui_controls_factory_aura.h",
]
if (is_linux && !use_x11) {
sources += [
"//ui/aura/test/ui_controls_factory_ozone.cc",
"//ui/events/test/events_test_utils.cc"
]
}
deps += [
"//ui/aura",
"//ui/events",
"//ui/strings",
"//ui/wm",
"//ui/wm/public",
"//ui/views",
"//ui/views/controls/webview",
]
if (toolkit_views) {
deps += [
"//ui/views/controls/webview",
]
}
if (is_win) {
sources += [
# Support for UI input events.
# Part of //base/test:test_config which is testingonly.
"//base/test/test_switches.cc",
"//base/test/test_switches.h",
"//base/test/test_timeouts.cc",
"//base/test/test_timeouts.h",
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_aurawin.cc",
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls_internal_win.cc",
"//ui/base/test/ui_controls_internal_win.h",
]
}
if (is_linux) {
sources += [
# Support for UI input events.
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/aura_test_utils.cc",
"//ui/aura/test/aura_test_utils.h",
# Part of //ui/events:test_support which is testingonly.
"//ui/events/test/x11_event_waiter.cc",
"//ui/events/test/x11_event_waiter.h",
]
if (use_x11) {
sources += [
# Support for UI input events.
# Part of //ui/base/x:test_support which is testingonly.
"//ui/base/x/test/x11_ui_controls_test_helper.cc",
"//ui/base/x/test/x11_ui_controls_test_helper.h",
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
}
}
if (is_win || is_linux) {
if (use_aura) {
sources += [
"libcef/browser/native/browser_platform_delegate_native_aura.cc",
"libcef/browser/native/browser_platform_delegate_native_aura.h",
"libcef/browser/views/view_util_aura.cc",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/desktop_test_views_delegate_aura.cc",
"//ui/views/test/test_views_delegate_aura.cc",
# Support for UI input events.
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls_aura.cc",
"//ui/aura/test/ui_controls_factory_aura.h",
]
deps += [
"//ui/aura",
"//ui/wm",
"//ui/wm/public",
]
if (is_win) {
sources += [
# Support for UI input events.
# Part of //base/test:test_config which is testingonly.
"//base/test/test_switches.cc",
"//base/test/test_switches.h",
"//base/test/test_timeouts.cc",
"//base/test/test_timeouts.h",
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_aurawin.cc",
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls_internal_win.cc",
"//ui/base/test/ui_controls_internal_win.h",
]
}
if (is_linux) {
sources += [
# Support for UI input events.
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/aura_test_utils.cc",
"//ui/aura/test/aura_test_utils.h",
# Part of //ui/events:test_support which is testingonly.
"//ui/events/test/x11_event_waiter.cc",
"//ui/events/test/x11_event_waiter.h",
]
if (use_x11) {
sources += [
# Support for UI input events.
# Part of //ui/base/x:test_support which is testingonly.
"//ui/base/x/test/x11_ui_controls_test_helper.cc",
"//ui/base/x/test/x11_ui_controls_test_helper.h",
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
} else {
sources += [
# Support for UI input events.
# Part of //ui/base:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_ozone.cc",
# Part of //ui//events:test_support which is testingonly.
"//ui/events/test/events_test_utils.cc"
]
}
}
}
if (is_mac) {
sources += [
"libcef/browser/views/view_util_mac.mm",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/desktop_test_views_delegate_mac.mm",
"//ui/views/test/test_views_delegate_mac.mm",
# Support for UI input events.
# Part of //ui/base:test_support which is testingonly.
"//ui/base/test/ui_controls_mac.mm",
# Part of //ui//events:test_support which is testingonly.
"//ui/events/test/cocoa_test_event_utils.mm",
]
}
} else {
@ -2366,8 +2384,7 @@ if (is_mac) {
gypi_paths2.shared_sources_browser +
gypi_paths2.shared_sources_common +
gypi_paths2.shared_sources_renderer +
gypi_paths2.ceftests_sources_common +
gypi_paths2.ceftests_sources_views
gypi_paths2.ceftests_sources_common
deps = [
":libcef",

View File

@ -260,6 +260,8 @@
'tests/cefclient/browser/root_window_create.cc',
'tests/cefclient/browser/root_window_manager.cc',
'tests/cefclient/browser/root_window_manager.h',
'tests/cefclient/browser/root_window_views.cc',
'tests/cefclient/browser/root_window_views.h',
'tests/cefclient/browser/scheme_test.cc',
'tests/cefclient/browser/scheme_test.h',
'tests/cefclient/browser/server_test.cc',
@ -269,10 +271,18 @@
'tests/cefclient/browser/test_runner.h',
'tests/cefclient/browser/urlrequest_test.cc',
'tests/cefclient/browser/urlrequest_test.h',
'tests/cefclient/browser/views_menu_bar.cc',
'tests/cefclient/browser/views_menu_bar.h',
'tests/cefclient/browser/views_style.cc',
'tests/cefclient/browser/views_style.h',
'tests/cefclient/browser/views_window.cc',
'tests/cefclient/browser/views_window.h',
'tests/cefclient/browser/window_test.cc',
'tests/cefclient/browser/window_test.h',
'tests/cefclient/browser/window_test_runner.cc',
'tests/cefclient/browser/window_test_runner.h',
'tests/cefclient/browser/window_test_runner_views.cc',
'tests/cefclient/browser/window_test_runner_views.h',
],
'cefclient_sources_common': [
'tests/cefclient/common/client_app_delegates_common.cc',
@ -345,20 +355,10 @@
'tests/cefclient/browser/osr_window_win.cc',
'tests/cefclient/browser/osr_window_win.h',
'tests/cefclient/browser/resource_util_win_idmap.cc',
'tests/cefclient/browser/root_window_views.cc',
'tests/cefclient/browser/root_window_views.h',
'tests/cefclient/browser/root_window_win.cc',
'tests/cefclient/browser/root_window_win.h',
'tests/cefclient/browser/temp_window_win.cc',
'tests/cefclient/browser/temp_window_win.h',
'tests/cefclient/browser/views_menu_bar.cc',
'tests/cefclient/browser/views_menu_bar.h',
'tests/cefclient/browser/views_style.cc',
'tests/cefclient/browser/views_style.h',
'tests/cefclient/browser/views_window.cc',
'tests/cefclient/browser/views_window.h',
'tests/cefclient/browser/window_test_runner_views.cc',
'tests/cefclient/browser/window_test_runner_views.h',
'tests/cefclient/browser/window_test_runner_win.cc',
'tests/cefclient/browser/window_test_runner_win.h',
'tests/cefclient/cefclient_win.cc',
@ -411,22 +411,12 @@
'tests/cefclient/browser/resource_util_linux.cc',
'tests/cefclient/browser/root_window_gtk.cc',
'tests/cefclient/browser/root_window_gtk.h',
'tests/cefclient/browser/root_window_views.cc',
'tests/cefclient/browser/root_window_views.h',
'tests/cefclient/browser/temp_window_x11.cc',
'tests/cefclient/browser/temp_window_x11.h',
'tests/cefclient/browser/util_gtk.cc',
'tests/cefclient/browser/util_gtk.h',
'tests/cefclient/browser/views_menu_bar.cc',
'tests/cefclient/browser/views_menu_bar.h',
'tests/cefclient/browser/views_style.cc',
'tests/cefclient/browser/views_style.h',
'tests/cefclient/browser/views_window.cc',
'tests/cefclient/browser/views_window.h',
'tests/cefclient/browser/window_test_runner_gtk.cc',
'tests/cefclient/browser/window_test_runner_gtk.h',
'tests/cefclient/browser/window_test_runner_views.cc',
'tests/cefclient/browser/window_test_runner_views.h',
'tests/cefclient/cefclient_gtk.cc',
],
'cefsimple_sources_common': [
@ -538,12 +528,6 @@
'tests/ceftests/v8_unittest.cc',
'tests/ceftests/values_unittest.cc',
'tests/ceftests/version_unittest.cc',
'tests/ceftests/waitable_event_unittest.cc',
'tests/ceftests/webui_unittest.cc',
'tests/ceftests/xml_reader_unittest.cc',
'tests/ceftests/zip_reader_unittest.cc',
],
'ceftests_sources_views': [
'tests/ceftests/views/button_unittest.cc',
'tests/ceftests/views/panel_unittest.cc',
'tests/ceftests/views/scroll_view_unittest.cc',
@ -551,6 +535,10 @@
'tests/ceftests/views/test_window_delegate.h',
'tests/ceftests/views/textfield_unittest.cc',
'tests/ceftests/views/window_unittest.cc',
'tests/ceftests/waitable_event_unittest.cc',
'tests/ceftests/webui_unittest.cc',
'tests/ceftests/xml_reader_unittest.cc',
'tests/ceftests/zip_reader_unittest.cc',
],
'ceftests_sources_win': [
'tests/ceftests/resource_util_win_idmap.cc',

View File

@ -57,7 +57,7 @@ class Size;
class Vector2d;
} // namespace gfx
#if defined(USE_AURA)
#if defined(TOOLKIT_VIEWS)
namespace views {
class Widget;
}

View File

@ -29,6 +29,7 @@
#include "content/browser/renderer_host/text_input_manager.h"
#include "content/public/browser/render_frame_metadata_provider.h"
#include "content/public/common/widget_type.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/compositor/compositor.h"
#include "ui/events/base_event_utils.h"
@ -45,10 +46,6 @@
#include "ui/gfx/win/window_impl.h"
#endif
#if defined(USE_AURA)
#include "ui/base/cursor/cursor.h"
#endif
namespace content {
class DelegatedFrameHost;
class DelegatedFrameHostClient;

View File

@ -8,8 +8,6 @@
#include "libcef/browser/views/view_adapter.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/point.h"
@ -290,23 +288,4 @@ bool ConvertPointFromWindow(views::View* view, gfx::Point* point) {
return true;
}
gfx::NativeWindow GetNativeWindow(views::Widget* widget) {
if (widget) {
aura::Window* window = widget->GetNativeWindow();
if (window)
return window->GetRootWindow();
}
return nullptr;
}
CefWindowHandle GetWindowHandle(views::Widget* widget) {
// Same implementation as views::HWNDForView() but cross-platform.
if (widget) {
aura::Window* window = widget->GetNativeWindow();
if (window && window->GetRootWindow())
return window->GetHost()->GetAcceleratedWidget();
}
return kNullWindowHandle;
}
} // namespace view_util

View File

@ -117,6 +117,9 @@ bool ConvertPointFromWindow(views::View* view, gfx::Point* point);
// Returns the native window handle for |widget|. May return nullptr.
gfx::NativeWindow GetNativeWindow(views::Widget* widget);
// Returns the native view handle for |widget|. May return nullptr.
gfx::NativeView GetNativeView(views::Widget* widget);
// Returns the platform window handle for |widget|. May return nullptr.
CefWindowHandle GetWindowHandle(views::Widget* widget);

View File

@ -0,0 +1,36 @@
// 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.
#include "libcef/browser/views/view_util.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/views/widget/widget.h"
namespace view_util {
gfx::NativeWindow GetNativeWindow(views::Widget* widget) {
if (widget) {
aura::Window* window = widget->GetNativeWindow();
if (window)
return window->GetRootWindow();
}
return nullptr;
}
gfx::NativeView GetNativeView(views::Widget* widget) {
return GetNativeWindow(widget);
}
CefWindowHandle GetWindowHandle(views::Widget* widget) {
// Same implementation as views::HWNDForView() but cross-platform.
if (widget) {
aura::Window* window = widget->GetNativeWindow();
if (window && window->GetRootWindow())
return window->GetHost()->GetAcceleratedWidget();
}
return kNullWindowHandle;
}
} // namespace view_util

View File

@ -0,0 +1,32 @@
// 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/views/view_util.h"
#include "include/internal/cef_types_mac.h"
#include "ui/views/widget/widget.h"
namespace view_util {
gfx::NativeWindow GetNativeWindow(views::Widget* widget) {
if (widget)
return widget->GetNativeWindow();
return gfx::NativeWindow();
}
gfx::NativeView GetNativeView(views::Widget* widget) {
if (widget)
return widget->GetNativeView();
return gfx::NativeView();
}
CefWindowHandle GetWindowHandle(views::Widget* widget) {
auto view = GetNativeView(widget);
if (view)
return CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view.GetNativeNSView());
return kNullWindowHandle;
}
} // namespace view_util

View File

@ -10,7 +10,6 @@
#include "libcef/features/runtime.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/native_frame_view.h"
@ -24,6 +23,10 @@
#include "ui/views/win/hwnd_util.h"
#endif
#if defined(USE_AURA)
#include "ui/aura/window.h"
#endif
namespace {
// Specialize ClientView to handle Widget-related events.
@ -272,7 +275,7 @@ void CefWindowView::CreateWidget() {
if (parent_window && !parent_window->IsSame(cef_window)) {
CefWindowImpl* parent_window_impl =
static_cast<CefWindowImpl*>(parent_window.get());
params.parent = view_util::GetNativeWindow(parent_window_impl->widget());
params.parent = view_util::GetNativeView(parent_window_impl->widget());
if (is_menu) {
// Don't clip the window to parent bounds.
params.type = views::Widget::InitParams::TYPE_MENU;

View File

@ -9,7 +9,7 @@
#include "chrome/browser/platform_util.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#if defined(USE_AURA)
#if defined(TOOLKIT_VIEWS)
#include "ui/views/widget/widget.h"
#endif
@ -38,7 +38,7 @@ CefWebContentsDialogHelper::GetWebContentsModalDialogHost() {
}
gfx::NativeView CefWebContentsDialogHelper::GetHostView() const {
#if defined(USE_AURA)
#if defined(TOOLKIT_VIEWS)
return browser_delegate_->GetWindowWidget()->GetNativeView();
#else
NOTIMPLEMENTED();

View File

@ -505,6 +505,9 @@ patches = [
{
# Fix build errors with enable_background_mode=false.
# https://bugs.chromium.org/p/chromium/issues/detail?id=1100085
#
# Changes to support the Chrome runtime in CEF (app_controller_mac.mm).
# https://bitbucket.org/chromiumembedded/cef/issues/2969
'name': 'chrome_browser_background_mode_1100085',
},
{

View File

@ -1,8 +1,16 @@
diff --git chrome/browser/app_controller_mac.mm chrome/browser/app_controller_mac.mm
index e2eb5c2c73d0..601b582c6675 100644
index e2eb5c2c73d0..d08b0a9a2a54 100644
--- chrome/browser/app_controller_mac.mm
+++ chrome/browser/app_controller_mac.mm
@@ -1194,6 +1194,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
@@ -29,6 +29,7 @@
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/branding_buildflags.h"
+#include "cef/libcef/features/features.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/apps/app_shim/app_shim_manager_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_termination_manager.h"
@@ -1194,6 +1195,7 @@ - (void)commandDispatch:(id)sender {
// Run a (background) application in a new tab.
- (void)executeApplication:(id)sender {
@ -10,7 +18,7 @@ index e2eb5c2c73d0..601b582c6675 100644
NSInteger tag = [sender tag];
Profile* profile = [self lastProfile];
DCHECK(profile);
@@ -1202,6 +1203,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
@@ -1202,6 +1204,7 @@ - (void)executeApplication:(id)sender {
tag < static_cast<int>(applications.size()));
const extensions::Extension* extension = applications.GetExtension(tag);
BackgroundModeManager::LaunchBackgroundApplication(profile, extension);
@ -18,7 +26,7 @@ index e2eb5c2c73d0..601b582c6675 100644
}
// Same as |-commandDispatch:|, but executes commands using a disposition
@@ -1599,6 +1601,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
@@ -1599,6 +1602,7 @@ - (NSMenu*)applicationDockMenu:(NSApplication*)sender {
// TODO(rickcam): Mock out BackgroundApplicationListModel, then add unit
// tests which use the mock in place of the profile-initialized model.
@ -26,7 +34,7 @@ index e2eb5c2c73d0..601b582c6675 100644
// Avoid breaking unit tests which have no profile.
if (profile) {
BackgroundApplicationListModel applications(profile);
@@ -1625,6 +1628,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
@@ -1625,6 +1629,7 @@ - (NSMenu*)applicationDockMenu:(NSApplication*)sender {
}
}
}
@ -34,6 +42,20 @@ index e2eb5c2c73d0..601b582c6675 100644
return dockMenu;
}
@@ -1835,11 +1840,13 @@ - (void)handoffActiveURLChanged:(content::WebContents*)webContents {
namespace {
void UpdateProfileInUse(Profile* profile, Profile::CreateStatus status) {
+#if !BUILDFLAG(ENABLE_CEF)
if (status == Profile::CREATE_STATUS_INITIALIZED) {
AppController* controller =
base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
[controller windowChangedToProfile:profile];
}
+#endif // !BUILDFLAG(ENABLE_CEF)
}
} // namespace
diff --git chrome/browser/browser_process.h chrome/browser/browser_process.h
index 1ea08a7ad6ae..473ebde08451 100644
--- chrome/browser/browser_process.h

View File

@ -128,6 +128,44 @@ index fee4d5f1a8ca..2e4fb506d851 100644
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
// of lacros-chrome is complete.
#if defined(OS_WIN) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
diff --git chrome/browser/chrome_browser_main_mac.mm chrome/browser/chrome_browser_main_mac.mm
index c30b73c2575f..5da45a243f9b 100644
--- chrome/browser/chrome_browser_main_mac.mm
+++ chrome/browser/chrome_browser_main_mac.mm
@@ -16,6 +16,7 @@
#include "base/path_service.h"
#include "base/strings/sys_string_conversions.h"
#include "build/branding_buildflags.h"
+#include "cef/libcef/features/features.h"
#import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_listener.h"
#include "chrome/browser/browser_process.h"
@@ -111,6 +112,7 @@
}
}
+#if !BUILDFLAG(ENABLE_CEF)
// Create the app delegate. This object is intentionally leaked as a global
// singleton. It is accessed through -[NSApp delegate].
AppController* app_controller = [[AppController alloc] init];
@@ -119,6 +121,7 @@
chrome::BuildMainMenu(NSApp, app_controller,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), false);
[app_controller mainMenuCreated];
+#endif // BUILDFLAG(ENABLE_CEF)
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
@@ -175,7 +178,9 @@
}
void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() {
+#if !BUILDFLAG(ENABLE_CEF)
AppController* appController =
base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
[appController didEndMainMessageLoop];
+#endif
}
diff --git chrome/browser/notifications/notification_platform_bridge_mac.mm chrome/browser/notifications/notification_platform_bridge_mac.mm
index 9e8fcb9f9f91..2a9eaca0fb0d 100644
--- chrome/browser/notifications/notification_platform_bridge_mac.mm
@ -140,7 +178,7 @@ index 9e8fcb9f9f91..2a9eaca0fb0d 100644
#include "chrome/browser/browser_features.h"
#include "chrome/browser/notifications/notification_common.h"
#include "chrome/browser/notifications/notification_display_service_impl.h"
@@ -451,6 +452,12 @@ getDisplayedAlertsForProfileId:(NSString*)profileId
@@ -451,6 +452,12 @@ - (void)notificationClick:(NSDictionary*)notificationResponseData {
- (id<NotificationDelivery>)serviceProxy {
id<NotificationDelivery> proxy = [_xpcConnection remoteObjectProxy];

View File

@ -103,7 +103,6 @@ MainContextImpl::MainContextImpl(CefRefPtr<CefCommandLine> command_line,
use_chrome_runtime_ = false;
}
#if defined(OS_WIN) || defined(OS_LINUX)
// Whether the Views framework will be used.
use_views_ = command_line_->HasSwitch(switches::kUseViews);
@ -126,7 +125,6 @@ MainContextImpl::MainContextImpl(CefRefPtr<CefCommandLine> command_line,
// Use the draggable regions test as the default URL for frameless windows.
main_url_ = "http://tests/draggable";
}
#endif // defined(OS_WIN) || defined(OS_LINUX)
if (command_line_->HasSwitch(switches::kBackgroundColor)) {
// Parse the background color value.

View File

@ -4,9 +4,7 @@
#include "tests/cefclient/browser/root_window.h"
#if defined(OS_WIN) || defined(OS_LINUX)
#include "tests/cefclient/browser/root_window_views.h"
#endif
#if defined(OS_WIN)
#include "tests/cefclient/browser/root_window_win.h"
@ -21,11 +19,7 @@ namespace client {
// static
scoped_refptr<RootWindow> RootWindow::Create(bool use_views) {
if (use_views) {
#if defined(OS_WIN) || defined(OS_LINUX)
return new RootWindowViews();
#else
LOG(FATAL) << "Views framework is not supported on this platform.";
#endif
}
#if defined(OS_WIN)

View File

@ -686,9 +686,13 @@ ViewsWindow::ViewsWindow(Delegate* delegate,
frameless_ = command_line->HasSwitch(switches::kHideFrame) ||
delegate_->WithExtension();
#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.
if (!command_line->HasSwitch(switches::kHideTopMenu)) {
top_menu_bar_ = new ViewsMenuBar(this, ID_TOP_MENU_FIRST);
}
#endif
}
void ViewsWindow::SetBrowserView(CefRefPtr<CefBrowserView> browser_view) {

View File

@ -13,12 +13,8 @@
#include "tests/cefsimple/simple_handler.h"
// Receives notifications from the application.
@interface SimpleAppDelegate : NSObject <NSApplicationDelegate> {
@private
bool with_chrome_runtime_;
}
@interface SimpleAppDelegate : NSObject <NSApplicationDelegate>
- (id)initWithChromeRuntime:(bool)with_chrome_runtime;
- (void)createApplication:(id)object;
- (void)tryToTerminateApplication:(NSApplication*)app;
@end
@ -91,23 +87,11 @@
@implementation SimpleAppDelegate
- (id)initWithChromeRuntime:(bool)with_chrome_runtime {
if (self = [super init]) {
with_chrome_runtime_ = with_chrome_runtime;
}
return self;
}
// Create the application on the UI thread.
- (void)createApplication:(id)object {
if (!with_chrome_runtime_) {
// Chrome will create the top-level menu programmatically in
// chrome/browser/ui/cocoa/main_menu_builder.h
// TODO(chrome-runtime): Expose a way to customize this menu.
[[NSBundle mainBundle] loadNibNamed:@"MainMenu"
owner:NSApp
topLevelObjects:nil];
}
[[NSBundle mainBundle] loadNibNamed:@"MainMenu"
owner:NSApp
topLevelObjects:nil];
// Set the delegate for application events.
[[NSApplication sharedApplication] setDelegate:self];
@ -177,8 +161,7 @@ int main(int argc, char* argv[]) {
CefInitialize(main_args, settings, app.get(), NULL);
// Create the application delegate.
NSObject* delegate =
[[SimpleAppDelegate alloc] initWithChromeRuntime:with_chrome_runtime];
NSObject* delegate = [[SimpleAppDelegate alloc] init];
[delegate performSelectorOnMainThread:@selector(createApplication:)
withObject:nil
waitUntilDone:NO];

View File

@ -85,15 +85,10 @@ void SimpleApp::OnContextInitialized() {
CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine();
#if defined(OS_WIN) || defined(OS_LINUX)
// Create the browser using the Views framework if "--use-views" is specified
// via the command-line. Otherwise, create the browser using the native
// platform framework. The Views framework is currently only supported on
// Windows and Linux.
// platform framework.
const bool use_views = command_line->HasSwitch("use-views");
#else
const bool use_views = false;
#endif
// SimpleHandler implements browser-level callbacks.
CefRefPtr<SimpleHandler> handler(new SimpleHandler(use_views));

View File

@ -21,8 +21,6 @@
'ceftests_sources_common',
'ceftests_sources_linux:LINUX',
'ceftests_sources_mac:MAC',
'ceftests_sources_views:WINDOWS',
'ceftests_sources_views:LINUX',
'ceftests_sources_win:WINDOWS',
],
}}

View File

@ -8,20 +8,15 @@
#include "include/base/cef_logging.h"
#include "include/cef_command_line.h"
#include "include/cef_stream.h"
#include "include/views/cef_browser_view.h"
#include "include/views/cef_window.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_stream_resource_handler.h"
#include "tests/ceftests/test_request.h"
#include "tests/shared/common/client_switches.h"
#if defined(USE_AURA)
#include "include/views/cef_browser_view.h"
#include "include/views/cef_window.h"
#endif
namespace {
#if defined(USE_AURA)
// Delegate implementation for the CefWindow that will host the Views-based
// browser.
class TestWindowDelegate : public CefWindowDelegate {
@ -88,8 +83,6 @@ class TestBrowserViewDelegate : public CefBrowserViewDelegate {
DISALLOW_COPY_AND_ASSIGN(TestBrowserViewDelegate);
};
#endif // defined(USE_AURA)
} // namespace
// TestHandler::CompletionState
@ -353,7 +346,6 @@ void TestHandler::OnTestTimeout(int timeout_ms, bool treat_as_error) {
void TestHandler::CreateBrowser(const CefString& url,
CefRefPtr<CefRequestContext> request_context,
CefRefPtr<CefDictionaryValue> extra_info) {
#if defined(USE_AURA)
const bool use_views = CefCommandLine::GetGlobalCommandLine()->HasSwitch(
client::switches::kUseViews);
if (use_views && !CefCurrentlyOn(TID_UI)) {
@ -362,13 +354,11 @@ void TestHandler::CreateBrowser(const CefString& url,
request_context, extra_info));
return;
}
#endif // defined(USE_AURA)
CefWindowInfo windowInfo;
CefBrowserSettings settings;
PopulateBrowserSettings(&settings);
#if defined(USE_AURA)
if (use_views) {
// Create the BrowserView.
CefRefPtr<CefBrowserView> browser_view = CefBrowserView::CreateBrowserView(
@ -377,9 +367,7 @@ void TestHandler::CreateBrowser(const CefString& url,
// Create the Window. It will show itself after creation.
TestWindowDelegate::CreateBrowserWindow(browser_view, std::string());
} else
#endif // defined(USE_AURA)
{
} else {
#if defined(OS_WIN)
windowInfo.SetAsPopup(nullptr, "CefUnitTest");
windowInfo.style |= WS_VISIBLE;

View File

@ -189,12 +189,12 @@ void CefTestSuite::PreInitialize() {
HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0);
#endif
#if defined(OS_LINUX) && defined(USE_AURA)
#if defined(OS_LINUX)
// When calling native char conversion functions (e.g wrctomb) we need to
// have the locale set. In the absence of such a call the "C" locale is the
// default. In the gtk code (below) gtk_init() implicitly sets a locale.
setlocale(LC_ALL, "");
#endif // defined(OS_LINUX) && defined(USE_AURA)
#endif // defined(OS_LINUX)
// Don't add additional code to this function. Instead add it to Initialize().
}

View File

@ -995,8 +995,6 @@ if platform == 'windows':
'tests/ceftests/', ceftests_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_resources_win'], \
'tests/ceftests/', ceftests_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_views'], \
'tests/ceftests/', ceftests_dir, options.quiet)
if not options.nodocs:
# generate doc files
@ -1257,8 +1255,6 @@ elif platform == 'linux':
# transfer ceftests files
transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_linux'], \
'tests/ceftests/', ceftests_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['ceftests_sources_views'], \
'tests/ceftests/', ceftests_dir, options.quiet)
if not options.noarchive:
# create an archive for each output directory