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

Side by Side Diff: ui/gfx/android/device_info.cc

Issue 11886074: Use correct favicon scale factor on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed and added JavaBitmap JNI registration to .h Created 7 years, 11 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/common/android/device_info.h" 5 #include "ui/gfx/android/device_info.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 "jni/DeviceInfo_jni.h" 10 #include "jni/DeviceInfo_jni.h"
11 11
12 using base::android::AttachCurrentThread; 12 using base::android::AttachCurrentThread;
13 using base::android::ConvertJavaStringToUTF8; 13 using base::android::ConvertJavaStringToUTF8;
14 using base::android::ScopedJavaLocalRef; 14 using base::android::ScopedJavaLocalRef;
15 15
16 namespace content { 16 namespace gfx {
17 17
18 DeviceInfo::DeviceInfo() { 18 DeviceInfo::DeviceInfo() {
19 JNIEnv* env = AttachCurrentThread(); 19 JNIEnv* env = AttachCurrentThread();
20 j_device_info_.Reset(Java_DeviceInfo_create(env, 20 j_device_info_.Reset(Java_DeviceInfo_create(env,
21 base::android::GetApplicationContext())); 21 base::android::GetApplicationContext()));
22 } 22 }
23 23
24 DeviceInfo::~DeviceInfo() { 24 DeviceInfo::~DeviceInfo() {
25 } 25 }
26 26
27 int DeviceInfo::GetHeight() { 27 int DeviceInfo::GetDisplayHeight() {
28 JNIEnv* env = AttachCurrentThread(); 28 JNIEnv* env = AttachCurrentThread();
29 jint result = 29 jint result =
30 Java_DeviceInfo_getHeight(env, j_device_info_.obj()); 30 Java_DeviceInfo_getDisplayHeight(env, j_device_info_.obj());
31 return static_cast<int>(result); 31 return static_cast<int>(result);
32 } 32 }
33 33
34 int DeviceInfo::GetWidth() { 34 int DeviceInfo::GetDisplayWidth() {
35 JNIEnv* env = AttachCurrentThread(); 35 JNIEnv* env = AttachCurrentThread();
36 jint result = 36 jint result =
37 Java_DeviceInfo_getWidth(env, j_device_info_.obj()); 37 Java_DeviceInfo_getDisplayWidth(env, j_device_info_.obj());
38 return static_cast<int>(result); 38 return static_cast<int>(result);
39 } 39 }
40 40
41 int DeviceInfo::GetBitsPerPixel() { 41 int DeviceInfo::GetBitsPerPixel() {
42 JNIEnv* env = AttachCurrentThread(); 42 JNIEnv* env = AttachCurrentThread();
43 jint result = 43 jint result =
44 Java_DeviceInfo_getBitsPerPixel(env, j_device_info_.obj()); 44 Java_DeviceInfo_getBitsPerPixel(env, j_device_info_.obj());
45 return static_cast<int>(result); 45 return static_cast<int>(result);
46 } 46 }
47 47
48 int DeviceInfo::GetBitsPerComponent() { 48 int DeviceInfo::GetBitsPerComponent() {
49 JNIEnv* env = AttachCurrentThread(); 49 JNIEnv* env = AttachCurrentThread();
50 jint result = 50 jint result =
51 Java_DeviceInfo_getBitsPerComponent(env, j_device_info_.obj()); 51 Java_DeviceInfo_getBitsPerComponent(env, j_device_info_.obj());
52 return static_cast<int>(result); 52 return static_cast<int>(result);
53 } 53 }
54 54
55 double DeviceInfo::GetDPIScale() { 55 double DeviceInfo::GetDIPScale() {
56 JNIEnv* env = AttachCurrentThread(); 56 JNIEnv* env = AttachCurrentThread();
57 jdouble result = 57 jdouble result =
58 Java_DeviceInfo_getDPIScale(env, j_device_info_.obj()); 58 Java_DeviceInfo_getDIPScale(env, j_device_info_.obj());
59 return static_cast<double>(result); 59 return static_cast<double>(result);
60 } 60 }
61 61
62 double DeviceInfo::GetRefreshRate() { 62 double DeviceInfo::GetRefreshRate() {
63 JNIEnv* env = AttachCurrentThread(); 63 JNIEnv* env = AttachCurrentThread();
64 jdouble result = 64 jdouble result =
65 Java_DeviceInfo_getRefreshRate(env, j_device_info_.obj()); 65 Java_DeviceInfo_getRefreshRate(env, j_device_info_.obj());
66 return static_cast<double>(result); 66 return static_cast<double>(result);
67 } 67 }
68 68
69 std::string DeviceInfo::GetNetworkCountryIso() { 69 std::string DeviceInfo::GetNetworkCountryIso() {
70 JNIEnv* env = AttachCurrentThread(); 70 JNIEnv* env = AttachCurrentThread();
71 ScopedJavaLocalRef<jstring> result = 71 ScopedJavaLocalRef<jstring> result =
72 Java_DeviceInfo_getNetworkCountryIso(env, j_device_info_.obj()); 72 Java_DeviceInfo_getNetworkCountryIso(env, j_device_info_.obj());
73 return ConvertJavaStringToUTF8(result); 73 return ConvertJavaStringToUTF8(result);
74 } 74 }
75 75
76 bool RegisterDeviceInfo(JNIEnv* env) { 76 // static
77 bool DeviceInfo::RegisterDeviceInfo(JNIEnv* env) {
77 return RegisterNativesImpl(env); 78 return RegisterNativesImpl(env);
78 } 79 }
79 80
80 } // namespace content 81 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698