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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = | 83 use_wide_viewport = |
84 GetFieldID(env, clazz, "mUseWideViewport", "Z"); | 84 GetFieldID(env, clazz, "mUseWideViewport", "Z"); |
| 85 load_with_overview_mode = |
| 86 GetFieldID(env, clazz, "mLoadWithOverviewMode", "Z"); |
85 } | 87 } |
86 | 88 |
87 // Field ids | 89 // Field ids |
88 jfieldID text_size_percent; | 90 jfieldID text_size_percent; |
89 jfieldID standard_fond_family; | 91 jfieldID standard_fond_family; |
90 jfieldID fixed_font_family; | 92 jfieldID fixed_font_family; |
91 jfieldID sans_serif_font_family; | 93 jfieldID sans_serif_font_family; |
92 jfieldID serif_font_family; | 94 jfieldID serif_font_family; |
93 jfieldID cursive_font_family; | 95 jfieldID cursive_font_family; |
94 jfieldID fantasy_font_family; | 96 jfieldID fantasy_font_family; |
95 jfieldID default_text_encoding; | 97 jfieldID default_text_encoding; |
96 jfieldID user_agent; | 98 jfieldID user_agent; |
97 jfieldID minimum_font_size; | 99 jfieldID minimum_font_size; |
98 jfieldID minimum_logical_font_size; | 100 jfieldID minimum_logical_font_size; |
99 jfieldID default_font_size; | 101 jfieldID default_font_size; |
100 jfieldID default_fixed_font_size; | 102 jfieldID default_fixed_font_size; |
101 jfieldID load_images_automatically; | 103 jfieldID load_images_automatically; |
102 jfieldID images_enabled; | 104 jfieldID images_enabled; |
103 jfieldID java_script_enabled; | 105 jfieldID java_script_enabled; |
104 jfieldID allow_universal_access_from_file_urls; | 106 jfieldID allow_universal_access_from_file_urls; |
105 jfieldID allow_file_access_from_file_urls; | 107 jfieldID allow_file_access_from_file_urls; |
106 jfieldID java_script_can_open_windows_automatically; | 108 jfieldID java_script_can_open_windows_automatically; |
107 jfieldID support_multiple_windows; | 109 jfieldID support_multiple_windows; |
108 jfieldID dom_storage_enabled; | 110 jfieldID dom_storage_enabled; |
109 jfieldID use_wide_viewport; | 111 jfieldID use_wide_viewport; |
| 112 jfieldID load_with_overview_mode; |
110 }; | 113 }; |
111 | 114 |
112 ContentSettings::ContentSettings(JNIEnv* env, | 115 ContentSettings::ContentSettings(JNIEnv* env, |
113 jobject obj, | 116 jobject obj, |
114 WebContents* contents, | 117 WebContents* contents, |
115 bool is_master_mode) | 118 bool is_master_mode) |
116 : WebContentsObserver(contents), | 119 : WebContentsObserver(contents), |
117 is_master_mode_(is_master_mode), | 120 is_master_mode_(is_master_mode), |
118 content_settings_(env, obj) { | 121 content_settings_(env, obj) { |
119 } | 122 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 obj, | 262 obj, |
260 field_ids_->dom_storage_enabled, | 263 field_ids_->dom_storage_enabled, |
261 prefs.local_storage_enabled); | 264 prefs.local_storage_enabled); |
262 CheckException(env); | 265 CheckException(env); |
263 | 266 |
264 env->SetBooleanField( | 267 env->SetBooleanField( |
265 obj, | 268 obj, |
266 field_ids_->use_wide_viewport, | 269 field_ids_->use_wide_viewport, |
267 prefs.viewport_enabled); | 270 prefs.viewport_enabled); |
268 CheckException(env); | 271 CheckException(env); |
| 272 |
| 273 env->SetBooleanField( |
| 274 obj, |
| 275 field_ids_->load_with_overview_mode, |
| 276 prefs.viewport_scale_content_to_fit); |
| 277 CheckException(env); |
269 } | 278 } |
270 | 279 |
271 void ContentSettings::SyncToNativeImpl() { | 280 void ContentSettings::SyncToNativeImpl() { |
272 JNIEnv* env = base::android::AttachCurrentThread(); | 281 JNIEnv* env = base::android::AttachCurrentThread(); |
273 CHECK(env); | 282 CHECK(env); |
274 if (!field_ids_.get()) | 283 if (!field_ids_.get()) |
275 field_ids_.reset(new FieldIds(env)); | 284 field_ids_.reset(new FieldIds(env)); |
276 | 285 |
277 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); | 286 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); |
278 jobject obj = scoped_obj.obj(); | 287 jobject obj = scoped_obj.obj(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 375 |
367 prefs.application_cache_enabled = | 376 prefs.application_cache_enabled = |
368 Java_ContentSettings_getAppCacheEnabled(env, obj); | 377 Java_ContentSettings_getAppCacheEnabled(env, obj); |
369 | 378 |
370 prefs.local_storage_enabled = env->GetBooleanField( | 379 prefs.local_storage_enabled = env->GetBooleanField( |
371 obj, field_ids_->dom_storage_enabled); | 380 obj, field_ids_->dom_storage_enabled); |
372 | 381 |
373 prefs.viewport_enabled = env->GetBooleanField( | 382 prefs.viewport_enabled = env->GetBooleanField( |
374 obj, field_ids_->use_wide_viewport); | 383 obj, field_ids_->use_wide_viewport); |
375 | 384 |
| 385 prefs.viewport_scale_content_to_fit = env->GetBooleanField( |
| 386 obj, field_ids_->load_with_overview_mode); |
| 387 |
376 render_view_host->UpdateWebkitPreferences(prefs); | 388 render_view_host->UpdateWebkitPreferences(prefs); |
377 } | 389 } |
378 | 390 |
379 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { | 391 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { |
380 SyncFromNativeImpl(); | 392 SyncFromNativeImpl(); |
381 } | 393 } |
382 | 394 |
383 void ContentSettings::SyncToNative(JNIEnv* env, jobject obj) { | 395 void ContentSettings::SyncToNative(JNIEnv* env, jobject obj) { |
384 SyncToNativeImpl(); | 396 SyncToNativeImpl(); |
385 } | 397 } |
(...skipping 16 matching lines...) Expand all Loading... |
402 new ContentSettings(env, obj, web_contents, is_master_mode); | 414 new ContentSettings(env, obj, web_contents, is_master_mode); |
403 return reinterpret_cast<jint>(content_settings); | 415 return reinterpret_cast<jint>(content_settings); |
404 } | 416 } |
405 | 417 |
406 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 418 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
407 return base::android::ConvertUTF8ToJavaString( | 419 return base::android::ConvertUTF8ToJavaString( |
408 env, GetContentClient()->GetUserAgent()).Release(); | 420 env, GetContentClient()->GetUserAgent()).Release(); |
409 } | 421 } |
410 | 422 |
411 } // namespace content | 423 } // namespace content |
OLD | NEW |