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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 blink::WebContentDecryptionModule* initial_cdm, | 320 blink::WebContentDecryptionModule* initial_cdm, |
318 const blink::WebString& sink_id) { | 321 const blink::WebString& sink_id) { |
319 return global_state()->media_factory()->CreateMediaPlayer( | 322 return global_state()->media_factory()->CreateMediaPlayer( |
320 frame, url, client, encrypted_client, initial_cdm, GetApp()->shell()); | 323 frame, url, client, encrypted_client, initial_cdm, GetApp()->shell()); |
321 } | 324 } |
322 | 325 |
323 blink::WebFrame* HTMLFrame::createChildFrame( | 326 blink::WebFrame* HTMLFrame::createChildFrame( |
324 blink::WebLocalFrame* parent, | 327 blink::WebLocalFrame* parent, |
325 blink::WebTreeScopeType scope, | 328 blink::WebTreeScopeType scope, |
326 const blink::WebString& frame_name, | 329 const blink::WebString& frame_name, |
327 blink::WebSandboxFlags sandbox_flags) { | 330 blink::WebSandboxFlags sandbox_flags, |
| 331 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
328 DCHECK(IsLocal()); // Can't create children of remote frames. | 332 DCHECK(IsLocal()); // Can't create children of remote frames. |
329 DCHECK_EQ(parent, web_frame_); | 333 DCHECK_EQ(parent, web_frame_); |
330 DCHECK(window_); // If we're local we have to have a window. | 334 DCHECK(window_); // If we're local we have to have a window. |
331 // Create the window that will house the frame now. We embed once we know the | 335 // Create the window that will house the frame now. We embed once we know the |
332 // url (see decidePolicyForNavigation()). | 336 // url (see decidePolicyForNavigation()). |
333 mus::Window* child_window = window_->connection()->NewWindow(); | 337 mus::Window* child_window = window_->connection()->NewWindow(); |
334 ReplicatedFrameState child_state; | 338 ReplicatedFrameState child_state; |
335 child_state.name = frame_name; | 339 child_state.name = frame_name; |
336 child_state.tree_scope = scope; | 340 child_state.tree_scope = scope; |
337 child_state.sandbox_flags = sandbox_flags; | 341 child_state.sandbox_flags = sandbox_flags; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 DVLOG(2) << "HTMLFrame::SwapToLocal this=" << this << " id=" << id_; | 678 DVLOG(2) << "HTMLFrame::SwapToLocal this=" << this << " id=" << id_; |
675 CHECK(!IsLocal()); | 679 CHECK(!IsLocal()); |
676 // It doesn't make sense for the root to swap to local. | 680 // It doesn't make sense for the root to swap to local. |
677 CHECK(parent_); | 681 CHECK(parent_); |
678 delegate_ = delegate; | 682 delegate_ = delegate; |
679 SetWindow(window); | 683 SetWindow(window); |
680 SetReplicatedFrameStateFromClientProperties(properties, &state_); | 684 SetReplicatedFrameStateFromClientProperties(properties, &state_); |
681 blink::WebLocalFrame* local_web_frame = | 685 blink::WebLocalFrame* local_web_frame = |
682 blink::WebLocalFrame::create(state_.tree_scope, this); | 686 blink::WebLocalFrame::create(state_.tree_scope, this); |
683 local_web_frame->initializeToReplaceRemoteFrame( | 687 local_web_frame->initializeToReplaceRemoteFrame( |
684 web_frame_->toWebRemoteFrame(), state_.name, state_.sandbox_flags); | 688 web_frame_->toWebRemoteFrame(), state_.name, state_.sandbox_flags, |
| 689 // TODO(lazyboy): Figure out replicating WebFrameOwnerProperties. |
| 690 blink::WebFrameOwnerProperties()); |
685 // The swap() ends up calling to frameDetached() and deleting the old. | 691 // The swap() ends up calling to frameDetached() and deleting the old. |
686 web_frame_->swap(local_web_frame); | 692 web_frame_->swap(local_web_frame); |
687 web_frame_ = local_web_frame; | 693 web_frame_ = local_web_frame; |
688 | 694 |
689 web_layer_.reset(); | 695 web_layer_.reset(); |
690 } | 696 } |
691 | 697 |
692 void HTMLFrame::SwapDelegate(HTMLFrameDelegate* delegate) { | 698 void HTMLFrame::SwapDelegate(HTMLFrameDelegate* delegate) { |
693 DCHECK(IsLocal()); | 699 DCHECK(IsLocal()); |
694 HTMLFrameDelegate* old_delegate = delegate_; | 700 HTMLFrameDelegate* old_delegate = delegate_; |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 | 1036 |
1031 if (!surface_layer_) | 1037 if (!surface_layer_) |
1032 return; | 1038 return; |
1033 | 1039 |
1034 surface_layer_->SetSurfaceId(cc::SurfaceId(owned_window_->window()->id()), | 1040 surface_layer_->SetSurfaceId(cc::SurfaceId(owned_window_->window()->id()), |
1035 global_state()->device_pixel_ratio(), | 1041 global_state()->device_pixel_ratio(), |
1036 owned_window_->window()->bounds().size()); | 1042 owned_window_->window()->bounds().size()); |
1037 } | 1043 } |
1038 | 1044 |
1039 } // namespace mojo | 1045 } // namespace mojo |
OLD | NEW |