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/android/content_settings.h" | 5 #include "content/browser/android/content_settings.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 "content/browser/android/content_view_core_impl.h" | 9 #include "content/browser/android/content_view_core_impl.h" |
10 #include "content/browser/renderer_host/render_view_host_delegate.h" | 10 #include "content/browser/renderer_host/render_view_host_delegate.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 GetFieldID(env, clazz, "mMinimumLogicalFontSize", "I"); | 61 GetFieldID(env, clazz, "mMinimumLogicalFontSize", "I"); |
62 default_font_size = GetFieldID(env, clazz, "mDefaultFontSize", "I"); | 62 default_font_size = GetFieldID(env, clazz, "mDefaultFontSize", "I"); |
63 default_fixed_font_size = | 63 default_fixed_font_size = |
64 GetFieldID(env, clazz, "mDefaultFixedFontSize", "I"); | 64 GetFieldID(env, clazz, "mDefaultFixedFontSize", "I"); |
65 load_images_automatically = | 65 load_images_automatically = |
66 GetFieldID(env, clazz, "mLoadsImagesAutomatically", "Z"); | 66 GetFieldID(env, clazz, "mLoadsImagesAutomatically", "Z"); |
67 java_script_enabled = | 67 java_script_enabled = |
68 GetFieldID(env, clazz, "mJavaScriptEnabled", "Z"); | 68 GetFieldID(env, clazz, "mJavaScriptEnabled", "Z"); |
69 java_script_can_open_windows_automatically = | 69 java_script_can_open_windows_automatically = |
70 GetFieldID(env, clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z"); | 70 GetFieldID(env, clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z"); |
| 71 dom_storage_enabled = |
| 72 GetFieldID(env, clazz, "mDomStorageEnabled", "Z"); |
71 } | 73 } |
72 | 74 |
73 // Field ids | 75 // Field ids |
74 jfieldID standard_fond_family; | 76 jfieldID standard_fond_family; |
75 jfieldID fixed_font_family; | 77 jfieldID fixed_font_family; |
76 jfieldID sans_serif_font_family; | 78 jfieldID sans_serif_font_family; |
77 jfieldID serif_font_family; | 79 jfieldID serif_font_family; |
78 jfieldID cursive_font_family; | 80 jfieldID cursive_font_family; |
79 jfieldID fantasy_font_family; | 81 jfieldID fantasy_font_family; |
80 jfieldID default_text_encoding; | 82 jfieldID default_text_encoding; |
81 jfieldID user_agent; | 83 jfieldID user_agent; |
82 jfieldID minimum_font_size; | 84 jfieldID minimum_font_size; |
83 jfieldID minimum_logical_font_size; | 85 jfieldID minimum_logical_font_size; |
84 jfieldID default_font_size; | 86 jfieldID default_font_size; |
85 jfieldID default_fixed_font_size; | 87 jfieldID default_fixed_font_size; |
86 jfieldID load_images_automatically; | 88 jfieldID load_images_automatically; |
87 jfieldID java_script_enabled; | 89 jfieldID java_script_enabled; |
88 jfieldID java_script_can_open_windows_automatically; | 90 jfieldID java_script_can_open_windows_automatically; |
| 91 jfieldID dom_storage_enabled; |
89 }; | 92 }; |
90 | 93 |
91 ContentSettings::ContentSettings(JNIEnv* env, | 94 ContentSettings::ContentSettings(JNIEnv* env, |
92 jobject obj, | 95 jobject obj, |
93 WebContents* contents, | 96 WebContents* contents, |
94 bool is_master_mode) | 97 bool is_master_mode) |
95 : WebContentsObserver(contents), | 98 : WebContentsObserver(contents), |
96 is_master_mode_(is_master_mode) { | 99 is_master_mode_(is_master_mode) { |
97 content_settings_.Reset(env, obj); | 100 content_settings_.Reset(env, obj); |
98 } | 101 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 CheckException(env); | 188 CheckException(env); |
186 | 189 |
187 env->SetBooleanField( | 190 env->SetBooleanField( |
188 obj, | 191 obj, |
189 field_ids_->java_script_can_open_windows_automatically, | 192 field_ids_->java_script_can_open_windows_automatically, |
190 prefs.javascript_can_open_windows_automatically); | 193 prefs.javascript_can_open_windows_automatically); |
191 CheckException(env); | 194 CheckException(env); |
192 | 195 |
193 Java_ContentSettings_setPluginsDisabled(env, obj, !prefs.plugins_enabled); | 196 Java_ContentSettings_setPluginsDisabled(env, obj, !prefs.plugins_enabled); |
194 CheckException(env); | 197 CheckException(env); |
| 198 |
| 199 env->SetBooleanField( |
| 200 obj, |
| 201 field_ids_->dom_storage_enabled, |
| 202 prefs.local_storage_enabled); |
| 203 CheckException(env); |
195 } | 204 } |
196 | 205 |
197 void ContentSettings::SyncToNativeImpl() { | 206 void ContentSettings::SyncToNativeImpl() { |
198 JNIEnv* env = base::android::AttachCurrentThread(); | 207 JNIEnv* env = base::android::AttachCurrentThread(); |
199 CHECK(env); | 208 CHECK(env); |
200 if (!field_ids_.get()) | 209 if (!field_ids_.get()) |
201 field_ids_.reset(new FieldIds(env)); | 210 field_ids_.reset(new FieldIds(env)); |
202 | 211 |
203 jobject obj = content_settings_.obj(); | 212 jobject obj = content_settings_.obj(); |
204 RenderViewHost* render_view_host = web_contents()->GetRenderViewHost(); | 213 RenderViewHost* render_view_host = web_contents()->GetRenderViewHost(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 env->GetBooleanField(obj, field_ids_->load_images_automatically); | 270 env->GetBooleanField(obj, field_ids_->load_images_automatically); |
262 | 271 |
263 prefs.javascript_enabled = | 272 prefs.javascript_enabled = |
264 env->GetBooleanField(obj, field_ids_->java_script_enabled); | 273 env->GetBooleanField(obj, field_ids_->java_script_enabled); |
265 | 274 |
266 prefs.javascript_can_open_windows_automatically = env->GetBooleanField( | 275 prefs.javascript_can_open_windows_automatically = env->GetBooleanField( |
267 obj, field_ids_->java_script_can_open_windows_automatically); | 276 obj, field_ids_->java_script_can_open_windows_automatically); |
268 | 277 |
269 prefs.plugins_enabled = !Java_ContentSettings_getPluginsDisabled(env, obj); | 278 prefs.plugins_enabled = !Java_ContentSettings_getPluginsDisabled(env, obj); |
270 | 279 |
| 280 prefs.local_storage_enabled = env->GetBooleanField( |
| 281 obj, field_ids_->dom_storage_enabled); |
| 282 |
271 render_view_host->UpdateWebkitPreferences(prefs); | 283 render_view_host->UpdateWebkitPreferences(prefs); |
272 } | 284 } |
273 | 285 |
274 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { | 286 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { |
275 SyncFromNativeImpl(); | 287 SyncFromNativeImpl(); |
276 } | 288 } |
277 | 289 |
278 void ContentSettings::SyncToNative(JNIEnv* env, jobject obj) { | 290 void ContentSettings::SyncToNative(JNIEnv* env, jobject obj) { |
279 SyncToNativeImpl(); | 291 SyncToNativeImpl(); |
280 } | 292 } |
(...skipping 13 matching lines...) Expand all Loading... |
294 return reinterpret_cast<jint>(content_settings); | 306 return reinterpret_cast<jint>(content_settings); |
295 } | 307 } |
296 | 308 |
297 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 309 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
298 // "Version/4.0" had been hardcoded in the legacy WebView. | 310 // "Version/4.0" had been hardcoded in the legacy WebView. |
299 std::string ua = webkit_glue::BuildUserAgentFromProduct("Version/4.0"); | 311 std::string ua = webkit_glue::BuildUserAgentFromProduct("Version/4.0"); |
300 return base::android::ConvertUTF8ToJavaString(env, ua).Release(); | 312 return base::android::ConvertUTF8ToJavaString(env, ua).Release(); |
301 } | 313 } |
302 | 314 |
303 } // namespace content | 315 } // namespace content |
OLD | NEW |