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" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "components/html_viewer/ax_provider_impl.h" | 15 #include "components/html_viewer/ax_provider_impl.h" |
16 #include "components/html_viewer/blink_basic_type_converters.h" | 16 #include "components/html_viewer/blink_basic_type_converters.h" |
17 #include "components/html_viewer/blink_input_events_type_converters.h" | 17 #include "components/html_viewer/blink_input_events_type_converters.h" |
18 #include "components/html_viewer/blink_text_input_type_converters.h" | 18 #include "components/html_viewer/blink_text_input_type_converters.h" |
19 #include "components/html_viewer/blink_url_request_type_converters.h" | 19 #include "components/html_viewer/blink_url_request_type_converters.h" |
20 #include "components/html_viewer/geolocation_client_impl.h" | 20 #include "components/html_viewer/geolocation_client_impl.h" |
21 #include "components/html_viewer/global_state.h" | 21 #include "components/html_viewer/global_state.h" |
22 #include "components/html_viewer/html_frame_delegate.h" | 22 #include "components/html_viewer/html_frame_delegate.h" |
23 #include "components/html_viewer/html_frame_properties.h" | 23 #include "components/html_viewer/html_frame_properties.h" |
24 #include "components/html_viewer/html_frame_tree_manager.h" | 24 #include "components/html_viewer/html_frame_tree_manager.h" |
25 #include "components/html_viewer/media_factory.h" | 25 #include "components/html_viewer/media_factory.h" |
| 26 #include "components/html_viewer/stats_collection_controller.h" |
26 #include "components/html_viewer/touch_handler.h" | 27 #include "components/html_viewer/touch_handler.h" |
27 #include "components/html_viewer/web_layer_impl.h" | 28 #include "components/html_viewer/web_layer_impl.h" |
28 #include "components/html_viewer/web_layer_tree_view_impl.h" | 29 #include "components/html_viewer/web_layer_tree_view_impl.h" |
29 #include "components/html_viewer/web_storage_namespace_impl.h" | 30 #include "components/html_viewer/web_storage_namespace_impl.h" |
30 #include "components/html_viewer/web_url_loader_impl.h" | 31 #include "components/html_viewer/web_url_loader_impl.h" |
31 #include "components/view_manager/ids.h" | 32 #include "components/view_manager/ids.h" |
32 #include "components/view_manager/public/cpp/scoped_view_ptr.h" | 33 #include "components/view_manager/public/cpp/scoped_view_ptr.h" |
33 #include "components/view_manager/public/cpp/view.h" | 34 #include "components/view_manager/public/cpp/view.h" |
34 #include "components/view_manager/public/cpp/view_manager.h" | 35 #include "components/view_manager/public/cpp/view_manager.h" |
35 #include "components/view_manager/public/interfaces/surfaces.mojom.h" | 36 #include "components/view_manager/public/interfaces/surfaces.mojom.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 const gfx::Size size_in_dips = gfx::ConvertSizeToDIP( | 156 const gfx::Size size_in_dips = gfx::ConvertSizeToDIP( |
156 params->view->viewport_metrics().device_pixel_ratio, size_in_pixels); | 157 params->view->viewport_metrics().device_pixel_ratio, size_in_pixels); |
157 web_widget_->resize(size_in_dips); | 158 web_widget_->resize(size_in_dips); |
158 web_frame_ = local_web_frame; | 159 web_frame_ = local_web_frame; |
159 web_view()->setDeviceScaleFactor(global_state()->device_pixel_ratio()); | 160 web_view()->setDeviceScaleFactor(global_state()->device_pixel_ratio()); |
160 if (id_ != params->view->id()) { | 161 if (id_ != params->view->id()) { |
161 blink::WebRemoteFrame* remote_web_frame = | 162 blink::WebRemoteFrame* remote_web_frame = |
162 blink::WebRemoteFrame::create(state_.tree_scope, this); | 163 blink::WebRemoteFrame::create(state_.tree_scope, this); |
163 local_web_frame->swap(remote_web_frame); | 164 local_web_frame->swap(remote_web_frame); |
164 web_frame_ = remote_web_frame; | 165 web_frame_ = remote_web_frame; |
| 166 } else { |
| 167 // Collect startup perf data for local main frames in test environments. |
| 168 // Child frames aren't tracked, and tracking remote frames is redundant. |
| 169 startup_performance_data_collector_ = |
| 170 StatsCollectionController::Install(web_frame_, GetLocalRootApp()); |
165 } | 171 } |
166 } else if (!params->allow_local_shared_frame && params->view && | 172 } else if (!params->allow_local_shared_frame && params->view && |
167 id_ == params->view->id()) { | 173 id_ == params->view->id()) { |
168 // Frame represents the local frame, and it isn't the root of the tree. | 174 // Frame represents the local frame, and it isn't the root of the tree. |
169 HTMLFrame* previous_sibling = GetPreviousSibling(this); | 175 HTMLFrame* previous_sibling = GetPreviousSibling(this); |
170 blink::WebFrame* previous_web_frame = | 176 blink::WebFrame* previous_web_frame = |
171 previous_sibling ? previous_sibling->web_frame() : nullptr; | 177 previous_sibling ? previous_sibling->web_frame() : nullptr; |
172 DCHECK(!parent_->IsLocal()); | 178 DCHECK(!parent_->IsLocal()); |
173 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createLocalChild( | 179 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createLocalChild( |
174 state_.tree_scope, state_.name, state_.sandbox_flags, this, | 180 state_.tree_scope, state_.name, state_.sandbox_flags, this, |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 } | 749 } |
744 | 750 |
745 void HTMLFrame::didAddMessageToConsole(const blink::WebConsoleMessage& message, | 751 void HTMLFrame::didAddMessageToConsole(const blink::WebConsoleMessage& message, |
746 const blink::WebString& source_name, | 752 const blink::WebString& source_name, |
747 unsigned source_line, | 753 unsigned source_line, |
748 const blink::WebString& stack_trace) { | 754 const blink::WebString& stack_trace) { |
749 VLOG(1) << "[" << source_name.utf8() << "(" << source_line << ")] " | 755 VLOG(1) << "[" << source_name.utf8() << "(" << source_line << ")] " |
750 << message.text.utf8(); | 756 << message.text.utf8(); |
751 } | 757 } |
752 | 758 |
| 759 void HTMLFrame::didHandleOnloadEvents(blink::WebLocalFrame* frame) { |
| 760 static bool recorded = false; |
| 761 if (!recorded && startup_performance_data_collector_) { |
| 762 startup_performance_data_collector_->SetFirstWebContentsMainFrameLoadTime( |
| 763 base::Time::Now().ToInternalValue()); |
| 764 recorded = true; |
| 765 } |
| 766 } |
| 767 |
753 void HTMLFrame::didFinishLoad(blink::WebLocalFrame* frame) { | 768 void HTMLFrame::didFinishLoad(blink::WebLocalFrame* frame) { |
754 if (GetLocalRoot() == this) | 769 if (GetLocalRoot() == this) |
755 delegate_->OnFrameDidFinishLoad(); | 770 delegate_->OnFrameDidFinishLoad(); |
756 } | 771 } |
757 | 772 |
758 void HTMLFrame::didNavigateWithinPage(blink::WebLocalFrame* frame, | 773 void HTMLFrame::didNavigateWithinPage(blink::WebLocalFrame* frame, |
759 const blink::WebHistoryItem& history_item, | 774 const blink::WebHistoryItem& history_item, |
760 blink::WebHistoryCommitType commit_type) { | 775 blink::WebHistoryCommitType commit_type) { |
761 GetLocalRoot()->server_->DidNavigateLocally(id_, | 776 GetLocalRoot()->server_->DidNavigateLocally(id_, |
762 history_item.urlString().utf8()); | 777 history_item.urlString().utf8()); |
763 } | 778 } |
764 | 779 |
| 780 void HTMLFrame::didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame) { |
| 781 static bool recorded = false; |
| 782 if (!recorded && startup_performance_data_collector_) { |
| 783 startup_performance_data_collector_->SetFirstVisuallyNonEmptyLayoutTime( |
| 784 base::Time::Now().ToInternalValue()); |
| 785 recorded = true; |
| 786 } |
| 787 } |
| 788 |
765 blink::WebGeolocationClient* HTMLFrame::geolocationClient() { | 789 blink::WebGeolocationClient* HTMLFrame::geolocationClient() { |
766 if (!geolocation_client_impl_) | 790 if (!geolocation_client_impl_) |
767 geolocation_client_impl_.reset(new GeolocationClientImpl); | 791 geolocation_client_impl_.reset(new GeolocationClientImpl); |
768 return geolocation_client_impl_.get(); | 792 return geolocation_client_impl_.get(); |
769 } | 793 } |
770 | 794 |
771 blink::WebEncryptedMediaClient* HTMLFrame::encryptedMediaClient() { | 795 blink::WebEncryptedMediaClient* HTMLFrame::encryptedMediaClient() { |
772 return global_state()->media_factory()->GetEncryptedMediaClient(); | 796 return global_state()->media_factory()->GetEncryptedMediaClient(); |
773 } | 797 } |
774 | 798 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 | 901 |
878 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { | 902 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { |
879 NOTIMPLEMENTED(); | 903 NOTIMPLEMENTED(); |
880 } | 904 } |
881 | 905 |
882 void HTMLFrame::forwardInputEvent(const blink::WebInputEvent* event) { | 906 void HTMLFrame::forwardInputEvent(const blink::WebInputEvent* event) { |
883 NOTIMPLEMENTED(); | 907 NOTIMPLEMENTED(); |
884 } | 908 } |
885 | 909 |
886 } // namespace mojo | 910 } // namespace mojo |
OLD | NEW |