No need to add new methods to WebContentsPreferences
This commit is contained in:
parent
cee1c459c7
commit
72440d4ae7
3 changed files with 19 additions and 55 deletions
|
@ -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<base::string16>& values,
|
||||
const std::vector<base::string16>& 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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue