Merge pull request #9819 from ferreus/dev/vladimir_fix9231

🐛 Fix #9231: Don't load url when detached.
This commit is contained in:
Cheng Zhao 2017-07-19 11:15:30 +09:00 committed by GitHub
commit 52c6c7e676
3 changed files with 17 additions and 0 deletions

View file

@ -993,6 +993,10 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
return;
}
if (guest_delegate_ && !guest_delegate_->IsAttached()) {
return;
}
content::NavigationController::LoadURLParams params(url);
GURL http_referrer;

View file

@ -28,6 +28,7 @@ WebViewGuestDelegate::WebViewGuestDelegate()
guest_host_(nullptr),
auto_size_enabled_(false),
is_full_page_plugin_(false),
attached_(false),
api_web_contents_(nullptr) {}
WebViewGuestDelegate::~WebViewGuestDelegate() {
@ -110,7 +111,12 @@ void WebViewGuestDelegate::DidFinishNavigation(
}
}
void WebViewGuestDelegate::DidDetach() {
attached_ = false;
}
void WebViewGuestDelegate::DidAttach(int guest_proxy_routing_id) {
attached_ = true;
api_web_contents_->Emit("did-attach");
embedder_zoom_controller_ =
WebContentsZoomController::FromWebContents(embedder_web_contents_);

View file

@ -47,6 +47,9 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
// and normal sizes.
void SetSize(const SetSizeParams& params);
// Return true if attached.
bool IsAttached() const { return attached_; }
protected:
// content::WebContentsObserver:
void DidFinishNavigation(
@ -54,6 +57,7 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
// content::BrowserPluginGuestDelegate:
void DidAttach(int guest_proxy_routing_id) final;
void DidDetach() final;
content::WebContents* GetOwnerWebContents() const final;
void GuestSizeChanged(const gfx::Size& new_size) final;
void SetGuestHost(content::GuestHost* guest_host) final;
@ -116,6 +120,9 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
// Whether the guest view is inside a plugin document.
bool is_full_page_plugin_;
// Whether attached.
bool attached_;
api::WebContents* api_web_contents_;
DISALLOW_COPY_AND_ASSIGN(WebViewGuestDelegate);