mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Use Chrome file dialogs on all platforms and runtimes (fixes issue #3314)
All file dialogs irrespective of source, platform and runtime will now be routed through CefFileDialogManager and trigger CefDialogHandler callbacks (see issue #3293). Adds Chrome runtime support for CefBrowserHost::RunFileDialog and CefDialogHandler callbacks. Adds Alloy runtime support for internal GTK file and print dialogs on Linux subject to the following limitations: 1. Internal GTK implementation: - Cannot be used with multi-threaded-message-loop because Chromium's internal GTK implementation is not thread-safe (does not use GDK threads). - Dialogs will not be modal to application windows when used with off-screen rendering due to lack of access to the client's top-level GtkWindow. 2. Cefclient CefDialogHandler implementation: - Cannot be used with Views because it requires a top-level GtkWindow. Due to the above limitations no dialog implementation is currently provided for Views + multi-threaded-message-loop on Linux. In cases where both implementations are supported the cefclient version is now behind an optional `--use-client-dialogs` command-line flag. Expressly forbids multiple simultaneous file dialogs with the internal platform implementation which uses modal dialogs. CefDialogHandler will still be notified and can optionally handle each request without a modal dialog (see issue #3154). Removes some RunFileDialog parameters that are not supported by the Chrome file dialog implementation (selected_accept_filter parameter, cef_file_dialog_mode_t overwrite/read-only flags).
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/devtools/devtools_manager.h"
|
||||
#include "libcef/browser/file_dialog_manager.h"
|
||||
#include "libcef/browser/frame_host_impl.h"
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
|
||||
@@ -156,6 +157,11 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
CefRefPtr<CefRequestContext> GetRequestContext() override;
|
||||
bool HasView() override;
|
||||
void SetFocus(bool focus) override;
|
||||
void RunFileDialog(FileDialogMode mode,
|
||||
const CefString& title,
|
||||
const CefString& default_file_path,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) override;
|
||||
void StartDownload(const CefString& url) override;
|
||||
void DownloadImage(const CefString& image_url,
|
||||
bool is_favicon,
|
||||
@@ -234,6 +240,22 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
virtual void OnSetFocus(cef_focus_source_t source) = 0;
|
||||
void ViewText(const std::string& text);
|
||||
|
||||
// Calls CefFileDialogManager methods.
|
||||
void RunFileChooserForBrowser(
|
||||
const blink::mojom::FileChooserParams& params,
|
||||
CefFileDialogManager::RunFileChooserCallback callback);
|
||||
void RunSelectFile(ui::SelectFileDialog::Listener* listener,
|
||||
std::unique_ptr<ui::SelectFilePolicy> policy,
|
||||
ui::SelectFileDialog::Type type,
|
||||
const std::u16string& title,
|
||||
const base::FilePath& default_path,
|
||||
const ui::SelectFileDialog::FileTypeInfo* file_types,
|
||||
int file_type_index,
|
||||
const base::FilePath::StringType& default_extension,
|
||||
gfx::NativeWindow owning_window,
|
||||
void* params);
|
||||
void SelectFileListenerDestroyed(ui::SelectFileDialog::Listener* listener);
|
||||
|
||||
// Called from CefBrowserInfoManager::MaybeAllowNavigation.
|
||||
virtual bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
||||
bool is_guest_view,
|
||||
@@ -269,13 +291,27 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
}
|
||||
|
||||
// Returns the Widget owner for the browser window. Only used with windowed
|
||||
// rendering.
|
||||
// browsers.
|
||||
views::Widget* GetWindowWidget() const;
|
||||
|
||||
// Returns the BrowserView associated with this browser. Only used with Views-
|
||||
// based browsers.
|
||||
CefRefPtr<CefBrowserView> GetBrowserView() const;
|
||||
|
||||
// Returns the top-level native window for this browser. With windowed
|
||||
// browsers this will be an aura::Window* on Aura platforms (Windows/Linux)
|
||||
// and an NSWindow wrapper object from native_widget_types.h on MacOS. With
|
||||
// windowless browsers this method will always return an empty value.
|
||||
gfx::NativeWindow GetTopLevelNativeWindow() const;
|
||||
|
||||
// Returns true if this browser is currently focused. A browser is considered
|
||||
// focused when the top-level RenderFrameHost is in the parent chain of the
|
||||
// currently focused RFH within the frame tree. In addition, its associated
|
||||
// RenderWidgetHost must also be focused. With windowed browsers only one
|
||||
// browser should be focused at a time. With windowless browsers this relies
|
||||
// on the client to properly configure focus state.
|
||||
bool IsFocused() const;
|
||||
|
||||
protected:
|
||||
bool EnsureDevToolsManager();
|
||||
void InitializeDevToolsRegistrationOnUIThread(
|
||||
@@ -286,6 +322,9 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
|
||||
void SetFocusInternal(bool focus);
|
||||
|
||||
// Create the CefFileDialogManager if it doesn't already exist.
|
||||
bool EnsureFileDialogManager();
|
||||
|
||||
// Thread-safe members.
|
||||
CefBrowserSettings settings_;
|
||||
CefRefPtr<CefClient> client_;
|
||||
@@ -301,6 +340,9 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
// Only accessed on the UI thread.
|
||||
base::ObserverList<Observer> observers_;
|
||||
|
||||
// Used for creating and managing file dialogs.
|
||||
std::unique_ptr<CefFileDialogManager> file_dialog_manager_;
|
||||
|
||||
// Volatile state accessed from multiple threads. All access must be protected
|
||||
// by |state_lock_|.
|
||||
base::Lock state_lock_;
|
||||
|
Reference in New Issue
Block a user