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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 minimum_font_size = GetFieldID(env, clazz, "mMinimumFontSize", "I"); | 59 minimum_font_size = GetFieldID(env, clazz, "mMinimumFontSize", "I"); |
60 minimum_logical_font_size = | 60 minimum_logical_font_size = |
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 allow_universal_access_from_file_urls = |
| 70 GetFieldID(env, clazz, "mAllowUniversalAccessFromFileURLs", "Z"); |
| 71 allow_file_access_from_file_urls = |
| 72 GetFieldID(env, clazz, "mAllowFileAccessFromFileURLs", "Z"); |
69 java_script_can_open_windows_automatically = | 73 java_script_can_open_windows_automatically = |
70 GetFieldID(env, clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z"); | 74 GetFieldID(env, clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z"); |
71 dom_storage_enabled = | 75 dom_storage_enabled = |
72 GetFieldID(env, clazz, "mDomStorageEnabled", "Z"); | 76 GetFieldID(env, clazz, "mDomStorageEnabled", "Z"); |
73 } | 77 } |
74 | 78 |
75 // Field ids | 79 // Field ids |
76 jfieldID standard_fond_family; | 80 jfieldID standard_fond_family; |
77 jfieldID fixed_font_family; | 81 jfieldID fixed_font_family; |
78 jfieldID sans_serif_font_family; | 82 jfieldID sans_serif_font_family; |
79 jfieldID serif_font_family; | 83 jfieldID serif_font_family; |
80 jfieldID cursive_font_family; | 84 jfieldID cursive_font_family; |
81 jfieldID fantasy_font_family; | 85 jfieldID fantasy_font_family; |
82 jfieldID default_text_encoding; | 86 jfieldID default_text_encoding; |
83 jfieldID user_agent; | 87 jfieldID user_agent; |
84 jfieldID minimum_font_size; | 88 jfieldID minimum_font_size; |
85 jfieldID minimum_logical_font_size; | 89 jfieldID minimum_logical_font_size; |
86 jfieldID default_font_size; | 90 jfieldID default_font_size; |
87 jfieldID default_fixed_font_size; | 91 jfieldID default_fixed_font_size; |
88 jfieldID load_images_automatically; | 92 jfieldID load_images_automatically; |
89 jfieldID java_script_enabled; | 93 jfieldID java_script_enabled; |
| 94 jfieldID allow_universal_access_from_file_urls; |
| 95 jfieldID allow_file_access_from_file_urls; |
90 jfieldID java_script_can_open_windows_automatically; | 96 jfieldID java_script_can_open_windows_automatically; |
91 jfieldID dom_storage_enabled; | 97 jfieldID dom_storage_enabled; |
92 }; | 98 }; |
93 | 99 |
94 ContentSettings::ContentSettings(JNIEnv* env, | 100 ContentSettings::ContentSettings(JNIEnv* env, |
95 jobject obj, | 101 jobject obj, |
96 WebContents* contents, | 102 WebContents* contents, |
97 bool is_master_mode) | 103 bool is_master_mode) |
98 : WebContentsObserver(contents), | 104 : WebContentsObserver(contents), |
99 is_master_mode_(is_master_mode) { | 105 is_master_mode_(is_master_mode) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 obj, | 188 obj, |
183 field_ids_->load_images_automatically, prefs.loads_images_automatically); | 189 field_ids_->load_images_automatically, prefs.loads_images_automatically); |
184 CheckException(env); | 190 CheckException(env); |
185 | 191 |
186 env->SetBooleanField( | 192 env->SetBooleanField( |
187 obj, field_ids_->java_script_enabled, prefs.javascript_enabled); | 193 obj, field_ids_->java_script_enabled, prefs.javascript_enabled); |
188 CheckException(env); | 194 CheckException(env); |
189 | 195 |
190 env->SetBooleanField( | 196 env->SetBooleanField( |
191 obj, | 197 obj, |
| 198 field_ids_->allow_universal_access_from_file_urls, |
| 199 prefs.allow_universal_access_from_file_urls); |
| 200 CheckException(env); |
| 201 |
| 202 env->SetBooleanField( |
| 203 obj, |
| 204 field_ids_->allow_file_access_from_file_urls, |
| 205 prefs.allow_file_access_from_file_urls); |
| 206 CheckException(env); |
| 207 |
| 208 env->SetBooleanField( |
| 209 obj, |
192 field_ids_->java_script_can_open_windows_automatically, | 210 field_ids_->java_script_can_open_windows_automatically, |
193 prefs.javascript_can_open_windows_automatically); | 211 prefs.javascript_can_open_windows_automatically); |
194 CheckException(env); | 212 CheckException(env); |
195 | 213 |
196 Java_ContentSettings_setPluginsDisabled(env, obj, !prefs.plugins_enabled); | 214 Java_ContentSettings_setPluginsDisabled(env, obj, !prefs.plugins_enabled); |
197 CheckException(env); | 215 CheckException(env); |
198 | 216 |
199 env->SetBooleanField( | 217 env->SetBooleanField( |
200 obj, | 218 obj, |
201 field_ids_->dom_storage_enabled, | 219 field_ids_->dom_storage_enabled, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 283 |
266 prefs.default_fixed_font_size = | 284 prefs.default_fixed_font_size = |
267 env->GetIntField(obj, field_ids_->default_fixed_font_size); | 285 env->GetIntField(obj, field_ids_->default_fixed_font_size); |
268 | 286 |
269 prefs.loads_images_automatically = | 287 prefs.loads_images_automatically = |
270 env->GetBooleanField(obj, field_ids_->load_images_automatically); | 288 env->GetBooleanField(obj, field_ids_->load_images_automatically); |
271 | 289 |
272 prefs.javascript_enabled = | 290 prefs.javascript_enabled = |
273 env->GetBooleanField(obj, field_ids_->java_script_enabled); | 291 env->GetBooleanField(obj, field_ids_->java_script_enabled); |
274 | 292 |
| 293 prefs.allow_universal_access_from_file_urls = env->GetBooleanField( |
| 294 obj, field_ids_->allow_universal_access_from_file_urls); |
| 295 |
| 296 prefs.allow_file_access_from_file_urls = env->GetBooleanField( |
| 297 obj, field_ids_->allow_file_access_from_file_urls); |
| 298 |
275 prefs.javascript_can_open_windows_automatically = env->GetBooleanField( | 299 prefs.javascript_can_open_windows_automatically = env->GetBooleanField( |
276 obj, field_ids_->java_script_can_open_windows_automatically); | 300 obj, field_ids_->java_script_can_open_windows_automatically); |
277 | 301 |
278 prefs.plugins_enabled = !Java_ContentSettings_getPluginsDisabled(env, obj); | 302 prefs.plugins_enabled = !Java_ContentSettings_getPluginsDisabled(env, obj); |
279 | 303 |
280 prefs.local_storage_enabled = env->GetBooleanField( | 304 prefs.local_storage_enabled = env->GetBooleanField( |
281 obj, field_ids_->dom_storage_enabled); | 305 obj, field_ids_->dom_storage_enabled); |
282 | 306 |
283 render_view_host->UpdateWebkitPreferences(prefs); | 307 render_view_host->UpdateWebkitPreferences(prefs); |
284 } | 308 } |
(...skipping 21 matching lines...) Expand all Loading... |
306 return reinterpret_cast<jint>(content_settings); | 330 return reinterpret_cast<jint>(content_settings); |
307 } | 331 } |
308 | 332 |
309 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 333 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
310 // "Version/4.0" had been hardcoded in the legacy WebView. | 334 // "Version/4.0" had been hardcoded in the legacy WebView. |
311 std::string ua = webkit_glue::BuildUserAgentFromProduct("Version/4.0"); | 335 std::string ua = webkit_glue::BuildUserAgentFromProduct("Version/4.0"); |
312 return base::android::ConvertUTF8ToJavaString(env, ua).Release(); | 336 return base::android::ConvertUTF8ToJavaString(env, ua).Release(); |
313 } | 337 } |
314 | 338 |
315 } // namespace content | 339 } // namespace content |
OLD | NEW |