Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 10255020: Get the default device scale factor from monitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated comment Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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"
71 #elif defined(OS_WIN) 73 #elif defined(OS_WIN)
72 #include "content/browser/web_contents/web_contents_view_win.h" 74 #include "content/browser/web_contents/web_contents_view_win.h"
73 #elif defined(TOOLKIT_GTK) 75 #elif defined(TOOLKIT_GTK)
74 #include "content/browser/web_contents/web_contents_view_gtk.h" 76 #include "content/browser/web_contents/web_contents_view_gtk.h"
75 #elif defined(OS_MACOSX) 77 #elif defined(OS_MACOSX)
76 #include "content/browser/web_contents/web_contents_view_mac.h" 78 #include "content/browser/web_contents/web_contents_view_mac.h"
79 #include "ui/base/ui_base_switches.h"
77 #include "ui/gfx/surface/io_surface_support_mac.h" 80 #include "ui/gfx/surface/io_surface_support_mac.h"
78 #elif defined(OS_ANDROID) 81 #elif defined(OS_ANDROID)
79 #include "content/browser/web_contents/web_contents_view_android.h" 82 #include "content/browser/web_contents/web_contents_view_android.h"
80 #endif 83 #endif
81 84
82 // Cross-Site Navigations 85 // Cross-Site Navigations
83 // 86 //
84 // If a WebContentsImpl is told to navigate to a different web site (as 87 // If a WebContentsImpl is told to navigate to a different web site (as
85 // determined by SiteInstance), it will replace its current RenderViewHost with 88 // determined by SiteInstance), it will replace its current RenderViewHost with
86 // a new RenderViewHost dedicated to the new SiteInstance. This works as 89 // a new RenderViewHost dedicated to the new SiteInstance. This works as
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 // Force accelerated compositing and 2d canvas off for chrome:, about: and 500 // Force accelerated compositing and 2d canvas off for chrome:, about: and
498 // chrome-devtools: pages (unless it's specifically allowed). 501 // chrome-devtools: pages (unless it's specifically allowed).
499 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) || 502 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) ||
500 url.SchemeIs(chrome::kChromeUIScheme) || 503 url.SchemeIs(chrome::kChromeUIScheme) ||
501 (url.SchemeIs(chrome::kAboutScheme) && 504 (url.SchemeIs(chrome::kAboutScheme) &&
502 url.spec() != chrome::kAboutBlankURL)) && 505 url.spec() != chrome::kAboutBlankURL)) &&
503 !command_line.HasSwitch(switches::kAllowWebUICompositing)) { 506 !command_line.HasSwitch(switches::kAllowWebUICompositing)) {
504 prefs.accelerated_compositing_enabled = false; 507 prefs.accelerated_compositing_enabled = false;
505 prefs.accelerated_2d_canvas_enabled = false; 508 prefs.accelerated_2d_canvas_enabled = false;
506 } 509 }
507 510 #if defined(OS_MACOSX)
511 // Mac doesn't have gfx::Screen::GetMonitorNearestWindow impl.
512 // crbug.com/125690.
508 int default_device_scale_factor; 513 int default_device_scale_factor;
509 base::StringToInt(command_line.GetSwitchValueASCII( 514 base::StringToInt(command_line.GetSwitchValueASCII(
510 switches::kDefaultDeviceScaleFactor), 515 switches::kDefaultDeviceScaleFactor),
511 &default_device_scale_factor); 516 &default_device_scale_factor);
512
513 prefs.default_device_scale_factor = default_device_scale_factor; 517 prefs.default_device_scale_factor = default_device_scale_factor;
518 #else
519 if (rvh->GetView()) {
520 gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow(
521 rvh->GetView()->GetNativeView());
522 prefs.default_device_scale_factor =
523 static_cast<int>(monitor.device_scale_factor());
524 } else {
525 prefs.default_device_scale_factor = 1;
526 }
527 #endif
514 528
515 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); 529 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs);
516 530
517 return prefs; 531 return prefs;
518 } 532 }
519 533
520 NavigationControllerImpl& WebContentsImpl::GetControllerImpl() { 534 NavigationControllerImpl& WebContentsImpl::GetControllerImpl() {
521 return controller_; 535 return controller_;
522 } 536 }
523 537
(...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2640 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2627 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); 2641 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh);
2628 // Can be NULL during tests. 2642 // Can be NULL during tests.
2629 if (rwh_view) 2643 if (rwh_view)
2630 rwh_view->SetSize(GetView()->GetContainerSize()); 2644 rwh_view->SetSize(GetView()->GetContainerSize());
2631 } 2645 }
2632 2646
2633 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { 2647 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() {
2634 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); 2648 return static_cast<RenderViewHostImpl*>(GetRenderViewHost());
2635 } 2649 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698