Chromium Code Reviews| Index: mojo/services/html_viewer/html_document_view.cc |
| diff --git a/mojo/services/html_viewer/html_document_view.cc b/mojo/services/html_viewer/html_document_view.cc |
| index 7751aa4e07dc74502b2cf07b10d5b40ee3ae7734..69d66162bd5fc7314dfb97a36814d11a7d2eb29e 100644 |
| --- a/mojo/services/html_viewer/html_document_view.cc |
| +++ b/mojo/services/html_viewer/html_document_view.cc |
| @@ -80,11 +80,11 @@ bool CanNavigateLocally(blink::WebFrame* frame, |
| HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider, |
| ViewManager* view_manager) |
| - : view_manager_(view_manager), |
| + : SimpleFrameClient(service_provider, 0), |
| + view_manager_(view_manager), |
| web_view_(NULL), |
| root_(NULL), |
| repaint_pending_(false), |
| - navigator_host_(service_provider), |
| weak_factory_(this) { |
| } |
| @@ -97,6 +97,7 @@ HTMLDocumentView::~HTMLDocumentView() { |
| void HTMLDocumentView::AttachToView(View* view) { |
| root_ = view; |
| + root_id_ = root_->id(); |
| root_->SetColor(SK_ColorCYAN); // Dummy background color. |
| web_view_ = blink::WebView::create(this); |
| @@ -145,13 +146,60 @@ bool HTMLDocumentView::allowsBrokenNullLayerTreeView() const { |
| return true; |
| } |
| -blink::WebCookieJar* HTMLDocumentView::cookieJar(blink::WebLocalFrame* frame) { |
| +SimpleFrameClient::SimpleFrameClient(ServiceProvider* service_provider, |
| + Id root_id) |
| + : service_provider_(service_provider), |
| + navigator_host_(service_provider), |
| + root_id_(root_id) { |
| +} |
| + |
| +SimpleFrameClient::~SimpleFrameClient() { |
| +} |
| + |
| +blink::WebFrame* SimpleFrameClient::createChildFrame( |
| + blink::WebLocalFrame* parent, |
| + const blink::WebString& frameName) { |
| + // TODO(mpcomplete): What happens if root_ is destroyed and the child frames |
| + // live on? Can that happen? |
| + blink::WebLocalFrame* web_frame = |
| + blink::WebLocalFrame::create(new SimpleFrameClient(service_provider_, |
|
darin (slow to review)
2014/08/14 23:45:52
why do you need a new WebFrameClient instance per
Matt Perry
2014/08/15 00:40:04
Doh. I guess you don't. I assumed WebLocalFrame ex
|
| + root_id_)); |
| + parent->appendChild(web_frame); |
| + |
| + return web_frame; |
| +} |
| + |
| +void SimpleFrameClient::didDisownOpener(blink::WebLocalFrame* frame) { |
| +} |
| + |
| +void SimpleFrameClient::frameDetached(blink::WebFrame* frame) { |
| + bool is_subframe = !!frame->parent(); |
| + |
| + if (is_subframe) |
| + frame->parent()->removeChild(frame); |
| + |
| + // |frame| is invalid after here. |
| + frame->close(); |
| + |
| + if (is_subframe) { |
| + delete this; |
| + // Object is invalid after this point. |
| + } |
| +} |
| + |
| +void SimpleFrameClient::frameFocused() { |
| +} |
| + |
| +void SimpleFrameClient::willClose(blink::WebFrame* frame) { |
| +} |
| + |
| +blink::WebCookieJar* SimpleFrameClient::cookieJar(blink::WebLocalFrame* frame) { |
| // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar. |
| // Either it should, as it once did, or we should find another solution here. |
| return blink::Platform::current()->cookieJar(); |
| } |
| -blink::WebNavigationPolicy HTMLDocumentView::decidePolicyForNavigation( |
| +blink::WebNavigationPolicy SimpleFrameClient::decidePolicyForNavigation( |
| blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, |
| const blink::WebURLRequest& request, blink::WebNavigationType nav_type, |
| blink::WebNavigationPolicy default_policy, bool is_redirect) { |
| @@ -162,24 +210,24 @@ blink::WebNavigationPolicy HTMLDocumentView::decidePolicyForNavigation( |
| nav_details->request = URLRequest::From(request); |
| navigator_host_->RequestNavigate( |
| - root_->id(), |
| + root_id_, |
| WebNavigationPolicyToNavigationTarget(default_policy), |
| nav_details.Pass()); |
| return blink::WebNavigationPolicyIgnore; |
| } |
| -void HTMLDocumentView::didAddMessageToConsole( |
| +void SimpleFrameClient::didAddMessageToConsole( |
| const blink::WebConsoleMessage& message, |
| const blink::WebString& source_name, |
| unsigned source_line, |
| const blink::WebString& stack_trace) { |
| } |
| -void HTMLDocumentView::didNavigateWithinPage( |
| +void SimpleFrameClient::didNavigateWithinPage( |
| blink::WebLocalFrame* frame, const blink::WebHistoryItem& history_item, |
| blink::WebHistoryCommitType commit_type) { |
| - navigator_host_->DidNavigateLocally(root_->id(), |
| + navigator_host_->DidNavigateLocally(root_id_, |
| history_item.urlString().utf8()); |
| } |
| @@ -194,6 +242,7 @@ void HTMLDocumentView::OnViewDestroyed(View* view) { |
| DCHECK_EQ(view, root_); |
| view->RemoveObserver(this); |
| root_ = NULL; |
| + root_id_ = 0; |
| } |
| void HTMLDocumentView::OnViewInputEvent(View* view, const EventPtr& event) { |