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 <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <utility> | 10 #include <utility> |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "components/html_viewer/web_layer_tree_view_impl.h" | 35 #include "components/html_viewer/web_layer_tree_view_impl.h" |
36 #include "components/html_viewer/web_storage_namespace_impl.h" | 36 #include "components/html_viewer/web_storage_namespace_impl.h" |
37 #include "components/html_viewer/web_url_loader_impl.h" | 37 #include "components/html_viewer/web_url_loader_impl.h" |
38 #include "components/mus/public/cpp/scoped_window_ptr.h" | 38 #include "components/mus/public/cpp/scoped_window_ptr.h" |
39 #include "components/mus/public/cpp/window.h" | 39 #include "components/mus/public/cpp/window.h" |
40 #include "components/mus/public/cpp/window_tree_connection.h" | 40 #include "components/mus/public/cpp/window_tree_connection.h" |
41 #include "components/mus/ws/ids.h" | 41 #include "components/mus/ws/ids.h" |
42 #include "mojo/common/common_type_converters.h" | 42 #include "mojo/common/common_type_converters.h" |
43 #include "mojo/converters/blink/blink_input_events_type_converters.h" | 43 #include "mojo/converters/blink/blink_input_events_type_converters.h" |
44 #include "mojo/converters/geometry/geometry_type_converters.h" | 44 #include "mojo/converters/geometry/geometry_type_converters.h" |
45 #include "mojo/shell/public/cpp/application_impl.h" | 45 #include "mojo/shell/public/cpp/shell.h" |
46 #include "mojo/shell/public/cpp/connect.h" | |
47 #include "mojo/shell/public/interfaces/shell.mojom.h" | |
48 #include "third_party/WebKit/public/platform/Platform.h" | 46 #include "third_party/WebKit/public/platform/Platform.h" |
49 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" | 47 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" |
50 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 48 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
51 #include "third_party/WebKit/public/platform/WebSize.h" | 49 #include "third_party/WebKit/public/platform/WebSize.h" |
52 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 50 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
53 #include "third_party/WebKit/public/web/WebDocument.h" | 51 #include "third_party/WebKit/public/web/WebDocument.h" |
54 #include "third_party/WebKit/public/web/WebElement.h" | 52 #include "third_party/WebKit/public/web/WebElement.h" |
55 #include "third_party/WebKit/public/web/WebFindOptions.h" | 53 #include "third_party/WebKit/public/web/WebFindOptions.h" |
56 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" | 54 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" |
57 #include "third_party/WebKit/public/web/WebInputEvent.h" | 55 #include "third_party/WebKit/public/web/WebInputEvent.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 GetValueFromClientProperties("devtools-state", params->properties); | 168 GetValueFromClientProperties("devtools-state", params->properties); |
171 std::string devtools_state_str = devtools_state.To<std::string>(); | 169 std::string devtools_state_str = devtools_state.To<std::string>(); |
172 devtools_agent_.reset(new DevToolsAgentImpl( | 170 devtools_agent_.reset(new DevToolsAgentImpl( |
173 web_frame_->toWebLocalFrame(), devtools_id.To<std::string>(), | 171 web_frame_->toWebLocalFrame(), devtools_id.To<std::string>(), |
174 devtools_state.is_null() ? nullptr : &devtools_state_str)); | 172 devtools_state.is_null() ? nullptr : &devtools_state_str)); |
175 } | 173 } |
176 | 174 |
177 // Collect startup perf data for local main frames in test environments. | 175 // Collect startup perf data for local main frames in test environments. |
178 // Child frames aren't tracked, and tracking remote frames is redundant. | 176 // Child frames aren't tracked, and tracking remote frames is redundant. |
179 startup_performance_data_collector_ = | 177 startup_performance_data_collector_ = |
180 StatsCollectionController::Install(web_frame_, GetApp()); | 178 StatsCollectionController::Install(web_frame_, GetShell()); |
181 } | 179 } |
182 } else if (!params->is_local_create_child && params->window && | 180 } else if (!params->is_local_create_child && params->window && |
183 id_ == params->window->id()) { | 181 id_ == params->window->id()) { |
184 // Frame represents the local frame, and it isn't the root of the tree. | 182 // Frame represents the local frame, and it isn't the root of the tree. |
185 HTMLFrame* previous_sibling = GetPreviousSibling(this); | 183 HTMLFrame* previous_sibling = GetPreviousSibling(this); |
186 blink::WebFrame* previous_web_frame = | 184 blink::WebFrame* previous_web_frame = |
187 previous_sibling ? previous_sibling->web_frame() : nullptr; | 185 previous_sibling ? previous_sibling->web_frame() : nullptr; |
188 CHECK(!parent_->IsLocal()); | 186 CHECK(!parent_->IsLocal()); |
189 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createLocalChild( | 187 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createLocalChild( |
190 state_.tree_scope, state_.name, state_.sandbox_flags, this, | 188 state_.tree_scope, state_.name, state_.sandbox_flags, this, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 blink::WebMediaPlayer* HTMLFrame::createMediaPlayer( | 310 blink::WebMediaPlayer* HTMLFrame::createMediaPlayer( |
313 blink::WebLocalFrame* frame, | 311 blink::WebLocalFrame* frame, |
314 blink::WebMediaPlayer::LoadType load_type, | 312 blink::WebMediaPlayer::LoadType load_type, |
315 const blink::WebURL& url, | 313 const blink::WebURL& url, |
316 blink::WebMediaPlayerClient* client, | 314 blink::WebMediaPlayerClient* client, |
317 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 315 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
318 blink::WebContentDecryptionModule* initial_cdm, | 316 blink::WebContentDecryptionModule* initial_cdm, |
319 const blink::WebString& sink_id, | 317 const blink::WebString& sink_id, |
320 blink::WebMediaSession* media_session) { | 318 blink::WebMediaSession* media_session) { |
321 return global_state()->media_factory()->CreateMediaPlayer( | 319 return global_state()->media_factory()->CreateMediaPlayer( |
322 frame, url, client, encrypted_client, initial_cdm, GetApp()->shell()); | 320 frame, url, client, encrypted_client, initial_cdm, GetShell()); |
323 } | 321 } |
324 | 322 |
325 blink::WebFrame* HTMLFrame::createChildFrame( | 323 blink::WebFrame* HTMLFrame::createChildFrame( |
326 blink::WebLocalFrame* parent, | 324 blink::WebLocalFrame* parent, |
327 blink::WebTreeScopeType scope, | 325 blink::WebTreeScopeType scope, |
328 const blink::WebString& frame_name, | 326 const blink::WebString& frame_name, |
329 blink::WebSandboxFlags sandbox_flags, | 327 blink::WebSandboxFlags sandbox_flags, |
330 const blink::WebFrameOwnerProperties& frame_owner_properties) { | 328 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
331 DCHECK(IsLocal()); // Can't create children of remote frames. | 329 DCHECK(IsLocal()); // Can't create children of remote frames. |
332 DCHECK_EQ(parent, web_frame_); | 330 DCHECK_EQ(parent, web_frame_); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 } | 563 } |
566 } | 564 } |
567 | 565 |
568 HTMLFrame* HTMLFrame::GetFirstAncestorWithDelegate() { | 566 HTMLFrame* HTMLFrame::GetFirstAncestorWithDelegate() { |
569 HTMLFrame* frame = this; | 567 HTMLFrame* frame = this; |
570 while (frame && !frame->delegate_) | 568 while (frame && !frame->delegate_) |
571 frame = frame->parent_; | 569 frame = frame->parent_; |
572 return frame; | 570 return frame; |
573 } | 571 } |
574 | 572 |
575 mojo::ApplicationImpl* HTMLFrame::GetApp() { | 573 mojo::Shell* HTMLFrame::GetShell() { |
576 return GetFirstAncestorWithDelegate()->delegate_->GetApp(); | 574 return GetFirstAncestorWithDelegate()->delegate_->GetShell(); |
577 } | 575 } |
578 | 576 |
579 web_view::mojom::Frame* HTMLFrame::GetServerFrame() { | 577 web_view::mojom::Frame* HTMLFrame::GetServerFrame() { |
580 // Prefer an ancestor with a server Frame. | 578 // Prefer an ancestor with a server Frame. |
581 for (HTMLFrame* frame = this; frame; frame = frame->parent_) { | 579 for (HTMLFrame* frame = this; frame; frame = frame->parent_) { |
582 if (frame->server_.get()) | 580 if (frame->server_.get()) |
583 return frame->server_.get(); | 581 return frame->server_.get(); |
584 } | 582 } |
585 | 583 |
586 // We're a remote frame with no local frame ancestors. Use the server Frame | 584 // We're a remote frame with no local frame ancestors. Use the server Frame |
587 // from the local frame of the HTMLFrameTreeManager. | 585 // from the local frame of the HTMLFrameTreeManager. |
588 return frame_tree_manager_->local_frame_->server_.get(); | 586 return frame_tree_manager_->local_frame_->server_.get(); |
589 } | 587 } |
590 | 588 |
591 void HTMLFrame::SetWindow(mus::Window* window) { | 589 void HTMLFrame::SetWindow(mus::Window* window) { |
592 if (window_) { | 590 if (window_) { |
593 window_->set_input_event_handler(nullptr); | 591 window_->set_input_event_handler(nullptr); |
594 window_->RemoveObserver(this); | 592 window_->RemoveObserver(this); |
595 } | 593 } |
596 window_ = window; | 594 window_ = window; |
597 if (window_) { | 595 if (window_) { |
598 window_->AddObserver(this); | 596 window_->AddObserver(this); |
599 window_->set_input_event_handler(this); | 597 window_->set_input_event_handler(this); |
600 } | 598 } |
601 } | 599 } |
602 | 600 |
603 void HTMLFrame::CreateRootWebWidget() { | 601 void HTMLFrame::CreateRootWebWidget() { |
604 DCHECK(!html_widget_); | 602 DCHECK(!html_widget_); |
605 if (window_) { | 603 if (window_) { |
606 HTMLWidgetRootLocal::CreateParams create_params(GetApp(), global_state(), | 604 HTMLWidgetRootLocal::CreateParams create_params(GetShell(), global_state(), |
607 window_); | 605 window_); |
608 html_widget_.reset( | 606 html_widget_.reset( |
609 delegate_->GetHTMLFactory()->CreateHTMLWidgetRootLocal(&create_params)); | 607 delegate_->GetHTMLFactory()->CreateHTMLWidgetRootLocal(&create_params)); |
610 } else { | 608 } else { |
611 html_widget_.reset(new HTMLWidgetRootRemote(global_state())); | 609 html_widget_.reset(new HTMLWidgetRootRemote(global_state())); |
612 } | 610 } |
613 } | 611 } |
614 | 612 |
615 void HTMLFrame::CreateLocalRootWebWidget(blink::WebLocalFrame* local_frame) { | 613 void HTMLFrame::CreateLocalRootWebWidget(blink::WebLocalFrame* local_frame) { |
616 DCHECK(!html_widget_); | 614 DCHECK(!html_widget_); |
617 DCHECK(IsLocal()); | 615 DCHECK(IsLocal()); |
618 html_widget_.reset( | 616 html_widget_.reset(new HTMLWidgetLocalRoot(GetShell(), global_state(), |
619 new HTMLWidgetLocalRoot(GetApp(), global_state(), window_, local_frame)); | 617 window_, local_frame)); |
620 } | 618 } |
621 | 619 |
622 void HTMLFrame::UpdateFocus() { | 620 void HTMLFrame::UpdateFocus() { |
623 blink::WebWidget* web_widget = GetWebWidget(); | 621 blink::WebWidget* web_widget = GetWebWidget(); |
624 if (!web_widget || !window_) | 622 if (!web_widget || !window_) |
625 return; | 623 return; |
626 const bool is_focused = window_ && window_->HasFocus(); | 624 const bool is_focused = window_ && window_->HasFocus(); |
627 web_widget->setFocus(is_focused); | 625 web_widget->setFocus(is_focused); |
628 if (web_widget->isWebView()) | 626 if (web_widget->isWebView()) |
629 static_cast<blink::WebView*>(web_widget)->setIsActive(is_focused); | 627 static_cast<blink::WebView*>(web_widget)->setIsActive(is_focused); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 | 1041 |
1044 if (!surface_layer_) | 1042 if (!surface_layer_) |
1045 return; | 1043 return; |
1046 | 1044 |
1047 surface_layer_->SetSurfaceId(cc::SurfaceId(owned_window_->window()->id()), | 1045 surface_layer_->SetSurfaceId(cc::SurfaceId(owned_window_->window()->id()), |
1048 global_state()->device_pixel_ratio(), | 1046 global_state()->device_pixel_ratio(), |
1049 owned_window_->window()->bounds().size()); | 1047 owned_window_->window()->bounds().size()); |
1050 } | 1048 } |
1051 | 1049 |
1052 } // namespace mojo | 1050 } // namespace mojo |
OLD | NEW |