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 startup_performance_data_collector_ = | |
yzshen1
2015/08/17 21:45:52
Please consider commenting on why it is only insta
msw
2015/08/17 22:08:04
Done.
| |
168 StatsCollectionController::Install(web_frame_, GetLocalRootApp()); | |
165 } | 169 } |
166 } else if (!params->allow_local_shared_frame && params->view && | 170 } else if (!params->allow_local_shared_frame && params->view && |
167 id_ == params->view->id()) { | 171 id_ == params->view->id()) { |
168 // Frame represents the local frame, and it isn't the root of the tree. | 172 // Frame represents the local frame, and it isn't the root of the tree. |
169 HTMLFrame* previous_sibling = GetPreviousSibling(this); | 173 HTMLFrame* previous_sibling = GetPreviousSibling(this); |
170 blink::WebFrame* previous_web_frame = | 174 blink::WebFrame* previous_web_frame = |
171 previous_sibling ? previous_sibling->web_frame() : nullptr; | 175 previous_sibling ? previous_sibling->web_frame() : nullptr; |
172 DCHECK(!parent_->IsLocal()); | 176 DCHECK(!parent_->IsLocal()); |
173 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createLocalChild( | 177 web_frame_ = parent_->web_frame()->toWebRemoteFrame()->createLocalChild( |
174 state_.tree_scope, state_.name, state_.sandbox_flags, this, | 178 state_.tree_scope, state_.name, state_.sandbox_flags, this, |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
743 } | 747 } |
744 | 748 |
745 void HTMLFrame::didAddMessageToConsole(const blink::WebConsoleMessage& message, | 749 void HTMLFrame::didAddMessageToConsole(const blink::WebConsoleMessage& message, |
746 const blink::WebString& source_name, | 750 const blink::WebString& source_name, |
747 unsigned source_line, | 751 unsigned source_line, |
748 const blink::WebString& stack_trace) { | 752 const blink::WebString& stack_trace) { |
749 VLOG(1) << "[" << source_name.utf8() << "(" << source_line << ")] " | 753 VLOG(1) << "[" << source_name.utf8() << "(" << source_line << ")] " |
750 << message.text.utf8(); | 754 << message.text.utf8(); |
751 } | 755 } |
752 | 756 |
757 void HTMLFrame::didHandleOnloadEvents(blink::WebLocalFrame* frame) { | |
758 static bool recorded = false; | |
759 if (!recorded && startup_performance_data_collector_) { | |
760 startup_performance_data_collector_->SetFirstWebContentsMainFrameLoadTime( | |
761 base::Time::Now().ToInternalValue()); | |
762 recorded = true; | |
763 } | |
764 } | |
765 | |
753 void HTMLFrame::didFinishLoad(blink::WebLocalFrame* frame) { | 766 void HTMLFrame::didFinishLoad(blink::WebLocalFrame* frame) { |
754 if (GetLocalRoot() == this) | 767 if (GetLocalRoot() == this) |
755 delegate_->OnFrameDidFinishLoad(); | 768 delegate_->OnFrameDidFinishLoad(); |
756 } | 769 } |
757 | 770 |
758 void HTMLFrame::didNavigateWithinPage(blink::WebLocalFrame* frame, | 771 void HTMLFrame::didNavigateWithinPage(blink::WebLocalFrame* frame, |
759 const blink::WebHistoryItem& history_item, | 772 const blink::WebHistoryItem& history_item, |
760 blink::WebHistoryCommitType commit_type) { | 773 blink::WebHistoryCommitType commit_type) { |
761 GetLocalRoot()->server_->DidNavigateLocally(id_, | 774 GetLocalRoot()->server_->DidNavigateLocally(id_, |
762 history_item.urlString().utf8()); | 775 history_item.urlString().utf8()); |
763 } | 776 } |
764 | 777 |
778 void HTMLFrame::didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame) { | |
779 static bool recorded = false; | |
780 if (!recorded && startup_performance_data_collector_) { | |
781 startup_performance_data_collector_->SetFirstVisuallyNonEmptyLayoutTime( | |
782 base::Time::Now().ToInternalValue()); | |
783 recorded = true; | |
784 } | |
785 } | |
786 | |
765 blink::WebGeolocationClient* HTMLFrame::geolocationClient() { | 787 blink::WebGeolocationClient* HTMLFrame::geolocationClient() { |
766 if (!geolocation_client_impl_) | 788 if (!geolocation_client_impl_) |
767 geolocation_client_impl_.reset(new GeolocationClientImpl); | 789 geolocation_client_impl_.reset(new GeolocationClientImpl); |
768 return geolocation_client_impl_.get(); | 790 return geolocation_client_impl_.get(); |
769 } | 791 } |
770 | 792 |
771 blink::WebEncryptedMediaClient* HTMLFrame::encryptedMediaClient() { | 793 blink::WebEncryptedMediaClient* HTMLFrame::encryptedMediaClient() { |
772 return global_state()->media_factory()->GetEncryptedMediaClient(); | 794 return global_state()->media_factory()->GetEncryptedMediaClient(); |
773 } | 795 } |
774 | 796 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
877 | 899 |
878 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { | 900 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { |
879 NOTIMPLEMENTED(); | 901 NOTIMPLEMENTED(); |
880 } | 902 } |
881 | 903 |
882 void HTMLFrame::forwardInputEvent(const blink::WebInputEvent* event) { | 904 void HTMLFrame::forwardInputEvent(const blink::WebInputEvent* event) { |
883 NOTIMPLEMENTED(); | 905 NOTIMPLEMENTED(); |
884 } | 906 } |
885 | 907 |
886 } // namespace mojo | 908 } // namespace mojo |
OLD | NEW |