Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/dump_without_crashing.h" | 14 #include "base/debug/dump_without_crashing.h" |
| 15 #include "base/feature_list.h" | 15 #include "base/feature_list.h" |
| 16 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
| 17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 20 #include "base/metrics/histogram_macros.h" | 20 #include "base/metrics/histogram_macros.h" |
| 21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 22 #include "base/strings/string_number_conversions.h" | |
| 22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/sys_info.h" | 25 #include "base/sys_info.h" |
| 25 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 26 #include "base/trace_event/trace_event.h" | 27 #include "base/trace_event/trace_event.h" |
| 27 #include "base/values.h" | 28 #include "base/values.h" |
| 28 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 29 #include "cc/base/switches.h" | 30 #include "cc/base/switches.h" |
| 31 #include "components/variations/variations_associated_data.h" | |
| 30 #include "content/browser/bad_message.h" | 32 #include "content/browser/bad_message.h" |
| 31 #include "content/browser/child_process_security_policy_impl.h" | 33 #include "content/browser/child_process_security_policy_impl.h" |
| 32 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 34 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 33 #include "content/browser/frame_host/frame_tree.h" | 35 #include "content/browser/frame_host/frame_tree.h" |
| 34 #include "content/browser/gpu/compositor_util.h" | 36 #include "content/browser/gpu/compositor_util.h" |
| 35 #include "content/browser/gpu/gpu_data_manager_impl.h" | 37 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 36 #include "content/browser/gpu/gpu_process_host.h" | 38 #include "content/browser/gpu/gpu_process_host.h" |
| 37 #include "content/browser/host_zoom_map_impl.h" | 39 #include "content/browser/host_zoom_map_impl.h" |
| 38 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 40 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 39 #include "content/browser/renderer_host/dip_util.h" | 41 #include "content/browser/renderer_host/dip_util.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 return GetProcess()->HasConnection() && GetWidget()->renderer_initialized(); | 408 return GetProcess()->HasConnection() && GetWidget()->renderer_initialized(); |
| 407 } | 409 } |
| 408 | 410 |
| 409 void RenderViewHostImpl::SyncRendererPrefs() { | 411 void RenderViewHostImpl::SyncRendererPrefs() { |
| 410 RendererPreferences renderer_preferences = | 412 RendererPreferences renderer_preferences = |
| 411 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); | 413 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); |
| 412 GetPlatformSpecificPrefs(&renderer_preferences); | 414 GetPlatformSpecificPrefs(&renderer_preferences); |
| 413 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), renderer_preferences)); | 415 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), renderer_preferences)); |
| 414 } | 416 } |
| 415 | 417 |
| 418 namespace { | |
| 419 | |
| 420 void MaybeSetFloatParameterFromMap( | |
|
ojan
2016/11/08 19:41:15
Drive-by pet-peeve nit: I don't feel like this "Ma
altimin
2016/11/09 14:46:29
Done.
| |
| 421 const std::map<std::string, std::string>& settings, | |
| 422 const std::string& setting_name, | |
| 423 float* value) { | |
| 424 const auto& find_it = settings.find(setting_name); | |
| 425 if (find_it == settings.end()) | |
| 426 return; | |
| 427 double parsed_value; | |
| 428 if (!base::StringToDouble(find_it->second, &parsed_value)) | |
| 429 return; | |
| 430 *value = parsed_value; | |
| 431 } | |
| 432 | |
| 433 } // namespace | |
| 434 | |
| 416 WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() { | 435 WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() { |
| 417 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); | 436 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); |
| 418 WebPreferences prefs; | 437 WebPreferences prefs; |
| 419 | 438 |
| 420 const base::CommandLine& command_line = | 439 const base::CommandLine& command_line = |
| 421 *base::CommandLine::ForCurrentProcess(); | 440 *base::CommandLine::ForCurrentProcess(); |
| 422 | 441 |
| 423 prefs.web_security_enabled = | 442 prefs.web_security_enabled = |
| 424 !command_line.HasSwitch(switches::kDisableWebSecurity); | 443 !command_line.HasSwitch(switches::kDisableWebSecurity); |
| 425 | 444 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 plugin_mixed_content_status == "BlockableMixedContent"; | 584 plugin_mixed_content_status == "BlockableMixedContent"; |
| 566 | 585 |
| 567 prefs.v8_cache_options = GetV8CacheOptions(); | 586 prefs.v8_cache_options = GetV8CacheOptions(); |
| 568 | 587 |
| 569 prefs.user_gesture_required_for_presentation = !command_line.HasSwitch( | 588 prefs.user_gesture_required_for_presentation = !command_line.HasSwitch( |
| 570 switches::kDisableGestureRequirementForPresentation); | 589 switches::kDisableGestureRequirementForPresentation); |
| 571 | 590 |
| 572 if (delegate_ && delegate_->HideDownloadUI()) | 591 if (delegate_ && delegate_->HideDownloadUI()) |
| 573 prefs.hide_download_ui = true; | 592 prefs.hide_download_ui = true; |
| 574 | 593 |
| 594 std::map<std::string, std::string> expensive_background_throttling_prefs; | |
| 595 variations::GetVariationParamsByFeature( | |
|
clamy
2016/11/09 14:28:51
We've tried to avoid using things from components
altimin
2016/11/09 14:46:29
I didn't find any other cases of plumbing paramete
clamy
2016/11/09 15:27:07
Acknowledged.
| |
| 596 features::kExpensiveBackgroundTimerThrottling, | |
| 597 &expensive_background_throttling_prefs); | |
| 598 MaybeSetFloatParameterFromMap( | |
| 599 expensive_background_throttling_prefs, "cpu_budget", | |
| 600 &prefs.expensive_background_throttling_cpu_budget); | |
| 601 MaybeSetFloatParameterFromMap( | |
| 602 expensive_background_throttling_prefs, "initial_budget", | |
| 603 &prefs.expensive_background_throttling_initial_budget); | |
| 604 MaybeSetFloatParameterFromMap( | |
| 605 expensive_background_throttling_prefs, "max_budget", | |
| 606 &prefs.expensive_background_throttling_max_budget); | |
| 607 MaybeSetFloatParameterFromMap( | |
| 608 expensive_background_throttling_prefs, "max_delay", | |
| 609 &prefs.expensive_background_throttling_max_delay); | |
| 610 | |
| 575 GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs); | 611 GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs); |
| 576 return prefs; | 612 return prefs; |
| 577 } | 613 } |
| 578 | 614 |
| 579 void RenderViewHostImpl::ClosePage() { | 615 void RenderViewHostImpl::ClosePage() { |
| 580 is_waiting_for_close_ack_ = true; | 616 is_waiting_for_close_ack_ = true; |
| 581 GetWidget()->StartHangMonitorTimeout( | 617 GetWidget()->StartHangMonitorTimeout( |
| 582 TimeDelta::FromMilliseconds(kUnloadTimeoutMS), | 618 TimeDelta::FromMilliseconds(kUnloadTimeoutMS), |
| 583 blink::WebInputEvent::Undefined, | 619 blink::WebInputEvent::Undefined, |
| 584 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_CLOSE_PAGE); | 620 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_CLOSE_PAGE); |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1322 // Note: We are using the origin URL provided by the sender here. It may be | 1358 // Note: We are using the origin URL provided by the sender here. It may be |
| 1323 // different from the receiver's. | 1359 // different from the receiver's. |
| 1324 file_system_file.url = | 1360 file_system_file.url = |
| 1325 GURL(storage::GetIsolatedFileSystemRootURIString( | 1361 GURL(storage::GetIsolatedFileSystemRootURIString( |
| 1326 file_system_url.origin(), filesystem_id, std::string()) | 1362 file_system_url.origin(), filesystem_id, std::string()) |
| 1327 .append(register_name)); | 1363 .append(register_name)); |
| 1328 } | 1364 } |
| 1329 } | 1365 } |
| 1330 | 1366 |
| 1331 } // namespace content | 1367 } // namespace content |
| OLD | NEW |