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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 143 } |
144 | 144 |
145 // static | 145 // static |
146 bool ContentSettings::RegisterContentSettings(JNIEnv* env) { | 146 bool ContentSettings::RegisterContentSettings(JNIEnv* env) { |
147 return RegisterNativesImpl(env); | 147 return RegisterNativesImpl(env); |
148 } | 148 } |
149 | 149 |
150 void ContentSettings::SyncFromNativeImpl() { | 150 void ContentSettings::SyncFromNativeImpl() { |
151 JNIEnv* env = base::android::AttachCurrentThread(); | 151 JNIEnv* env = base::android::AttachCurrentThread(); |
152 CHECK(env); | 152 CHECK(env); |
153 if (!field_ids_.get()) | 153 if (!field_ids_) |
154 field_ids_.reset(new FieldIds(env)); | 154 field_ids_.reset(new FieldIds(env)); |
155 | 155 |
156 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); | 156 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); |
157 jobject obj = scoped_obj.obj(); | 157 jobject obj = scoped_obj.obj(); |
158 if (!obj) | 158 if (!obj) |
159 return; | 159 return; |
160 RenderViewHost* render_view_host = web_contents()->GetRenderViewHost(); | 160 RenderViewHost* render_view_host = web_contents()->GetRenderViewHost(); |
161 WebPreferences prefs = render_view_host->GetDelegate()->GetWebkitPrefs(); | 161 WebPreferences prefs = render_view_host->GetDelegate()->GetWebkitPrefs(); |
162 | 162 |
163 Java_ContentSettings_setTextAutosizingEnabled( | 163 Java_ContentSettings_setTextAutosizingEnabled( |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 302 |
303 str.Reset( | 303 str.Reset( |
304 ConvertUTF8ToJavaString(env, prefs.default_video_poster_url.spec())); | 304 ConvertUTF8ToJavaString(env, prefs.default_video_poster_url.spec())); |
305 env->SetObjectField(obj, field_ids_->default_video_poster_url, str.obj()); | 305 env->SetObjectField(obj, field_ids_->default_video_poster_url, str.obj()); |
306 CheckException(env); | 306 CheckException(env); |
307 } | 307 } |
308 | 308 |
309 void ContentSettings::SyncToNativeImpl() { | 309 void ContentSettings::SyncToNativeImpl() { |
310 JNIEnv* env = base::android::AttachCurrentThread(); | 310 JNIEnv* env = base::android::AttachCurrentThread(); |
311 CHECK(env); | 311 CHECK(env); |
312 if (!field_ids_.get()) | 312 if (!field_ids_) |
313 field_ids_.reset(new FieldIds(env)); | 313 field_ids_.reset(new FieldIds(env)); |
314 | 314 |
315 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); | 315 ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env); |
316 jobject obj = scoped_obj.obj(); | 316 jobject obj = scoped_obj.obj(); |
317 if (!obj) | 317 if (!obj) |
318 return; | 318 return; |
319 RenderViewHost* render_view_host = web_contents()->GetRenderViewHost(); | 319 RenderViewHost* render_view_host = web_contents()->GetRenderViewHost(); |
320 WebPreferences prefs = render_view_host->GetDelegate()->GetWebkitPrefs(); | 320 WebPreferences prefs = render_view_host->GetDelegate()->GetWebkitPrefs(); |
321 | 321 |
322 prefs.text_autosizing_enabled = | 322 prefs.text_autosizing_enabled = |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 new ContentSettings(env, obj, web_contents, is_master_mode); | 463 new ContentSettings(env, obj, web_contents, is_master_mode); |
464 return reinterpret_cast<jint>(content_settings); | 464 return reinterpret_cast<jint>(content_settings); |
465 } | 465 } |
466 | 466 |
467 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 467 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
468 return base::android::ConvertUTF8ToJavaString( | 468 return base::android::ConvertUTF8ToJavaString( |
469 env, GetContentClient()->GetUserAgent()).Release(); | 469 env, GetContentClient()->GetUserAgent()).Release(); |
470 } | 470 } |
471 | 471 |
472 } // namespace content | 472 } // namespace content |
OLD | NEW |