2020-07-04 20:21:34 +02:00
|
|
|
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2011 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 CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
|
|
|
|
|
2022-06-02 11:49:50 +02:00
|
|
|
#include "libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.h"
|
2020-07-04 20:21:34 +02:00
|
|
|
#include "libcef/browser/browser_platform_delegate.h"
|
|
|
|
|
|
|
|
#include "base/memory/weak_ptr.h"
|
2022-02-17 19:17:29 +01:00
|
|
|
#include "components/find_in_page/find_notification_details.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
#include "content/public/browser/web_contents.h"
|
|
|
|
#include "ui/gfx/geometry/size.h"
|
2020-07-04 20:21:34 +02:00
|
|
|
|
|
|
|
// Implementation of Alloy-based browser functionality.
|
|
|
|
class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
|
|
|
public:
|
2021-12-06 21:40:25 +01:00
|
|
|
CefBrowserPlatformDelegateAlloy(const CefBrowserPlatformDelegateAlloy&) =
|
|
|
|
delete;
|
|
|
|
CefBrowserPlatformDelegateAlloy& operator=(
|
|
|
|
const CefBrowserPlatformDelegateAlloy&) = delete;
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
content::WebContents* CreateWebContents(CefBrowserCreateParams& create_params,
|
|
|
|
bool& own_web_contents) override;
|
2020-07-04 20:21:34 +02:00
|
|
|
void WebContentsCreated(content::WebContents* web_contents,
|
|
|
|
bool owned) override;
|
|
|
|
void AddNewContents(content::WebContents* source,
|
|
|
|
std::unique_ptr<content::WebContents> new_contents,
|
|
|
|
const GURL& target_url,
|
|
|
|
WindowOpenDisposition disposition,
|
2022-09-26 21:30:45 +02:00
|
|
|
const blink::mojom::WindowFeatures& window_features,
|
2020-07-04 20:21:34 +02:00
|
|
|
bool user_gesture,
|
|
|
|
bool* was_blocked) override;
|
2021-07-23 18:40:13 +02:00
|
|
|
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
|
|
bool is_main_frame_navigation) override;
|
2020-07-04 20:21:34 +02:00
|
|
|
void RenderViewReady() override;
|
2020-09-25 03:40:47 +02:00
|
|
|
void BrowserCreated(CefBrowserHostBase* browser) override;
|
2020-07-04 20:21:34 +02:00
|
|
|
void CreateExtensionHost(const extensions::Extension* extension,
|
|
|
|
const GURL& url,
|
2021-04-21 00:52:34 +02:00
|
|
|
extensions::mojom::ViewType host_type) override;
|
2020-07-04 20:21:34 +02:00
|
|
|
extensions::ExtensionHost* GetExtensionHost() const override;
|
2020-09-25 03:40:47 +02:00
|
|
|
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
2022-06-02 11:49:50 +02:00
|
|
|
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
|
|
|
|
const override;
|
2020-07-04 20:21:34 +02:00
|
|
|
void SendCaptureLostEvent() override;
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC))
|
2020-07-04 20:21:34 +02:00
|
|
|
void NotifyMoveOrResizeStarted() override;
|
|
|
|
#endif
|
|
|
|
bool PreHandleGestureEvent(content::WebContents* source,
|
|
|
|
const blink::WebGestureEvent& event) override;
|
|
|
|
bool IsNeverComposited(content::WebContents* web_contents) override;
|
2024-04-17 18:01:26 +02:00
|
|
|
bool IsAlloyStyle() const override { return true; }
|
2020-07-04 20:21:34 +02:00
|
|
|
void SetAutoResizeEnabled(bool enabled,
|
|
|
|
const CefSize& min_size,
|
|
|
|
const CefSize& max_size) override;
|
2022-02-17 19:17:29 +01:00
|
|
|
void Find(const CefString& searchText,
|
2020-07-04 20:21:34 +02:00
|
|
|
bool forward,
|
|
|
|
bool matchCase,
|
|
|
|
bool findNext) override;
|
|
|
|
void StopFinding(bool clearSelection) override;
|
|
|
|
|
2022-02-17 19:17:29 +01:00
|
|
|
// Called from AlloyBrowserHostImpl::FindReply().
|
|
|
|
bool HandleFindReply(int request_id,
|
|
|
|
int number_of_matches,
|
|
|
|
const gfx::Rect& selection_rect,
|
|
|
|
int active_match_ordinal,
|
|
|
|
bool final_update);
|
|
|
|
|
|
|
|
const find_in_page::FindNotificationDetails& last_search_result() const {
|
|
|
|
return last_search_result_;
|
|
|
|
}
|
|
|
|
|
2020-07-04 20:21:34 +02:00
|
|
|
protected:
|
|
|
|
CefBrowserPlatformDelegateAlloy();
|
|
|
|
|
|
|
|
base::RepeatingClosure GetBoundsChangedCallback();
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
// Called from BrowserPlatformDelegateNative::set_windowless_handler().
|
|
|
|
void set_as_secondary() { primary_ = false; }
|
|
|
|
|
2020-07-04 20:21:34 +02:00
|
|
|
private:
|
|
|
|
void SetOwnedWebContents(content::WebContents* owned_contents);
|
|
|
|
|
|
|
|
void DestroyExtensionHost();
|
|
|
|
void OnExtensionHostDeleted();
|
|
|
|
|
|
|
|
void ConfigureAutoResize();
|
|
|
|
|
2024-04-27 03:21:18 +02:00
|
|
|
// Attach all the associated helpers that are needed for the WebContents. It
|
|
|
|
// is safe to call this on a WebContents that was already attached.
|
|
|
|
void AttachHelpers(content::WebContents* web_contents);
|
|
|
|
|
2020-07-04 20:21:34 +02:00
|
|
|
// Non-nullptr if this object owns the WebContents. Will be nullptr for popup
|
|
|
|
// browsers between the calls to WebContentsCreated() and AddNewContents(),
|
|
|
|
// and may never be set if the parent browser is destroyed during popup
|
|
|
|
// creation.
|
|
|
|
std::unique_ptr<content::WebContents> owned_web_contents_;
|
|
|
|
|
|
|
|
// Used for the print preview dialog.
|
2022-06-02 11:49:50 +02:00
|
|
|
std::unique_ptr<AlloyWebContentsDialogHelper> web_contents_dialog_helper_;
|
2020-07-04 20:21:34 +02:00
|
|
|
|
2022-02-17 19:17:29 +01:00
|
|
|
// The last find result. This object contains details about the number of
|
|
|
|
// matches, the find selection rectangle, etc.
|
|
|
|
find_in_page::FindNotificationDetails last_search_result_;
|
2020-07-04 20:21:34 +02:00
|
|
|
|
|
|
|
// Used when the browser is hosting an extension.
|
|
|
|
extensions::ExtensionHost* extension_host_ = nullptr;
|
|
|
|
bool is_background_host_ = false;
|
|
|
|
|
|
|
|
// Used with auto-resize.
|
|
|
|
bool auto_resize_enabled_ = false;
|
|
|
|
gfx::Size auto_resize_min_;
|
|
|
|
gfx::Size auto_resize_max_;
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
// True if this is the primary platform delegate, in which case it will
|
|
|
|
// register WebContents delegate/observers.
|
|
|
|
bool primary_ = true;
|
|
|
|
|
2020-07-04 20:21:34 +02:00
|
|
|
base::WeakPtrFactory<CefBrowserPlatformDelegateAlloy> weak_ptr_factory_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
|