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/web_view/frame.h" | 5 #include "components/web_view/frame.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 if (view_) { | 89 if (view_) { |
90 view_->ClearLocalProperty(kFrame); | 90 view_->ClearLocalProperty(kFrame); |
91 if (view_ownership_ == ViewOwnership::OWNS_VIEW) | 91 if (view_ownership_ == ViewOwnership::OWNS_VIEW) |
92 view_->Destroy(); | 92 view_->Destroy(); |
93 } | 93 } |
94 tree_->delegate_->DidDestroyFrame(this); | 94 tree_->delegate_->DidDestroyFrame(this); |
95 } | 95 } |
96 | 96 |
97 void Frame::Init(Frame* parent, | 97 void Frame::Init(Frame* parent, |
98 mojo::ViewTreeClientPtr view_tree_client, | 98 mojo::ViewTreeClientPtr view_tree_client, |
99 mojo::InterfaceRequest<mojom::Frame> frame_request) { | 99 mojo::InterfaceRequest<mojom::Frame> frame_request, |
100 base::TimeTicks navigation_start_time) { | |
100 { | 101 { |
101 // Set the FrameClient to null so that we don't notify the client of the | 102 // Set the FrameClient to null so that we don't notify the client of the |
102 // add before OnConnect(). | 103 // add before OnConnect(). |
103 base::AutoReset<mojom::FrameClient*> frame_client_resetter(&frame_client_, | 104 base::AutoReset<mojom::FrameClient*> frame_client_resetter(&frame_client_, |
104 nullptr); | 105 nullptr); |
105 if (parent) | 106 if (parent) |
106 parent->Add(this); | 107 parent->Add(this); |
107 } | 108 } |
108 | 109 |
110 navigation_start_time_ = navigation_start_time; | |
109 const ClientType client_type = frame_request.is_pending() | 111 const ClientType client_type = frame_request.is_pending() |
110 ? ClientType::NEW_CHILD_FRAME | 112 ? ClientType::NEW_CHILD_FRAME |
111 : ClientType::EXISTING_FRAME_NEW_APP; | 113 : ClientType::EXISTING_FRAME_NEW_APP; |
112 InitClient(client_type, nullptr, view_tree_client.Pass(), | 114 InitClient(client_type, nullptr, view_tree_client.Pass(), |
113 frame_request.Pass()); | 115 frame_request.Pass()); |
114 | 116 |
115 tree_->delegate_->DidCreateFrame(this); | 117 tree_->delegate_->DidCreateFrame(this); |
116 | 118 |
117 DVLOG(2) << "Frame id=" << id_ << " parent=" << (parent_ ? parent_->id_ : 0) | 119 DVLOG(2) << "Frame id=" << id_ << " parent=" << (parent_ ? parent_->id_ : 0) |
118 << " app_id=" << app_id_ << " this=" << this; | 120 << " app_id=" << app_id_ << " this=" << this; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 if (client_type == ClientType::NEW_CHILD_FRAME) { | 200 if (client_type == ClientType::NEW_CHILD_FRAME) { |
199 // Don't install an error handler. We allow for the target to only | 201 // Don't install an error handler. We allow for the target to only |
200 // implement ViewTreeClient. | 202 // implement ViewTreeClient. |
201 // This frame (and client) was created by an existing FrameClient. There | 203 // This frame (and client) was created by an existing FrameClient. There |
202 // is no need to send it OnConnect(). | 204 // is no need to send it OnConnect(). |
203 frame_binding_.reset( | 205 frame_binding_.reset( |
204 new mojo::Binding<mojom::Frame>(this, frame_request.Pass())); | 206 new mojo::Binding<mojom::Frame>(this, frame_request.Pass())); |
205 frame_client_->OnConnect( | 207 frame_client_->OnConnect( |
206 nullptr, tree_->change_id(), id_, mojom::VIEW_CONNECT_TYPE_USE_NEW, | 208 nullptr, tree_->change_id(), id_, mojom::VIEW_CONNECT_TYPE_USE_NEW, |
207 mojo::Array<mojom::FrameDataPtr>(), | 209 mojo::Array<mojom::FrameDataPtr>(), |
210 navigation_start_time_.ToInternalValue(), | |
208 base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); | 211 base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); |
212 navigation_start_time_ = base::TimeTicks(); | |
209 } else { | 213 } else { |
210 std::vector<const Frame*> frames; | 214 std::vector<const Frame*> frames; |
211 tree_->root()->BuildFrameTree(&frames); | 215 tree_->root()->BuildFrameTree(&frames); |
212 | 216 |
213 mojo::Array<mojom::FrameDataPtr> array(frames.size()); | 217 mojo::Array<mojom::FrameDataPtr> array(frames.size()); |
214 for (size_t i = 0; i < frames.size(); ++i) | 218 for (size_t i = 0; i < frames.size(); ++i) |
215 array[i] = FrameToFrameData(frames[i]).Pass(); | 219 array[i] = FrameToFrameData(frames[i]).Pass(); |
216 | 220 |
217 mojom::FramePtr frame_ptr; | 221 mojom::FramePtr frame_ptr; |
218 // Don't install an error handler. We allow for the target to only | 222 // Don't install an error handler. We allow for the target to only |
219 // implement ViewTreeClient. | 223 // implement ViewTreeClient. |
220 frame_binding_.reset( | 224 frame_binding_.reset( |
221 new mojo::Binding<mojom::Frame>(this, GetProxy(&frame_ptr).Pass())); | 225 new mojo::Binding<mojom::Frame>(this, GetProxy(&frame_ptr).Pass())); |
222 frame_client_->OnConnect( | 226 frame_client_->OnConnect( |
223 frame_ptr.Pass(), tree_->change_id(), id_, | 227 frame_ptr.Pass(), tree_->change_id(), id_, |
224 client_type == ClientType::EXISTING_FRAME_SAME_APP | 228 client_type == ClientType::EXISTING_FRAME_SAME_APP |
225 ? mojom::VIEW_CONNECT_TYPE_USE_EXISTING | 229 ? mojom::VIEW_CONNECT_TYPE_USE_EXISTING |
226 : mojom::VIEW_CONNECT_TYPE_USE_NEW, | 230 : mojom::VIEW_CONNECT_TYPE_USE_NEW, |
227 array.Pass(), | 231 array.Pass(), navigation_start_time_.ToInternalValue(), |
228 base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); | 232 base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); |
233 navigation_start_time_ = base::TimeTicks(); | |
229 tree_->delegate_->DidStartNavigation(this); | 234 tree_->delegate_->DidStartNavigation(this); |
230 | 235 |
231 // We need |embedded_connection_id_| is order to validate requests to | 236 // We need |embedded_connection_id_| is order to validate requests to |
232 // create a child frame (OnCreatedFrame()). Pause incoming methods until | 237 // create a child frame (OnCreatedFrame()). Pause incoming methods until |
233 // we get the id to prevent race conditions. | 238 // we get the id to prevent race conditions. |
234 if (embedded_connection_id_ == kInvalidConnectionId) | 239 if (embedded_connection_id_ == kInvalidConnectionId) |
235 frame_binding_->PauseIncomingMethodCallProcessing(); | 240 frame_binding_->PauseIncomingMethodCallProcessing(); |
236 } | 241 } |
237 } | 242 } |
238 | 243 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 | 340 |
336 pending_navigate_.reset(); | 341 pending_navigate_.reset(); |
337 | 342 |
338 // We need a View to navigate. When we get the View we'll complete the | 343 // We need a View to navigate. When we get the View we'll complete the |
339 // navigation. | 344 // navigation. |
340 if (!view_) { | 345 if (!view_) { |
341 pending_navigate_ = request.Pass(); | 346 pending_navigate_ = request.Pass(); |
342 return; | 347 return; |
343 } | 348 } |
344 | 349 |
350 navigation_start_time_ = | |
sky
2015/10/14 22:46:24
Does navigation_start_time_ need to be a member? C
yzshen1
2015/10/14 22:59:15
In that case we also need to pass it to ChangeClie
sky
2015/10/14 23:08:36
The problem with the member is that it's easy to a
yzshen1
2015/10/15 00:05:10
Done.
| |
351 base::TimeTicks::FromInternalValue(request->originating_time_ticks); | |
345 // Drop any pending navigation requests. | 352 // Drop any pending navigation requests. |
346 navigate_weak_ptr_factory_.InvalidateWeakPtrs(); | 353 navigate_weak_ptr_factory_.InvalidateWeakPtrs(); |
347 | 354 |
348 DVLOG(2) << "Frame::StartNavigate id=" << id_ << " url=" << request->url; | 355 DVLOG(2) << "Frame::StartNavigate id=" << id_ << " url=" << request->url; |
349 | 356 |
350 const GURL requested_url(request->url); | 357 const GURL requested_url(request->url); |
351 tree_->delegate_->CanNavigateFrame( | 358 tree_->delegate_->CanNavigateFrame( |
352 this, request.Pass(), | 359 this, request.Pass(), |
353 base::Bind(&Frame::OnCanNavigateFrame, | 360 base::Bind(&Frame::OnCanNavigateFrame, |
354 navigate_weak_ptr_factory_.GetWeakPtr(), requested_url)); | 361 navigate_weak_ptr_factory_.GetWeakPtr(), requested_url)); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 final_update); | 578 final_update); |
572 } | 579 } |
573 | 580 |
574 void Frame::OnFindInPageSelectionUpdated(int32_t request_id, | 581 void Frame::OnFindInPageSelectionUpdated(int32_t request_id, |
575 int32_t active_match_ordinal) { | 582 int32_t active_match_ordinal) { |
576 tree_->delegate_->OnFindInPageSelectionUpdated(request_id, this, | 583 tree_->delegate_->OnFindInPageSelectionUpdated(request_id, this, |
577 active_match_ordinal); | 584 active_match_ordinal); |
578 } | 585 } |
579 | 586 |
580 } // namespace web_view | 587 } // namespace web_view |
OLD | NEW |