Fix webview for the new API
This commit is contained in:
parent
8328bce3f6
commit
12d5474077
7 changed files with 78 additions and 1 deletions
5
atom.gyp
5
atom.gyp
|
@ -281,6 +281,8 @@
|
||||||
'atom/renderer/atom_render_view_observer.h',
|
'atom/renderer/atom_render_view_observer.h',
|
||||||
'atom/renderer/atom_renderer_client.cc',
|
'atom/renderer/atom_renderer_client.cc',
|
||||||
'atom/renderer/atom_renderer_client.h',
|
'atom/renderer/atom_renderer_client.h',
|
||||||
|
'atom/renderer/guest_view_container.cc',
|
||||||
|
'atom/renderer/guest_view_container.h',
|
||||||
'chromium_src/chrome/browser/browser_process.cc',
|
'chromium_src/chrome/browser/browser_process.cc',
|
||||||
'chromium_src/chrome/browser/browser_process.h',
|
'chromium_src/chrome/browser/browser_process.h',
|
||||||
'chromium_src/chrome/browser/chrome_notification_types.h',
|
'chromium_src/chrome/browser/chrome_notification_types.h',
|
||||||
|
@ -550,8 +552,9 @@
|
||||||
'SK_SUPPORT_LEGACY_GETTOPDEVICE',
|
'SK_SUPPORT_LEGACY_GETTOPDEVICE',
|
||||||
# Disable warnings for g_settings_list_schemas.
|
# Disable warnings for g_settings_list_schemas.
|
||||||
'GLIB_DISABLE_DEPRECATION_WARNINGS',
|
'GLIB_DISABLE_DEPRECATION_WARNINGS',
|
||||||
# Defined in V8.
|
# Defined in Chromium but not exposed in its gyp file.
|
||||||
'V8_USE_EXTERNAL_STARTUP_DATA',
|
'V8_USE_EXTERNAL_STARTUP_DATA',
|
||||||
|
'ENABLE_PLUGINS',
|
||||||
],
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
'<@(lib_sources)',
|
'<@(lib_sources)',
|
||||||
|
|
|
@ -56,6 +56,7 @@ WebContents::WebContents(content::WebContents* web_contents)
|
||||||
guest_instance_id_(-1),
|
guest_instance_id_(-1),
|
||||||
element_instance_id_(-1),
|
element_instance_id_(-1),
|
||||||
guest_opaque_(true),
|
guest_opaque_(true),
|
||||||
|
guest_sizer_(nullptr),
|
||||||
auto_size_enabled_(false) {
|
auto_size_enabled_(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ WebContents::WebContents(const mate::Dictionary& options)
|
||||||
: guest_instance_id_(-1),
|
: guest_instance_id_(-1),
|
||||||
element_instance_id_(-1),
|
element_instance_id_(-1),
|
||||||
guest_opaque_(true),
|
guest_opaque_(true),
|
||||||
|
guest_sizer_(nullptr),
|
||||||
auto_size_enabled_(false) {
|
auto_size_enabled_(false) {
|
||||||
options.Get("guestInstanceId", &guest_instance_id_);
|
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) {
|
void WebContents::ElementSizeChanged(const gfx::Size& size) {
|
||||||
element_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,
|
void WebContents::GuestSizeChanged(const gfx::Size& old_size,
|
||||||
|
@ -302,6 +312,10 @@ void WebContents::RegisterDestructionCallback(
|
||||||
destruction_callback_ = callback;
|
destruction_callback_ = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebContents::SetGuestSizer(content::GuestSizer* guest_sizer) {
|
||||||
|
guest_sizer_ = guest_sizer;
|
||||||
|
}
|
||||||
|
|
||||||
void WebContents::WillAttach(content::WebContents* embedder_web_contents,
|
void WebContents::WillAttach(content::WebContents* embedder_web_contents,
|
||||||
int element_instance_id,
|
int element_instance_id,
|
||||||
bool is_full_page_plugin) {
|
bool is_full_page_plugin) {
|
||||||
|
|
|
@ -176,9 +176,11 @@ class WebContents : public mate::EventEmitter,
|
||||||
// content::BrowserPluginGuestDelegate:
|
// content::BrowserPluginGuestDelegate:
|
||||||
void DidAttach(int guest_proxy_routing_id) final;
|
void DidAttach(int guest_proxy_routing_id) final;
|
||||||
void ElementSizeChanged(const gfx::Size& size) final;
|
void ElementSizeChanged(const gfx::Size& size) final;
|
||||||
|
content::WebContents* GetOwnerWebContents() const final;
|
||||||
void GuestSizeChanged(const gfx::Size& old_size,
|
void GuestSizeChanged(const gfx::Size& old_size,
|
||||||
const gfx::Size& new_size) final;
|
const gfx::Size& new_size) final;
|
||||||
void RegisterDestructionCallback(const DestructionCallback& callback) final;
|
void RegisterDestructionCallback(const DestructionCallback& callback) final;
|
||||||
|
void SetGuestSizer(content::GuestSizer* guest_sizer) final;
|
||||||
void WillAttach(content::WebContents* embedder_web_contents,
|
void WillAttach(content::WebContents* embedder_web_contents,
|
||||||
int element_instance_id,
|
int element_instance_id,
|
||||||
bool is_full_page_plugin) final;
|
bool is_full_page_plugin) final;
|
||||||
|
@ -223,6 +225,9 @@ class WebContents : public mate::EventEmitter,
|
||||||
// element may not match the size of the guest.
|
// element may not match the size of the guest.
|
||||||
gfx::Size guest_size_;
|
gfx::Size guest_size_;
|
||||||
|
|
||||||
|
// A pointer to the guest_sizer.
|
||||||
|
content::GuestSizer* guest_sizer_;
|
||||||
|
|
||||||
// Indicates whether autosize mode is enabled or not.
|
// Indicates whether autosize mode is enabled or not.
|
||||||
bool auto_size_enabled_;
|
bool auto_size_enabled_;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "atom/common/node_bindings.h"
|
#include "atom/common/node_bindings.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "atom/renderer/atom_render_view_observer.h"
|
#include "atom/renderer/atom_render_view_observer.h"
|
||||||
|
#include "atom/renderer/guest_view_container.h"
|
||||||
#include "chrome/renderer/printing/print_web_view_helper.h"
|
#include "chrome/renderer/printing/print_web_view_helper.h"
|
||||||
#include "chrome/renderer/tts_dispatcher.h"
|
#include "chrome/renderer/tts_dispatcher.h"
|
||||||
#include "content/public/common/content_constants.h"
|
#include "content/public/common/content_constants.h"
|
||||||
|
@ -149,6 +150,17 @@ bool AtomRendererClient::ShouldFork(blink::WebFrame* frame,
|
||||||
return http_method == "GET";
|
return http_method == "GET";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content::BrowserPluginDelegate* AtomRendererClient::CreateBrowserPluginDelegate(
|
||||||
|
content::RenderFrame* render_frame,
|
||||||
|
const std::string& mime_type,
|
||||||
|
const GURL& original_url) {
|
||||||
|
if (mime_type == content::kBrowserPluginMimeType) {
|
||||||
|
return new GuestViewContainer(render_frame);
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AtomRendererClient::EnableWebRuntimeFeatures() {
|
void AtomRendererClient::EnableWebRuntimeFeatures() {
|
||||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||||
bool b;
|
bool b;
|
||||||
|
|
|
@ -51,6 +51,10 @@ class AtomRendererClient : public content::ContentRendererClient,
|
||||||
bool is_initial_navigation,
|
bool is_initial_navigation,
|
||||||
bool is_server_redirect,
|
bool is_server_redirect,
|
||||||
bool* send_referrer) override;
|
bool* send_referrer) override;
|
||||||
|
content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
|
||||||
|
content::RenderFrame* render_frame,
|
||||||
|
const std::string& mime_type,
|
||||||
|
const GURL& original_url) override;
|
||||||
|
|
||||||
void EnableWebRuntimeFeatures();
|
void EnableWebRuntimeFeatures();
|
||||||
|
|
||||||
|
|
15
atom/renderer/guest_view_container.cc
Normal file
15
atom/renderer/guest_view_container.cc
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/renderer/guest_view_container.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame) {
|
||||||
|
}
|
||||||
|
|
||||||
|
GuestViewContainer::~GuestViewContainer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace atom
|
24
atom/renderer/guest_view_container.h
Normal file
24
atom/renderer/guest_view_container.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_RENDERER_GUEST_VIEW_CONTAINER_H_
|
||||||
|
#define ATOM_RENDERER_GUEST_VIEW_CONTAINER_H_
|
||||||
|
|
||||||
|
#include "content/public/renderer/browser_plugin_delegate.h"
|
||||||
|
#include "v8/include/v8.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
class GuestViewContainer : public content::BrowserPluginDelegate {
|
||||||
|
public:
|
||||||
|
explicit GuestViewContainer(content::RenderFrame* render_frame);
|
||||||
|
~GuestViewContainer() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(GuestViewContainer);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_RENDERER_GUEST_VIEW_CONTAINER_H_
|
Loading…
Reference in a new issue