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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "mojo/converters/geometry/geometry_type_converters.h" | 45 #include "mojo/converters/geometry/geometry_type_converters.h" |
46 #include "skia/ext/refptr.h" | 46 #include "skia/ext/refptr.h" |
47 #include "third_party/WebKit/public/platform/Platform.h" | 47 #include "third_party/WebKit/public/platform/Platform.h" |
48 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" | 48 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" |
49 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 49 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
50 #include "third_party/WebKit/public/platform/WebSize.h" | 50 #include "third_party/WebKit/public/platform/WebSize.h" |
51 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 51 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
52 #include "third_party/WebKit/public/web/WebDocument.h" | 52 #include "third_party/WebKit/public/web/WebDocument.h" |
53 #include "third_party/WebKit/public/web/WebElement.h" | 53 #include "third_party/WebKit/public/web/WebElement.h" |
54 #include "third_party/WebKit/public/web/WebFindOptions.h" | 54 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 55 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" |
55 #include "third_party/WebKit/public/web/WebInputEvent.h" | 56 #include "third_party/WebKit/public/web/WebInputEvent.h" |
56 #include "third_party/WebKit/public/web/WebKit.h" | 57 #include "third_party/WebKit/public/web/WebKit.h" |
57 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 58 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
58 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 59 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
59 #include "third_party/WebKit/public/web/WebRemoteFrame.h" | 60 #include "third_party/WebKit/public/web/WebRemoteFrame.h" |
60 #include "third_party/WebKit/public/web/WebRemoteFrameClient.h" | 61 #include "third_party/WebKit/public/web/WebRemoteFrameClient.h" |
61 #include "third_party/WebKit/public/web/WebScriptSource.h" | 62 #include "third_party/WebKit/public/web/WebScriptSource.h" |
62 #include "third_party/WebKit/public/web/WebView.h" | 63 #include "third_party/WebKit/public/web/WebView.h" |
63 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h" | 64 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h" |
64 #include "third_party/skia/include/core/SkCanvas.h" | 65 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 184 } |
184 } else if (!params->is_local_create_child && params->window && | 185 } else if (!params->is_local_create_child && params->window && |
185 id_ == params->window->id()) { | 186 id_ == params->window->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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 316 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
314 blink::WebContentDecryptionModule* initial_cdm) { | 317 blink::WebContentDecryptionModule* initial_cdm) { |
315 return global_state()->media_factory()->CreateMediaPlayer( | 318 return global_state()->media_factory()->CreateMediaPlayer( |
316 frame, url, client, encrypted_client, initial_cdm, GetApp()->shell()); | 319 frame, url, client, encrypted_client, initial_cdm, GetApp()->shell()); |
317 } | 320 } |
318 | 321 |
319 blink::WebFrame* HTMLFrame::createChildFrame( | 322 blink::WebFrame* HTMLFrame::createChildFrame( |
320 blink::WebLocalFrame* parent, | 323 blink::WebLocalFrame* parent, |
321 blink::WebTreeScopeType scope, | 324 blink::WebTreeScopeType scope, |
322 const blink::WebString& frame_name, | 325 const blink::WebString& frame_name, |
323 blink::WebSandboxFlags sandbox_flags) { | 326 blink::WebSandboxFlags sandbox_flags, |
| 327 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
324 DCHECK(IsLocal()); // Can't create children of remote frames. | 328 DCHECK(IsLocal()); // Can't create children of remote frames. |
325 DCHECK_EQ(parent, web_frame_); | 329 DCHECK_EQ(parent, web_frame_); |
326 DCHECK(window_); // If we're local we have to have a window. | 330 DCHECK(window_); // If we're local we have to have a window. |
327 // Create the window that will house the frame now. We embed once we know the | 331 // Create the window that will house the frame now. We embed once we know the |
328 // url (see decidePolicyForNavigation()). | 332 // url (see decidePolicyForNavigation()). |
329 mus::Window* child_window = window_->connection()->NewWindow(); | 333 mus::Window* child_window = window_->connection()->NewWindow(); |
330 ReplicatedFrameState child_state; | 334 ReplicatedFrameState child_state; |
331 child_state.name = frame_name; | 335 child_state.name = frame_name; |
332 child_state.tree_scope = scope; | 336 child_state.tree_scope = scope; |
333 child_state.sandbox_flags = sandbox_flags; | 337 child_state.sandbox_flags = sandbox_flags; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 DVLOG(2) << "HTMLFrame::SwapToLocal this=" << this << " id=" << id_; | 672 DVLOG(2) << "HTMLFrame::SwapToLocal this=" << this << " id=" << id_; |
669 CHECK(!IsLocal()); | 673 CHECK(!IsLocal()); |
670 // It doesn't make sense for the root to swap to local. | 674 // It doesn't make sense for the root to swap to local. |
671 CHECK(parent_); | 675 CHECK(parent_); |
672 delegate_ = delegate; | 676 delegate_ = delegate; |
673 SetWindow(window); | 677 SetWindow(window); |
674 SetReplicatedFrameStateFromClientProperties(properties, &state_); | 678 SetReplicatedFrameStateFromClientProperties(properties, &state_); |
675 blink::WebLocalFrame* local_web_frame = | 679 blink::WebLocalFrame* local_web_frame = |
676 blink::WebLocalFrame::create(state_.tree_scope, this); | 680 blink::WebLocalFrame::create(state_.tree_scope, this); |
677 local_web_frame->initializeToReplaceRemoteFrame( | 681 local_web_frame->initializeToReplaceRemoteFrame( |
678 web_frame_->toWebRemoteFrame(), state_.name, state_.sandbox_flags); | 682 web_frame_->toWebRemoteFrame(), state_.name, state_.sandbox_flags, |
| 683 // TODO(lazyboy): Figure out replicating WebFrameOwnerProperties. |
| 684 blink::WebFrameOwnerProperties()); |
679 // The swap() ends up calling to frameDetached() and deleting the old. | 685 // The swap() ends up calling to frameDetached() and deleting the old. |
680 web_frame_->swap(local_web_frame); | 686 web_frame_->swap(local_web_frame); |
681 web_frame_ = local_web_frame; | 687 web_frame_ = local_web_frame; |
682 | 688 |
683 web_layer_.reset(); | 689 web_layer_.reset(); |
684 } | 690 } |
685 | 691 |
686 void HTMLFrame::SwapDelegate(HTMLFrameDelegate* delegate) { | 692 void HTMLFrame::SwapDelegate(HTMLFrameDelegate* delegate) { |
687 DCHECK(IsLocal()); | 693 DCHECK(IsLocal()); |
688 HTMLFrameDelegate* old_delegate = delegate_; | 694 HTMLFrameDelegate* old_delegate = delegate_; |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 if (!surface_layer_) | 1032 if (!surface_layer_) |
1027 return; | 1033 return; |
1028 | 1034 |
1029 surface_layer_->SetSurfaceId( | 1035 surface_layer_->SetSurfaceId( |
1030 cc::SurfaceId(owned_window_->window()->id()), | 1036 cc::SurfaceId(owned_window_->window()->id()), |
1031 global_state()->device_pixel_ratio(), | 1037 global_state()->device_pixel_ratio(), |
1032 owned_window_->window()->bounds().To<gfx::Rect>().size()); | 1038 owned_window_->window()->bounds().To<gfx::Rect>().size()); |
1033 } | 1039 } |
1034 | 1040 |
1035 } // namespace mojo | 1041 } // namespace mojo |
OLD | NEW |