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

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

Issue 2122023002: Cross-process frames should be notified of device scale factor changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Version of patch without second test. Created 4 years, 4 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
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_view_android.h" 5 #include "content/browser/web_contents/web_contents_view_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/android/content_view_core_impl.h" 10 #include "content/browser/android/content_view_core_impl.h"
11 #include "content/browser/frame_host/interstitial_page_impl.h" 11 #include "content/browser/frame_host/interstitial_page_impl.h"
12 #include "content/browser/renderer_host/render_widget_host_view_android.h" 12 #include "content/browser/renderer_host/render_widget_host_view_android.h"
13 #include "content/browser/renderer_host/render_view_host_factory.h" 13 #include "content/browser/renderer_host/render_view_host_factory.h"
14 #include "content/browser/renderer_host/render_view_host_impl.h" 14 #include "content/browser/renderer_host/render_view_host_impl.h"
15 #include "content/browser/web_contents/web_contents_impl.h" 15 #include "content/browser/web_contents/web_contents_impl.h"
16 #include "content/public/browser/render_widget_host.h" 16 #include "content/public/browser/render_widget_host.h"
17 #include "content/public/browser/web_contents_delegate.h" 17 #include "content/public/browser/web_contents_delegate.h"
18 #include "content/public/common/drop_data.h" 18 #include "content/public/common/drop_data.h"
19 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
20 #include "ui/display/screen.h"
21 #include "ui/gfx/android/device_display_info.h"
19 #include "ui/gfx/android/java_bitmap.h" 22 #include "ui/gfx/android/java_bitmap.h"
20 #include "ui/gfx/image/image_skia.h" 23 #include "ui/gfx/image/image_skia.h"
21 24
22 using base::android::AttachCurrentThread; 25 using base::android::AttachCurrentThread;
23 using base::android::ConvertUTF16ToJavaString; 26 using base::android::ConvertUTF16ToJavaString;
24 using base::android::JavaRef; 27 using base::android::JavaRef;
25 using base::android::ScopedJavaLocalRef; 28 using base::android::ScopedJavaLocalRef;
26 29
27 namespace content { 30 namespace content {
28 31
32 // static
33 void WebContentsView::GetDefaultScreenInfo(
34 blink::WebScreenInfo* results) {
35 const display::Display& display =
36 display::Screen::GetScreen()->GetPrimaryDisplay();
37 results->rect = display.bounds();
38 // TODO(husky): Remove any system controls from availableRect.
39 results->availableRect = display.work_area();
40 results->deviceScaleFactor = display.device_scale_factor();
41 results->orientationAngle = display.RotationAsDegree();
42 results->orientationType =
43 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
44 gfx::DeviceDisplayInfo info;
45 results->depth = display.color_depth();
46 results->depthPerComponent = display.depth_per_component();
47 results->isMonochrome = (results->depthPerComponent == 0);
48 }
49
29 WebContentsView* CreateWebContentsView( 50 WebContentsView* CreateWebContentsView(
30 WebContentsImpl* web_contents, 51 WebContentsImpl* web_contents,
31 WebContentsViewDelegate* delegate, 52 WebContentsViewDelegate* delegate,
32 RenderViewHostDelegateView** render_view_host_delegate_view) { 53 RenderViewHostDelegateView** render_view_host_delegate_view) {
33 WebContentsViewAndroid* rv = new WebContentsViewAndroid( 54 WebContentsViewAndroid* rv = new WebContentsViewAndroid(
34 web_contents, delegate); 55 web_contents, delegate);
35 *render_view_host_delegate_view = rv; 56 *render_view_host_delegate_view = rv;
36 return rv; 57 return rv;
37 } 58 }
38 59
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return rwhv->GetNativeView(); 98 return rwhv->GetNativeView();
78 99
79 // TODO(sievers): This should return null. 100 // TODO(sievers): This should return null.
80 return GetNativeView(); 101 return GetNativeView();
81 } 102 }
82 103
83 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { 104 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const {
84 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; 105 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr;
85 } 106 }
86 107
108 void WebContentsViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) const {
109 // ScreenInfo isn't tied to the widget on Android. Always return the default.
110 WebContentsView::GetDefaultScreenInfo(result);
111 }
112
87 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { 113 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const {
88 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize()) 114 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize())
89 : gfx::Rect(); 115 : gfx::Rect();
90 } 116 }
91 117
92 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) { 118 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) {
93 if (content_view_core_) 119 if (content_view_core_)
94 content_view_core_->SetTitle(title); 120 content_view_core_->SetTitle(title);
95 } 121 }
96 122
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // This is called when we the renderer asks us to take focus back (i.e., it has 300 // This is called when we the renderer asks us to take focus back (i.e., it has
275 // iterated past the last focusable element on the page). 301 // iterated past the last focusable element on the page).
276 void WebContentsViewAndroid::TakeFocus(bool reverse) { 302 void WebContentsViewAndroid::TakeFocus(bool reverse) {
277 if (web_contents_->GetDelegate() && 303 if (web_contents_->GetDelegate() &&
278 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) 304 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse))
279 return; 305 return;
280 web_contents_->GetRenderWidgetHostView()->Focus(); 306 web_contents_->GetRenderWidgetHostView()->Focus();
281 } 307 }
282 308
283 } // namespace content 309 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_android.h ('k') | content/browser/web_contents/web_contents_view_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698