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:
@@ -10,8 +10,10 @@
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_menu_model.h"
|
||||
#include "include/cef_menu_model_delegate.h"
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/threading/platform_thread.h"
|
||||
#include "ui/base/models/menu_model.h"
|
||||
|
||||
@@ -42,8 +44,22 @@ class CefMenuModelImpl : public CefMenuModel {
|
||||
virtual ~Delegate() {}
|
||||
};
|
||||
|
||||
// The delegate must outlive this class.
|
||||
explicit CefMenuModelImpl(Delegate* delegate);
|
||||
class Observer {
|
||||
public:
|
||||
// Notifies the delegate that the menu is about to show.
|
||||
virtual void MenuWillShow(CefRefPtr<CefMenuModelImpl> source) {};
|
||||
|
||||
// Notifies the delegate that the menu has closed.
|
||||
virtual void MenuClosed(CefRefPtr<CefMenuModelImpl> source) {};
|
||||
|
||||
protected:
|
||||
virtual ~Observer() {}
|
||||
};
|
||||
|
||||
// Either |delegate| or |menu_model_delegate| must be non-nullptr.
|
||||
// If |delegate| is non-nullptr it must outlive this class.
|
||||
CefMenuModelImpl(Delegate* delegate,
|
||||
CefRefPtr<CefMenuModelDelegate> menu_model_delegate);
|
||||
~CefMenuModelImpl() override;
|
||||
|
||||
// CefMenuModel methods.
|
||||
@@ -116,12 +132,20 @@ class CefMenuModelImpl : public CefMenuModel {
|
||||
// Verify that only a single reference exists to all CefMenuModelImpl objects.
|
||||
bool VerifyRefCount();
|
||||
|
||||
// Manage observer objects. The observer must either outlive this object or
|
||||
// remove itself before destruction.
|
||||
void AddObserver(Observer* observer);
|
||||
void RemoveObserver(Observer* observer);
|
||||
bool HasObserver(Observer* observer) const;
|
||||
|
||||
// Helper for adding custom menu items originating from the renderer process.
|
||||
void AddMenuItem(const content::MenuItem& menu_item);
|
||||
|
||||
ui::MenuModel* model() { return model_.get(); }
|
||||
|
||||
// Used when created via CefMenuManager.
|
||||
Delegate* delegate() { return delegate_; }
|
||||
void set_delegate(Delegate* delegate) { delegate_ = NULL; }
|
||||
void set_delegate(Delegate* delegate) { delegate_ = delegate; }
|
||||
|
||||
private:
|
||||
struct Item;
|
||||
@@ -140,10 +164,19 @@ class CefMenuModelImpl : public CefMenuModel {
|
||||
bool VerifyContext();
|
||||
|
||||
base::PlatformThreadId supported_thread_id_;
|
||||
|
||||
// Used when created via CefMenuManager.
|
||||
Delegate* delegate_;
|
||||
|
||||
// Used when created via CefMenuModel::CreateMenuModel().
|
||||
CefRefPtr<CefMenuModelDelegate> menu_model_delegate_;
|
||||
|
||||
ItemVector items_;
|
||||
scoped_ptr<ui::MenuModel> model_;
|
||||
|
||||
// Observers that want to be notified of changes to this object.
|
||||
base::ObserverList<Observer> observers_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefMenuModelImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefMenuModelImpl);
|
||||
};
|
||||
|
Reference in New Issue
Block a user