| 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 return GetProcess()->HasConnection() && GetWidget()->renderer_initialized(); | 401 return GetProcess()->HasConnection() && GetWidget()->renderer_initialized(); |
| 400 } | 402 } |
| 401 | 403 |
| 402 void RenderViewHostImpl::SyncRendererPrefs() { | 404 void RenderViewHostImpl::SyncRendererPrefs() { |
| 403 RendererPreferences renderer_preferences = | 405 RendererPreferences renderer_preferences = |
| 404 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); | 406 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); |
| 405 GetPlatformSpecificPrefs(&renderer_preferences); | 407 GetPlatformSpecificPrefs(&renderer_preferences); |
| 406 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), renderer_preferences)); | 408 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), renderer_preferences)); |
| 407 } | 409 } |
| 408 | 410 |
| 411 namespace { |
| 412 |
| 413 void SetFloatParameterFromMap( |
| 414 const std::map<std::string, std::string>& settings, |
| 415 const std::string& setting_name, |
| 416 float* value) { |
| 417 const auto& find_it = settings.find(setting_name); |
| 418 if (find_it == settings.end()) |
| 419 return; |
| 420 double parsed_value; |
| 421 if (!base::StringToDouble(find_it->second, &parsed_value)) |
| 422 return; |
| 423 *value = parsed_value; |
| 424 } |
| 425 |
| 426 } // namespace |
| 427 |
| 409 WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() { | 428 WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() { |
| 410 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); | 429 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); |
| 411 WebPreferences prefs; | 430 WebPreferences prefs; |
| 412 | 431 |
| 413 const base::CommandLine& command_line = | 432 const base::CommandLine& command_line = |
| 414 *base::CommandLine::ForCurrentProcess(); | 433 *base::CommandLine::ForCurrentProcess(); |
| 415 | 434 |
| 416 prefs.web_security_enabled = | 435 prefs.web_security_enabled = |
| 417 !command_line.HasSwitch(switches::kDisableWebSecurity); | 436 !command_line.HasSwitch(switches::kDisableWebSecurity); |
| 418 | 437 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 plugin_mixed_content_status == "BlockableMixedContent"; | 577 plugin_mixed_content_status == "BlockableMixedContent"; |
| 559 | 578 |
| 560 prefs.v8_cache_options = GetV8CacheOptions(); | 579 prefs.v8_cache_options = GetV8CacheOptions(); |
| 561 | 580 |
| 562 prefs.user_gesture_required_for_presentation = !command_line.HasSwitch( | 581 prefs.user_gesture_required_for_presentation = !command_line.HasSwitch( |
| 563 switches::kDisableGestureRequirementForPresentation); | 582 switches::kDisableGestureRequirementForPresentation); |
| 564 | 583 |
| 565 if (delegate_ && delegate_->HideDownloadUI()) | 584 if (delegate_ && delegate_->HideDownloadUI()) |
| 566 prefs.hide_download_ui = true; | 585 prefs.hide_download_ui = true; |
| 567 | 586 |
| 587 std::map<std::string, std::string> expensive_background_throttling_prefs; |
| 588 variations::GetVariationParamsByFeature( |
| 589 features::kExpensiveBackgroundTimerThrottling, |
| 590 &expensive_background_throttling_prefs); |
| 591 SetFloatParameterFromMap(expensive_background_throttling_prefs, "cpu_budget", |
| 592 &prefs.expensive_background_throttling_cpu_budget); |
| 593 SetFloatParameterFromMap( |
| 594 expensive_background_throttling_prefs, "initial_budget", |
| 595 &prefs.expensive_background_throttling_initial_budget); |
| 596 SetFloatParameterFromMap(expensive_background_throttling_prefs, "max_budget", |
| 597 &prefs.expensive_background_throttling_max_budget); |
| 598 SetFloatParameterFromMap(expensive_background_throttling_prefs, "max_delay", |
| 599 &prefs.expensive_background_throttling_max_delay); |
| 600 |
| 568 GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs); | 601 GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs); |
| 569 return prefs; | 602 return prefs; |
| 570 } | 603 } |
| 571 | 604 |
| 572 void RenderViewHostImpl::ClosePage() { | 605 void RenderViewHostImpl::ClosePage() { |
| 573 is_waiting_for_close_ack_ = true; | 606 is_waiting_for_close_ack_ = true; |
| 574 GetWidget()->StartHangMonitorTimeout( | 607 GetWidget()->StartHangMonitorTimeout( |
| 575 TimeDelta::FromMilliseconds(kUnloadTimeoutMS), | 608 TimeDelta::FromMilliseconds(kUnloadTimeoutMS), |
| 576 blink::WebInputEvent::Undefined, | 609 blink::WebInputEvent::Undefined, |
| 577 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_CLOSE_PAGE); | 610 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_CLOSE_PAGE); |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 // Note: We are using the origin URL provided by the sender here. It may be | 1290 // Note: We are using the origin URL provided by the sender here. It may be |
| 1258 // different from the receiver's. | 1291 // different from the receiver's. |
| 1259 file_system_file.url = | 1292 file_system_file.url = |
| 1260 GURL(storage::GetIsolatedFileSystemRootURIString( | 1293 GURL(storage::GetIsolatedFileSystemRootURIString( |
| 1261 file_system_url.origin(), filesystem_id, std::string()) | 1294 file_system_url.origin(), filesystem_id, std::string()) |
| 1262 .append(register_name)); | 1295 .append(register_name)); |
| 1263 } | 1296 } |
| 1264 } | 1297 } |
| 1265 | 1298 |
| 1266 } // namespace content | 1299 } // namespace content |
| OLD | NEW |