std::unique_ptr<WebContents>
This commit is contained in:
parent
8060e915c2
commit
a5b09e25ea
4 changed files with 24 additions and 19 deletions
|
@ -362,7 +362,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
}
|
}
|
||||||
session_.Reset(isolate, session.ToV8());
|
session_.Reset(isolate, session.ToV8());
|
||||||
|
|
||||||
content::WebContents* web_contents;
|
std::unique_ptr<content::WebContents> web_contents;
|
||||||
if (IsGuest()) {
|
if (IsGuest()) {
|
||||||
scoped_refptr<content::SiteInstance> site_instance =
|
scoped_refptr<content::SiteInstance> site_instance =
|
||||||
content::SiteInstance::CreateForURL(session->browser_context(),
|
content::SiteInstance::CreateForURL(session->browser_context(),
|
||||||
|
@ -405,7 +405,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
web_contents = content::WebContents::Create(params);
|
web_contents = content::WebContents::Create(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitWithSessionAndOptions(isolate, web_contents, session, options);
|
InitWithSessionAndOptions(isolate, web_contents.release(), session, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::InitZoomController(content::WebContents* web_contents,
|
void WebContents::InitZoomController(content::WebContents* web_contents,
|
||||||
|
@ -537,16 +537,17 @@ void WebContents::WebContentsCreated(content::WebContents* source_contents,
|
||||||
Emit("-web-contents-created", api_web_contents, target_url, frame_name);
|
Emit("-web-contents-created", api_web_contents, target_url, frame_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::AddNewContents(content::WebContents* source,
|
void WebContents::AddNewContents(
|
||||||
content::WebContents* new_contents,
|
content::WebContents* source,
|
||||||
WindowOpenDisposition disposition,
|
std::unique_ptr<content::WebContents> new_contents,
|
||||||
const gfx::Rect& initial_rect,
|
WindowOpenDisposition disposition,
|
||||||
bool user_gesture,
|
const gfx::Rect& initial_rect,
|
||||||
bool* was_blocked) {
|
bool user_gesture,
|
||||||
new ChildWebContentsTracker(new_contents);
|
bool* was_blocked) {
|
||||||
|
new ChildWebContentsTracker(new_contents.get());
|
||||||
v8::Locker locker(isolate());
|
v8::Locker locker(isolate());
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
auto api_web_contents = CreateFrom(isolate(), new_contents);
|
auto api_web_contents = CreateFrom(isolate(), new_contents.release());
|
||||||
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
|
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
|
||||||
initial_rect.x(), initial_rect.y(), initial_rect.width(),
|
initial_rect.x(), initial_rect.y(), initial_rect.width(),
|
||||||
initial_rect.height())) {
|
initial_rect.height())) {
|
||||||
|
|
|
@ -300,7 +300,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
content::WebContents* new_contents) override;
|
content::WebContents* new_contents) override;
|
||||||
void AddNewContents(content::WebContents* source,
|
void AddNewContents(content::WebContents* source,
|
||||||
content::WebContents* new_contents,
|
std::unique_ptr<content::WebContents> new_contents,
|
||||||
WindowOpenDisposition disposition,
|
WindowOpenDisposition disposition,
|
||||||
const gfx::Rect& initial_rect,
|
const gfx::Rect& initial_rect,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include "atom/browser/web_view_guest_delegate.h"
|
#include "atom/browser/web_view_guest_delegate.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "atom/browser/api/atom_api_web_contents.h"
|
#include "atom/browser/api/atom_api_web_contents.h"
|
||||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||||
#include "content/browser/web_contents/web_contents_impl.h"
|
#include "content/browser/web_contents/web_contents_impl.h"
|
||||||
|
@ -104,13 +106,16 @@ content::WebContents* WebViewGuestDelegate::CreateNewGuestWindow(
|
||||||
guest_params.initial_size =
|
guest_params.initial_size =
|
||||||
embedder_web_contents_->GetContainerBounds().size();
|
embedder_web_contents_->GetContainerBounds().size();
|
||||||
guest_params.context = embedder_web_contents_->GetNativeView();
|
guest_params.context = embedder_web_contents_->GetNativeView();
|
||||||
auto* guest_contents = content::WebContents::Create(guest_params);
|
std::unique_ptr<content::WebContents> guest_contents =
|
||||||
|
content::WebContents::Create(guest_params);
|
||||||
|
content::RenderWidgetHost* render_widget_host =
|
||||||
|
guest_contents->GetRenderViewHost()->GetWidget();
|
||||||
auto* guest_contents_impl =
|
auto* guest_contents_impl =
|
||||||
static_cast<content::WebContentsImpl*>(guest_contents);
|
static_cast<content::WebContentsImpl*>(guest_contents.release());
|
||||||
guest_contents_impl->GetView()->CreateViewForWidget(
|
guest_contents_impl->GetView()->CreateViewForWidget(render_widget_host,
|
||||||
guest_contents->GetRenderViewHost()->GetWidget(), false);
|
false);
|
||||||
|
|
||||||
return guest_contents;
|
return guest_contents_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -320,9 +320,8 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
||||||
DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this));
|
DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this));
|
||||||
|
|
||||||
if (!external_devtools_web_contents_) { // no external devtools
|
if (!external_devtools_web_contents_) { // no external devtools
|
||||||
managed_devtools_web_contents_.reset(
|
managed_devtools_web_contents_ = content::WebContents::Create(
|
||||||
content::WebContents::Create(content::WebContents::CreateParams(
|
content::WebContents::CreateParams(web_contents_->GetBrowserContext()));
|
||||||
web_contents_->GetBrowserContext())));
|
|
||||||
managed_devtools_web_contents_->SetDelegate(this);
|
managed_devtools_web_contents_->SetDelegate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue