mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Implement Views framework on Windows and Linux (issue #1749).
- Add Views header files in a new include/views directory. - Add initial top-level window (CefWindow), control (CefBrowserView, CefLabelButton, CefMenuButton, CefPanel, CefScrollView, CefTextfield) and layout (CefBoxLayout, CefFlowLayout) support. See libcef/browser/views/view_impl.h comments for implementation details. - Add Views example usage in cefclient and cefsimple and Views unit tests in cef_unittests. Pass the `--use-views` command-line flag to cefclient, cefsimple and cef_unittests to run using the Views framework instead of platform APIs. For cefclient and cefsimple this will create the browser window and all related functionality using the Views framework. For cef_unittests this will run all tests (except OSR tests) in a Views-based browser window. Views- specific unit tests (`--gtest_filter=Views*`) will be run even if the the `--use-views` flag is not specified. - Pass the `--hide-frame` command-line flag to cefclient to demo a frameless Views-based browser window. - Pass the `--hide-controls` command-line flag to cefclient to demo a browser window without top controls. This also works in non-Views mode. - Pass the `--enable-high-dpi-support` command-line flag to cef_unittests on Windows to test high-DPI support on a display that supports it. - Add CefImage for reading/writing image file formats. - Add CefBrowser::DownloadImage() for downloading image URLs as a CefImage representation. This is primarily for loading favicons. - Add CefMenuModel::CreateMenuModel() and CefMenuModelDelegate for creating custom menus. This is primarily for use with CefMenuButton. - Add CefBrowser::TryCloseBrowser() helper for closing a browser. Also improve related documentation in cef_life_span_handler.h. - Rename cef_page_range_t to cef_range_t. It is now also used by CefTextfield. - Remove CefLifeSpanHandler::RunModal() which is never called. - Add draggable regions example to cefclient.
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_client.h"
|
||||
#include "include/cef_frame.h"
|
||||
#include "include/views/cef_browser_view.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/file_dialog_manager.h"
|
||||
#include "libcef/browser/frame_host_impl.h"
|
||||
#include "libcef/browser/javascript_dialog_manager.h"
|
||||
@@ -37,10 +37,17 @@ namespace net {
|
||||
class URLRequest;
|
||||
}
|
||||
|
||||
#if defined(USE_AURA)
|
||||
namespace views {
|
||||
class Widget;
|
||||
}
|
||||
#endif // defined(USE_AURA)
|
||||
|
||||
struct Cef_DraggableRegion_Params;
|
||||
struct Cef_Request_Params;
|
||||
struct Cef_Response_Params;
|
||||
class CefBrowserInfo;
|
||||
class CefBrowserPlatformDelegate;
|
||||
class CefDevToolsFrontend;
|
||||
struct CefNavigateParams;
|
||||
class SiteInstance;
|
||||
@@ -86,15 +93,37 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
|
||||
~CefBrowserHostImpl() override;
|
||||
|
||||
struct CreateParams {
|
||||
// Platform-specific window creation info. Will be nullptr when creating a
|
||||
// views-hosted browser.
|
||||
scoped_ptr<CefWindowInfo> window_info;
|
||||
|
||||
#if defined(USE_AURA)
|
||||
// The BrowserView that will own a views-hosted browser. Will be nullptr for
|
||||
// popup browsers (the BrowserView will be created later in that case).
|
||||
CefRefPtr<CefBrowserView> browser_view;
|
||||
#endif
|
||||
|
||||
// Client implementation. May be nullptr.
|
||||
CefRefPtr<CefClient> client;
|
||||
|
||||
// Initial URL to load. May be empty.
|
||||
CefString url;
|
||||
|
||||
// Browser settings.
|
||||
CefBrowserSettings settings;
|
||||
|
||||
// Other browser that opened this DevTools browser. Will be nullptr for non-
|
||||
// DevTools browsers.
|
||||
CefRefPtr<CefBrowserHostImpl> devtools_opener;
|
||||
|
||||
// Request context to use when creating the browser. If nullptr the global
|
||||
// request context will be used.
|
||||
CefRefPtr<CefRequestContext> request_context;
|
||||
};
|
||||
|
||||
// Create a new CefBrowserHostImpl instance.
|
||||
static CefRefPtr<CefBrowserHostImpl> Create(
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefString& url,
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefBrowserHostImpl> opener,
|
||||
bool is_popup,
|
||||
CefRefPtr<CefRequestContext> request_context);
|
||||
static CefRefPtr<CefBrowserHostImpl> Create(CreateParams& create_params);
|
||||
|
||||
// Returns the browser associated with the specified RenderViewHost.
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForHost(
|
||||
@@ -118,10 +147,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// CefBrowserHost methods.
|
||||
CefRefPtr<CefBrowser> GetBrowser() override;
|
||||
void CloseBrowser(bool force_close) override;
|
||||
bool TryCloseBrowser() override;
|
||||
void SetFocus(bool focus) override;
|
||||
void SetWindowVisibility(bool visible) override;
|
||||
CefWindowHandle GetWindowHandle() override;
|
||||
CefWindowHandle GetOpenerWindowHandle() override;
|
||||
bool HasView() override;
|
||||
CefRefPtr<CefClient> GetClient() override;
|
||||
CefRefPtr<CefRequestContext> GetRequestContext() override;
|
||||
double GetZoomLevel() override;
|
||||
@@ -134,6 +165,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) override;
|
||||
void StartDownload(const CefString& url) override;
|
||||
void DownloadImage(const CefString& image_url,
|
||||
bool is_favicon,
|
||||
uint32 max_image_size,
|
||||
bool bypass_cache,
|
||||
CefRefPtr<CefDownloadImageCallback> callback) override;
|
||||
void Print() override;
|
||||
void PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
@@ -212,6 +248,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Returns true if windowless rendering is enabled.
|
||||
bool IsWindowless() const;
|
||||
|
||||
// Returns true if this browser is views-hosted.
|
||||
bool IsViewsHosted() const;
|
||||
|
||||
// Called when the OS window hosting the browser is destroyed.
|
||||
void WindowDestroyed();
|
||||
|
||||
@@ -226,6 +265,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Returns the Widget owner for the browser window. Only used with windowed
|
||||
// rendering.
|
||||
views::Widget* GetWindowWidget() const;
|
||||
|
||||
// Returns the BrowserView associated with this browser. Only used with views-
|
||||
// based browsers.
|
||||
CefRefPtr<CefBrowserView> GetBrowserView() const;
|
||||
#endif
|
||||
|
||||
// Returns the frame associated with the specified URLRequest.
|
||||
@@ -271,7 +314,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Set the frame that currently has focus.
|
||||
void SetFocusedFrame(int64 frame_id);
|
||||
|
||||
// Convert from view coordinates to screen coordinates.
|
||||
// Convert from view coordinates to screen coordinates. Potential display
|
||||
// scaling will be applied to the result.
|
||||
gfx::Point GetScreenPoint(const gfx::Point& view) const;
|
||||
|
||||
// Thread safe accessors.
|
||||
@@ -449,6 +493,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
content::WebContents* web_contents,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefBrowserHostImpl> opener,
|
||||
bool is_devtools_popup,
|
||||
CefRefPtr<CefRequestContext> request_context,
|
||||
scoped_ptr<CefBrowserPlatformDelegate> platform_delegate);
|
||||
|
||||
@@ -521,6 +566,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
CefRefPtr<CefRequestContext> request_context_;
|
||||
scoped_ptr<CefBrowserPlatformDelegate> platform_delegate_;
|
||||
const bool is_windowless_;
|
||||
const bool is_views_hosted_;
|
||||
CefWindowHandle host_window_handle_;
|
||||
|
||||
// Volatile state information. All access must be protected by the state lock.
|
||||
base::Lock state_lock_;
|
||||
|
Reference in New Issue
Block a user