mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-13 10:06:28 +01:00
8733cb89c7
The Chrome browser can now be hosted in a Views-based application on Windows and Linux. To launch a fully-featured Chrome window using cefsimple: $ cefsimple --enable-chrome-runtime To launch a minimally-styled Views-hosted window using cefsimple: $ cefsimple --enable-chrome-runtime --use-views To launch a fully-styled Views-hosted window using cefclient: $ cefclient --enable-chrome-runtime --use-views Views unit tests also now pass with the Chrome runtime enabled: $ ceftests --gtest_filter=Views* --enable-chrome-runtime Known issues: - Popup browsers cannot be intercepted and reparented.
234 lines
8.6 KiB
Diff
234 lines
8.6 KiB
Diff
diff --git chrome/browser/ui/views/frame/browser_frame.cc chrome/browser/ui/views/frame/browser_frame.cc
|
|
index 5c03f250e500..ecfce9c2c7c7 100644
|
|
--- chrome/browser/ui/views/frame/browser_frame.cc
|
|
+++ chrome/browser/ui/views/frame/browser_frame.cc
|
|
@@ -63,15 +63,23 @@ bool IsUsingGtkTheme(Profile* profile) {
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// BrowserFrame, public:
|
|
|
|
+BrowserFrame::BrowserFrame() : BrowserFrame(nullptr) {}
|
|
+
|
|
BrowserFrame::BrowserFrame(BrowserView* browser_view)
|
|
: native_browser_frame_(nullptr),
|
|
root_view_(nullptr),
|
|
browser_frame_view_(nullptr),
|
|
- browser_view_(browser_view) {
|
|
- browser_view_->set_frame(this);
|
|
+ browser_view_(nullptr) {
|
|
set_is_secondary_widget(false);
|
|
// Don't focus anything on creation, selecting a tab will set the focus.
|
|
set_focus_on_creation(false);
|
|
+ if (browser_view)
|
|
+ InitBrowserView(browser_view);
|
|
+}
|
|
+
|
|
+void BrowserFrame::InitBrowserView(BrowserView* browser_view) {
|
|
+ browser_view_ = browser_view;
|
|
+ browser_view_->set_frame(this);
|
|
}
|
|
|
|
BrowserFrame::~BrowserFrame() {}
|
|
@@ -133,6 +141,12 @@ gfx::Rect BrowserFrame::GetBoundsForTabStripRegion(
|
|
}
|
|
|
|
int BrowserFrame::GetTopInset() const {
|
|
+ if (!browser_frame_view_) {
|
|
+ // With CEF the browser may already be part of a larger Views layout. Zero
|
|
+ // out the adjustment in BrowserView::GetTopInsetInBrowserView() so that
|
|
+ // the browser isn't shifted to the top of the window.
|
|
+ return browser_view_->y();
|
|
+ }
|
|
return browser_frame_view_->GetTopInset(false);
|
|
}
|
|
|
|
@@ -167,15 +181,21 @@ void BrowserFrame::GetWindowPlacement(gfx::Rect* bounds,
|
|
|
|
content::KeyboardEventProcessingResult BrowserFrame::PreHandleKeyboardEvent(
|
|
const content::NativeWebKeyboardEvent& event) {
|
|
+ if (!native_browser_frame_)
|
|
+ return content::KeyboardEventProcessingResult::NOT_HANDLED;
|
|
return native_browser_frame_->PreHandleKeyboardEvent(event);
|
|
}
|
|
|
|
bool BrowserFrame::HandleKeyboardEvent(
|
|
const content::NativeWebKeyboardEvent& event) {
|
|
+ if (!native_browser_frame_)
|
|
+ return false;
|
|
return native_browser_frame_->HandleKeyboardEvent(event);
|
|
}
|
|
|
|
void BrowserFrame::OnBrowserViewInitViewsComplete() {
|
|
+ if (!browser_frame_view_)
|
|
+ return;
|
|
browser_frame_view_->OnBrowserViewInitViewsComplete();
|
|
}
|
|
|
|
@@ -208,7 +228,8 @@ const ui::ThemeProvider* BrowserFrame::GetThemeProvider() const {
|
|
}
|
|
|
|
const ui::NativeTheme* BrowserFrame::GetNativeTheme() const {
|
|
- if (browser_view_->browser()->profile()->IsIncognitoProfile() &&
|
|
+ if (browser_view_ &&
|
|
+ browser_view_->browser()->profile()->IsIncognitoProfile() &&
|
|
ThemeServiceFactory::GetForProfile(browser_view_->browser()->profile())
|
|
->UsingDefaultTheme()) {
|
|
return ui::NativeTheme::GetInstanceForDarkUI();
|
|
diff --git chrome/browser/ui/views/frame/browser_frame.h chrome/browser/ui/views/frame/browser_frame.h
|
|
index 3a1314f21ce4..f9464abc97a7 100644
|
|
--- chrome/browser/ui/views/frame/browser_frame.h
|
|
+++ chrome/browser/ui/views/frame/browser_frame.h
|
|
@@ -53,7 +53,9 @@ enum class TabDragKind {
|
|
// This is a virtual interface that allows system specific browser frames.
|
|
class BrowserFrame : public views::Widget, public views::ContextMenuController {
|
|
public:
|
|
+ BrowserFrame();
|
|
explicit BrowserFrame(BrowserView* browser_view);
|
|
+ void InitBrowserView(BrowserView* browser_view);
|
|
~BrowserFrame() override;
|
|
|
|
// 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 c4d99326bacf..3c7b45b99186 100644
|
|
--- chrome/browser/ui/views/frame/browser_view.cc
|
|
+++ chrome/browser/ui/views/frame/browser_view.cc
|
|
@@ -545,16 +545,26 @@ class BrowserView::AccessibilityModeObserver : public ui::AXModeObserver {
|
|
// static
|
|
const char BrowserView::kViewClassName[] = "BrowserView";
|
|
|
|
+BrowserView::BrowserView() : BrowserView(nullptr) {}
|
|
+
|
|
BrowserView::BrowserView(std::unique_ptr<Browser> browser)
|
|
: views::ClientView(nullptr, nullptr),
|
|
- browser_(std::move(browser)),
|
|
accessibility_mode_observer_(
|
|
std::make_unique<AccessibilityModeObserver>(this)) {
|
|
+ if (browser)
|
|
+ InitBrowser(std::move(browser));
|
|
+}
|
|
+
|
|
+void BrowserView::InitBrowser(std::unique_ptr<Browser> browser) {
|
|
+ DCHECK(!browser_);
|
|
+ browser_ = std::move(browser);
|
|
+
|
|
+ immersive_mode_controller_ = chrome::CreateImmersiveModeController();
|
|
+
|
|
SetShowIcon(::ShouldShowWindowIcon(browser_.get()));
|
|
SetHasWindowSizeControls(!chrome::IsRunningInForcedAppMode());
|
|
|
|
browser_->tab_strip_model()->AddObserver(this);
|
|
- immersive_mode_controller_ = chrome::CreateImmersiveModeController();
|
|
|
|
// Top container holds tab strip region and toolbar and lives at the front of
|
|
// the view hierarchy.
|
|
@@ -1340,6 +1350,8 @@ bool BrowserView::ShouldHideUIForFullscreen() const {
|
|
if (immersive_mode_controller_->IsEnabled())
|
|
return false;
|
|
|
|
+ if (!frame_->GetFrameView())
|
|
+ return false;
|
|
return frame_->GetFrameView()->ShouldHideTopUIForFullscreen();
|
|
}
|
|
|
|
@@ -2357,7 +2369,8 @@ BrowserView::GetNativeViewHostsForTopControlsSlide() const {
|
|
}
|
|
|
|
void BrowserView::ReparentTopContainerForEndOfImmersive() {
|
|
- overlay_view_->SetVisible(false);
|
|
+ if (overlay_view_)
|
|
+ overlay_view_->SetVisible(false);
|
|
top_container()->DestroyLayer();
|
|
AddChildViewAt(top_container(), 0);
|
|
EnsureFocusOrder();
|
|
@@ -2804,7 +2817,8 @@ 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);
|
|
- frame()->GetFrameView()->UpdateMinimumSize();
|
|
+ if (frame()->GetFrameView())
|
|
+ frame()->GetFrameView()->UpdateMinimumSize();
|
|
|
|
// Some of the situations when the BrowserView is laid out are:
|
|
// - Enter/exit immersive fullscreen mode.
|
|
@@ -2907,7 +2921,8 @@ void BrowserView::AddedToWidget() {
|
|
SetToolbarButtonProvider(toolbar_);
|
|
|
|
frame_->OnBrowserViewInitViewsComplete();
|
|
- frame_->GetFrameView()->UpdateMinimumSize();
|
|
+ if (frame_->GetFrameView())
|
|
+ frame_->GetFrameView()->UpdateMinimumSize();
|
|
using_native_frame_ = frame_->ShouldUseNativeFrame();
|
|
|
|
MaybeInitializeWebUITabStrip();
|
|
diff --git chrome/browser/ui/views/frame/browser_view.h chrome/browser/ui/views/frame/browser_view.h
|
|
index 986798357dbc..2793bf7b184e 100644
|
|
--- chrome/browser/ui/views/frame/browser_view.h
|
|
+++ chrome/browser/ui/views/frame/browser_view.h
|
|
@@ -117,7 +117,9 @@ class BrowserView : public BrowserWindow,
|
|
// The browser view's class name.
|
|
static const char kViewClassName[];
|
|
|
|
+ BrowserView();
|
|
explicit BrowserView(std::unique_ptr<Browser> browser);
|
|
+ void InitBrowser(std::unique_ptr<Browser> browser);
|
|
~BrowserView() override;
|
|
|
|
void set_frame(BrowserFrame* frame) { frame_ = frame; }
|
|
diff --git chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
|
|
index 824acb2c7c8a..cd81e0e3f4d3 100644
|
|
--- chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
|
|
+++ chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
|
|
@@ -578,37 +578,53 @@ gfx::Range BrowserTabStripController::ListTabsInGroup(
|
|
}
|
|
|
|
bool BrowserTabStripController::IsFrameCondensed() const {
|
|
+ if (!GetFrameView())
|
|
+ return false;
|
|
return GetFrameView()->IsFrameCondensed();
|
|
}
|
|
|
|
bool BrowserTabStripController::HasVisibleBackgroundTabShapes() const {
|
|
+ if (!GetFrameView())
|
|
+ return false;
|
|
return GetFrameView()->HasVisibleBackgroundTabShapes(
|
|
BrowserFrameActiveState::kUseCurrent);
|
|
}
|
|
|
|
bool BrowserTabStripController::EverHasVisibleBackgroundTabShapes() const {
|
|
+ if (!GetFrameView())
|
|
+ return false;
|
|
return GetFrameView()->EverHasVisibleBackgroundTabShapes();
|
|
}
|
|
|
|
bool BrowserTabStripController::ShouldPaintAsActiveFrame() const {
|
|
+ if (!GetFrameView())
|
|
+ return false;
|
|
return GetFrameView()->ShouldPaintAsActive();
|
|
}
|
|
|
|
bool BrowserTabStripController::CanDrawStrokes() const {
|
|
+ if (!GetFrameView())
|
|
+ return false;
|
|
return GetFrameView()->CanDrawStrokes();
|
|
}
|
|
|
|
SkColor BrowserTabStripController::GetFrameColor(
|
|
BrowserFrameActiveState active_state) const {
|
|
+ if (!GetFrameView())
|
|
+ return SK_ColorWHITE;
|
|
return GetFrameView()->GetFrameColor(active_state);
|
|
}
|
|
|
|
SkColor BrowserTabStripController::GetToolbarTopSeparatorColor() const {
|
|
+ if (!GetFrameView())
|
|
+ return SK_ColorWHITE;
|
|
return GetFrameView()->GetToolbarTopSeparatorColor();
|
|
}
|
|
|
|
base::Optional<int> BrowserTabStripController::GetCustomBackgroundId(
|
|
BrowserFrameActiveState active_state) const {
|
|
+ if (!GetFrameView())
|
|
+ return base::nullopt;
|
|
return GetFrameView()->GetCustomBackgroundId(active_state);
|
|
}
|
|
|