| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "mojo/converters/geometry/geometry_type_converters.h" | 44 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 45 #include "skia/ext/refptr.h" | 45 #include "skia/ext/refptr.h" |
| 46 #include "third_party/WebKit/public/platform/Platform.h" | 46 #include "third_party/WebKit/public/platform/Platform.h" |
| 47 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" | 47 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" |
| 48 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 48 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 49 #include "third_party/WebKit/public/platform/WebSize.h" | 49 #include "third_party/WebKit/public/platform/WebSize.h" |
| 50 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 50 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 51 #include "third_party/WebKit/public/web/WebDocument.h" | 51 #include "third_party/WebKit/public/web/WebDocument.h" |
| 52 #include "third_party/WebKit/public/web/WebElement.h" | 52 #include "third_party/WebKit/public/web/WebElement.h" |
| 53 #include "third_party/WebKit/public/web/WebFindOptions.h" | 53 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 54 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" |
| 54 #include "third_party/WebKit/public/web/WebInputEvent.h" | 55 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 55 #include "third_party/WebKit/public/web/WebKit.h" | 56 #include "third_party/WebKit/public/web/WebKit.h" |
| 56 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 57 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 57 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 58 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
| 58 #include "third_party/WebKit/public/web/WebRemoteFrame.h" | 59 #include "third_party/WebKit/public/web/WebRemoteFrame.h" |
| 59 #include "third_party/WebKit/public/web/WebRemoteFrameClient.h" | 60 #include "third_party/WebKit/public/web/WebRemoteFrameClient.h" |
| 60 #include "third_party/WebKit/public/web/WebScriptSource.h" | 61 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 61 #include "third_party/WebKit/public/web/WebView.h" | 62 #include "third_party/WebKit/public/web/WebView.h" |
| 62 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h" | 63 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h" |
| 63 #include "third_party/skia/include/core/SkCanvas.h" | 64 #include "third_party/skia/include/core/SkCanvas.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 184 } |
| 184 } else if (!params->is_local_create_child && params->view && | 185 } else if (!params->is_local_create_child && params->view && |
| 185 id_ == params->view->id()) { | 186 id_ == params->view->id()) { |
| 186 // Frame represents the local frame, and it isn't the root of the tree. | 187 // Frame represents the local frame, and it isn't the root of the tree. |
| 187 HTMLFrame* previous_sibling = GetPreviousSibling(this); | 188 HTMLFrame* previous_sibling = GetPreviousSibling(this); |
| 188 blink::WebFrame* previous_web_frame = | 189 blink::WebFrame* previous_web_frame = |
| 189 previous_sibling ? previous_sibling->web_frame() : nullptr; | 190 previous_sibling ? previous_sibling->web_frame() : nullptr; |
| 190 CHECK(!parent_->IsLocal()); | 191 CHECK(!parent_->IsLocal()); |
| 191 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createLocalChild( | 192 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createLocalChild( |
| 192 state_.tree_scope, state_.name, state_.sandbox_flags, this, | 193 state_.tree_scope, state_.name, state_.sandbox_flags, this, |
| 193 previous_web_frame); | 194 previous_web_frame, |
| 195 // TODO(lazyboy): Replicate WebFrameOwnerProperties where needed. |
| 196 blink::WebFrameOwnerProperties()); |
| 194 CreateLocalRootWebWidget(web_frame_->toWebLocalFrame()); | 197 CreateLocalRootWebWidget(web_frame_->toWebLocalFrame()); |
| 195 } else if (!parent_->IsLocal()) { | 198 } else if (!parent_->IsLocal()) { |
| 196 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createRemoteChild( | 199 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createRemoteChild( |
| 197 state_.tree_scope, state_.name, state_.sandbox_flags, this); | 200 state_.tree_scope, state_.name, state_.sandbox_flags, this); |
| 198 } else { | 201 } else { |
| 199 CHECK(params->is_local_create_child); | 202 CHECK(params->is_local_create_child); |
| 200 | 203 |
| 201 blink::WebLocalFrame* child_web_frame = | 204 blink::WebLocalFrame* child_web_frame = |
| 202 blink::WebLocalFrame::create(state_.tree_scope, this); | 205 blink::WebLocalFrame::create(state_.tree_scope, this); |
| 203 web_frame_ = child_web_frame; | 206 web_frame_ = child_web_frame; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 314 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
| 312 blink::WebContentDecryptionModule* initial_cdm) { | 315 blink::WebContentDecryptionModule* initial_cdm) { |
| 313 return global_state()->media_factory()->CreateMediaPlayer( | 316 return global_state()->media_factory()->CreateMediaPlayer( |
| 314 frame, url, client, encrypted_client, initial_cdm, GetApp()->shell()); | 317 frame, url, client, encrypted_client, initial_cdm, GetApp()->shell()); |
| 315 } | 318 } |
| 316 | 319 |
| 317 blink::WebFrame* HTMLFrame::createChildFrame( | 320 blink::WebFrame* HTMLFrame::createChildFrame( |
| 318 blink::WebLocalFrame* parent, | 321 blink::WebLocalFrame* parent, |
| 319 blink::WebTreeScopeType scope, | 322 blink::WebTreeScopeType scope, |
| 320 const blink::WebString& frame_name, | 323 const blink::WebString& frame_name, |
| 321 blink::WebSandboxFlags sandbox_flags) { | 324 blink::WebSandboxFlags sandbox_flags, |
| 325 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
| 322 DCHECK(IsLocal()); // Can't create children of remote frames. | 326 DCHECK(IsLocal()); // Can't create children of remote frames. |
| 323 DCHECK_EQ(parent, web_frame_); | 327 DCHECK_EQ(parent, web_frame_); |
| 324 DCHECK(view_); // If we're local we have to have a view. | 328 DCHECK(view_); // If we're local we have to have a view. |
| 325 // Create the view that will house the frame now. We embed once we know the | 329 // Create the view that will house the frame now. We embed once we know the |
| 326 // url (see decidePolicyForNavigation()). | 330 // url (see decidePolicyForNavigation()). |
| 327 mus::View* child_view = view_->connection()->CreateView(); | 331 mus::View* child_view = view_->connection()->CreateView(); |
| 328 ReplicatedFrameState child_state; | 332 ReplicatedFrameState child_state; |
| 329 child_state.name = frame_name; | 333 child_state.name = frame_name; |
| 330 child_state.tree_scope = scope; | 334 child_state.tree_scope = scope; |
| 331 child_state.sandbox_flags = sandbox_flags; | 335 child_state.sandbox_flags = sandbox_flags; |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 DVLOG(2) << "HTMLFrame::SwapToLocal this=" << this << " id=" << id_; | 657 DVLOG(2) << "HTMLFrame::SwapToLocal this=" << this << " id=" << id_; |
| 654 CHECK(!IsLocal()); | 658 CHECK(!IsLocal()); |
| 655 // It doesn't make sense for the root to swap to local. | 659 // It doesn't make sense for the root to swap to local. |
| 656 CHECK(parent_); | 660 CHECK(parent_); |
| 657 delegate_ = delegate; | 661 delegate_ = delegate; |
| 658 SetView(view); | 662 SetView(view); |
| 659 SetReplicatedFrameStateFromClientProperties(properties, &state_); | 663 SetReplicatedFrameStateFromClientProperties(properties, &state_); |
| 660 blink::WebLocalFrame* local_web_frame = | 664 blink::WebLocalFrame* local_web_frame = |
| 661 blink::WebLocalFrame::create(state_.tree_scope, this); | 665 blink::WebLocalFrame::create(state_.tree_scope, this); |
| 662 local_web_frame->initializeToReplaceRemoteFrame( | 666 local_web_frame->initializeToReplaceRemoteFrame( |
| 663 web_frame_->toWebRemoteFrame(), state_.name, state_.sandbox_flags); | 667 web_frame_->toWebRemoteFrame(), state_.name, state_.sandbox_flags, |
| 668 // TODO(lazyboy): Figure out replicating WebFrameOwnerProperties. |
| 669 blink::WebFrameOwnerProperties()); |
| 664 // The swap() ends up calling to frameDetached() and deleting the old. | 670 // The swap() ends up calling to frameDetached() and deleting the old. |
| 665 web_frame_->swap(local_web_frame); | 671 web_frame_->swap(local_web_frame); |
| 666 web_frame_ = local_web_frame; | 672 web_frame_ = local_web_frame; |
| 667 | 673 |
| 668 web_layer_.reset(); | 674 web_layer_.reset(); |
| 669 } | 675 } |
| 670 | 676 |
| 671 void HTMLFrame::SwapDelegate(HTMLFrameDelegate* delegate) { | 677 void HTMLFrame::SwapDelegate(HTMLFrameDelegate* delegate) { |
| 672 DCHECK(IsLocal()); | 678 DCHECK(IsLocal()); |
| 673 HTMLFrameDelegate* old_delegate = delegate_; | 679 HTMLFrameDelegate* old_delegate = delegate_; |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 if (!surface_layer_) | 1016 if (!surface_layer_) |
| 1011 return; | 1017 return; |
| 1012 | 1018 |
| 1013 surface_layer_->SetSurfaceId( | 1019 surface_layer_->SetSurfaceId( |
| 1014 cc::SurfaceId(owned_view_->view()->id()), | 1020 cc::SurfaceId(owned_view_->view()->id()), |
| 1015 global_state()->device_pixel_ratio(), | 1021 global_state()->device_pixel_ratio(), |
| 1016 owned_view_->view()->bounds().To<gfx::Rect>().size()); | 1022 owned_view_->view()->bounds().To<gfx::Rect>().size()); |
| 1017 } | 1023 } |
| 1018 | 1024 |
| 1019 } // namespace mojo | 1025 } // namespace mojo |
| OLD | NEW |