Skip to content

Commit

Permalink
Override default implementation of createChildFrame() for print preview.
Browse files Browse the repository at this point in the history
https://src.chromium.org/viewvc/blink?view=rev&revision=164135 updated
Blink to remove a transitional hack that was implemented to help us
change the way frame lifetimes were managed. However, as a result, Blink
now always assume that createChildFrame() will return a non-null value.
WebFrameClients that expect to ever create child frames must override
this method and frameDetached() if they don't want to crash.

BUG=330994
R=boliu@chromium.org, scottbyer@chromium.org

Review URL: https://codereview.chromium.org/122553002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242941 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dcheng@chromium.org committed Jan 3, 2014
1 parent ea8b7b6 commit 9e9ae72
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
17 changes: 15 additions & 2 deletions android_webview/renderer/print_web_view_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,13 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient,
// blink::WebViewClient override:
virtual void didStopLoading();

virtual void CallOnReady();
// blink::WebFrameClient override:
virtual blink::WebFrame* createChildFrame(blink::WebFrame* parent,
const blink::WebString& name);
virtual void frameDetached(blink::WebFrame* frame);

private:
void CallOnReady();
void ResizeForPrinting();
void RestoreSize();
void CopySelection(const WebPreferences& preferences);
Expand Down Expand Up @@ -669,6 +673,16 @@ void PrepareFrameAndViewForPrint::didStopLoading() {
weak_ptr_factory_.GetWeakPtr()));
}

blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame(
blink::WebFrame* parent,
const blink::WebString& name) {
return blink::WebFrame::create(this);
}

void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame) {
frame->close();
}

void PrepareFrameAndViewForPrint::CallOnReady() {
return on_ready_.Run(); // Can delete |this|.
}
Expand Down Expand Up @@ -704,7 +718,6 @@ void PrepareFrameAndViewForPrint::FinishPrinting() {
DCHECK(!frame->isLoading());
owns_web_view_ = false;
web_view->close();
frame->close();
}
}
frame_.Reset(NULL);
Expand Down
17 changes: 15 additions & 2 deletions chrome/renderer/printing/print_web_view_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,13 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient,
// blink::WebViewClient override:
virtual void didStopLoading();

virtual void CallOnReady();
// blink::WebFrameClient override:
virtual blink::WebFrame* createChildFrame(blink::WebFrame* parent,
const blink::WebString& name);
virtual void frameDetached(blink::WebFrame* frame);

private:
void CallOnReady();
void ResizeForPrinting();
void RestoreSize();
void CopySelection(const WebPreferences& preferences);
Expand Down Expand Up @@ -664,6 +668,16 @@ void PrepareFrameAndViewForPrint::didStopLoading() {
weak_ptr_factory_.GetWeakPtr()));
}

blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame(
blink::WebFrame* parent,
const blink::WebString& name) {
return blink::WebFrame::create(this);
}

void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame) {
frame->close();
}

void PrepareFrameAndViewForPrint::CallOnReady() {
return on_ready_.Run(); // Can delete |this|.
}
Expand Down Expand Up @@ -699,7 +713,6 @@ void PrepareFrameAndViewForPrint::FinishPrinting() {
DCHECK(!frame->isLoading());
owns_web_view_ = false;
web_view->close();
frame->close();
}
}
frame_.Reset(NULL);
Expand Down

0 comments on commit 9e9ae72

Please sign in to comment.