restructure code to use web_preferences if possible
This commit is contained in:
parent
cafb9477b0
commit
f8b3009ebf
16 changed files with 88 additions and 47 deletions
|
@ -933,10 +933,9 @@ bool WebContents::OnMessageReceived(const IPC::Message& message,
|
||||||
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
||||||
if (!relay)
|
if (!relay)
|
||||||
return false;
|
return false;
|
||||||
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContents, message, frame_host)
|
|
||||||
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
|
|
||||||
IPC_END_MESSAGE_MAP()
|
|
||||||
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, frame_host)
|
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, frame_host)
|
||||||
|
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_ShowPopup,
|
||||||
|
relay->window.get(), NativeWindow::ShowAutofillPopup)
|
||||||
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_HidePopup,
|
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_HidePopup,
|
||||||
relay->window.get(), NativeWindow::HideAutofillPopup)
|
relay->window.get(), NativeWindow::HideAutofillPopup)
|
||||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||||
|
@ -945,16 +944,6 @@ bool WebContents::OnMessageReceived(const IPC::Message& message,
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::ShowAutofillPopup(
|
|
||||||
content::RenderFrameHost* frame_host,
|
|
||||||
const gfx::RectF& bounds,
|
|
||||||
const std::vector<base::string16>& values,
|
|
||||||
const std::vector<base::string16>& labels) {
|
|
||||||
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
|
||||||
if (relay)
|
|
||||||
relay->window->ShowAutofillPopup(frame_host, this, bounds, values, labels);
|
|
||||||
}
|
|
||||||
|
|
||||||
// There are three ways of destroying a webContents:
|
// There are three ways of destroying a webContents:
|
||||||
// 1. call webContents.destroy();
|
// 1. call webContents.destroy();
|
||||||
// 2. garbage collection;
|
// 2. garbage collection;
|
||||||
|
@ -1634,10 +1623,6 @@ bool WebContents::IsOffScreen() const {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::IsOffScreenOrEmbedderOffscreen() const {
|
|
||||||
return IsOffScreen() || (IsGuest() && embedder_ && embedder_->IsOffScreen());
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
|
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
|
||||||
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
|
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
|
|
||||||
// Methods for offscreen rendering
|
// Methods for offscreen rendering
|
||||||
bool IsOffScreen() const;
|
bool IsOffScreen() const;
|
||||||
bool IsOffScreenOrEmbedderOffscreen() const;
|
|
||||||
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
||||||
void StartPainting();
|
void StartPainting();
|
||||||
void StopPainting();
|
void StopPainting();
|
||||||
|
@ -358,12 +357,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
void DevToolsOpened() override;
|
void DevToolsOpened() override;
|
||||||
void DevToolsClosed() override;
|
void DevToolsClosed() override;
|
||||||
|
|
||||||
void ShowAutofillPopup(
|
|
||||||
content::RenderFrameHost* frame_host,
|
|
||||||
const gfx::RectF& bounds,
|
|
||||||
const std::vector<base::string16>& values,
|
|
||||||
const std::vector<base::string16>& labels);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AtomBrowserContext* GetBrowserContext() const;
|
AtomBrowserContext* GetBrowserContext() const;
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
||||||
// Show save dialog if save path was not set already on item
|
// Show save dialog if save path was not set already on item
|
||||||
file_dialog::DialogSettings settings;
|
file_dialog::DialogSettings settings;
|
||||||
settings.parent_window = window;
|
settings.parent_window = window;
|
||||||
|
settings.force_detached = window->IsOffScreenDummy();
|
||||||
settings.title = item->GetURL().spec();
|
settings.title = item->GetURL().spec();
|
||||||
settings.default_path = default_path;
|
settings.default_path = default_path;
|
||||||
if (path.empty() && file_dialog::ShowSaveDialog(settings, &path)) {
|
if (path.empty() && file_dialog::ShowSaveDialog(settings, &path)) {
|
||||||
|
|
|
@ -242,7 +242,8 @@ void CommonWebContentsDelegate::RunFileChooser(
|
||||||
content::RenderFrameHost* render_frame_host,
|
content::RenderFrameHost* render_frame_host,
|
||||||
const content::FileChooserParams& params) {
|
const content::FileChooserParams& params) {
|
||||||
if (!web_dialog_helper_)
|
if (!web_dialog_helper_)
|
||||||
web_dialog_helper_.reset(new WebDialogHelper(owner_window()));
|
web_dialog_helper_.reset(new WebDialogHelper(owner_window(),
|
||||||
|
owner_window()->IsOffScreenDummy()));
|
||||||
web_dialog_helper_->RunFileChooser(render_frame_host, params);
|
web_dialog_helper_->RunFileChooser(render_frame_host, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +251,8 @@ void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest,
|
||||||
int request_id,
|
int request_id,
|
||||||
const base::FilePath& path) {
|
const base::FilePath& path) {
|
||||||
if (!web_dialog_helper_)
|
if (!web_dialog_helper_)
|
||||||
web_dialog_helper_.reset(new WebDialogHelper(owner_window()));
|
web_dialog_helper_.reset(new WebDialogHelper(owner_window(),
|
||||||
|
owner_window()->IsOffScreenDummy()));
|
||||||
web_dialog_helper_->EnumerateDirectory(guest, request_id, path);
|
web_dialog_helper_->EnumerateDirectory(guest, request_id, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,6 +300,7 @@ void CommonWebContentsDelegate::DevToolsSaveToFile(
|
||||||
} else {
|
} else {
|
||||||
file_dialog::DialogSettings settings;
|
file_dialog::DialogSettings settings;
|
||||||
settings.parent_window = owner_window();
|
settings.parent_window = owner_window();
|
||||||
|
settings.force_detached = owner_window()->IsOffScreenDummy();
|
||||||
settings.title = url;
|
settings.title = url;
|
||||||
settings.default_path = base::FilePath::FromUTF8Unsafe(url);
|
settings.default_path = base::FilePath::FromUTF8Unsafe(url);
|
||||||
if (!file_dialog::ShowSaveDialog(settings, &path)) {
|
if (!file_dialog::ShowSaveDialog(settings, &path)) {
|
||||||
|
@ -364,6 +367,7 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
|
||||||
std::vector<base::FilePath> paths;
|
std::vector<base::FilePath> paths;
|
||||||
file_dialog::DialogSettings settings;
|
file_dialog::DialogSettings settings;
|
||||||
settings.parent_window = owner_window();
|
settings.parent_window = owner_window();
|
||||||
|
settings.force_detached = owner_window()->IsOffScreenDummy();
|
||||||
settings.properties = file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
|
settings.properties = file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
|
||||||
if (!file_dialog::ShowOpenDialog(settings, &paths))
|
if (!file_dialog::ShowOpenDialog(settings, &paths))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -232,7 +232,6 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
const content::NativeWebKeyboardEvent& event) {}
|
const content::NativeWebKeyboardEvent& event) {}
|
||||||
virtual void ShowAutofillPopup(
|
virtual void ShowAutofillPopup(
|
||||||
content::RenderFrameHost* frame_host,
|
content::RenderFrameHost* frame_host,
|
||||||
atom::api::WebContents* web_contents,
|
|
||||||
const gfx::RectF& bounds,
|
const gfx::RectF& bounds,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels) {}
|
const std::vector<base::string16>& labels) {}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "atom/browser/api/atom_api_web_contents.h"
|
#include "atom/browser/api/atom_api_web_contents.h"
|
||||||
#include "atom/browser/native_browser_view_views.h"
|
#include "atom/browser/native_browser_view_views.h"
|
||||||
#include "atom/browser/ui/views/menu_bar.h"
|
#include "atom/browser/ui/views/menu_bar.h"
|
||||||
|
#include "atom/browser/web_contents_preferences.h"
|
||||||
#include "atom/browser/window_list.h"
|
#include "atom/browser/window_list.h"
|
||||||
#include "atom/common/color_util.h"
|
#include "atom/common/color_util.h"
|
||||||
#include "atom/common/draggable_region.h"
|
#include "atom/common/draggable_region.h"
|
||||||
|
@ -1357,13 +1358,19 @@ void NativeWindowViews::HandleKeyboardEvent(
|
||||||
|
|
||||||
void NativeWindowViews::ShowAutofillPopup(
|
void NativeWindowViews::ShowAutofillPopup(
|
||||||
content::RenderFrameHost* frame_host,
|
content::RenderFrameHost* frame_host,
|
||||||
atom::api::WebContents* web_contents,
|
|
||||||
const gfx::RectF& bounds,
|
const gfx::RectF& bounds,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels) {
|
const std::vector<base::string16>& labels) {
|
||||||
|
WebContentsPreferences* web_preferences =
|
||||||
|
WebContentsPreferences::FromWebContents(web_contents());
|
||||||
|
|
||||||
|
bool isOffsceen = web_preferences->IsOffScreen(web_contents());
|
||||||
|
bool isEmbedderOffscreen = web_preferences->IsGuest(web_contents()) &&
|
||||||
|
web_preferences->IsOffScreen(web_preferences->Embedder(web_contents()));
|
||||||
|
|
||||||
autofill_popup_->CreateView(
|
autofill_popup_->CreateView(
|
||||||
frame_host,
|
frame_host,
|
||||||
web_contents->IsOffScreenOrEmbedderOffscreen(),
|
isOffsceen || isEmbedderOffscreen,
|
||||||
widget(),
|
widget(),
|
||||||
bounds);
|
bounds);
|
||||||
autofill_popup_->SetItems(values, labels);
|
autofill_popup_->SetItems(values, labels);
|
||||||
|
|
|
@ -190,7 +190,6 @@ class NativeWindowViews : public NativeWindow,
|
||||||
const content::NativeWebKeyboardEvent& event) override;
|
const content::NativeWebKeyboardEvent& event) override;
|
||||||
void ShowAutofillPopup(
|
void ShowAutofillPopup(
|
||||||
content::RenderFrameHost* frame_host,
|
content::RenderFrameHost* frame_host,
|
||||||
atom::api::WebContents* web_contents,
|
|
||||||
const gfx::RectF& bounds,
|
const gfx::RectF& bounds,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels) override;
|
const std::vector<base::string16>& labels) override;
|
||||||
|
|
|
@ -79,12 +79,12 @@ void OffScreenOutputDevice::EndPaint() {
|
||||||
OnPaint(damage_rect_);
|
OnPaint(damage_rect_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenOutputDevice::SetActive(bool active) {
|
void OffScreenOutputDevice::SetActive(bool active, bool paint) {
|
||||||
if (active == active_)
|
if (active == active_)
|
||||||
return;
|
return;
|
||||||
active_ = active;
|
active_ = active;
|
||||||
|
|
||||||
if (active_)
|
if (active_ && paint)
|
||||||
OnPaint(gfx::Rect(viewport_pixel_size_));
|
OnPaint(gfx::Rect(viewport_pixel_size_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class OffScreenOutputDevice : public cc::SoftwareOutputDevice {
|
||||||
SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override;
|
SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override;
|
||||||
void EndPaint() override;
|
void EndPaint() override;
|
||||||
|
|
||||||
void SetActive(bool active);
|
void SetActive(bool active, bool paint);
|
||||||
void OnPaint(const gfx::Rect& damage_rect);
|
void OnPaint(const gfx::Rect& damage_rect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -549,7 +549,7 @@ void OffScreenRenderWidgetHostView::SubmitCompositorFrame(
|
||||||
if (!frame.render_pass_list.empty()) {
|
if (!frame.render_pass_list.empty()) {
|
||||||
if (software_output_device_) {
|
if (software_output_device_) {
|
||||||
if (!begin_frame_timer_.get() || IsPopupWidget()) {
|
if (!begin_frame_timer_.get() || IsPopupWidget()) {
|
||||||
software_output_device_->SetActive(painting_);
|
software_output_device_->SetActive(painting_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The compositor will draw directly to the SoftwareOutputDevice which
|
// The compositor will draw directly to the SoftwareOutputDevice which
|
||||||
|
@ -935,7 +935,7 @@ void OffScreenRenderWidgetHostView::SetNeedsBeginFrames(
|
||||||
begin_frame_timer_->SetActive(needs_begin_frames);
|
begin_frame_timer_->SetActive(needs_begin_frames);
|
||||||
|
|
||||||
if (software_output_device_) {
|
if (software_output_device_) {
|
||||||
software_output_device_->SetActive(needs_begin_frames && painting_);
|
software_output_device_->SetActive(needs_begin_frames && painting_, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1151,7 +1151,7 @@ void OffScreenRenderWidgetHostView::SetPainting(bool painting) {
|
||||||
painting_ = painting;
|
painting_ = painting;
|
||||||
|
|
||||||
if (software_output_device_) {
|
if (software_output_device_) {
|
||||||
software_output_device_->SetActive(painting_);
|
software_output_device_->SetActive(painting_, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct DialogSettings {
|
||||||
Filters filters;
|
Filters filters;
|
||||||
int properties = 0;
|
int properties = 0;
|
||||||
bool shows_tag_field = true;
|
bool shows_tag_field = true;
|
||||||
|
bool force_detached = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ShowOpenDialog(const DialogSettings& settings,
|
bool ShowOpenDialog(const DialogSettings& settings,
|
||||||
|
|
|
@ -110,13 +110,13 @@ void SetupDialogForProperties(NSOpenPanel* dialog, int properties) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run modal dialog with parent window and return user's choice.
|
// Run modal dialog with parent window and return user's choice.
|
||||||
int RunModalDialog(NSSavePanel* dialog, atom::NativeWindow* parent_window) {
|
int RunModalDialog(NSSavePanel* dialog, const DialogSettings& settings) {
|
||||||
__block int chosen = NSFileHandlingPanelCancelButton;
|
__block int chosen = NSFileHandlingPanelCancelButton;
|
||||||
if (!parent_window || !parent_window->GetNativeWindow() ||
|
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||||
parent_window->IsOffScreenDummy()) {
|
settings.force_detached) {
|
||||||
chosen = [dialog runModal];
|
chosen = [dialog runModal];
|
||||||
} else {
|
} else {
|
||||||
NSWindow* window = parent_window->GetNativeWindow();
|
NSWindow* window = settings.parent_window->GetNativeWindow();
|
||||||
|
|
||||||
[dialog beginSheetModalForWindow:window
|
[dialog beginSheetModalForWindow:window
|
||||||
completionHandler:^(NSInteger c) {
|
completionHandler:^(NSInteger c) {
|
||||||
|
@ -146,7 +146,7 @@ bool ShowOpenDialog(const DialogSettings& settings,
|
||||||
SetupDialog(dialog, settings);
|
SetupDialog(dialog, settings);
|
||||||
SetupDialogForProperties(dialog, settings.properties);
|
SetupDialogForProperties(dialog, settings.properties);
|
||||||
|
|
||||||
int chosen = RunModalDialog(dialog, settings.parent_window);
|
int chosen = RunModalDialog(dialog, settings);
|
||||||
if (chosen == NSFileHandlingPanelCancelButton)
|
if (chosen == NSFileHandlingPanelCancelButton)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ void ShowOpenDialog(const DialogSettings& settings,
|
||||||
__block OpenDialogCallback callback = c;
|
__block OpenDialogCallback callback = c;
|
||||||
|
|
||||||
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||||
settings.parent_window->IsOffScreenDummy()) {
|
settings.force_detached) {
|
||||||
int chosen = [dialog runModal];
|
int chosen = [dialog runModal];
|
||||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||||
callback.Run(false, std::vector<base::FilePath>());
|
callback.Run(false, std::vector<base::FilePath>());
|
||||||
|
@ -197,7 +197,7 @@ bool ShowSaveDialog(const DialogSettings& settings,
|
||||||
|
|
||||||
SetupDialog(dialog, settings);
|
SetupDialog(dialog, settings);
|
||||||
|
|
||||||
int chosen = RunModalDialog(dialog, settings.parent_window);
|
int chosen = RunModalDialog(dialog, settings);
|
||||||
if (chosen == NSFileHandlingPanelCancelButton || ![[dialog URL] isFileURL])
|
if (chosen == NSFileHandlingPanelCancelButton || ![[dialog URL] isFileURL])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ void ShowSaveDialog(const DialogSettings& settings,
|
||||||
__block SaveDialogCallback callback = c;
|
__block SaveDialogCallback callback = c;
|
||||||
|
|
||||||
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||||
settings.parent_window->IsOffScreenDummy()) {
|
settings.force_detached) {
|
||||||
int chosen = [dialog runModal];
|
int chosen = [dialog runModal];
|
||||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||||
callback.Run(false, base::FilePath());
|
callback.Run(false, base::FilePath());
|
||||||
|
|
|
@ -239,6 +239,52 @@ bool WebContentsPreferences::IsPluginsEnabled(
|
||||||
return IsPreferenceEnabled("plugins", web_contents);
|
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(
|
bool WebContentsPreferences::DisablePopups(
|
||||||
content::WebContents* web_contents) {
|
content::WebContents* web_contents) {
|
||||||
return IsPreferenceEnabled("disablePopups", web_contents);
|
return IsPreferenceEnabled("disablePopups", web_contents);
|
||||||
|
|
|
@ -43,6 +43,9 @@ class WebContentsPreferences
|
||||||
static bool UsesNativeWindowOpen(content::WebContents* web_contents);
|
static bool UsesNativeWindowOpen(content::WebContents* web_contents);
|
||||||
static bool DisablePopups(content::WebContents* web_contents);
|
static bool DisablePopups(content::WebContents* web_contents);
|
||||||
static bool IsPluginsEnabled(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.
|
// Modify the WebPreferences according to |web_contents|'s preferences.
|
||||||
static void OverrideWebkitPrefs(
|
static void OverrideWebkitPrefs(
|
||||||
|
|
|
@ -182,8 +182,9 @@ file_dialog::Filters GetFileTypesFromAcceptType(
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
WebDialogHelper::WebDialogHelper(NativeWindow* window)
|
WebDialogHelper::WebDialogHelper(NativeWindow* window, bool offscreen)
|
||||||
: window_(window),
|
: window_(window),
|
||||||
|
offscreen_(offscreen),
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +198,7 @@ void WebDialogHelper::RunFileChooser(
|
||||||
std::vector<content::FileChooserFileInfo> result;
|
std::vector<content::FileChooserFileInfo> result;
|
||||||
|
|
||||||
file_dialog::DialogSettings settings;
|
file_dialog::DialogSettings settings;
|
||||||
|
settings.force_detached = offscreen_;
|
||||||
settings.filters = GetFileTypesFromAcceptType(params.accept_types);
|
settings.filters = GetFileTypesFromAcceptType(params.accept_types);
|
||||||
settings.parent_window = window_;
|
settings.parent_window = window_;
|
||||||
settings.title = base::UTF16ToUTF8(params.title);
|
settings.title = base::UTF16ToUTF8(params.title);
|
||||||
|
|
|
@ -23,7 +23,7 @@ class NativeWindow;
|
||||||
|
|
||||||
class WebDialogHelper {
|
class WebDialogHelper {
|
||||||
public:
|
public:
|
||||||
explicit WebDialogHelper(NativeWindow* window);
|
explicit WebDialogHelper(NativeWindow* window, bool offscreen);
|
||||||
~WebDialogHelper();
|
~WebDialogHelper();
|
||||||
|
|
||||||
void RunFileChooser(content::RenderFrameHost* render_frame_host,
|
void RunFileChooser(content::RenderFrameHost* render_frame_host,
|
||||||
|
@ -34,6 +34,7 @@ class WebDialogHelper {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NativeWindow* window_;
|
NativeWindow* window_;
|
||||||
|
bool offscreen_;
|
||||||
|
|
||||||
base::WeakPtrFactory<WebDialogHelper> weak_factory_;
|
base::WeakPtrFactory<WebDialogHelper> weak_factory_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue