OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_document.h" | 5 #include "components/html_viewer/html_document.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.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/devtools_service/public/cpp/switches.h" | 15 #include "components/devtools_service/public/cpp/switches.h" |
16 #include "components/html_viewer/blink_input_events_type_converters.h" | 16 #include "components/html_viewer/blink_input_events_type_converters.h" |
17 #include "components/html_viewer/blink_url_request_type_converters.h" | 17 #include "components/html_viewer/blink_url_request_type_converters.h" |
18 #include "components/html_viewer/devtools_agent_impl.h" | 18 #include "components/html_viewer/devtools_agent_impl.h" |
19 #include "components/html_viewer/geolocation_client_impl.h" | 19 #include "components/html_viewer/geolocation_client_impl.h" |
20 #include "components/html_viewer/global_state.h" | 20 #include "components/html_viewer/global_state.h" |
21 #include "components/html_viewer/media_factory.h" | 21 #include "components/html_viewer/media_factory.h" |
| 22 #include "components/html_viewer/stats_collection_controller.h" |
22 #include "components/html_viewer/web_layer_tree_view_impl.h" | 23 #include "components/html_viewer/web_layer_tree_view_impl.h" |
23 #include "components/html_viewer/web_storage_namespace_impl.h" | 24 #include "components/html_viewer/web_storage_namespace_impl.h" |
24 #include "components/html_viewer/web_url_loader_impl.h" | 25 #include "components/html_viewer/web_url_loader_impl.h" |
25 #include "components/view_manager/public/cpp/view.h" | 26 #include "components/view_manager/public/cpp/view.h" |
26 #include "components/view_manager/public/cpp/view_manager.h" | 27 #include "components/view_manager/public/cpp/view_manager.h" |
27 #include "components/view_manager/public/cpp/view_property.h" | 28 #include "components/view_manager/public/cpp/view_property.h" |
28 #include "components/view_manager/public/interfaces/surfaces.mojom.h" | 29 #include "components/view_manager/public/interfaces/surfaces.mojom.h" |
29 #include "mojo/application/public/cpp/application_impl.h" | 30 #include "mojo/application/public/cpp/application_impl.h" |
30 #include "mojo/application/public/cpp/connect.h" | 31 #include "mojo/application/public/cpp/connect.h" |
31 #include "mojo/application/public/interfaces/shell.mojom.h" | 32 #include "mojo/application/public/interfaces/shell.mojom.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 241 |
241 // TODO(yzshen): http://crbug.com/498986 Creating DevToolsAgentImpl instances | 242 // TODO(yzshen): http://crbug.com/498986 Creating DevToolsAgentImpl instances |
242 // causes html_viewer_apptests flakiness currently. Before we fix that we | 243 // causes html_viewer_apptests flakiness currently. Before we fix that we |
243 // cannot enable remote debugging (which is required by Telemetry tests) on | 244 // cannot enable remote debugging (which is required by Telemetry tests) on |
244 // the bots. | 245 // the bots. |
245 if (EnableRemoteDebugging()) { | 246 if (EnableRemoteDebugging()) { |
246 devtools_agent_.reset( | 247 devtools_agent_.reset( |
247 new DevToolsAgentImpl(main_frame, html_document_app_->shell())); | 248 new DevToolsAgentImpl(main_frame, html_document_app_->shell())); |
248 } | 249 } |
249 | 250 |
| 251 startup_performance_data_collector_ = |
| 252 StatsCollectionController::Install(main_frame, html_document_app_); |
| 253 |
250 GURL url(response->url); | 254 GURL url(response->url); |
251 | 255 |
252 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; | 256 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; |
253 extra_data->synthetic_response = response.Pass(); | 257 extra_data->synthetic_response = response.Pass(); |
254 | 258 |
255 blink::WebURLRequest web_request; | 259 blink::WebURLRequest web_request; |
256 web_request.initialize(); | 260 web_request.initialize(); |
257 web_request.setURL(url); | 261 web_request.setURL(url); |
258 web_request.setExtraData(extra_data); | 262 web_request.setExtraData(extra_data); |
259 | 263 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 395 |
392 void HTMLDocument::didAddMessageToConsole( | 396 void HTMLDocument::didAddMessageToConsole( |
393 const blink::WebConsoleMessage& message, | 397 const blink::WebConsoleMessage& message, |
394 const blink::WebString& source_name, | 398 const blink::WebString& source_name, |
395 unsigned source_line, | 399 unsigned source_line, |
396 const blink::WebString& stack_trace) { | 400 const blink::WebString& stack_trace) { |
397 VLOG(1) << "[" << source_name.utf8() << "(" << source_line << ")] " | 401 VLOG(1) << "[" << source_name.utf8() << "(" << source_line << ")] " |
398 << message.text.utf8(); | 402 << message.text.utf8(); |
399 } | 403 } |
400 | 404 |
| 405 void HTMLDocument::didHandleOnloadEvents(blink::WebLocalFrame* frame) { |
| 406 static bool recorded = false; |
| 407 if (!recorded && startup_performance_data_collector_) { |
| 408 startup_performance_data_collector_->SetFirstWebContentsMainFrameLoadTime( |
| 409 base::Time::Now().ToInternalValue()); |
| 410 recorded = true; |
| 411 } |
| 412 } |
| 413 |
401 void HTMLDocument::didFinishLoad(blink::WebLocalFrame* frame) { | 414 void HTMLDocument::didFinishLoad(blink::WebLocalFrame* frame) { |
402 // TODO(msw): Notify AxProvider clients of updates on child frame loads. | 415 // TODO(msw): Notify AxProvider clients of updates on child frame loads. |
403 did_finish_load_ = true; | 416 did_finish_load_ = true; |
404 // Bind any pending AxProviderImpl interface requests. | 417 // Bind any pending AxProviderImpl interface requests. |
405 for (auto it : ax_provider_requests_) | 418 for (auto it : ax_provider_requests_) |
406 ax_providers_.insert(new AxProviderImpl(web_view_, it->Pass())); | 419 ax_providers_.insert(new AxProviderImpl(web_view_, it->Pass())); |
407 STLDeleteElements(&ax_provider_requests_); | 420 STLDeleteElements(&ax_provider_requests_); |
408 } | 421 } |
409 | 422 |
410 void HTMLDocument::didNavigateWithinPage( | 423 void HTMLDocument::didNavigateWithinPage( |
411 blink::WebLocalFrame* frame, | 424 blink::WebLocalFrame* frame, |
412 const blink::WebHistoryItem& history_item, | 425 const blink::WebHistoryItem& history_item, |
413 blink::WebHistoryCommitType commit_type) { | 426 blink::WebHistoryCommitType commit_type) { |
414 if (navigator_host_.get()) | 427 if (navigator_host_.get()) |
415 navigator_host_->DidNavigateLocally(history_item.urlString().utf8()); | 428 navigator_host_->DidNavigateLocally(history_item.urlString().utf8()); |
416 } | 429 } |
417 | 430 |
| 431 void HTMLDocument::didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame) { |
| 432 static bool recorded = false; |
| 433 if (!recorded && startup_performance_data_collector_) { |
| 434 startup_performance_data_collector_->SetFirstVisuallyNonEmptyLayoutTime( |
| 435 base::Time::Now().ToInternalValue()); |
| 436 recorded = true; |
| 437 } |
| 438 } |
| 439 |
418 blink::WebEncryptedMediaClient* HTMLDocument::encryptedMediaClient() { | 440 blink::WebEncryptedMediaClient* HTMLDocument::encryptedMediaClient() { |
419 return global_state_->media_factory()->GetEncryptedMediaClient(); | 441 return global_state_->media_factory()->GetEncryptedMediaClient(); |
420 } | 442 } |
421 | 443 |
422 void HTMLDocument::OnViewBoundsChanged(View* view, | 444 void HTMLDocument::OnViewBoundsChanged(View* view, |
423 const Rect& old_bounds, | 445 const Rect& old_bounds, |
424 const Rect& new_bounds) { | 446 const Rect& new_bounds) { |
425 DCHECK_EQ(view, root_); | 447 DCHECK_EQ(view, root_); |
426 UpdateWebviewSizeFromViewSize(); | 448 UpdateWebviewSizeFromViewSize(); |
427 } | 449 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 490 |
469 void HTMLDocument::UpdateFocus() { | 491 void HTMLDocument::UpdateFocus() { |
470 if (!web_view_) | 492 if (!web_view_) |
471 return; | 493 return; |
472 bool is_focused = root_ && root_->HasFocus(); | 494 bool is_focused = root_ && root_->HasFocus(); |
473 web_view_->setFocus(is_focused); | 495 web_view_->setFocus(is_focused); |
474 web_view_->setIsActive(is_focused); | 496 web_view_->setIsActive(is_focused); |
475 } | 497 } |
476 | 498 |
477 } // namespace html_viewer | 499 } // namespace html_viewer |
OLD | NEW |