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 "mandoline/tab/frame.h" | 5 #include "mandoline/tab/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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 frame_tree_server_binding_.Bind(GetProxy(&frame_tree_server_ptr).Pass()); | 148 frame_tree_server_binding_.Bind(GetProxy(&frame_tree_server_ptr).Pass()); |
149 if (frame_tree_client_) { | 149 if (frame_tree_client_) { |
150 frame_tree_client_->OnConnect(frame_tree_server_ptr.Pass(), | 150 frame_tree_client_->OnConnect(frame_tree_server_ptr.Pass(), |
151 tree_->change_id(), array.Pass()); | 151 tree_->change_id(), array.Pass()); |
152 tree_->delegate_->DidStartNavigation(this); | 152 tree_->delegate_->DidStartNavigation(this); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void Frame::OnWillNavigateAck(FrameTreeClient* frame_tree_client, | 156 void Frame::OnWillNavigateAck(FrameTreeClient* frame_tree_client, |
157 scoped_ptr<FrameUserData> user_data, | 157 scoped_ptr<FrameUserData> user_data, |
158 mojo::ViewManagerClientPtr view_manager_client) { | 158 mojo::ViewTreeClientPtr view_tree_client) { |
159 while (!children_.empty()) | 159 while (!children_.empty()) |
160 delete children_[0]; | 160 delete children_[0]; |
161 | 161 |
162 user_data_ = user_data.Pass(); | 162 user_data_ = user_data.Pass(); |
163 frame_tree_client_ = frame_tree_client; | 163 frame_tree_client_ = frame_tree_client; |
164 frame_tree_server_binding_.Close(); | 164 frame_tree_server_binding_.Close(); |
165 loading_ = false; | 165 loading_ = false; |
166 progress_ = 0.f; | 166 progress_ = 0.f; |
167 | 167 |
168 view_->Embed(view_manager_client.Pass()); | 168 view_->Embed(view_tree_client.Pass()); |
169 InitClient(); | 169 InitClient(); |
170 } | 170 } |
171 | 171 |
172 void Frame::SetView(mojo::View* view) { | 172 void Frame::SetView(mojo::View* view) { |
173 DCHECK(!view_); | 173 DCHECK(!view_); |
174 DCHECK_EQ(id_, view->id()); | 174 DCHECK_EQ(id_, view->id()); |
175 view_ = view; | 175 view_ = view; |
176 view_->SetLocalProperty(kFrame, this); | 176 view_->SetLocalProperty(kFrame, this); |
177 view_->AddObserver(this); | 177 view_->AddObserver(this); |
178 if (pending_navigate_.get()) | 178 if (pending_navigate_.get()) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // We need a View to navigate. When we get the View we'll complete the | 217 // We need a View to navigate. When we get the View we'll complete the |
218 // navigation. | 218 // navigation. |
219 // TODO(sky): consider state and what is not legal while waiting. | 219 // TODO(sky): consider state and what is not legal while waiting. |
220 if (!view_) { | 220 if (!view_) { |
221 pending_navigate_ = request.Pass(); | 221 pending_navigate_ = request.Pass(); |
222 return; | 222 return; |
223 } | 223 } |
224 | 224 |
225 FrameTreeClient* frame_tree_client = nullptr; | 225 FrameTreeClient* frame_tree_client = nullptr; |
226 scoped_ptr<FrameUserData> user_data; | 226 scoped_ptr<FrameUserData> user_data; |
227 mojo::ViewManagerClientPtr view_manager_client; | 227 mojo::ViewTreeClientPtr view_tree_client; |
228 if (!tree_->delegate_->CanNavigateFrame(this, request.Pass(), | 228 if (!tree_->delegate_->CanNavigateFrame(this, request.Pass(), |
229 &frame_tree_client, &user_data, | 229 &frame_tree_client, &user_data, |
230 &view_manager_client)) { | 230 &view_tree_client)) { |
231 return; | 231 return; |
232 } | 232 } |
233 | 233 |
234 // TODO(sky): consider what state this should correspond to. Should we | 234 // TODO(sky): consider what state this should correspond to. Should we |
235 // disallow certain operations until we get the ack? | 235 // disallow certain operations until we get the ack? |
236 Frame* ancestor_with_frame_tree_client = GetAncestorWithFrameTreeClient(); | 236 Frame* ancestor_with_frame_tree_client = GetAncestorWithFrameTreeClient(); |
237 DCHECK(ancestor_with_frame_tree_client); | 237 DCHECK(ancestor_with_frame_tree_client); |
238 ancestor_with_frame_tree_client->frame_tree_client_->OnWillNavigate( | 238 ancestor_with_frame_tree_client->frame_tree_client_->OnWillNavigate( |
239 id_, base::Bind(&Frame::OnWillNavigateAck, weak_factory_.GetWeakPtr(), | 239 id_, base::Bind(&Frame::OnWillNavigateAck, weak_factory_.GetWeakPtr(), |
240 frame_tree_client, base::Passed(&user_data), | 240 frame_tree_client, base::Passed(&user_data), |
241 base::Passed(&view_manager_client))); | 241 base::Passed(&view_tree_client))); |
242 } | 242 } |
243 | 243 |
244 void Frame::LoadingStartedImpl() { | 244 void Frame::LoadingStartedImpl() { |
245 DCHECK(!loading_); | 245 DCHECK(!loading_); |
246 loading_ = true; | 246 loading_ = true; |
247 progress_ = 0.f; | 247 progress_ = 0.f; |
248 tree_->LoadingStateChanged(); | 248 tree_->LoadingStateChanged(); |
249 } | 249 } |
250 | 250 |
251 void Frame::LoadingStoppedImpl() { | 251 void Frame::LoadingStoppedImpl() { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 // Else case if |target_frame| == root. Treat at top level request. | 439 // Else case if |target_frame| == root. Treat at top level request. |
440 } | 440 } |
441 tree_->delegate_->NavigateTopLevel(this, request.Pass()); | 441 tree_->delegate_->NavigateTopLevel(this, request.Pass()); |
442 } | 442 } |
443 | 443 |
444 void Frame::DidNavigateLocally(uint32_t frame_id, const mojo::String& url) { | 444 void Frame::DidNavigateLocally(uint32_t frame_id, const mojo::String& url) { |
445 NOTIMPLEMENTED(); | 445 NOTIMPLEMENTED(); |
446 } | 446 } |
447 | 447 |
448 } // namespace mandoline | 448 } // namespace mandoline |
OLD | NEW |