diff options
Diffstat (limited to 'android_webview')
-rw-r--r-- | android_webview/android_webview.gyp | 6 | ||||
-rw-r--r-- | android_webview/browser/aw_content_browser_client.cc | 14 | ||||
-rw-r--r-- | android_webview/browser/aw_content_browser_client.h | 7 | ||||
-rw-r--r-- | android_webview/browser/aw_web_preferences_populater.cc | 9 | ||||
-rw-r--r-- | android_webview/browser/aw_web_preferences_populater.h | 27 | ||||
-rw-r--r-- | android_webview/browser/jni_dependency_factory.h | 2 | ||||
-rw-r--r-- | android_webview/lib/main/aw_main_delegate.cc | 5 | ||||
-rw-r--r-- | android_webview/lib/main/aw_main_delegate.h | 1 | ||||
-rw-r--r-- | android_webview/native/aw_settings.cc | 210 | ||||
-rw-r--r-- | android_webview/native/aw_settings.h | 6 | ||||
-rw-r--r-- | android_webview/native/aw_web_preferences_populater_impl.cc | 26 | ||||
-rw-r--r-- | android_webview/native/aw_web_preferences_populater_impl.h | 34 | ||||
-rw-r--r-- | android_webview/native/webview_native.gyp | 2 |
13 files changed, 264 insertions, 85 deletions
diff --git a/android_webview/android_webview.gyp b/android_webview/android_webview.gyp index eea495e..824e610 100644 --- a/android_webview/android_webview.gyp +++ b/android_webview/android_webview.gyp @@ -125,15 +125,17 @@ 'browser/aw_javascript_dialog_manager.h', 'browser/aw_login_delegate.cc', 'browser/aw_login_delegate.h', + 'browser/aw_pref_store.cc', + 'browser/aw_pref_store.h', 'browser/aw_quota_manager_bridge.cc', 'browser/aw_quota_manager_bridge.h', 'browser/aw_quota_permission_context.cc', 'browser/aw_quota_permission_context.h', - 'browser/aw_pref_store.cc', - 'browser/aw_pref_store.h', 'browser/aw_request_interceptor.cc', 'browser/aw_request_interceptor.h', 'browser/aw_result_codes.h', + 'browser/aw_web_preferences_populater.cc', + 'browser/aw_web_preferences_populater.h', 'browser/browser_view_renderer.h', 'browser/find_helper.cc', 'browser/find_helper.h', diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc index decdb73..97bdf1f 100644 --- a/android_webview/browser/aw_content_browser_client.cc +++ b/android_webview/browser/aw_content_browser_client.cc @@ -9,6 +9,7 @@ #include "android_webview/browser/aw_contents_client_bridge_base.h" #include "android_webview/browser/aw_cookie_access_policy.h" #include "android_webview/browser/aw_quota_permission_context.h" +#include "android_webview/browser/aw_web_preferences_populater.h" #include "android_webview/browser/jni_dependency_factory.h" #include "android_webview/browser/net_disk_cache_remover.h" #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h" @@ -19,12 +20,14 @@ #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" #include "content/public/common/url_constants.h" #include "grit/ui_resources.h" #include "net/android/network_library.h" #include "net/ssl/ssl_info.h" #include "ui/base/l10n/l10n_util_android.h" #include "ui/base/resource/resource_bundle.h" +#include "webkit/common/webpreferences.h" namespace android_webview { namespace { @@ -387,4 +390,15 @@ bool AwContentBrowserClient::AllowPepperSocketAPI( return false; } +void AwContentBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* rvh, + const GURL& url, + WebPreferences* web_prefs) { + if (!preferences_populater_.get()) { + preferences_populater_ = make_scoped_ptr(native_factory_-> + CreateWebPreferencesPopulater()); + } + preferences_populater_->PopulateFor( + content::WebContents::FromRenderViewHost(rvh), web_prefs); +} + } // namespace android_webview diff --git a/android_webview/browser/aw_content_browser_client.h b/android_webview/browser/aw_content_browser_client.h index 8321bcc..afa29cb 100644 --- a/android_webview/browser/aw_content_browser_client.h +++ b/android_webview/browser/aw_content_browser_client.h @@ -5,12 +5,15 @@ #ifndef ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_ #define ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_ +#include "android_webview/browser/aw_web_preferences_populater.h" #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "content/public/browser/content_browser_client.h" #include "net/url_request/url_request_job_factory.h" +struct WebPreferences; + namespace android_webview { class AwBrowserContext; @@ -150,11 +153,15 @@ class AwContentBrowserClient : public content::ContentBrowserClient { const GURL& url, bool private_api, const content::SocketPermissionRequest* params) OVERRIDE; + virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh, + const GURL& url, + WebPreferences* web_prefs) OVERRIDE; private: // Android WebView currently has a single global (non-off-the-record) browser // context. scoped_ptr<AwBrowserContext> browser_context_; + scoped_ptr<AwWebPreferencesPopulater> preferences_populater_; JniDependencyFactory* native_factory_; diff --git a/android_webview/browser/aw_web_preferences_populater.cc b/android_webview/browser/aw_web_preferences_populater.cc new file mode 100644 index 0000000..5f37936 --- /dev/null +++ b/android_webview/browser/aw_web_preferences_populater.cc @@ -0,0 +1,9 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "android_webview/browser/aw_web_preferences_populater.h" + +namespace android_webview { +AwWebPreferencesPopulater::~AwWebPreferencesPopulater() {} +} // namespace android_webview diff --git a/android_webview/browser/aw_web_preferences_populater.h b/android_webview/browser/aw_web_preferences_populater.h new file mode 100644 index 0000000..4f50694 --- /dev/null +++ b/android_webview/browser/aw_web_preferences_populater.h @@ -0,0 +1,27 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ANDROID_WEBVIEW_BROWSER_AW_WEB_PREFERENCES_POPULATER_H_ +#define ANDROID_WEBVIEW_BROWSER_AW_WEB_PREFERENCES_POPULATER_H_ + +struct WebPreferences; + +namespace content { +class WebContents; +} + +namespace android_webview { + +// Empty base class so this can be destroyed by AwContentBrowserClient. +class AwWebPreferencesPopulater { + public: + virtual ~AwWebPreferencesPopulater(); + + virtual void PopulateFor(content::WebContents* web_contents, + WebPreferences* web_prefs) = 0; +}; + +} // namespace android_webview + +#endif // ANDROID_WEBVIEW_BROWSER_AW_WEB_PREFERENCES_POPULATER_H_ diff --git a/android_webview/browser/jni_dependency_factory.h b/android_webview/browser/jni_dependency_factory.h index 4adcc25..e6e0ea9 100644 --- a/android_webview/browser/jni_dependency_factory.h +++ b/android_webview/browser/jni_dependency_factory.h @@ -15,6 +15,7 @@ namespace android_webview { class AwBrowserContext; class AwQuotaManagerBridge; +class AwWebPreferencesPopulater; // Used to create instances of objects under native that are used in browser. class JniDependencyFactory { @@ -27,6 +28,7 @@ class JniDependencyFactory { AwBrowserContext* browser_context) = 0; virtual content::WebContentsViewDelegate* CreateViewDelegate( content::WebContents* web_contents) = 0; + virtual AwWebPreferencesPopulater* CreateWebPreferencesPopulater() = 0; }; } // namespace android_webview diff --git a/android_webview/lib/main/aw_main_delegate.cc b/android_webview/lib/main/aw_main_delegate.cc index 83cd27d..7993e0c 100644 --- a/android_webview/lib/main/aw_main_delegate.cc +++ b/android_webview/lib/main/aw_main_delegate.cc @@ -12,6 +12,7 @@ #include "android_webview/native/aw_geolocation_permission_context.h" #include "android_webview/native/aw_quota_manager_bridge_impl.h" #include "android_webview/native/aw_web_contents_view_delegate.h" +#include "android_webview/native/aw_web_preferences_populater_impl.h" #include "android_webview/renderer/aw_content_renderer_client.h" #include "base/command_line.h" #include "base/lazy_instance.h" @@ -141,4 +142,8 @@ content::WebContentsViewDelegate* AwMainDelegate::CreateViewDelegate( return AwWebContentsViewDelegate::Create(web_contents); } +AwWebPreferencesPopulater* AwMainDelegate::CreateWebPreferencesPopulater() { + return new AwWebPreferencesPopulaterImpl(); +} + } // namespace android_webview diff --git a/android_webview/lib/main/aw_main_delegate.h b/android_webview/lib/main/aw_main_delegate.h index fbf3a73..8fe2b79 100644 --- a/android_webview/lib/main/aw_main_delegate.h +++ b/android_webview/lib/main/aw_main_delegate.h @@ -47,6 +47,7 @@ class AwMainDelegate : public content::ContentMainDelegate, AwBrowserContext* browser_context) OVERRIDE; virtual content::WebContentsViewDelegate* CreateViewDelegate( content::WebContents* web_contents) OVERRIDE; + virtual AwWebPreferencesPopulater* CreateWebPreferencesPopulater() OVERRIDE; scoped_ptr<content::BrowserMainRunner> browser_runner_; AwContentClient content_client_; diff --git a/android_webview/native/aw_settings.cc b/android_webview/native/aw_settings.cc index 292defe..14f49aa 100644 --- a/android_webview/native/aw_settings.cc +++ b/android_webview/native/aw_settings.cc @@ -8,6 +8,7 @@ #include "android_webview/native/aw_contents.h" #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "base/supports_user_data.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/render_view_host.h" @@ -24,13 +25,37 @@ using base::android::ScopedJavaLocalRef; namespace android_webview { +const void* kAwSettingsUserDataKey = &kAwSettingsUserDataKey; + +class AwSettingsUserData : public base::SupportsUserData::Data { + public: + AwSettingsUserData(AwSettings* ptr) : settings_(ptr) {} + + static AwSettings* GetSettings(content::WebContents* web_contents) { + if (!web_contents) + return NULL; + AwSettingsUserData* data = reinterpret_cast<AwSettingsUserData*>( + web_contents->GetUserData(kAwSettingsUserDataKey)); + return data ? data->settings_ : NULL; + } + + private: + AwSettings* settings_; +}; + AwSettings::AwSettings(JNIEnv* env, jobject obj, jint web_contents) : WebContentsObserver( reinterpret_cast<content::WebContents*>(web_contents)), aw_settings_(env, obj) { + reinterpret_cast<content::WebContents*>(web_contents)-> + SetUserData(kAwSettingsUserDataKey, new AwSettingsUserData(this)); } AwSettings::~AwSettings() { + if (web_contents()) { + web_contents()->SetUserData(kAwSettingsUserDataKey, NULL); + } + JNIEnv* env = base::android::AttachCurrentThread(); ScopedJavaLocalRef<jobject> scoped_obj = aw_settings_.get(env); jobject obj = scoped_obj.obj(); @@ -43,6 +68,10 @@ void AwSettings::Destroy(JNIEnv* env, jobject obj) { delete this; } +AwSettings* AwSettings::FromWebContents(content::WebContents* web_contents) { + return AwSettingsUserData::GetSettings(web_contents); +} + AwRenderViewHostExt* AwSettings::GetAwRenderViewHostExt() { if (!web_contents()) return NULL; AwContents* contents = AwContents::FromWebContents(web_contents()); @@ -100,160 +129,175 @@ void AwSettings::UpdateWebkitPreferencesLocked(JNIEnv* env, jobject obj) { content::RenderViewHost* render_view_host = web_contents()->GetRenderViewHost(); if (!render_view_host) return; - WebPreferences prefs = render_view_host->GetWebkitPreferences(); + render_view_host->UpdateWebkitPreferences( + render_view_host->GetWebkitPreferences()); +} + +void AwSettings::UpdateInitialPageScaleLocked(JNIEnv* env, jobject obj) { + AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt(); + if (!rvhe) return; - prefs.text_autosizing_enabled = + float initial_page_scale_percent = + Java_AwSettings_getInitialPageScalePercentLocked(env, obj); + if (initial_page_scale_percent == 0) { + rvhe->SetInitialPageScale(-1); + } else { + float dip_scale = static_cast<float>( + Java_AwSettings_getDIPScaleLocked(env, obj)); + rvhe->SetInitialPageScale(initial_page_scale_percent / dip_scale / 100.0f); + } +} + +void AwSettings::UpdateFormDataPreferencesLocked(JNIEnv* env, jobject obj) { + if (!web_contents()) return; + AwContents* contents = AwContents::FromWebContents(web_contents()); + if (!contents) return; + + contents->SetSaveFormData(Java_AwSettings_getSaveFormDataLocked(env, obj)); +} + +void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) { + // A single WebContents can normally have 0 to many RenderViewHost instances + // associated with it. + // This is important since there is only one RenderViewHostExt instance per + // WebContents (and not one RVHExt per RVH, as you might expect) and updating + // settings via RVHExt only ever updates the 'current' RVH. + // In android_webview we don't swap out the RVH on cross-site navigations, so + // we shouldn't have to deal with the multiple RVH per WebContents case. That + // in turn means that the newly created RVH is always the 'current' RVH + // (since we only ever go from 0 to 1 RVH instances) and hence the DCHECK. + DCHECK(web_contents()->GetRenderViewHost() == render_view_host); + + UpdateEverything(); +} + +void AwSettings::WebContentsDestroyed(content::WebContents* web_contents) { + delete this; +} + +void AwSettings::PopulateWebPreferences(WebPreferences* web_prefs) { + JNIEnv* env = base::android::AttachCurrentThread(); + CHECK(env); + + AwRenderViewHostExt* render_view_host_ext = GetAwRenderViewHostExt(); + if (!render_view_host_ext) return; + + ScopedJavaLocalRef<jobject> scoped_obj = aw_settings_.get(env); + jobject obj = scoped_obj.obj(); + if (!obj) return; + + web_prefs->text_autosizing_enabled = Java_AwSettings_getTextAutosizingEnabledLocked(env, obj); int text_size_percent = Java_AwSettings_getTextSizePercentLocked(env, obj); - if (prefs.text_autosizing_enabled) { - prefs.font_scale_factor = text_size_percent / 100.0f; - prefs.force_enable_zoom = text_size_percent >= 130; + if (web_prefs->text_autosizing_enabled) { + web_prefs->font_scale_factor = text_size_percent / 100.0f; + web_prefs->force_enable_zoom = text_size_percent >= 130; // Use the default zoom factor value when Text Autosizer is turned on. render_view_host_ext->SetTextZoomFactor(1); } else { - prefs.force_enable_zoom = false; + web_prefs->force_enable_zoom = false; render_view_host_ext->SetTextZoomFactor(text_size_percent / 100.0f); } - prefs.standard_font_family_map[webkit_glue::kCommonScript] = + web_prefs->standard_font_family_map[webkit_glue::kCommonScript] = ConvertJavaStringToUTF16( Java_AwSettings_getStandardFontFamilyLocked(env, obj)); - prefs.fixed_font_family_map[webkit_glue::kCommonScript] = + web_prefs->fixed_font_family_map[webkit_glue::kCommonScript] = ConvertJavaStringToUTF16( Java_AwSettings_getFixedFontFamilyLocked(env, obj)); - prefs.sans_serif_font_family_map[webkit_glue::kCommonScript] = + web_prefs->sans_serif_font_family_map[webkit_glue::kCommonScript] = ConvertJavaStringToUTF16( Java_AwSettings_getSansSerifFontFamilyLocked(env, obj)); - prefs.serif_font_family_map[webkit_glue::kCommonScript] = + web_prefs->serif_font_family_map[webkit_glue::kCommonScript] = ConvertJavaStringToUTF16( Java_AwSettings_getSerifFontFamilyLocked(env, obj)); - prefs.cursive_font_family_map[webkit_glue::kCommonScript] = + web_prefs->cursive_font_family_map[webkit_glue::kCommonScript] = ConvertJavaStringToUTF16( Java_AwSettings_getCursiveFontFamilyLocked(env, obj)); - prefs.fantasy_font_family_map[webkit_glue::kCommonScript] = + web_prefs->fantasy_font_family_map[webkit_glue::kCommonScript] = ConvertJavaStringToUTF16( Java_AwSettings_getFantasyFontFamilyLocked(env, obj)); - prefs.default_encoding = ConvertJavaStringToUTF8( + web_prefs->default_encoding = ConvertJavaStringToUTF8( Java_AwSettings_getDefaultTextEncodingLocked(env, obj)); - prefs.minimum_font_size = Java_AwSettings_getMinimumFontSizeLocked(env, obj); + web_prefs->minimum_font_size = + Java_AwSettings_getMinimumFontSizeLocked(env, obj); - prefs.minimum_logical_font_size = + web_prefs->minimum_logical_font_size = Java_AwSettings_getMinimumLogicalFontSizeLocked(env, obj); - prefs.default_font_size = Java_AwSettings_getDefaultFontSizeLocked(env, obj); + web_prefs->default_font_size = + Java_AwSettings_getDefaultFontSizeLocked(env, obj); - prefs.default_fixed_font_size = + web_prefs->default_fixed_font_size = Java_AwSettings_getDefaultFixedFontSizeLocked(env, obj); // Blink's LoadsImagesAutomatically and ImagesEnabled must be // set cris-cross to Android's. See // https://code.google.com/p/chromium/issues/detail?id=224317#c26 - prefs.loads_images_automatically = + web_prefs->loads_images_automatically = Java_AwSettings_getImagesEnabledLocked(env, obj); - prefs.images_enabled = + web_prefs->images_enabled = Java_AwSettings_getLoadsImagesAutomaticallyLocked(env, obj); - prefs.javascript_enabled = + web_prefs->javascript_enabled = Java_AwSettings_getJavaScriptEnabledLocked(env, obj); - prefs.allow_universal_access_from_file_urls = + web_prefs->allow_universal_access_from_file_urls = Java_AwSettings_getAllowUniversalAccessFromFileURLsLocked(env, obj); - prefs.allow_file_access_from_file_urls = + web_prefs->allow_file_access_from_file_urls = Java_AwSettings_getAllowFileAccessFromFileURLsLocked(env, obj); - prefs.javascript_can_open_windows_automatically = + web_prefs->javascript_can_open_windows_automatically = Java_AwSettings_getJavaScriptCanOpenWindowsAutomaticallyLocked(env, obj); - prefs.supports_multiple_windows = + web_prefs->supports_multiple_windows = Java_AwSettings_getSupportMultipleWindowsLocked(env, obj); - prefs.plugins_enabled = !Java_AwSettings_getPluginsDisabledLocked(env, obj); + web_prefs->plugins_enabled = + !Java_AwSettings_getPluginsDisabledLocked(env, obj); - prefs.application_cache_enabled = + web_prefs->application_cache_enabled = Java_AwSettings_getAppCacheEnabledLocked(env, obj); - prefs.local_storage_enabled = + web_prefs->local_storage_enabled = Java_AwSettings_getDomStorageEnabledLocked(env, obj); - prefs.databases_enabled = Java_AwSettings_getDatabaseEnabledLocked(env, obj); + web_prefs->databases_enabled = + Java_AwSettings_getDatabaseEnabledLocked(env, obj); - prefs.wide_viewport_quirk = true; - prefs.double_tap_to_zoom_enabled = prefs.use_wide_viewport = + web_prefs->wide_viewport_quirk = true; + web_prefs->double_tap_to_zoom_enabled = web_prefs->use_wide_viewport = Java_AwSettings_getUseWideViewportLocked(env, obj); - prefs.initialize_at_minimum_page_scale = + web_prefs->initialize_at_minimum_page_scale = Java_AwSettings_getLoadWithOverviewModeLocked(env, obj); - prefs.user_gesture_required_for_media_playback = + web_prefs->user_gesture_required_for_media_playback = Java_AwSettings_getMediaPlaybackRequiresUserGestureLocked(env, obj); ScopedJavaLocalRef<jstring> url = Java_AwSettings_getDefaultVideoPosterURLLocked(env, obj); - prefs.default_video_poster_url = url.obj() ? + web_prefs->default_video_poster_url = url.obj() ? GURL(ConvertJavaStringToUTF8(url)) : GURL(); bool support_quirks = Java_AwSettings_getSupportLegacyQuirksLocked(env, obj); - prefs.support_deprecated_target_density_dpi = support_quirks; - prefs.use_legacy_background_size_shorthand_behavior = support_quirks; - prefs.viewport_meta_layout_size_quirk = support_quirks; - prefs.viewport_meta_zero_values_quirk = support_quirks; - prefs.ignore_main_frame_overflow_hidden_quirk = support_quirks; + web_prefs->support_deprecated_target_density_dpi = support_quirks; + web_prefs->use_legacy_background_size_shorthand_behavior = support_quirks; + web_prefs->viewport_meta_layout_size_quirk = support_quirks; + web_prefs->viewport_meta_zero_values_quirk = support_quirks; + web_prefs->ignore_main_frame_overflow_hidden_quirk = support_quirks; - prefs.password_echo_enabled = + web_prefs->password_echo_enabled = Java_AwSettings_getPasswordEchoEnabled(env, obj); - - render_view_host->UpdateWebkitPreferences(prefs); -} - -void AwSettings::UpdateInitialPageScaleLocked(JNIEnv* env, jobject obj) { - AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt(); - if (!rvhe) return; - - float initial_page_scale_percent = - Java_AwSettings_getInitialPageScalePercentLocked(env, obj); - if (initial_page_scale_percent == 0) { - rvhe->SetInitialPageScale(-1); - } else { - float dip_scale = static_cast<float>( - Java_AwSettings_getDIPScaleLocked(env, obj)); - rvhe->SetInitialPageScale(initial_page_scale_percent / dip_scale / 100.0f); - } -} - -void AwSettings::UpdateFormDataPreferencesLocked(JNIEnv* env, jobject obj) { - if (!web_contents()) return; - AwContents* contents = AwContents::FromWebContents(web_contents()); - if (!contents) return; - - contents->SetSaveFormData(Java_AwSettings_getSaveFormDataLocked(env, obj)); -} - -void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) { - // A single WebContents can normally have 0 to many RenderViewHost instances - // associated with it. - // This is important since there is only one RenderViewHostExt instance per - // WebContents (and not one RVHExt per RVH, as you might expect) and updating - // settings via RVHExt only ever updates the 'current' RVH. - // In android_webview we don't swap out the RVH on cross-site navigations, so - // we shouldn't have to deal with the multiple RVH per WebContents case. That - // in turn means that the newly created RVH is always the 'current' RVH - // (since we only ever go from 0 to 1 RVH instances) and hence the DCHECK. - DCHECK(web_contents()->GetRenderViewHost() == render_view_host); - - UpdateEverything(); -} - -void AwSettings::WebContentsDestroyed(content::WebContents* web_contents) { - delete this; } static jint Init(JNIEnv* env, diff --git a/android_webview/native/aw_settings.h b/android_webview/native/aw_settings.h index 4c85c3e..29c477b 100644 --- a/android_webview/native/aw_settings.h +++ b/android_webview/native/aw_settings.h @@ -12,12 +12,16 @@ #include "base/memory/scoped_ptr.h" #include "content/public/browser/web_contents_observer.h" +struct WebPreferences; + namespace android_webview { class AwRenderViewHostExt; class AwSettings : public content::WebContentsObserver { public: + static AwSettings* FromWebContents(content::WebContents* web_contents); + AwSettings(JNIEnv* env, jobject obj, jint web_contents); virtual ~AwSettings(); @@ -31,6 +35,8 @@ class AwSettings : public content::WebContentsObserver { void UpdateWebkitPreferencesLocked(JNIEnv* env, jobject obj); void UpdateFormDataPreferencesLocked(JNIEnv* env, jobject obj); + void PopulateWebPreferences(WebPreferences* web_prefs); + private: AwRenderViewHostExt* GetAwRenderViewHostExt(); void UpdateEverything(); diff --git a/android_webview/native/aw_web_preferences_populater_impl.cc b/android_webview/native/aw_web_preferences_populater_impl.cc new file mode 100644 index 0000000..d8947c5 --- /dev/null +++ b/android_webview/native/aw_web_preferences_populater_impl.cc @@ -0,0 +1,26 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "android_webview/native/aw_web_preferences_populater_impl.h" + +#include "android_webview/native/aw_settings.h" + +namespace android_webview { + +AwWebPreferencesPopulaterImpl::AwWebPreferencesPopulaterImpl() { +} + +AwWebPreferencesPopulaterImpl::~AwWebPreferencesPopulaterImpl() { +} + +void AwWebPreferencesPopulaterImpl::PopulateFor( + content::WebContents* web_contents, + WebPreferences* web_prefs) { + AwSettings* aw_settings = AwSettings::FromWebContents(web_contents); + if (aw_settings) { + aw_settings->PopulateWebPreferences(web_prefs); + } +} + +} diff --git a/android_webview/native/aw_web_preferences_populater_impl.h b/android_webview/native/aw_web_preferences_populater_impl.h new file mode 100644 index 0000000..2a37045 --- /dev/null +++ b/android_webview/native/aw_web_preferences_populater_impl.h @@ -0,0 +1,34 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ANDROID_WEBVIEW_NATIVE_AW_WEB_PREFERENCES_POPULATER_IMPL_H_ +#define ANDROID_WEBVIEW_NATIVE_AW_WEB_PREFERENCES_POPULATER_IMPL_H_ + +#include "android_webview/browser/aw_web_preferences_populater.h" + +#include "base/compiler_specific.h" + +struct WebPreferences; + +namespace content { +class WebContents; +} + +namespace android_webview { + +class AwSettings; + +class AwWebPreferencesPopulaterImpl : public AwWebPreferencesPopulater { + public: + AwWebPreferencesPopulaterImpl(); + virtual ~AwWebPreferencesPopulaterImpl(); + + // AwWebPreferencesPopulater + virtual void PopulateFor(content::WebContents* web_contents, + WebPreferences* web_prefs) OVERRIDE; +}; + +} + +#endif // ANDROID_WEBVIEW_NATIVE_AW_WEB_PREFERENCES_POPULATER_IMPL_H_ diff --git a/android_webview/native/webview_native.gyp b/android_webview/native/webview_native.gyp index 1e1d5f8..f326320 100644 --- a/android_webview/native/webview_native.gyp +++ b/android_webview/native/webview_native.gyp @@ -64,6 +64,8 @@ 'aw_web_contents_delegate.h', 'aw_web_contents_view_delegate.cc', 'aw_web_contents_view_delegate.h', + 'aw_web_preferences_populater_impl.cc', + 'aw_web_preferences_populater_impl.h', 'cookie_manager.cc', 'cookie_manager.h', 'input_stream_impl.cc', |