| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 allow_universal_access_from_file_urls = | 73 allow_universal_access_from_file_urls = |
| 74 GetFieldID(env, clazz, "mAllowUniversalAccessFromFileURLs", "Z"); | 74 GetFieldID(env, clazz, "mAllowUniversalAccessFromFileURLs", "Z"); |
| 75 allow_file_access_from_file_urls = | 75 allow_file_access_from_file_urls = |
| 76 GetFieldID(env, clazz, "mAllowFileAccessFromFileURLs", "Z"); | 76 GetFieldID(env, clazz, "mAllowFileAccessFromFileURLs", "Z"); |
| 77 java_script_can_open_windows_automatically = | 77 java_script_can_open_windows_automatically = |
| 78 GetFieldID(env, clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z"); | 78 GetFieldID(env, clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z"); |
| 79 support_multiple_windows = | 79 support_multiple_windows = |
| 80 GetFieldID(env, clazz, "mSupportMultipleWindows", "Z"); | 80 GetFieldID(env, clazz, "mSupportMultipleWindows", "Z"); |
| 81 dom_storage_enabled = | 81 dom_storage_enabled = |
| 82 GetFieldID(env, clazz, "mDomStorageEnabled", "Z"); | 82 GetFieldID(env, clazz, "mDomStorageEnabled", "Z"); |
| 83 use_wide_viewport = |
| 84 GetFieldID(env, clazz, "mUseWideViewport", "Z"); |
| 83 } | 85 } |
| 84 | 86 |
| 85 // Field ids | 87 // Field ids |
| 86 jfieldID text_size_percent; | 88 jfieldID text_size_percent; |
| 87 jfieldID standard_fond_family; | 89 jfieldID standard_fond_family; |
| 88 jfieldID fixed_font_family; | 90 jfieldID fixed_font_family; |
| 89 jfieldID sans_serif_font_family; | 91 jfieldID sans_serif_font_family; |
| 90 jfieldID serif_font_family; | 92 jfieldID serif_font_family; |
| 91 jfieldID cursive_font_family; | 93 jfieldID cursive_font_family; |
| 92 jfieldID fantasy_font_family; | 94 jfieldID fantasy_font_family; |
| 93 jfieldID default_text_encoding; | 95 jfieldID default_text_encoding; |
| 94 jfieldID user_agent; | 96 jfieldID user_agent; |
| 95 jfieldID minimum_font_size; | 97 jfieldID minimum_font_size; |
| 96 jfieldID minimum_logical_font_size; | 98 jfieldID minimum_logical_font_size; |
| 97 jfieldID default_font_size; | 99 jfieldID default_font_size; |
| 98 jfieldID default_fixed_font_size; | 100 jfieldID default_fixed_font_size; |
| 99 jfieldID load_images_automatically; | 101 jfieldID load_images_automatically; |
| 100 jfieldID images_enabled; | 102 jfieldID images_enabled; |
| 101 jfieldID java_script_enabled; | 103 jfieldID java_script_enabled; |
| 102 jfieldID allow_universal_access_from_file_urls; | 104 jfieldID allow_universal_access_from_file_urls; |
| 103 jfieldID allow_file_access_from_file_urls; | 105 jfieldID allow_file_access_from_file_urls; |
| 104 jfieldID java_script_can_open_windows_automatically; | 106 jfieldID java_script_can_open_windows_automatically; |
| 105 jfieldID support_multiple_windows; | 107 jfieldID support_multiple_windows; |
| 106 jfieldID dom_storage_enabled; | 108 jfieldID dom_storage_enabled; |
| 109 jfieldID use_wide_viewport; |
| 107 }; | 110 }; |
| 108 | 111 |
| 109 ContentSettings::ContentSettings(JNIEnv* env, | 112 ContentSettings::ContentSettings(JNIEnv* env, |
| 110 jobject obj, | 113 jobject obj, |
| 111 WebContents* contents, | 114 WebContents* contents, |
| 112 bool is_master_mode) | 115 bool is_master_mode) |
| 113 : WebContentsObserver(contents), | 116 : WebContentsObserver(contents), |
| 114 is_master_mode_(is_master_mode), | 117 is_master_mode_(is_master_mode), |
| 115 content_settings_(env, obj) { | 118 content_settings_(env, obj) { |
| 116 } | 119 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 CheckException(env); | 253 CheckException(env); |
| 251 | 254 |
| 252 // We don't need to sync AppCache settings to Java, because there are | 255 // We don't need to sync AppCache settings to Java, because there are |
| 253 // no getters for them in the API. | 256 // no getters for them in the API. |
| 254 | 257 |
| 255 env->SetBooleanField( | 258 env->SetBooleanField( |
| 256 obj, | 259 obj, |
| 257 field_ids_->dom_storage_enabled, | 260 field_ids_->dom_storage_enabled, |
| 258 prefs.local_storage_enabled); | 261 prefs.local_storage_enabled); |
| 259 CheckException(env); | 262 CheckException(env); |
| 263 |
| 264 env->SetBooleanField( |
| 265 obj, |
| 266 field_ids_->use_wide_viewport, |
| 267 prefs.viewport_enabled); |
| 268 CheckException(env); |
| 260 } | 269 } |
| 261 | 270 |
| 262 void ContentSettings::SyncToNativeImpl() { | 271 void ContentSettings::SyncToNativeImpl() { |
| 263 JNIEnv* env = base::android::AttachCurrentThread(); | 272 JNIEnv* env = base::android::AttachCurrentThread(); |
| 264 CHECK(env); | 273 CHECK(env); |
| 265 if (!field_ids_.get()) | 274 if (!field_ids_.get()) |
| 266 field_ids_.reset(new FieldIds(env)); | 275 field_ids_.reset(new FieldIds(env)); |
| 267 | 276 |
| 268 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); | 277 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); |
| 269 jobject obj = scoped_obj.obj(); | 278 jobject obj = scoped_obj.obj(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 obj, field_ids_->support_multiple_windows); | 363 obj, field_ids_->support_multiple_windows); |
| 355 | 364 |
| 356 prefs.plugins_enabled = !Java_ContentSettings_getPluginsDisabled(env, obj); | 365 prefs.plugins_enabled = !Java_ContentSettings_getPluginsDisabled(env, obj); |
| 357 | 366 |
| 358 prefs.application_cache_enabled = | 367 prefs.application_cache_enabled = |
| 359 Java_ContentSettings_getAppCacheEnabled(env, obj); | 368 Java_ContentSettings_getAppCacheEnabled(env, obj); |
| 360 | 369 |
| 361 prefs.local_storage_enabled = env->GetBooleanField( | 370 prefs.local_storage_enabled = env->GetBooleanField( |
| 362 obj, field_ids_->dom_storage_enabled); | 371 obj, field_ids_->dom_storage_enabled); |
| 363 | 372 |
| 373 prefs.viewport_enabled = env->GetBooleanField( |
| 374 obj, field_ids_->use_wide_viewport); |
| 375 |
| 364 render_view_host->UpdateWebkitPreferences(prefs); | 376 render_view_host->UpdateWebkitPreferences(prefs); |
| 365 } | 377 } |
| 366 | 378 |
| 367 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { | 379 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { |
| 368 SyncFromNativeImpl(); | 380 SyncFromNativeImpl(); |
| 369 } | 381 } |
| 370 | 382 |
| 371 void ContentSettings::SyncToNative(JNIEnv* env, jobject obj) { | 383 void ContentSettings::SyncToNative(JNIEnv* env, jobject obj) { |
| 372 SyncToNativeImpl(); | 384 SyncToNativeImpl(); |
| 373 } | 385 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 390 new ContentSettings(env, obj, web_contents, is_master_mode); | 402 new ContentSettings(env, obj, web_contents, is_master_mode); |
| 391 return reinterpret_cast<jint>(content_settings); | 403 return reinterpret_cast<jint>(content_settings); |
| 392 } | 404 } |
| 393 | 405 |
| 394 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 406 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
| 395 return base::android::ConvertUTF8ToJavaString( | 407 return base::android::ConvertUTF8ToJavaString( |
| 396 env, GetContentClient()->GetUserAgent()).Release(); | 408 env, GetContentClient()->GetUserAgent()).Release(); |
| 397 } | 409 } |
| 398 | 410 |
| 399 } // namespace content | 411 } // namespace content |
| OLD | NEW |