OLD | NEW |
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 if (IsLocal()) | 264 if (IsLocal()) |
265 return true; | 265 return true; |
266 | 266 |
267 for (HTMLFrame* child : children_) { | 267 for (HTMLFrame* child : children_) { |
268 if (child->HasLocalDescendant()) | 268 if (child->HasLocalDescendant()) |
269 return true; | 269 return true; |
270 } | 270 } |
271 return false; | 271 return false; |
272 } | 272 } |
273 | 273 |
274 void HTMLFrame::LoadRequest(const blink::WebURLRequest& request) { | 274 void HTMLFrame::LoadRequest(const blink::WebURLRequest& request, |
| 275 base::TimeTicks navigation_start_time) { |
275 DCHECK(IsLocal()); | 276 DCHECK(IsLocal()); |
276 | 277 |
277 DVLOG(2) << "HTMLFrame::LoadRequest this=" << this << " id=" << id_ | 278 DVLOG(2) << "HTMLFrame::LoadRequest this=" << this << " id=" << id_ |
278 << " URL=" << GURL(request.url()); | 279 << " URL=" << GURL(request.url()); |
279 | 280 |
280 pending_navigation_ = false; | 281 pending_navigation_ = false; |
| 282 navigation_start_time_ = navigation_start_time; |
281 web_frame_->toWebLocalFrame()->loadRequest(request); | 283 web_frame_->toWebLocalFrame()->loadRequest(request); |
282 } | 284 } |
283 | 285 |
284 HTMLFrame::~HTMLFrame() { | 286 HTMLFrame::~HTMLFrame() { |
285 DVLOG(2) << "~HTMLFrame this=" << this << " id=" << id_; | 287 DVLOG(2) << "~HTMLFrame this=" << this << " id=" << id_; |
286 | 288 |
287 DCHECK(children_.empty()); | 289 DCHECK(children_.empty()); |
288 | 290 |
289 if (parent_) { | 291 if (parent_) { |
290 auto iter = | 292 auto iter = |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 } | 389 } |
388 | 390 |
389 // Ask the Frame to handle the navigation. Returning | 391 // Ask the Frame to handle the navigation. Returning |
390 // WebNavigationPolicyHandledByClient to inform blink that the navigation is | 392 // WebNavigationPolicyHandledByClient to inform blink that the navigation is |
391 // being handled. | 393 // being handled. |
392 DVLOG(2) << "HTMLFrame::decidePolicyForNavigation calls " | 394 DVLOG(2) << "HTMLFrame::decidePolicyForNavigation calls " |
393 << "Frame::RequestNavigate this=" << this << " id=" << id_ | 395 << "Frame::RequestNavigate this=" << this << " id=" << id_ |
394 << " URL=" << GURL(info.urlRequest.url()); | 396 << " URL=" << GURL(info.urlRequest.url()); |
395 | 397 |
396 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest); | 398 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest); |
| 399 url_request->originating_time_ticks = |
| 400 base::TimeTicks::Now().ToInternalValue(); |
397 server_->RequestNavigate( | 401 server_->RequestNavigate( |
398 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), id_, | 402 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), id_, |
399 url_request.Pass()); | 403 url_request.Pass()); |
400 | 404 |
401 // TODO(yzshen): crbug.com/532556 If the server side drops the request, | 405 // TODO(yzshen): crbug.com/532556 If the server side drops the request, |
402 // this frame will be in permenant-loading state. We should send a | 406 // this frame will be in permenant-loading state. We should send a |
403 // notification to mark this frame as not loading in that case. We also need | 407 // notification to mark this frame as not loading in that case. We also need |
404 // to better keep track of multiple pending navigations. | 408 // to better keep track of multiple pending navigations. |
405 pending_navigation_ = true; | 409 pending_navigation_ = true; |
406 return blink::WebNavigationPolicyHandledByClient; | 410 return blink::WebNavigationPolicyHandledByClient; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 server_->SetClientProperty(kPropertyFrameOrigin, | 487 server_->SetClientProperty(kPropertyFrameOrigin, |
484 FrameOriginToClientProperty(frame)); | 488 FrameOriginToClientProperty(frame)); |
485 | 489 |
486 // TODO(erg): We need to pass way more information from here through to the | 490 // TODO(erg): We need to pass way more information from here through to the |
487 // other side. See FrameHostMsg_DidCommitProvisionalLoad_Params. It is a grab | 491 // other side. See FrameHostMsg_DidCommitProvisionalLoad_Params. It is a grab |
488 // bag of everything and it looks like a combination of | 492 // bag of everything and it looks like a combination of |
489 // NavigatorImpl::DidNavigate and | 493 // NavigatorImpl::DidNavigate and |
490 // NavigationControllerImpl::RendererDidNavigate use everything passed | 494 // NavigationControllerImpl::RendererDidNavigate use everything passed |
491 // through. | 495 // through. |
492 server_->DidCommitProvisionalLoad(); | 496 server_->DidCommitProvisionalLoad(); |
| 497 |
| 498 if (!navigation_start_time_.is_null()) { |
| 499 frame->dataSource()->setNavigationStartTime( |
| 500 navigation_start_time_.ToInternalValue() / |
| 501 static_cast<double>(base::Time::kMicrosecondsPerSecond)); |
| 502 navigation_start_time_ = base::TimeTicks(); |
| 503 } |
493 } | 504 } |
494 | 505 |
495 void HTMLFrame::didReceiveTitle(blink::WebLocalFrame* frame, | 506 void HTMLFrame::didReceiveTitle(blink::WebLocalFrame* frame, |
496 const blink::WebString& title, | 507 const blink::WebString& title, |
497 blink::WebTextDirection direction) { | 508 blink::WebTextDirection direction) { |
498 // TODO(beng): handle |direction|. | 509 // TODO(beng): handle |direction|. |
499 mojo::String formatted; | 510 mojo::String formatted; |
500 if (!title.isNull()) { | 511 if (!title.isNull()) { |
501 formatted = | 512 formatted = |
502 mojo::String::From(base::string16(title).substr(0, kMaxTitleChars)); | 513 mojo::String::From(base::string16(title).substr(0, kMaxTitleChars)); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 void HTMLFrame::OnViewFocusChanged(mus::View* gained_focus, | 785 void HTMLFrame::OnViewFocusChanged(mus::View* gained_focus, |
775 mus::View* lost_focus) { | 786 mus::View* lost_focus) { |
776 UpdateFocus(); | 787 UpdateFocus(); |
777 } | 788 } |
778 | 789 |
779 void HTMLFrame::OnConnect(web_view::mojom::FramePtr frame, | 790 void HTMLFrame::OnConnect(web_view::mojom::FramePtr frame, |
780 uint32_t change_id, | 791 uint32_t change_id, |
781 uint32_t view_id, | 792 uint32_t view_id, |
782 web_view::mojom::ViewConnectType view_connect_type, | 793 web_view::mojom::ViewConnectType view_connect_type, |
783 mojo::Array<web_view::mojom::FrameDataPtr> frame_data, | 794 mojo::Array<web_view::mojom::FrameDataPtr> frame_data, |
| 795 int64_t navigation_start_time_ticks, |
784 const OnConnectCallback& callback) { | 796 const OnConnectCallback& callback) { |
785 // This is called if this frame is created by way of OnCreatedFrame(). | 797 // This is called if this frame is created by way of OnCreatedFrame(). |
786 callback.Run(); | 798 callback.Run(); |
787 } | 799 } |
788 | 800 |
789 void HTMLFrame::OnFrameAdded(uint32_t change_id, | 801 void HTMLFrame::OnFrameAdded(uint32_t change_id, |
790 web_view::mojom::FrameDataPtr frame_data) { | 802 web_view::mojom::FrameDataPtr frame_data) { |
791 frame_tree_manager_->ProcessOnFrameAdded(this, change_id, frame_data.Pass()); | 803 frame_tree_manager_->ProcessOnFrameAdded(this, change_id, frame_data.Pass()); |
792 } | 804 } |
793 | 805 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 if (!surface_layer_) | 1022 if (!surface_layer_) |
1011 return; | 1023 return; |
1012 | 1024 |
1013 surface_layer_->SetSurfaceId( | 1025 surface_layer_->SetSurfaceId( |
1014 cc::SurfaceId(owned_view_->view()->id()), | 1026 cc::SurfaceId(owned_view_->view()->id()), |
1015 global_state()->device_pixel_ratio(), | 1027 global_state()->device_pixel_ratio(), |
1016 owned_view_->view()->bounds().To<gfx::Rect>().size()); | 1028 owned_view_->view()->bounds().To<gfx::Rect>().size()); |
1017 } | 1029 } |
1018 | 1030 |
1019 } // namespace mojo | 1031 } // namespace mojo |
OLD | NEW |