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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 database_enabled = | 83 database_enabled = |
84 GetFieldID(env, clazz, "mDatabaseEnabled", "Z"); | 84 GetFieldID(env, clazz, "mDatabaseEnabled", "Z"); |
85 use_wide_viewport = | 85 use_wide_viewport = |
86 GetFieldID(env, clazz, "mUseWideViewport", "Z"); | 86 GetFieldID(env, clazz, "mUseWideViewport", "Z"); |
| 87 load_with_overview_mode = |
| 88 GetFieldID(env, clazz, "mLoadWithOverviewMode", "Z"); |
87 } | 89 } |
88 | 90 |
89 // Field ids | 91 // Field ids |
90 jfieldID text_size_percent; | 92 jfieldID text_size_percent; |
91 jfieldID standard_fond_family; | 93 jfieldID standard_fond_family; |
92 jfieldID fixed_font_family; | 94 jfieldID fixed_font_family; |
93 jfieldID sans_serif_font_family; | 95 jfieldID sans_serif_font_family; |
94 jfieldID serif_font_family; | 96 jfieldID serif_font_family; |
95 jfieldID cursive_font_family; | 97 jfieldID cursive_font_family; |
96 jfieldID fantasy_font_family; | 98 jfieldID fantasy_font_family; |
97 jfieldID default_text_encoding; | 99 jfieldID default_text_encoding; |
98 jfieldID user_agent; | 100 jfieldID user_agent; |
99 jfieldID minimum_font_size; | 101 jfieldID minimum_font_size; |
100 jfieldID minimum_logical_font_size; | 102 jfieldID minimum_logical_font_size; |
101 jfieldID default_font_size; | 103 jfieldID default_font_size; |
102 jfieldID default_fixed_font_size; | 104 jfieldID default_fixed_font_size; |
103 jfieldID load_images_automatically; | 105 jfieldID load_images_automatically; |
104 jfieldID images_enabled; | 106 jfieldID images_enabled; |
105 jfieldID java_script_enabled; | 107 jfieldID java_script_enabled; |
106 jfieldID allow_universal_access_from_file_urls; | 108 jfieldID allow_universal_access_from_file_urls; |
107 jfieldID allow_file_access_from_file_urls; | 109 jfieldID allow_file_access_from_file_urls; |
108 jfieldID java_script_can_open_windows_automatically; | 110 jfieldID java_script_can_open_windows_automatically; |
109 jfieldID support_multiple_windows; | 111 jfieldID support_multiple_windows; |
110 jfieldID dom_storage_enabled; | 112 jfieldID dom_storage_enabled; |
111 jfieldID database_enabled; | 113 jfieldID database_enabled; |
112 jfieldID use_wide_viewport; | 114 jfieldID use_wide_viewport; |
| 115 jfieldID load_with_overview_mode; |
113 }; | 116 }; |
114 | 117 |
115 ContentSettings::ContentSettings(JNIEnv* env, | 118 ContentSettings::ContentSettings(JNIEnv* env, |
116 jobject obj, | 119 jobject obj, |
117 WebContents* contents, | 120 WebContents* contents, |
118 bool is_master_mode) | 121 bool is_master_mode) |
119 : WebContentsObserver(contents), | 122 : WebContentsObserver(contents), |
120 is_master_mode_(is_master_mode), | 123 is_master_mode_(is_master_mode), |
121 content_settings_(env, obj) { | 124 content_settings_(env, obj) { |
122 } | 125 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 obj, | 271 obj, |
269 field_ids_->database_enabled, | 272 field_ids_->database_enabled, |
270 prefs.databases_enabled); | 273 prefs.databases_enabled); |
271 CheckException(env); | 274 CheckException(env); |
272 | 275 |
273 env->SetBooleanField( | 276 env->SetBooleanField( |
274 obj, | 277 obj, |
275 field_ids_->use_wide_viewport, | 278 field_ids_->use_wide_viewport, |
276 prefs.viewport_enabled); | 279 prefs.viewport_enabled); |
277 CheckException(env); | 280 CheckException(env); |
| 281 |
| 282 env->SetBooleanField( |
| 283 obj, |
| 284 field_ids_->load_with_overview_mode, |
| 285 prefs.initialize_at_minimum_page_scale); |
| 286 CheckException(env); |
278 } | 287 } |
279 | 288 |
280 void ContentSettings::SyncToNativeImpl() { | 289 void ContentSettings::SyncToNativeImpl() { |
281 JNIEnv* env = base::android::AttachCurrentThread(); | 290 JNIEnv* env = base::android::AttachCurrentThread(); |
282 CHECK(env); | 291 CHECK(env); |
283 if (!field_ids_.get()) | 292 if (!field_ids_.get()) |
284 field_ids_.reset(new FieldIds(env)); | 293 field_ids_.reset(new FieldIds(env)); |
285 | 294 |
286 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); | 295 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); |
287 jobject obj = scoped_obj.obj(); | 296 jobject obj = scoped_obj.obj(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 391 |
383 prefs.local_storage_enabled = env->GetBooleanField( | 392 prefs.local_storage_enabled = env->GetBooleanField( |
384 obj, field_ids_->dom_storage_enabled); | 393 obj, field_ids_->dom_storage_enabled); |
385 | 394 |
386 prefs.databases_enabled = env->GetBooleanField( | 395 prefs.databases_enabled = env->GetBooleanField( |
387 obj, field_ids_->database_enabled); | 396 obj, field_ids_->database_enabled); |
388 | 397 |
389 prefs.viewport_enabled = env->GetBooleanField( | 398 prefs.viewport_enabled = env->GetBooleanField( |
390 obj, field_ids_->use_wide_viewport); | 399 obj, field_ids_->use_wide_viewport); |
391 | 400 |
| 401 prefs.initialize_at_minimum_page_scale = env->GetBooleanField( |
| 402 obj, field_ids_->load_with_overview_mode); |
| 403 |
392 render_view_host->UpdateWebkitPreferences(prefs); | 404 render_view_host->UpdateWebkitPreferences(prefs); |
393 } | 405 } |
394 | 406 |
395 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { | 407 void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) { |
396 SyncFromNativeImpl(); | 408 SyncFromNativeImpl(); |
397 } | 409 } |
398 | 410 |
399 void ContentSettings::SyncToNative(JNIEnv* env, jobject obj) { | 411 void ContentSettings::SyncToNative(JNIEnv* env, jobject obj) { |
400 SyncToNativeImpl(); | 412 SyncToNativeImpl(); |
401 } | 413 } |
(...skipping 16 matching lines...) Expand all Loading... |
418 new ContentSettings(env, obj, web_contents, is_master_mode); | 430 new ContentSettings(env, obj, web_contents, is_master_mode); |
419 return reinterpret_cast<jint>(content_settings); | 431 return reinterpret_cast<jint>(content_settings); |
420 } | 432 } |
421 | 433 |
422 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 434 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
423 return base::android::ConvertUTF8ToJavaString( | 435 return base::android::ConvertUTF8ToJavaString( |
424 env, GetContentClient()->GetUserAgent()).Release(); | 436 env, GetContentClient()->GetUserAgent()).Release(); |
425 } | 437 } |
426 | 438 |
427 } // namespace content | 439 } // namespace content |
OLD | NEW |