Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: components/html_viewer/html_frame.cc

Issue 1375083002: Mandoline: html_frame returns WebNavigationPolicyHandledByClient to blink when the navigation reque… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/html_viewer/html_frame.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/html_viewer/html_frame.h" 5 #include "components/html_viewer/html_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 } // namespace 117 } // namespace
118 118
119 HTMLFrame::HTMLFrame(CreateParams* params) 119 HTMLFrame::HTMLFrame(CreateParams* params)
120 : frame_tree_manager_(params->manager), 120 : frame_tree_manager_(params->manager),
121 parent_(params->parent), 121 parent_(params->parent),
122 view_(nullptr), 122 view_(nullptr),
123 id_(params->id), 123 id_(params->id),
124 web_frame_(nullptr), 124 web_frame_(nullptr),
125 delegate_(params->delegate), 125 delegate_(params->delegate),
126 pending_navigation_(false),
126 weak_factory_(this) { 127 weak_factory_(this) {
127 if (parent_) 128 if (parent_)
128 parent_->children_.push_back(this); 129 parent_->children_.push_back(this);
129 130
130 if (params->view && params->view->id() == id_) 131 if (params->view && params->view->id() == id_)
131 SetView(params->view); 132 SetView(params->view);
132 133
133 SetReplicatedFrameStateFromClientProperties(params->properties, &state_); 134 SetReplicatedFrameStateFromClientProperties(params->properties, &state_);
134 135
135 if (!parent_) { 136 if (!parent_) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 if (IsLocal()) 263 if (IsLocal())
263 return true; 264 return true;
264 265
265 for (HTMLFrame* child : children_) { 266 for (HTMLFrame* child : children_) {
266 if (child->HasLocalDescendant()) 267 if (child->HasLocalDescendant())
267 return true; 268 return true;
268 } 269 }
269 return false; 270 return false;
270 } 271 }
271 272
273 void HTMLFrame::LoadRequest(const blink::WebURLRequest& request) {
274 DCHECK(IsLocal());
275
276 DVLOG(2) << "HTMLFrame::LoadRequest this=" << this << " id=" << id_
277 << " URL=" << GURL(request.url());
278
279 pending_navigation_ = false;
280 web_frame_->toWebLocalFrame()->loadRequest(request);
281 }
282
272 HTMLFrame::~HTMLFrame() { 283 HTMLFrame::~HTMLFrame() {
273 DVLOG(2) << "~HTMLFrame this=" << this << " id=" << id_; 284 DVLOG(2) << "~HTMLFrame this=" << this << " id=" << id_;
274 285
275 DCHECK(children_.empty()); 286 DCHECK(children_.empty());
276 287
277 if (parent_) { 288 if (parent_) {
278 auto iter = 289 auto iter =
279 std::find(parent_->children_.begin(), parent_->children_.end(), this); 290 std::find(parent_->children_.begin(), parent_->children_.end(), this);
280 parent_->children_.erase(iter); 291 parent_->children_.erase(iter);
281 } 292 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 DCHECK_EQ(blink::WebNavigationPolicyCurrentTab, info.defaultPolicy); 378 DCHECK_EQ(blink::WebNavigationPolicyCurrentTab, info.defaultPolicy);
368 return blink::WebNavigationPolicyCurrentTab; 379 return blink::WebNavigationPolicyCurrentTab;
369 } 380 }
370 381
371 // about:blank is treated as the same origin and is always allowed for frames. 382 // about:blank is treated as the same origin and is always allowed for frames.
372 if (parent_ && info.urlRequest.url() == GURL(url::kAboutBlankURL) && 383 if (parent_ && info.urlRequest.url() == GURL(url::kAboutBlankURL) &&
373 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab) { 384 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab) {
374 return blink::WebNavigationPolicyCurrentTab; 385 return blink::WebNavigationPolicyCurrentTab;
375 } 386 }
376 387
377 // Ask the Frame to handle the navigation. By returning 388 // Ask the Frame to handle the navigation. Returning
378 // WebNavigationPolicyIgnore the load is suppressed. 389 // WebNavigationPolicyHandledByClient to inform blink that the navigation is
390 // being handled.
391 DVLOG(2) << "HTMLFrame::decidePolicyForNavigation calls "
392 << "Frame::RequestNavigate this=" << this << " id=" << id_
393 << " URL=" << GURL(info.urlRequest.url());
394
379 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest); 395 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest);
380 server_->RequestNavigate( 396 server_->RequestNavigate(
381 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), id_, 397 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), id_,
382 url_request.Pass()); 398 url_request.Pass());
383 399
384 return blink::WebNavigationPolicyIgnore; 400 // TODO(yzshen): crbug.com/532556 If the server side drops the request,
401 // this frame will be in permenant-loading state. We should send a
402 // notification to mark this frame as not loading in that case. We also need
403 // to better keep track of multiple pending navigations.
404 pending_navigation_ = true;
405 return blink::WebNavigationPolicyHandledByClient;
406 }
407
408 bool HTMLFrame::hasPendingNavigation(blink::WebLocalFrame* frame) {
409 return pending_navigation_;
385 } 410 }
386 411
387 void HTMLFrame::didHandleOnloadEvents(blink::WebLocalFrame* frame) { 412 void HTMLFrame::didHandleOnloadEvents(blink::WebLocalFrame* frame) {
388 DVLOG(2) << "XXX HTMLFrame::didHandleOnloadEvents id=" << id_; 413 DVLOG(2) << "XXX HTMLFrame::didHandleOnloadEvents id=" << id_;
389 static bool recorded = false; 414 static bool recorded = false;
390 if (!recorded && startup_performance_data_collector_) { 415 if (!recorded && startup_performance_data_collector_) {
391 startup_performance_data_collector_->SetFirstWebContentsMainFrameLoadTime( 416 startup_performance_data_collector_->SetFirstWebContentsMainFrameLoadTime(
392 base::Time::Now().ToInternalValue()); 417 base::Time::Now().ToInternalValue());
393 recorded = true; 418 recorded = true;
394 } 419 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 cc::SurfaceId(owned_view_->view()->id()), 613 cc::SurfaceId(owned_view_->view()->id()),
589 global_state()->device_pixel_ratio(), 614 global_state()->device_pixel_ratio(),
590 owned_view_->view()->bounds().To<gfx::Rect>().size()); 615 owned_view_->view()->bounds().To<gfx::Rect>().size());
591 616
592 web_layer_.reset(new cc_blink::WebLayerImpl(surface_layer_)); 617 web_layer_.reset(new cc_blink::WebLayerImpl(surface_layer_));
593 } 618 }
594 remote_frame->setRemoteWebLayer(web_layer_.get()); 619 remote_frame->setRemoteWebLayer(web_layer_.get());
595 remote_frame->setReplicatedName(state_.name); 620 remote_frame->setReplicatedName(state_.name);
596 remote_frame->setReplicatedOrigin(state_.origin); 621 remote_frame->setReplicatedOrigin(state_.origin);
597 remote_frame->setReplicatedSandboxFlags(state_.sandbox_flags); 622 remote_frame->setReplicatedSandboxFlags(state_.sandbox_flags);
623
598 // Tell the frame that it is actually loading. This prevents its parent 624 // Tell the frame that it is actually loading. This prevents its parent
599 // from prematurely dispatching load event. 625 // from prematurely dispatching load event.
600 remote_frame->didStartLoading(); 626 remote_frame->didStartLoading();
627 pending_navigation_ = false;
628
601 web_frame_ = remote_frame; 629 web_frame_ = remote_frame;
602 SetView(nullptr); 630 SetView(nullptr);
603 server_.reset(); 631 server_.reset();
604 frame_client_binding_.reset(); 632 frame_client_binding_.reset();
605 if (delegate) 633 if (delegate)
606 delegate->OnFrameSwappedToRemote(); 634 delegate->OnFrameSwappedToRemote();
607 } 635 }
608 636
609 void HTMLFrame::SwapToLocal( 637 void HTMLFrame::SwapToLocal(
610 HTMLFrameDelegate* delegate, 638 HTMLFrameDelegate* delegate,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 if (!surface_layer_) 918 if (!surface_layer_)
891 return; 919 return;
892 920
893 surface_layer_->SetSurfaceId( 921 surface_layer_->SetSurfaceId(
894 cc::SurfaceId(owned_view_->view()->id()), 922 cc::SurfaceId(owned_view_->view()->id()),
895 global_state()->device_pixel_ratio(), 923 global_state()->device_pixel_ratio(),
896 owned_view_->view()->bounds().To<gfx::Rect>().size()); 924 owned_view_->view()->bounds().To<gfx::Rect>().size());
897 } 925 }
898 926
899 } // namespace mojo 927 } // namespace mojo
OLDNEW
« no previous file with comments | « components/html_viewer/html_frame.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698