diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index efe3ba0fb77b..0ae5092b4397 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -11,6 +11,7 @@ #include "atom/browser/native_browser_view_views.h" #include "atom/browser/ui/views/menu_bar.h" #include "atom/browser/web_contents_preferences.h" +#include "atom/browser/web_view_manager.h" #include "atom/browser/window_list.h" #include "atom/common/color_util.h" #include "atom/common/draggable_region.h" @@ -1362,13 +1363,25 @@ void NativeWindowViews::ShowAutofillPopup( const gfx::RectF& bounds, const std::vector& values, const std::vector& labels) { - WebContentsPreferences* web_preferences = - WebContentsPreferences::FromWebContents(web_contents); + const auto* web_preferences = + WebContentsPreferences::FromWebContents(web_contents)->web_preferences(); - bool is_offsceen = web_preferences->IsOffScreen(web_contents); - bool is_embedder_offscreen = - web_preferences->IsGuest(web_contents) && - web_preferences->IsOffScreen(web_preferences->Embedder(web_contents)); + bool is_offsceen = false; + web_preferences->GetBoolean("offscreen", &is_offsceen); + int guest_instance_id = 0; + web_preferences->GetInteger(options::kGuestInstanceID, &guest_instance_id); + + bool is_embedder_offscreen = false; + if (guest_instance_id) { + auto manager = WebViewManager::GetWebViewManager(web_contents); + if (manager) { + auto embedder = manager->GetEmbedder(guest_instance_id); + if (embedder) { + is_embedder_offscreen = WebContentsPreferences::IsPreferenceEnabled( + "offscreen", embedder); + } + } + } autofill_popup_->CreateView( frame_host, diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 83bd787b85ef..cc621625818f 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -239,52 +239,6 @@ bool WebContentsPreferences::IsPluginsEnabled( return IsPreferenceEnabled("plugins", web_contents); } -bool WebContentsPreferences::IsOffScreen( - content::WebContents* web_contents) { - return IsPreferenceEnabled("offscreen", web_contents); -} - -bool WebContentsPreferences::IsGuest( - content::WebContents* web_contents) { - WebContentsPreferences* self; - if (!web_contents) - return false; - - self = FromWebContents(web_contents); - if (!self) - return false; - - base::DictionaryValue& web_preferences = self->web_preferences_; - int guest_instance_id = 0; - return web_preferences.GetInteger( - options::kGuestInstanceID, &guest_instance_id); -} - -content::WebContents* WebContentsPreferences::Embedder( - content::WebContents* web_contents) { - WebContentsPreferences* self; - if (!web_contents) - return nullptr; - - self = FromWebContents(web_contents); - if (!self) - return nullptr; - - base::DictionaryValue& web_preferences = self->web_preferences_; - int g_instance_id = 0; - if (web_preferences.GetInteger(options::kGuestInstanceID, &g_instance_id)) { - auto manager = WebViewManager::GetWebViewManager(web_contents); - if (manager) { - auto embedder = manager->GetEmbedder(g_instance_id); - if (embedder) { - return embedder; - } - } - } - - return nullptr; -} - bool WebContentsPreferences::DisablePopups( content::WebContents* web_contents) { return IsPreferenceEnabled("disablePopups", web_contents); diff --git a/atom/browser/web_contents_preferences.h b/atom/browser/web_contents_preferences.h index 4fe34790c580..366aa1d95208 100644 --- a/atom/browser/web_contents_preferences.h +++ b/atom/browser/web_contents_preferences.h @@ -43,9 +43,6 @@ class WebContentsPreferences static bool UsesNativeWindowOpen(content::WebContents* web_contents); static bool DisablePopups(content::WebContents* web_contents); static bool IsPluginsEnabled(content::WebContents* web_contents); - static bool IsOffScreen(content::WebContents* web_contents); - static bool IsGuest(content::WebContents* web_contents); - static content::WebContents* Embedder(content::WebContents* web_contents); // Modify the WebPreferences according to |web_contents|'s preferences. static void OverrideWebkitPrefs(