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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "content/public/browser/user_metrics.h" | 51 #include "content/public/browser/user_metrics.h" |
52 #include "content/public/browser/web_contents_delegate.h" | 52 #include "content/public/browser/web_contents_delegate.h" |
53 #include "content/public/browser/web_contents_observer.h" | 53 #include "content/public/browser/web_contents_observer.h" |
54 #include "content/public/browser/web_contents_view.h" | 54 #include "content/public/browser/web_contents_view.h" |
55 #include "content/public/browser/web_ui_controller_factory.h" | 55 #include "content/public/browser/web_ui_controller_factory.h" |
56 #include "content/public/common/bindings_policy.h" | 56 #include "content/public/common/bindings_policy.h" |
57 #include "content/public/common/content_constants.h" | 57 #include "content/public/common/content_constants.h" |
58 #include "content/public/common/content_restriction.h" | 58 #include "content/public/common/content_restriction.h" |
59 #include "content/public/common/content_switches.h" | 59 #include "content/public/common/content_switches.h" |
60 #include "content/public/common/url_constants.h" | 60 #include "content/public/common/url_constants.h" |
| 61 #include "ui/gfx/monitor.h" |
| 62 #include "ui/gfx/screen.h" |
61 #include "net/base/mime_util.h" | 63 #include "net/base/mime_util.h" |
62 #include "net/base/net_util.h" | 64 #include "net/base/net_util.h" |
63 #include "net/base/network_change_notifier.h" | 65 #include "net/base/network_change_notifier.h" |
64 #include "net/url_request/url_request_context_getter.h" | 66 #include "net/url_request/url_request_context_getter.h" |
65 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 67 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
66 #include "webkit/glue/web_intent_data.h" | 68 #include "webkit/glue/web_intent_data.h" |
67 #include "webkit/glue/webpreferences.h" | 69 #include "webkit/glue/webpreferences.h" |
68 | 70 |
69 #if defined(USE_AURA) | 71 #if defined(USE_AURA) |
70 #include "content/browser/web_contents/web_contents_view_aura.h" | 72 #include "content/browser/web_contents/web_contents_view_aura.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 // chrome-devtools: pages (unless it's specifically allowed). | 500 // chrome-devtools: pages (unless it's specifically allowed). |
499 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) || | 501 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) || |
500 url.SchemeIs(chrome::kChromeUIScheme) || | 502 url.SchemeIs(chrome::kChromeUIScheme) || |
501 (url.SchemeIs(chrome::kAboutScheme) && | 503 (url.SchemeIs(chrome::kAboutScheme) && |
502 url.spec() != chrome::kAboutBlankURL)) && | 504 url.spec() != chrome::kAboutBlankURL)) && |
503 !command_line.HasSwitch(switches::kAllowWebUICompositing)) { | 505 !command_line.HasSwitch(switches::kAllowWebUICompositing)) { |
504 prefs.accelerated_compositing_enabled = false; | 506 prefs.accelerated_compositing_enabled = false; |
505 prefs.accelerated_2d_canvas_enabled = false; | 507 prefs.accelerated_2d_canvas_enabled = false; |
506 } | 508 } |
507 | 509 |
508 int default_device_scale_factor; | 510 if (rvh->GetView()) { |
509 base::StringToInt(command_line.GetSwitchValueASCII( | 511 gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow( |
510 switches::kDefaultDeviceScaleFactor), | 512 rvh->GetView()->GetNativeView()); |
511 &default_device_scale_factor); | 513 prefs.default_device_scale_factor = |
512 | 514 static_cast<int>(monitor.device_scale_factor()); |
513 prefs.default_device_scale_factor = default_device_scale_factor; | 515 } else { |
| 516 prefs.default_device_scale_factor = 1; |
| 517 } |
514 | 518 |
515 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); | 519 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); |
516 | 520 |
517 return prefs; | 521 return prefs; |
518 } | 522 } |
519 | 523 |
520 NavigationControllerImpl& WebContentsImpl::GetControllerImpl() { | 524 NavigationControllerImpl& WebContentsImpl::GetControllerImpl() { |
521 return controller_; | 525 return controller_; |
522 } | 526 } |
523 | 527 |
(...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2630 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2627 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2631 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2628 // Can be NULL during tests. | 2632 // Can be NULL during tests. |
2629 if (rwh_view) | 2633 if (rwh_view) |
2630 rwh_view->SetSize(GetView()->GetContainerSize()); | 2634 rwh_view->SetSize(GetView()->GetContainerSize()); |
2631 } | 2635 } |
2632 | 2636 |
2633 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 2637 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
2634 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 2638 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
2635 } | 2639 } |
OLD | NEW |