| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "components/mus/public/cpp/view.h" | 13 #include "components/mus/public/cpp/view.h" |
| 14 #include "components/mus/public/cpp/view_property.h" | 14 #include "components/mus/public/cpp/view_property.h" |
| 15 #include "components/web_view/frame_tree.h" | 15 #include "components/web_view/frame_tree.h" |
| 16 #include "components/web_view/frame_tree_delegate.h" | 16 #include "components/web_view/frame_tree_delegate.h" |
| 17 #include "components/web_view/frame_user_data.h" | 17 #include "components/web_view/frame_user_data.h" |
| 18 #include "components/web_view/frame_utils.h" | 18 #include "components/web_view/frame_utils.h" |
| 19 #include "mojo/application/public/interfaces/shell.mojom.h" | 19 #include "mojo/application/public/interfaces/shell.mojom.h" |
| 20 | 20 |
| 21 using mus::View; | 21 using mojo::View; |
| 22 | 22 |
| 23 DECLARE_VIEW_PROPERTY_TYPE(web_view::Frame*); | 23 DECLARE_VIEW_PROPERTY_TYPE(web_view::Frame*); |
| 24 | 24 |
| 25 namespace web_view { | 25 namespace web_view { |
| 26 | 26 |
| 27 // Used to find the Frame associated with a View. | 27 // Used to find the Frame associated with a View. |
| 28 DEFINE_LOCAL_VIEW_PROPERTY_KEY(Frame*, kFrame, nullptr); | 28 DEFINE_LOCAL_VIEW_PROPERTY_KEY(Frame*, kFrame, nullptr); |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 const uint32_t kNoParentId = 0u; | 32 const uint32_t kNoParentId = 0u; |
| 33 const mus::ConnectionSpecificId kInvalidConnectionId = 0u; | 33 const mojo::ConnectionSpecificId kInvalidConnectionId = 0u; |
| 34 | 34 |
| 35 FrameDataPtr FrameToFrameData(const Frame* frame) { | 35 FrameDataPtr FrameToFrameData(const Frame* frame) { |
| 36 FrameDataPtr frame_data(FrameData::New()); | 36 FrameDataPtr frame_data(FrameData::New()); |
| 37 frame_data->frame_id = frame->id(); | 37 frame_data->frame_id = frame->id(); |
| 38 frame_data->parent_id = frame->parent() ? frame->parent()->id() : kNoParentId; | 38 frame_data->parent_id = frame->parent() ? frame->parent()->id() : kNoParentId; |
| 39 frame_data->client_properties = | 39 frame_data->client_properties = |
| 40 mojo::Map<mojo::String, mojo::Array<uint8_t>>::From( | 40 mojo::Map<mojo::String, mojo::Array<uint8_t>>::From( |
| 41 frame->client_properties()); | 41 frame->client_properties()); |
| 42 return frame_data.Pass(); | 42 return frame_data.Pass(); |
| 43 } | 43 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 frame_tree_client_ = frame_tree_client; | 212 frame_tree_client_ = frame_tree_client; |
| 213 frame_tree_server_binding_.reset(); | 213 frame_tree_server_binding_.reset(); |
| 214 loading_ = false; | 214 loading_ = false; |
| 215 progress_ = 0.f; | 215 progress_ = 0.f; |
| 216 app_id_ = app_id; | 216 app_id_ = app_id; |
| 217 | 217 |
| 218 InitClient(client_type, frame_tree_server_binding.Pass(), | 218 InitClient(client_type, frame_tree_server_binding.Pass(), |
| 219 view_tree_client.Pass()); | 219 view_tree_client.Pass()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void Frame::OnEmbedAck(bool success, mus::ConnectionSpecificId connection_id) { | 222 void Frame::OnEmbedAck(bool success, mojo::ConnectionSpecificId connection_id) { |
| 223 if (success) | 223 if (success) |
| 224 embedded_connection_id_ = connection_id; | 224 embedded_connection_id_ = connection_id; |
| 225 } | 225 } |
| 226 | 226 |
| 227 void Frame::SetView(mus::View* view) { | 227 void Frame::SetView(mojo::View* view) { |
| 228 DCHECK(!view_); | 228 DCHECK(!view_); |
| 229 DCHECK_EQ(id_, view->id()); | 229 DCHECK_EQ(id_, view->id()); |
| 230 view_ = view; | 230 view_ = view; |
| 231 view_->SetLocalProperty(kFrame, this); | 231 view_->SetLocalProperty(kFrame, this); |
| 232 view_->AddObserver(this); | 232 view_->AddObserver(this); |
| 233 if (pending_navigate_.get()) | 233 if (pending_navigate_.get()) |
| 234 StartNavigate(pending_navigate_.Pass()); | 234 StartNavigate(pending_navigate_.Pass()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 Frame* Frame::GetAncestorWithFrameTreeClient() { | 237 Frame* Frame::GetAncestorWithFrameTreeClient() { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 400 } |
| 401 | 401 |
| 402 void Frame::OnTreeChanged(const TreeChangeParams& params) { | 402 void Frame::OnTreeChanged(const TreeChangeParams& params) { |
| 403 if (params.new_parent && this == tree_->root()) { | 403 if (params.new_parent && this == tree_->root()) { |
| 404 Frame* child_frame = FindFrame(params.target->id()); | 404 Frame* child_frame = FindFrame(params.target->id()); |
| 405 if (child_frame && !child_frame->view_) | 405 if (child_frame && !child_frame->view_) |
| 406 child_frame->SetView(params.target); | 406 child_frame->SetView(params.target); |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 void Frame::OnViewDestroying(mus::View* view) { | 410 void Frame::OnViewDestroying(mojo::View* view) { |
| 411 if (parent_) | 411 if (parent_) |
| 412 parent_->Remove(this); | 412 parent_->Remove(this); |
| 413 | 413 |
| 414 // Reset |view_ownership_| so we don't attempt to delete |view_| in the | 414 // Reset |view_ownership_| so we don't attempt to delete |view_| in the |
| 415 // destructor. | 415 // destructor. |
| 416 view_ownership_ = ViewOwnership::DOESNT_OWN_VIEW; | 416 view_ownership_ = ViewOwnership::DOESNT_OWN_VIEW; |
| 417 | 417 |
| 418 if (tree_->root() == this) { | 418 if (tree_->root() == this) { |
| 419 view_->RemoveObserver(this); | 419 view_->RemoveObserver(this); |
| 420 view_ = nullptr; | 420 view_ = nullptr; |
| 421 return; | 421 return; |
| 422 } | 422 } |
| 423 | 423 |
| 424 delete this; | 424 delete this; |
| 425 } | 425 } |
| 426 | 426 |
| 427 void Frame::OnViewEmbeddedAppDisconnected(mus::View* view) { | 427 void Frame::OnViewEmbeddedAppDisconnected(mojo::View* view) { |
| 428 // See FrameTreeDelegate::OnViewEmbeddedAppDisconnected() for details of when | 428 // See FrameTreeDelegate::OnViewEmbeddedAppDisconnected() for details of when |
| 429 // this happens. | 429 // this happens. |
| 430 // | 430 // |
| 431 // Currently we have no way to distinguish between the cases that lead to this | 431 // Currently we have no way to distinguish between the cases that lead to this |
| 432 // being called, so we assume we can continue on. Continuing on is important | 432 // being called, so we assume we can continue on. Continuing on is important |
| 433 // for html as it's entirely possible for a page to create a frame, navigate | 433 // for html as it's entirely possible for a page to create a frame, navigate |
| 434 // to a bogus url and expect the frame to still exist. | 434 // to a bogus url and expect the frame to still exist. |
| 435 // | 435 // |
| 436 // TODO(sky): notify the delegate on this? At a minimum the delegate cares | 436 // TODO(sky): notify the delegate on this? At a minimum the delegate cares |
| 437 // if the root is unembedded as this would correspond to a sab tab. | 437 // if the root is unembedded as this would correspond to a sab tab. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 // Else case if |target_frame| == root. Treat at top level request. | 537 // Else case if |target_frame| == root. Treat at top level request. |
| 538 } | 538 } |
| 539 tree_->delegate_->NavigateTopLevel(this, request.Pass()); | 539 tree_->delegate_->NavigateTopLevel(this, request.Pass()); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void Frame::DidNavigateLocally(uint32_t frame_id, const mojo::String& url) { | 542 void Frame::DidNavigateLocally(uint32_t frame_id, const mojo::String& url) { |
| 543 NOTIMPLEMENTED(); | 543 NOTIMPLEMENTED(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 } // namespace web_view | 546 } // namespace web_view |
| OLD | NEW |