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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 entry.transferred_global_request_id().child_id; | 213 entry.transferred_global_request_id().child_id; |
214 params->transferred_request_request_id = | 214 params->transferred_request_request_id = |
215 entry.transferred_global_request_id().request_id; | 215 entry.transferred_global_request_id().request_id; |
216 // Avoid downloading when in view-source mode. | 216 // Avoid downloading when in view-source mode. |
217 params->allow_download = !entry.IsViewSourceMode(); | 217 params->allow_download = !entry.IsViewSourceMode(); |
218 | 218 |
219 if (delegate) | 219 if (delegate) |
220 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); | 220 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); |
221 } | 221 } |
222 | 222 |
| 223 int GetSwitchValueAsInt( |
| 224 const CommandLine& command_line, |
| 225 const std::string& switch_string, |
| 226 int min_value) { |
| 227 std::string string_value = command_line.GetSwitchValueASCII(switch_string); |
| 228 int int_value; |
| 229 if (base::StringToInt(string_value, &int_value)) |
| 230 return std::max(min_value, int_value); |
| 231 else |
| 232 return min_value; |
| 233 } |
| 234 |
223 } // namespace | 235 } // namespace |
224 | 236 |
225 namespace content { | 237 namespace content { |
226 | 238 |
227 WebContents* WebContents::Create( | 239 WebContents* WebContents::Create( |
228 BrowserContext* browser_context, | 240 BrowserContext* browser_context, |
229 SiteInstance* site_instance, | 241 SiteInstance* site_instance, |
230 int routing_id, | 242 int routing_id, |
231 const WebContents* base_web_contents, | 243 const WebContents* base_web_contents, |
232 SessionStorageNamespace* session_storage_namespace) { | 244 SessionStorageNamespace* session_storage_namespace) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow( | 520 gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow( |
509 rvh->GetView()->GetNativeView()); | 521 rvh->GetView()->GetNativeView()); |
510 prefs.default_device_scale_factor = | 522 prefs.default_device_scale_factor = |
511 static_cast<int>(monitor.device_scale_factor()); | 523 static_cast<int>(monitor.device_scale_factor()); |
512 } else { | 524 } else { |
513 prefs.default_device_scale_factor = | 525 prefs.default_device_scale_factor = |
514 gfx::Monitor::GetDefaultDeviceScaleFactor();; | 526 gfx::Monitor::GetDefaultDeviceScaleFactor();; |
515 } | 527 } |
516 #endif | 528 #endif |
517 | 529 |
| 530 if (command_line.HasSwitch(switches::kDefaultTileWidth)) |
| 531 prefs.default_tile_width = |
| 532 GetSwitchValueAsInt(command_line, switches::kDefaultTileWidth, 1); |
| 533 if (command_line.HasSwitch(switches::kDefaultTileHeight)) |
| 534 prefs.default_tile_height = |
| 535 GetSwitchValueAsInt(command_line, switches::kDefaultTileHeight, 1); |
| 536 if (command_line.HasSwitch(switches::kMaxUntiledLayerWidth)) |
| 537 prefs.max_untiled_layer_width = |
| 538 GetSwitchValueAsInt(command_line, switches::kMaxUntiledLayerWidth, 1); |
| 539 if (command_line.HasSwitch(switches::kMaxUntiledLayerHeight)) |
| 540 prefs.max_untiled_layer_height = |
| 541 GetSwitchValueAsInt(command_line, switches::kMaxUntiledLayerHeight, 1); |
| 542 |
518 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); | 543 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); |
519 | 544 |
520 return prefs; | 545 return prefs; |
521 } | 546 } |
522 | 547 |
523 NavigationControllerImpl& WebContentsImpl::GetControllerImpl() { | 548 NavigationControllerImpl& WebContentsImpl::GetControllerImpl() { |
524 return controller_; | 549 return controller_; |
525 } | 550 } |
526 | 551 |
527 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 552 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
(...skipping 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2763 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2788 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2764 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2789 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2765 // Can be NULL during tests. | 2790 // Can be NULL during tests. |
2766 if (rwh_view) | 2791 if (rwh_view) |
2767 rwh_view->SetSize(GetView()->GetContainerSize()); | 2792 rwh_view->SetSize(GetView()->GetContainerSize()); |
2768 } | 2793 } |
2769 | 2794 |
2770 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 2795 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
2771 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 2796 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
2772 } | 2797 } |
OLD | NEW |