| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 HTMLFrame::HTMLFrame(CreateParams* params) | 120 HTMLFrame::HTMLFrame(CreateParams* params) |
| 121 : frame_tree_manager_(params->manager), | 121 : frame_tree_manager_(params->manager), |
| 122 parent_(params->parent), | 122 parent_(params->parent), |
| 123 window_(nullptr), | 123 window_(nullptr), |
| 124 id_(params->id), | 124 id_(params->id), |
| 125 web_frame_(nullptr), | 125 web_frame_(nullptr), |
| 126 delegate_(params->delegate), | 126 delegate_(params->delegate), |
| 127 pending_navigation_(false), | 127 pending_navigation_(false), |
| 128 weak_factory_(this) { | 128 weak_factory_(this) { |
| 129 TRACE_EVENT0("html_viewer", "HTMLFrame::HTMLFrame"); |
| 129 if (parent_) | 130 if (parent_) |
| 130 parent_->children_.push_back(this); | 131 parent_->children_.push_back(this); |
| 131 | 132 |
| 132 if (params->window && params->window->id() == id_) | 133 if (params->window && params->window->id() == id_) |
| 133 SetWindow(params->window); | 134 SetWindow(params->window); |
| 134 | 135 |
| 135 SetReplicatedFrameStateFromClientProperties(params->properties, &state_); | 136 SetReplicatedFrameStateFromClientProperties(params->properties, &state_); |
| 136 | 137 |
| 137 if (!parent_) { | 138 if (!parent_) { |
| 138 CreateRootWebWidget(); | 139 CreateRootWebWidget(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 267 |
| 267 for (HTMLFrame* child : children_) { | 268 for (HTMLFrame* child : children_) { |
| 268 if (child->HasLocalDescendant()) | 269 if (child->HasLocalDescendant()) |
| 269 return true; | 270 return true; |
| 270 } | 271 } |
| 271 return false; | 272 return false; |
| 272 } | 273 } |
| 273 | 274 |
| 274 void HTMLFrame::LoadRequest(const blink::WebURLRequest& request, | 275 void HTMLFrame::LoadRequest(const blink::WebURLRequest& request, |
| 275 base::TimeTicks navigation_start_time) { | 276 base::TimeTicks navigation_start_time) { |
| 277 TRACE_EVENT1("html_viewer", "HTMLFrame::LoadRequest", |
| 278 "url", request.url().string().utf8()); |
| 279 |
| 276 DCHECK(IsLocal()); | 280 DCHECK(IsLocal()); |
| 277 | 281 |
| 278 DVLOG(2) << "HTMLFrame::LoadRequest this=" << this << " id=" << id_ | 282 DVLOG(2) << "HTMLFrame::LoadRequest this=" << this << " id=" << id_ |
| 279 << " URL=" << GURL(request.url()); | 283 << " URL=" << GURL(request.url()); |
| 280 | 284 |
| 281 pending_navigation_ = false; | 285 pending_navigation_ = false; |
| 282 navigation_start_time_ = navigation_start_time; | 286 navigation_start_time_ = navigation_start_time; |
| 283 web_frame_->toWebLocalFrame()->loadRequest(request); | 287 web_frame_->toWebLocalFrame()->loadRequest(request); |
| 284 } | 288 } |
| 285 | 289 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 blink::WebWidget* web_widget = GetWebWidget(); | 615 blink::WebWidget* web_widget = GetWebWidget(); |
| 612 if (!web_widget || !window_) | 616 if (!web_widget || !window_) |
| 613 return; | 617 return; |
| 614 const bool is_focused = window_ && window_->HasFocus(); | 618 const bool is_focused = window_ && window_->HasFocus(); |
| 615 web_widget->setFocus(is_focused); | 619 web_widget->setFocus(is_focused); |
| 616 if (web_widget->isWebView()) | 620 if (web_widget->isWebView()) |
| 617 static_cast<blink::WebView*>(web_widget)->setIsActive(is_focused); | 621 static_cast<blink::WebView*>(web_widget)->setIsActive(is_focused); |
| 618 } | 622 } |
| 619 | 623 |
| 620 void HTMLFrame::SwapToRemote() { | 624 void HTMLFrame::SwapToRemote() { |
| 625 TRACE_EVENT0("html_viewer", "HTMLFrame::SwapToRemote"); |
| 626 |
| 621 DVLOG(2) << "HTMLFrame::SwapToRemote this=" << this << " id=" << id_; | 627 DVLOG(2) << "HTMLFrame::SwapToRemote this=" << this << " id=" << id_; |
| 622 | 628 |
| 623 DCHECK(IsLocal()); | 629 DCHECK(IsLocal()); |
| 624 | 630 |
| 625 HTMLFrameDelegate* delegate = delegate_; | 631 HTMLFrameDelegate* delegate = delegate_; |
| 626 delegate_ = nullptr; | 632 delegate_ = nullptr; |
| 627 | 633 |
| 628 blink::WebRemoteFrame* remote_frame = | 634 blink::WebRemoteFrame* remote_frame = |
| 629 blink::WebRemoteFrame::create(state_.tree_scope, this); | 635 blink::WebRemoteFrame::create(state_.tree_scope, this); |
| 630 remote_frame->initializeFromFrame(web_frame_->toWebLocalFrame()); | 636 remote_frame->initializeFromFrame(web_frame_->toWebLocalFrame()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 658 server_.reset(); | 664 server_.reset(); |
| 659 frame_client_binding_.reset(); | 665 frame_client_binding_.reset(); |
| 660 if (delegate) | 666 if (delegate) |
| 661 delegate->OnFrameSwappedToRemote(); | 667 delegate->OnFrameSwappedToRemote(); |
| 662 } | 668 } |
| 663 | 669 |
| 664 void HTMLFrame::SwapToLocal( | 670 void HTMLFrame::SwapToLocal( |
| 665 HTMLFrameDelegate* delegate, | 671 HTMLFrameDelegate* delegate, |
| 666 mus::Window* window, | 672 mus::Window* window, |
| 667 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties) { | 673 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties) { |
| 674 TRACE_EVENT0("html_viewer", "HTMLFrame::SwapToLocal"); |
| 668 DVLOG(2) << "HTMLFrame::SwapToLocal this=" << this << " id=" << id_; | 675 DVLOG(2) << "HTMLFrame::SwapToLocal this=" << this << " id=" << id_; |
| 669 CHECK(!IsLocal()); | 676 CHECK(!IsLocal()); |
| 670 // It doesn't make sense for the root to swap to local. | 677 // It doesn't make sense for the root to swap to local. |
| 671 CHECK(parent_); | 678 CHECK(parent_); |
| 672 delegate_ = delegate; | 679 delegate_ = delegate; |
| 673 SetWindow(window); | 680 SetWindow(window); |
| 674 SetReplicatedFrameStateFromClientProperties(properties, &state_); | 681 SetReplicatedFrameStateFromClientProperties(properties, &state_); |
| 675 blink::WebLocalFrame* local_web_frame = | 682 blink::WebLocalFrame* local_web_frame = |
| 676 blink::WebLocalFrame::create(state_.tree_scope, this); | 683 blink::WebLocalFrame::create(state_.tree_scope, this); |
| 677 local_web_frame->initializeToReplaceRemoteFrame( | 684 local_web_frame->initializeToReplaceRemoteFrame( |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 if (!surface_layer_) | 1033 if (!surface_layer_) |
| 1027 return; | 1034 return; |
| 1028 | 1035 |
| 1029 surface_layer_->SetSurfaceId( | 1036 surface_layer_->SetSurfaceId( |
| 1030 cc::SurfaceId(owned_window_->window()->id()), | 1037 cc::SurfaceId(owned_window_->window()->id()), |
| 1031 global_state()->device_pixel_ratio(), | 1038 global_state()->device_pixel_ratio(), |
| 1032 owned_window_->window()->bounds().To<gfx::Rect>().size()); | 1039 owned_window_->window()->bounds().To<gfx::Rect>().size()); |
| 1033 } | 1040 } |
| 1034 | 1041 |
| 1035 } // namespace mojo | 1042 } // namespace mojo |
| OLD | NEW |