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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 java_script_enabled = | 71 java_script_enabled = |
72 GetFieldID(env, clazz, "mJavaScriptEnabled", "Z"); | 72 GetFieldID(env, clazz, "mJavaScriptEnabled", "Z"); |
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 app_cache_enabled = | |
82 GetFieldID(env, clazz, "mAppCacheEnabled", "Z"); | |
83 app_cache_path = | |
84 GetFieldID(env, clazz, "mAppCachePath", kStringClassName); | |
81 dom_storage_enabled = | 85 dom_storage_enabled = |
82 GetFieldID(env, clazz, "mDomStorageEnabled", "Z"); | 86 GetFieldID(env, clazz, "mDomStorageEnabled", "Z"); |
83 } | 87 } |
84 | 88 |
85 // Field ids | 89 // Field ids |
86 jfieldID text_size_percent; | 90 jfieldID text_size_percent; |
87 jfieldID standard_fond_family; | 91 jfieldID standard_fond_family; |
88 jfieldID fixed_font_family; | 92 jfieldID fixed_font_family; |
89 jfieldID sans_serif_font_family; | 93 jfieldID sans_serif_font_family; |
90 jfieldID serif_font_family; | 94 jfieldID serif_font_family; |
91 jfieldID cursive_font_family; | 95 jfieldID cursive_font_family; |
92 jfieldID fantasy_font_family; | 96 jfieldID fantasy_font_family; |
93 jfieldID default_text_encoding; | 97 jfieldID default_text_encoding; |
94 jfieldID user_agent; | 98 jfieldID user_agent; |
95 jfieldID minimum_font_size; | 99 jfieldID minimum_font_size; |
96 jfieldID minimum_logical_font_size; | 100 jfieldID minimum_logical_font_size; |
97 jfieldID default_font_size; | 101 jfieldID default_font_size; |
98 jfieldID default_fixed_font_size; | 102 jfieldID default_fixed_font_size; |
99 jfieldID load_images_automatically; | 103 jfieldID load_images_automatically; |
100 jfieldID images_enabled; | 104 jfieldID images_enabled; |
101 jfieldID java_script_enabled; | 105 jfieldID java_script_enabled; |
102 jfieldID allow_universal_access_from_file_urls; | 106 jfieldID allow_universal_access_from_file_urls; |
103 jfieldID allow_file_access_from_file_urls; | 107 jfieldID allow_file_access_from_file_urls; |
104 jfieldID java_script_can_open_windows_automatically; | 108 jfieldID java_script_can_open_windows_automatically; |
105 jfieldID support_multiple_windows; | 109 jfieldID support_multiple_windows; |
110 jfieldID app_cache_enabled; | |
111 jfieldID app_cache_path; | |
106 jfieldID dom_storage_enabled; | 112 jfieldID dom_storage_enabled; |
107 }; | 113 }; |
108 | 114 |
109 ContentSettings::ContentSettings(JNIEnv* env, | 115 ContentSettings::ContentSettings(JNIEnv* env, |
110 jobject obj, | 116 jobject obj, |
111 WebContents* contents, | 117 WebContents* contents, |
112 bool is_master_mode) | 118 bool is_master_mode) |
113 : WebContentsObserver(contents), | 119 : WebContentsObserver(contents), |
114 is_master_mode_(is_master_mode), | 120 is_master_mode_(is_master_mode), |
115 content_settings_(env, obj) { | 121 content_settings_(env, obj) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 | 247 |
242 env->SetBooleanField( | 248 env->SetBooleanField( |
243 obj, | 249 obj, |
244 field_ids_->support_multiple_windows, | 250 field_ids_->support_multiple_windows, |
245 prefs.supports_multiple_windows); | 251 prefs.supports_multiple_windows); |
246 CheckException(env); | 252 CheckException(env); |
247 | 253 |
248 Java_ContentSettings_setPluginsDisabled(env, obj, !prefs.plugins_enabled); | 254 Java_ContentSettings_setPluginsDisabled(env, obj, !prefs.plugins_enabled); |
249 CheckException(env); | 255 CheckException(env); |
250 | 256 |
257 // We don't need to sync AppCache settings to Java, because there are | |
258 // no getters for them in the API. | |
259 | |
251 env->SetBooleanField( | 260 env->SetBooleanField( |
252 obj, | 261 obj, |
253 field_ids_->dom_storage_enabled, | 262 field_ids_->dom_storage_enabled, |
254 prefs.local_storage_enabled); | 263 prefs.local_storage_enabled); |
255 CheckException(env); | 264 CheckException(env); |
256 } | 265 } |
257 | 266 |
258 void ContentSettings::SyncToNativeImpl() { | 267 void ContentSettings::SyncToNativeImpl() { |
259 JNIEnv* env = base::android::AttachCurrentThread(); | 268 JNIEnv* env = base::android::AttachCurrentThread(); |
260 CHECK(env); | 269 CHECK(env); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 obj, field_ids_->allow_file_access_from_file_urls); | 353 obj, field_ids_->allow_file_access_from_file_urls); |
345 | 354 |
346 prefs.javascript_can_open_windows_automatically = env->GetBooleanField( | 355 prefs.javascript_can_open_windows_automatically = env->GetBooleanField( |
347 obj, field_ids_->java_script_can_open_windows_automatically); | 356 obj, field_ids_->java_script_can_open_windows_automatically); |
348 | 357 |
349 prefs.supports_multiple_windows = env->GetBooleanField( | 358 prefs.supports_multiple_windows = env->GetBooleanField( |
350 obj, field_ids_->support_multiple_windows); | 359 obj, field_ids_->support_multiple_windows); |
351 | 360 |
352 prefs.plugins_enabled = !Java_ContentSettings_getPluginsDisabled(env, obj); | 361 prefs.plugins_enabled = !Java_ContentSettings_getPluginsDisabled(env, obj); |
353 | 362 |
363 // AppCachePath is a global setting across all WebViews. | |
364 CR_DEFINE_STATIC_LOCAL(std::string, app_cache_path, ()); | |
boliu
2012/11/30 17:46:27
This is only global in WebViews, not inside webkit
joth
2012/11/30 22:16:59
also consider:
- CR_DEFINE_STATIC_LOCAL is not thr
mnaganov (inactive)
2012/12/03 15:07:36
I know it's not thread safe, but I was supposing t
mnaganov (inactive)
2012/12/03 15:07:36
The cache storage is global in WebKit, see Applica
| |
365 if (app_cache_path.empty()) { | |
366 str.Reset( | |
367 env, static_cast<jstring>( | |
368 env->GetObjectField(obj, field_ids_->app_cache_path))); | |
369 if (!str.is_null()) { | |
370 app_cache_path = ConvertJavaStringToUTF8(str); | |
371 // Java side should never set an empty string for the AppCache path. | |
372 DCHECK(!app_cache_path.empty()); | |
373 } | |
374 } | |
375 prefs.application_cache_enabled = | |
376 !app_cache_path.empty() && env->GetBooleanField( | |
377 obj, field_ids_->app_cache_enabled); | |
378 | |
354 prefs.local_storage_enabled = env->GetBooleanField( | 379 prefs.local_storage_enabled = env->GetBooleanField( |
355 obj, field_ids_->dom_storage_enabled); | 380 obj, field_ids_->dom_storage_enabled); |
356 | 381 |
357 render_view_host->UpdateWebkitPreferences(prefs); | 382 render_view_host->UpdateWebkitPreferences(prefs); |
358 } | 383 } |
359 | 384 |
360 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { | 385 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { |
361 SyncFromNativeImpl(); | 386 SyncFromNativeImpl(); |
362 } | 387 } |
363 | 388 |
(...skipping 19 matching lines...) Expand all Loading... | |
383 new ContentSettings(env, obj, web_contents, is_master_mode); | 408 new ContentSettings(env, obj, web_contents, is_master_mode); |
384 return reinterpret_cast<jint>(content_settings); | 409 return reinterpret_cast<jint>(content_settings); |
385 } | 410 } |
386 | 411 |
387 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 412 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
388 return base::android::ConvertUTF8ToJavaString( | 413 return base::android::ConvertUTF8ToJavaString( |
389 env, GetContentClient()->GetUserAgent()).Release(); | 414 env, GetContentClient()->GetUserAgent()).Release(); |
390 } | 415 } |
391 | 416 |
392 } // namespace content | 417 } // namespace content |
OLD | NEW |