Fix webview for the new API
This commit is contained in:
parent
8328bce3f6
commit
12d5474077
7 changed files with 78 additions and 1 deletions
|
@ -56,6 +56,7 @@ WebContents::WebContents(content::WebContents* web_contents)
|
|||
guest_instance_id_(-1),
|
||||
element_instance_id_(-1),
|
||||
guest_opaque_(true),
|
||||
guest_sizer_(nullptr),
|
||||
auto_size_enabled_(false) {
|
||||
}
|
||||
|
||||
|
@ -63,6 +64,7 @@ WebContents::WebContents(const mate::Dictionary& options)
|
|||
: guest_instance_id_(-1),
|
||||
element_instance_id_(-1),
|
||||
guest_opaque_(true),
|
||||
guest_sizer_(nullptr),
|
||||
auto_size_enabled_(false) {
|
||||
options.Get("guestInstanceId", &guest_instance_id_);
|
||||
|
||||
|
@ -287,6 +289,14 @@ void WebContents::DidAttach(int guest_proxy_routing_id) {
|
|||
|
||||
void WebContents::ElementSizeChanged(const gfx::Size& size) {
|
||||
element_size_ = size;
|
||||
|
||||
// Only resize if needed.
|
||||
if (!size.IsEmpty())
|
||||
guest_sizer_->SizeContents(size);
|
||||
}
|
||||
|
||||
content::WebContents* WebContents::GetOwnerWebContents() const {
|
||||
return embedder_web_contents_;
|
||||
}
|
||||
|
||||
void WebContents::GuestSizeChanged(const gfx::Size& old_size,
|
||||
|
@ -302,6 +312,10 @@ void WebContents::RegisterDestructionCallback(
|
|||
destruction_callback_ = callback;
|
||||
}
|
||||
|
||||
void WebContents::SetGuestSizer(content::GuestSizer* guest_sizer) {
|
||||
guest_sizer_ = guest_sizer;
|
||||
}
|
||||
|
||||
void WebContents::WillAttach(content::WebContents* embedder_web_contents,
|
||||
int element_instance_id,
|
||||
bool is_full_page_plugin) {
|
||||
|
|
|
@ -176,9 +176,11 @@ class WebContents : public mate::EventEmitter,
|
|||
// content::BrowserPluginGuestDelegate:
|
||||
void DidAttach(int guest_proxy_routing_id) final;
|
||||
void ElementSizeChanged(const gfx::Size& size) final;
|
||||
content::WebContents* GetOwnerWebContents() const final;
|
||||
void GuestSizeChanged(const gfx::Size& old_size,
|
||||
const gfx::Size& new_size) final;
|
||||
void RegisterDestructionCallback(const DestructionCallback& callback) final;
|
||||
void SetGuestSizer(content::GuestSizer* guest_sizer) final;
|
||||
void WillAttach(content::WebContents* embedder_web_contents,
|
||||
int element_instance_id,
|
||||
bool is_full_page_plugin) final;
|
||||
|
@ -223,6 +225,9 @@ class WebContents : public mate::EventEmitter,
|
|||
// element may not match the size of the guest.
|
||||
gfx::Size guest_size_;
|
||||
|
||||
// A pointer to the guest_sizer.
|
||||
content::GuestSizer* guest_sizer_;
|
||||
|
||||
// Indicates whether autosize mode is enabled or not.
|
||||
bool auto_size_enabled_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue