2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-04-25 17:49:37 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2014-04-24 16:45:25 +08:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 08:34:31 +01:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_H_
|
2014-04-24 16:45:25 +08:00
|
|
|
|
2019-04-02 15:38:16 -07:00
|
|
|
#include <map>
|
2018-09-12 19:25:56 -05:00
|
|
|
#include <memory>
|
2014-10-24 20:57:44 +08:00
|
|
|
#include <string>
|
2020-07-30 09:17:57 -07:00
|
|
|
#include <utility>
|
2015-04-18 01:25:31 +05:30
|
|
|
#include <vector>
|
2014-10-24 20:57:44 +08:00
|
|
|
|
2020-11-10 09:06:56 -08:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2018-02-22 15:57:03 +09:00
|
|
|
#include "base/observer_list.h"
|
2018-10-25 17:43:50 +11:00
|
|
|
#include "base/observer_list_types.h"
|
2021-06-17 15:42:51 +02:00
|
|
|
#include "chrome/browser/devtools/devtools_eye_dropper.h"
|
2020-11-10 09:06:56 -08:00
|
|
|
#include "chrome/browser/devtools/devtools_file_system_indexer.h"
|
2021-10-28 16:23:05 +02:00
|
|
|
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" // nogncheck
|
2016-08-26 15:30:02 -07:00
|
|
|
#include "content/common/cursors/webcursor.h"
|
2020-03-26 19:05:45 +01:00
|
|
|
#include "content/common/frame.mojom.h"
|
2019-10-02 14:38:27 +02:00
|
|
|
#include "content/public/browser/devtools_agent_host.h"
|
2017-06-17 00:35:43 +03:00
|
|
|
#include "content/public/browser/keyboard_event_processing_result.h"
|
2019-08-19 22:13:24 +02:00
|
|
|
#include "content/public/browser/render_widget_host.h"
|
2017-08-08 00:09:01 +03:00
|
|
|
#include "content/public/browser/web_contents.h"
|
2020-11-10 09:06:56 -08:00
|
|
|
#include "content/public/browser/web_contents_delegate.h"
|
2014-04-25 11:22:51 +08:00
|
|
|
#include "content/public/browser/web_contents_observer.h"
|
2018-10-02 01:30:53 +05:30
|
|
|
#include "electron/buildflags/buildflags.h"
|
2019-06-19 13:46:59 -07:00
|
|
|
#include "electron/shell/common/api/api.mojom.h"
|
2019-10-25 22:03:28 +09:00
|
|
|
#include "gin/handle.h"
|
2020-07-30 09:17:57 -07:00
|
|
|
#include "gin/wrappable.h"
|
2020-06-22 10:35:10 -07:00
|
|
|
#include "mojo/public/cpp/bindings/receiver_set.h"
|
2018-11-09 09:12:34 +05:30
|
|
|
#include "printing/buildflags/buildflags.h"
|
2019-06-19 13:46:59 -07:00
|
|
|
#include "shell/browser/api/frame_subscriber.h"
|
|
|
|
#include "shell/browser/api/save_page_handler.h"
|
2020-07-30 09:17:57 -07:00
|
|
|
#include "shell/browser/event_emitter_mixin.h"
|
2020-10-27 14:28:43 -07:00
|
|
|
#include "shell/browser/extended_web_contents_observer.h"
|
2020-11-10 09:06:56 -08:00
|
|
|
#include "shell/browser/ui/inspectable_web_contents.h"
|
|
|
|
#include "shell/browser/ui/inspectable_web_contents_delegate.h"
|
|
|
|
#include "shell/browser/ui/inspectable_web_contents_view_delegate.h"
|
2020-07-30 09:17:57 -07:00
|
|
|
#include "shell/common/gin_helper/cleaned_up_at_exit.h"
|
|
|
|
#include "shell/common/gin_helper/constructible.h"
|
2020-07-20 11:07:02 -07:00
|
|
|
#include "shell/common/gin_helper/error_thrower.h"
|
2021-07-26 09:02:16 -07:00
|
|
|
#include "shell/common/gin_helper/pinnable.h"
|
2021-06-08 15:22:43 -05:00
|
|
|
#include "ui/base/models/image_model.h"
|
2015-04-20 12:20:04 +05:30
|
|
|
#include "ui/gfx/image/image.h"
|
2014-04-24 16:45:25 +08:00
|
|
|
|
2018-11-09 09:12:34 +05:30
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
2021-05-19 16:15:47 -07:00
|
|
|
#include "shell/browser/printing/print_view_manager_electron.h"
|
2018-11-09 09:12:34 +05:30
|
|
|
#endif
|
|
|
|
|
2020-01-15 15:11:51 -08:00
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
2021-03-04 16:23:10 -08:00
|
|
|
#include "extensions/common/mojom/view_type.mojom.h"
|
2020-09-08 07:55:40 -04:00
|
|
|
|
2020-03-05 09:56:21 -05:00
|
|
|
namespace extensions {
|
|
|
|
class ScriptExecutor;
|
|
|
|
}
|
2020-01-15 15:11:51 -08:00
|
|
|
#endif
|
|
|
|
|
2015-09-18 11:06:38 +08:00
|
|
|
namespace blink {
|
2020-08-12 11:33:58 -07:00
|
|
|
struct DeviceEmulationParams;
|
2022-05-17 12:48:40 -04:00
|
|
|
// enum class PermissionType;
|
|
|
|
} // namespace blink
|
2015-09-18 11:06:38 +08:00
|
|
|
|
2019-10-25 22:03:28 +09:00
|
|
|
namespace gin_helper {
|
2014-11-03 22:12:56 +08:00
|
|
|
class Dictionary;
|
2019-10-25 22:03:28 +09:00
|
|
|
}
|
2014-11-03 22:12:56 +08:00
|
|
|
|
2018-04-11 10:42:14 +02:00
|
|
|
namespace network {
|
|
|
|
class ResourceRequestBody;
|
|
|
|
}
|
|
|
|
|
2020-05-11 13:42:24 -07:00
|
|
|
namespace gin {
|
2020-07-20 11:07:02 -07:00
|
|
|
class Arguments;
|
2020-11-17 11:13:58 -08:00
|
|
|
}
|
2020-05-11 13:42:24 -07:00
|
|
|
|
2021-10-28 16:23:05 +02:00
|
|
|
class ExclusiveAccessManager;
|
|
|
|
|
2014-04-24 16:45:25 +08:00
|
|
|
namespace electron {
|
|
|
|
|
2015-07-14 12:13:25 -07:00
|
|
|
class ElectronBrowserContext;
|
2017-04-27 19:28:48 -05:00
|
|
|
class ElectronJavaScriptDialogManager;
|
2018-10-19 15:50:30 +02:00
|
|
|
class InspectableWebContents;
|
2017-01-30 16:48:40 +05:30
|
|
|
class WebContentsZoomController;
|
2015-06-25 14:28:13 +08:00
|
|
|
class WebViewGuestDelegate;
|
2018-05-14 17:55:39 +02:00
|
|
|
class FrameSubscriber;
|
2020-11-10 09:06:56 -08:00
|
|
|
class WebDialogHelper;
|
|
|
|
class NativeWindow;
|
2014-04-24 16:45:25 +08:00
|
|
|
|
2018-10-02 01:30:53 +05:30
|
|
|
#if BUILDFLAG(ENABLE_OSR)
|
2018-11-29 21:25:02 -08:00
|
|
|
class OffScreenRenderWidgetHostView;
|
2020-11-10 09:06:56 -08:00
|
|
|
class OffScreenWebContentsView;
|
2018-03-20 10:25:51 +09:00
|
|
|
#endif
|
|
|
|
|
2015-06-25 14:28:13 +08:00
|
|
|
namespace api {
|
2015-05-29 11:12:55 +08:00
|
|
|
|
2018-02-22 15:48:53 +09:00
|
|
|
// Wrapper around the content::WebContents.
|
2021-10-28 16:23:05 +02:00
|
|
|
class WebContents : public ExclusiveAccessContext,
|
|
|
|
public gin::Wrappable<WebContents>,
|
2020-07-30 09:17:57 -07:00
|
|
|
public gin_helper::EventEmitterMixin<WebContents>,
|
|
|
|
public gin_helper::Constructible<WebContents>,
|
2021-07-26 09:02:16 -07:00
|
|
|
public gin_helper::Pinnable<WebContents>,
|
2020-07-30 09:17:57 -07:00
|
|
|
public gin_helper::CleanedUpAtExit,
|
2019-04-02 15:38:16 -07:00
|
|
|
public content::WebContentsObserver,
|
2020-11-10 09:06:56 -08:00
|
|
|
public content::WebContentsDelegate,
|
|
|
|
public InspectableWebContentsDelegate,
|
2020-12-14 10:57:36 -08:00
|
|
|
public InspectableWebContentsViewDelegate {
|
2014-04-24 16:45:25 +08:00
|
|
|
public:
|
2019-05-03 20:11:41 +02:00
|
|
|
enum class Type {
|
2020-10-27 18:51:45 +01:00
|
|
|
kBackgroundPage, // An extension background page.
|
|
|
|
kBrowserWindow, // Used by BrowserWindow.
|
|
|
|
kBrowserView, // Used by BrowserView.
|
|
|
|
kRemote, // Thin wrap around an existing WebContents.
|
|
|
|
kWebView, // Used by <webview>.
|
|
|
|
kOffScreen, // Used for offscreen rendering
|
2016-06-14 09:09:54 -07:00
|
|
|
};
|
|
|
|
|
2018-10-19 17:52:07 +09:00
|
|
|
// Create a new WebContents and return the V8 wrapper of it.
|
2020-07-30 09:17:57 -07:00
|
|
|
static gin::Handle<WebContents> New(v8::Isolate* isolate,
|
|
|
|
const gin_helper::Dictionary& options);
|
2018-10-19 17:52:07 +09:00
|
|
|
|
|
|
|
// Create a new V8 wrapper for an existing |web_content|.
|
|
|
|
//
|
|
|
|
// The lifetime of |web_contents| will be managed by this class.
|
2019-10-25 22:03:28 +09:00
|
|
|
static gin::Handle<WebContents> CreateAndTake(
|
2018-04-17 21:44:10 -04:00
|
|
|
v8::Isolate* isolate,
|
2018-10-23 03:02:25 +09:00
|
|
|
std::unique_ptr<content::WebContents> web_contents,
|
2018-04-17 21:44:10 -04:00
|
|
|
Type type);
|
2014-10-23 14:04:13 +08:00
|
|
|
|
2020-07-16 16:16:05 -07:00
|
|
|
// Get the api::WebContents associated with |web_contents|. Returns nullptr
|
|
|
|
// if there is no associated wrapper.
|
|
|
|
static WebContents* From(content::WebContents* web_contents);
|
|
|
|
static WebContents* FromID(int32_t id);
|
2018-10-19 17:52:07 +09:00
|
|
|
|
|
|
|
// Get the V8 wrapper of the |web_contents|, or create one if not existed.
|
|
|
|
//
|
|
|
|
// The lifetime of |web_contents| is NOT managed by this class, and the type
|
|
|
|
// of this wrapper is always REMOTE.
|
2019-10-25 22:03:28 +09:00
|
|
|
static gin::Handle<WebContents> FromOrCreate(
|
2018-10-19 17:52:07 +09:00
|
|
|
v8::Isolate* isolate,
|
|
|
|
content::WebContents* web_contents);
|
2014-04-24 16:45:25 +08:00
|
|
|
|
2020-12-16 00:52:43 +01:00
|
|
|
static gin::Handle<WebContents> CreateFromWebPreferences(
|
|
|
|
v8::Isolate* isolate,
|
|
|
|
const gin_helper::Dictionary& web_preferences);
|
|
|
|
|
2020-07-30 09:17:57 -07:00
|
|
|
// gin::Wrappable
|
|
|
|
static gin::WrapperInfo kWrapperInfo;
|
|
|
|
static v8::Local<v8::ObjectTemplate> FillObjectTemplate(
|
|
|
|
v8::Isolate*,
|
|
|
|
v8::Local<v8::ObjectTemplate>);
|
|
|
|
const char* GetTypeName() override;
|
2016-04-25 10:17:54 +09:00
|
|
|
|
2021-03-15 18:43:25 -04:00
|
|
|
void Destroy();
|
2019-06-14 04:44:36 +02:00
|
|
|
base::WeakPtr<WebContents> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
|
|
|
|
|
2020-05-14 15:11:45 +02:00
|
|
|
bool GetBackgroundThrottling() const;
|
2018-10-18 17:32:22 -07:00
|
|
|
void SetBackgroundThrottling(bool allowed);
|
2016-09-05 22:28:40 -03:00
|
|
|
int GetProcessID() const;
|
2017-05-15 13:29:34 -07:00
|
|
|
base::ProcessId GetOSProcessID() const;
|
2016-06-14 09:09:54 -07:00
|
|
|
Type GetType() const;
|
2015-06-23 16:16:10 +08:00
|
|
|
bool Equal(const WebContents* web_contents) const;
|
2019-10-25 22:03:28 +09:00
|
|
|
void LoadURL(const GURL& url, const gin_helper::Dictionary& options);
|
2021-04-27 16:11:18 -07:00
|
|
|
void Reload();
|
|
|
|
void ReloadIgnoringCache();
|
2015-12-02 13:49:30 -08:00
|
|
|
void DownloadURL(const GURL& url);
|
2015-09-15 09:17:45 +08:00
|
|
|
GURL GetURL() const;
|
2021-03-16 12:18:45 -04:00
|
|
|
std::u16string GetTitle() const;
|
2014-04-24 17:00:41 +08:00
|
|
|
bool IsLoading() const;
|
2016-04-18 10:37:08 -07:00
|
|
|
bool IsLoadingMainFrame() const;
|
2014-04-24 17:00:41 +08:00
|
|
|
bool IsWaitingForResponse() const;
|
|
|
|
void Stop();
|
2021-04-27 16:11:18 -07:00
|
|
|
bool CanGoBack() const;
|
2015-05-11 14:30:26 +08:00
|
|
|
void GoBack();
|
2021-04-27 16:11:18 -07:00
|
|
|
bool CanGoForward() const;
|
2015-05-11 14:30:26 +08:00
|
|
|
void GoForward();
|
2021-04-27 16:11:18 -07:00
|
|
|
bool CanGoToOffset(int offset) const;
|
2015-05-11 16:44:01 +08:00
|
|
|
void GoToOffset(int offset);
|
2021-04-27 16:11:18 -07:00
|
|
|
bool CanGoToIndex(int index) const;
|
|
|
|
void GoToIndex(int index);
|
|
|
|
int GetActiveIndex() const;
|
|
|
|
void ClearHistory();
|
|
|
|
int GetHistoryLength() const;
|
2017-03-08 22:06:26 -05:00
|
|
|
const std::string GetWebRTCIPHandlingPolicy() const;
|
|
|
|
void SetWebRTCIPHandlingPolicy(const std::string& webrtc_ip_handling_policy);
|
2021-10-26 11:03:59 +11:00
|
|
|
std::string GetMediaSourceID(content::WebContents* request_web_contents);
|
2014-04-24 17:00:41 +08:00
|
|
|
bool IsCrashed() const;
|
2020-10-02 14:50:24 -07:00
|
|
|
void ForcefullyCrashRenderer();
|
2020-07-20 11:07:02 -07:00
|
|
|
void SetUserAgent(const std::string& user_agent);
|
2015-07-22 12:25:10 +08:00
|
|
|
std::string GetUserAgent();
|
2014-10-24 21:04:50 +08:00
|
|
|
void InsertCSS(const std::string& css);
|
2019-02-14 09:03:28 -08:00
|
|
|
v8::Local<v8::Promise> SavePage(const base::FilePath& full_file_path,
|
|
|
|
const content::SavePageType& save_type);
|
2020-07-20 11:07:02 -07:00
|
|
|
void OpenDevTools(gin::Arguments* args);
|
2014-11-03 22:12:56 +08:00
|
|
|
void CloseDevTools();
|
|
|
|
bool IsDevToolsOpened();
|
2015-12-31 21:11:21 -08:00
|
|
|
bool IsDevToolsFocused();
|
2015-06-05 17:01:17 +08:00
|
|
|
void ToggleDevTools();
|
2020-08-12 11:33:58 -07:00
|
|
|
void EnableDeviceEmulation(const blink::DeviceEmulationParams& params);
|
2015-08-31 11:19:19 +02:00
|
|
|
void DisableDeviceEmulation();
|
2015-04-22 13:00:10 +05:30
|
|
|
void InspectElement(int x, int y);
|
2019-02-01 10:44:24 -08:00
|
|
|
void InspectSharedWorker();
|
2019-10-02 14:38:27 +02:00
|
|
|
void InspectSharedWorkerById(const std::string& workerId);
|
|
|
|
std::vector<scoped_refptr<content::DevToolsAgentHost>> GetAllSharedWorkers();
|
2015-06-05 15:41:03 +08:00
|
|
|
void InspectServiceWorker();
|
2017-06-25 12:01:05 -07:00
|
|
|
void SetIgnoreMenuShortcuts(bool ignore);
|
2015-06-15 21:40:49 +08:00
|
|
|
void SetAudioMuted(bool muted);
|
|
|
|
bool IsAudioMuted();
|
2018-07-12 12:35:11 +01:00
|
|
|
bool IsCurrentlyAudible();
|
2016-09-08 10:01:01 -07:00
|
|
|
void SetEmbedder(const WebContents* embedder);
|
2017-11-30 16:37:26 +09:00
|
|
|
void SetDevToolsWebContents(const WebContents* devtools);
|
2020-07-16 14:11:44 -07:00
|
|
|
v8::Local<v8::Value> GetNativeView(v8::Isolate* isolate) const;
|
2020-07-20 11:07:02 -07:00
|
|
|
void IncrementCapturerCount(gin::Arguments* args);
|
|
|
|
void DecrementCapturerCount(gin::Arguments* args);
|
2020-01-25 08:43:42 +08:00
|
|
|
bool IsBeingCaptured();
|
2021-03-15 18:43:25 -04:00
|
|
|
void HandleNewRenderFrame(content::RenderFrameHost* render_frame_host);
|
2015-01-19 12:09:47 -08:00
|
|
|
|
2018-11-09 09:12:34 +05:30
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
2022-05-19 10:05:07 +02:00
|
|
|
void OnGetDefaultPrinter(base::Value::Dict print_settings,
|
2020-01-31 19:20:11 +00:00
|
|
|
printing::CompletionCallback print_callback,
|
2021-03-16 12:18:45 -04:00
|
|
|
std::u16string device_name,
|
2020-01-31 19:20:11 +00:00
|
|
|
bool silent,
|
2021-10-05 09:16:04 +02:00
|
|
|
// <error, default_printer_name>
|
|
|
|
std::pair<std::string, std::u16string> info);
|
2020-07-20 11:07:02 -07:00
|
|
|
void Print(gin::Arguments* args);
|
2015-06-09 13:07:40 +08:00
|
|
|
// Print current page as PDF.
|
2022-05-31 08:21:25 +02:00
|
|
|
v8::Local<v8::Promise> PrintToPDF(const base::Value& settings);
|
|
|
|
void OnPDFCreated(gin_helper::Promise<v8::Local<v8::Value>> promise,
|
|
|
|
PrintViewManagerElectron::PrintResult print_result,
|
|
|
|
scoped_refptr<base::RefCountedMemory> data);
|
2018-11-09 09:12:34 +05:30
|
|
|
#endif
|
2015-06-09 13:07:40 +08:00
|
|
|
|
2020-11-10 09:06:03 -08:00
|
|
|
void SetNextChildWebPreferences(const gin_helper::Dictionary);
|
|
|
|
|
2015-07-24 15:09:11 +05:30
|
|
|
// DevTools workspace api.
|
2020-07-20 11:07:02 -07:00
|
|
|
void AddWorkSpace(gin::Arguments* args, const base::FilePath& path);
|
|
|
|
void RemoveWorkSpace(gin::Arguments* args, const base::FilePath& path);
|
2015-07-24 15:09:11 +05:30
|
|
|
|
2015-01-19 12:09:47 -08:00
|
|
|
// Editing commands.
|
|
|
|
void Undo();
|
|
|
|
void Redo();
|
|
|
|
void Cut();
|
|
|
|
void Copy();
|
|
|
|
void Paste();
|
2015-05-15 00:15:19 -07:00
|
|
|
void PasteAndMatchStyle();
|
2015-01-19 12:09:47 -08:00
|
|
|
void Delete();
|
|
|
|
void SelectAll();
|
|
|
|
void Unselect();
|
2021-03-16 12:18:45 -04:00
|
|
|
void Replace(const std::u16string& word);
|
|
|
|
void ReplaceMisspelling(const std::u16string& word);
|
2020-07-20 11:07:02 -07:00
|
|
|
uint32_t FindInPage(gin::Arguments* args);
|
2015-12-17 22:57:56 +05:30
|
|
|
void StopFindInPage(content::StopFindAction action);
|
2016-06-02 10:12:38 -07:00
|
|
|
void ShowDefinitionForSelection();
|
2016-07-26 12:06:11 -07:00
|
|
|
void CopyImageAt(int x, int y);
|
2015-01-19 12:09:47 -08:00
|
|
|
|
2015-07-24 12:58:28 +08:00
|
|
|
// Focus.
|
|
|
|
void Focus();
|
2016-08-03 12:29:55 +09:00
|
|
|
bool IsFocused() const;
|
2015-07-24 12:58:28 +08:00
|
|
|
|
2015-09-18 14:20:31 +08:00
|
|
|
// Send WebInputEvent to the page.
|
|
|
|
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
|
|
|
|
|
2015-09-18 15:57:43 +08:00
|
|
|
// Subscribe to the frame updates.
|
2020-07-20 11:07:02 -07:00
|
|
|
void BeginFrameSubscription(gin::Arguments* args);
|
2015-09-18 15:57:43 +08:00
|
|
|
void EndFrameSubscription();
|
|
|
|
|
2016-07-03 12:26:43 +09:00
|
|
|
// Dragging native items.
|
2020-07-20 11:07:02 -07:00
|
|
|
void StartDrag(const gin_helper::Dictionary& item, gin::Arguments* args);
|
2016-07-03 12:26:43 +09:00
|
|
|
|
2016-07-05 15:43:57 -07:00
|
|
|
// Captures the page with |rect|, |callback| would be called when capturing is
|
|
|
|
// done.
|
2020-07-20 11:07:02 -07:00
|
|
|
v8::Local<v8::Promise> CapturePage(gin::Arguments* args);
|
2016-07-05 15:43:57 -07:00
|
|
|
|
2015-06-25 14:28:13 +08:00
|
|
|
// Methods for creating <webview>.
|
2015-06-05 15:18:15 +08:00
|
|
|
bool IsGuest() const;
|
2018-08-16 15:57:40 -07:00
|
|
|
void AttachToIframe(content::WebContents* embedder_web_contents,
|
|
|
|
int embedder_frame_id);
|
2019-01-12 15:50:33 +09:00
|
|
|
void DetachFromOuterFrame();
|
2016-07-29 14:50:27 +02:00
|
|
|
|
2016-07-30 15:40:16 +02:00
|
|
|
// Methods for offscreen rendering
|
2016-07-28 12:10:56 +02:00
|
|
|
bool IsOffScreen() const;
|
2018-10-02 01:30:53 +05:30
|
|
|
#if BUILDFLAG(ENABLE_OSR)
|
2016-08-04 13:22:19 +09:00
|
|
|
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
2016-07-30 15:40:16 +02:00
|
|
|
void StartPainting();
|
|
|
|
void StopPainting();
|
|
|
|
bool IsPainting() const;
|
2016-07-31 12:19:56 +02:00
|
|
|
void SetFrameRate(int frame_rate);
|
2016-07-30 15:40:16 +02:00
|
|
|
int GetFrameRate() const;
|
2018-10-02 01:30:53 +05:30
|
|
|
#endif
|
2016-09-01 19:25:12 +02:00
|
|
|
void Invalidate();
|
2019-07-02 18:22:09 -07:00
|
|
|
gfx::Size GetSizeForNewRenderView(content::WebContents*) override;
|
2014-10-24 16:09:18 +08:00
|
|
|
|
2017-01-29 19:43:20 +05:30
|
|
|
// Methods for zoom handling.
|
|
|
|
void SetZoomLevel(double level);
|
2018-08-09 19:15:23 +02:00
|
|
|
double GetZoomLevel() const;
|
2020-03-13 23:13:05 +00:00
|
|
|
void SetZoomFactor(gin_helper::ErrorThrower thrower, double factor);
|
2018-08-09 19:15:23 +02:00
|
|
|
double GetZoomFactor() const;
|
2017-01-29 19:43:20 +05:30
|
|
|
|
2016-02-01 15:33:38 +05:30
|
|
|
// Callback triggered on permission response.
|
2019-10-28 18:12:35 -04:00
|
|
|
void OnEnterFullscreenModeForTab(
|
2020-06-01 13:34:34 -07:00
|
|
|
content::RenderFrameHost* requesting_frame,
|
2019-10-28 18:12:35 -04:00
|
|
|
const blink::mojom::FullscreenOptions& options,
|
|
|
|
bool allowed);
|
2016-02-01 15:33:38 +05:30
|
|
|
|
2016-03-31 06:28:23 +05:30
|
|
|
// Create window with the given disposition.
|
2018-04-17 21:44:10 -04:00
|
|
|
void OnCreateWindow(const GURL& target_url,
|
|
|
|
const content::Referrer& referrer,
|
|
|
|
const std::string& frame_name,
|
|
|
|
WindowOpenDisposition disposition,
|
2020-03-26 19:05:45 +01:00
|
|
|
const std::string& features,
|
2018-04-11 10:42:14 +02:00
|
|
|
const scoped_refptr<network::ResourceRequestBody>& body);
|
2016-03-31 06:28:23 +05:30
|
|
|
|
2018-08-11 00:19:49 +02:00
|
|
|
// Returns the preload script path of current WebContents.
|
2020-11-10 09:06:03 -08:00
|
|
|
std::vector<base::FilePath> GetPreloadPaths() const;
|
2018-08-11 00:19:49 +02:00
|
|
|
|
2015-09-22 21:56:56 +08:00
|
|
|
// Returns the web preferences of current WebContents.
|
2018-08-09 19:15:23 +02:00
|
|
|
v8::Local<v8::Value> GetLastWebPreferences(v8::Isolate* isolate) const;
|
2015-09-22 21:56:56 +08:00
|
|
|
|
2015-10-01 13:45:59 +08:00
|
|
|
// Returns the owner window.
|
2020-07-16 14:11:44 -07:00
|
|
|
v8::Local<v8::Value> GetOwnerBrowserWindow(v8::Isolate* isolate) const;
|
2015-10-01 13:45:59 +08:00
|
|
|
|
2020-05-26 22:21:38 +09:00
|
|
|
// Notifies the web page that there is user interaction.
|
|
|
|
void NotifyUserActivation();
|
|
|
|
|
2020-07-16 14:11:44 -07:00
|
|
|
v8::Local<v8::Promise> TakeHeapSnapshot(v8::Isolate* isolate,
|
|
|
|
const base::FilePath& file_path);
|
2021-10-06 07:30:31 +09:00
|
|
|
v8::Local<v8::Promise> GetProcessMemoryInfo(v8::Isolate* isolate);
|
2018-09-18 20:00:31 +02:00
|
|
|
|
2015-10-01 11:14:19 +08:00
|
|
|
// Properties.
|
2020-07-30 09:17:57 -07:00
|
|
|
int32_t ID() const { return id_; }
|
2015-10-01 11:14:19 +08:00
|
|
|
v8::Local<v8::Value> Session(v8::Isolate* isolate);
|
2019-08-19 22:13:24 +02:00
|
|
|
content::WebContents* HostWebContents() const;
|
2015-10-01 11:14:19 +08:00
|
|
|
v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate);
|
2016-01-21 23:52:23 +05:30
|
|
|
v8::Local<v8::Value> Debugger(v8::Isolate* isolate);
|
2020-10-09 12:50:46 -04:00
|
|
|
content::RenderFrameHost* MainFrame();
|
2015-10-01 11:14:19 +08:00
|
|
|
|
2017-01-30 16:48:40 +05:30
|
|
|
WebContentsZoomController* GetZoomController() { return zoom_controller_; }
|
|
|
|
|
2018-02-22 15:57:03 +09:00
|
|
|
void AddObserver(ExtendedWebContentsObserver* obs) {
|
|
|
|
observers_.AddObserver(obs);
|
|
|
|
}
|
|
|
|
void RemoveObserver(ExtendedWebContentsObserver* obs) {
|
2018-11-19 17:47:04 +01:00
|
|
|
// Trying to remove from an empty collection leads to an access violation
|
2021-03-04 16:25:30 -08:00
|
|
|
if (!observers_.empty())
|
2018-11-19 17:47:04 +01:00
|
|
|
observers_.RemoveObserver(obs);
|
2018-02-22 15:57:03 +09:00
|
|
|
}
|
|
|
|
|
2018-09-16 01:42:43 +10:00
|
|
|
bool EmitNavigationEvent(const std::string& event,
|
|
|
|
content::NavigationHandle* navigation_handle);
|
|
|
|
|
2020-07-30 09:17:57 -07:00
|
|
|
// this.emit(name, new Event(sender, message), args...);
|
|
|
|
template <typename... Args>
|
|
|
|
bool EmitWithSender(base::StringPiece name,
|
|
|
|
content::RenderFrameHost* sender,
|
2022-03-18 19:50:05 -07:00
|
|
|
electron::mojom::ElectronApiIPC::InvokeCallback callback,
|
2020-07-30 09:17:57 -07:00
|
|
|
Args&&... args) {
|
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
|
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
|
|
|
v8::HandleScope handle_scope(isolate);
|
|
|
|
v8::Local<v8::Object> wrapper;
|
|
|
|
if (!GetWrapper(isolate).ToLocal(&wrapper))
|
|
|
|
return false;
|
|
|
|
v8::Local<v8::Object> event = gin_helper::internal::CreateNativeEvent(
|
|
|
|
isolate, wrapper, sender, std::move(callback));
|
|
|
|
return EmitCustomEvent(name, event, std::forward<Args>(args)...);
|
|
|
|
}
|
|
|
|
|
2019-08-19 22:13:24 +02:00
|
|
|
WebContents* embedder() { return embedder_; }
|
|
|
|
|
2020-01-15 15:11:51 -08:00
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
|
|
|
extensions::ScriptExecutor* script_executor() {
|
|
|
|
return script_executor_.get();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-11-10 09:06:56 -08:00
|
|
|
// Set the window as owner window.
|
|
|
|
void SetOwnerWindow(NativeWindow* owner_window);
|
|
|
|
void SetOwnerWindow(content::WebContents* web_contents,
|
|
|
|
NativeWindow* owner_window);
|
|
|
|
|
|
|
|
// Returns the WebContents managed by this delegate.
|
|
|
|
content::WebContents* GetWebContents() const;
|
|
|
|
|
|
|
|
// Returns the WebContents of devtools.
|
|
|
|
content::WebContents* GetDevToolsWebContents() const;
|
|
|
|
|
2020-11-17 14:15:20 -08:00
|
|
|
InspectableWebContents* inspectable_web_contents() const {
|
|
|
|
return inspectable_web_contents_.get();
|
2020-11-10 09:06:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NativeWindow* owner_window() const { return owner_window_.get(); }
|
|
|
|
|
|
|
|
bool is_html_fullscreen() const { return html_fullscreen_; }
|
|
|
|
|
|
|
|
void set_fullscreen_frame(content::RenderFrameHost* rfh) {
|
|
|
|
fullscreen_frame_ = rfh;
|
|
|
|
}
|
|
|
|
|
2022-03-18 19:50:05 -07:00
|
|
|
// mojom::ElectronApiIPC
|
2020-12-14 10:57:36 -08:00
|
|
|
void Message(bool internal,
|
|
|
|
const std::string& channel,
|
|
|
|
blink::CloneableMessage arguments,
|
|
|
|
content::RenderFrameHost* render_frame_host);
|
|
|
|
void Invoke(bool internal,
|
|
|
|
const std::string& channel,
|
|
|
|
blink::CloneableMessage arguments,
|
2022-03-18 19:50:05 -07:00
|
|
|
electron::mojom::ElectronApiIPC::InvokeCallback callback,
|
2020-12-14 10:57:36 -08:00
|
|
|
content::RenderFrameHost* render_frame_host);
|
|
|
|
void ReceivePostMessage(const std::string& channel,
|
|
|
|
blink::TransferableMessage message,
|
|
|
|
content::RenderFrameHost* render_frame_host);
|
|
|
|
void MessageSync(
|
|
|
|
bool internal,
|
|
|
|
const std::string& channel,
|
|
|
|
blink::CloneableMessage arguments,
|
2022-03-18 19:50:05 -07:00
|
|
|
electron::mojom::ElectronApiIPC::MessageSyncCallback callback,
|
2020-12-14 10:57:36 -08:00
|
|
|
content::RenderFrameHost* render_frame_host);
|
2021-06-18 06:26:18 +02:00
|
|
|
void MessageTo(int32_t web_contents_id,
|
2020-12-14 10:57:36 -08:00
|
|
|
const std::string& channel,
|
|
|
|
blink::CloneableMessage arguments);
|
|
|
|
void MessageHost(const std::string& channel,
|
|
|
|
blink::CloneableMessage arguments,
|
|
|
|
content::RenderFrameHost* render_frame_host);
|
2022-03-18 19:50:05 -07:00
|
|
|
|
|
|
|
// mojom::ElectronWebContentsUtility
|
|
|
|
void OnFirstNonEmptyLayout(content::RenderFrameHost* render_frame_host);
|
2020-12-14 10:57:36 -08:00
|
|
|
void UpdateDraggableRegions(std::vector<mojom::DraggableRegionPtr> regions);
|
|
|
|
void SetTemporaryZoomLevel(double level);
|
|
|
|
void DoGetZoomLevel(
|
2022-03-18 19:50:05 -07:00
|
|
|
electron::mojom::ElectronWebContentsUtility::DoGetZoomLevelCallback
|
|
|
|
callback);
|
|
|
|
|
2021-06-07 19:00:22 -07:00
|
|
|
void SetImageAnimationPolicy(const std::string& new_policy);
|
2020-12-14 10:57:36 -08:00
|
|
|
|
2021-11-03 12:41:45 +01:00
|
|
|
// disable copy
|
|
|
|
WebContents(const WebContents&) = delete;
|
|
|
|
WebContents& operator=(const WebContents&) = delete;
|
|
|
|
|
2020-11-10 09:06:56 -08:00
|
|
|
private:
|
2018-10-19 17:52:07 +09:00
|
|
|
// Does not manage lifetime of |web_contents|.
|
|
|
|
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
|
|
|
|
// Takes over ownership of |web_contents|.
|
2016-08-16 21:15:10 -03:00
|
|
|
WebContents(v8::Isolate* isolate,
|
2018-10-23 03:02:25 +09:00
|
|
|
std::unique_ptr<content::WebContents> web_contents,
|
2016-08-16 21:15:10 -03:00
|
|
|
Type type);
|
2018-10-19 17:52:07 +09:00
|
|
|
// Creates a new content::WebContents.
|
2019-10-25 22:03:28 +09:00
|
|
|
WebContents(v8::Isolate* isolate, const gin_helper::Dictionary& options);
|
2018-04-17 16:03:51 -07:00
|
|
|
~WebContents() override;
|
2014-04-24 16:45:25 +08:00
|
|
|
|
2021-09-27 16:20:55 +09:00
|
|
|
// Delete this if garbage collection has not started.
|
|
|
|
void DeleteThisIfAlive();
|
|
|
|
|
2020-11-10 09:06:56 -08:00
|
|
|
// Creates a InspectableWebContents object and takes ownership of
|
|
|
|
// |web_contents|.
|
2021-09-20 00:34:11 +00:00
|
|
|
void InitWithWebContents(std::unique_ptr<content::WebContents> web_contents,
|
2020-11-10 09:06:56 -08:00
|
|
|
ElectronBrowserContext* browser_context,
|
|
|
|
bool is_guest);
|
|
|
|
|
2018-10-23 03:02:25 +09:00
|
|
|
void InitWithSessionAndOptions(
|
|
|
|
v8::Isolate* isolate,
|
|
|
|
std::unique_ptr<content::WebContents> web_contents,
|
2019-10-25 22:03:28 +09:00
|
|
|
gin::Handle<class Session> session,
|
|
|
|
const gin_helper::Dictionary& options);
|
2016-08-16 21:15:10 -03:00
|
|
|
|
2020-09-08 07:55:40 -04:00
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
|
|
|
void InitWithExtensionView(v8::Isolate* isolate,
|
|
|
|
content::WebContents* web_contents,
|
2021-03-04 16:23:10 -08:00
|
|
|
extensions::mojom::ViewType view_type);
|
2020-09-08 07:55:40 -04:00
|
|
|
#endif
|
|
|
|
|
2014-10-24 18:06:32 +08:00
|
|
|
// content::WebContentsDelegate:
|
2017-01-23 18:59:40 +09:00
|
|
|
bool DidAddMessageToConsole(content::WebContents* source,
|
2019-04-30 20:18:22 -04:00
|
|
|
blink::mojom::ConsoleMessageLevel level,
|
2021-03-16 12:18:45 -04:00
|
|
|
const std::u16string& message,
|
2017-01-23 18:59:40 +09:00
|
|
|
int32_t line_no,
|
2021-03-16 12:18:45 -04:00
|
|
|
const std::u16string& source_id) override;
|
2020-04-13 08:37:41 -07:00
|
|
|
bool IsWebContentsCreationOverridden(
|
|
|
|
content::SiteInstance* source_site_instance,
|
|
|
|
content::mojom::WindowContainerType window_container_type,
|
|
|
|
const GURL& opener_url,
|
2020-11-10 09:06:03 -08:00
|
|
|
const content::mojom::CreateNewWindowParams& params) override;
|
2020-04-13 08:37:41 -07:00
|
|
|
content::WebContents* CreateCustomWebContents(
|
|
|
|
content::RenderFrameHost* opener,
|
|
|
|
content::SiteInstance* source_site_instance,
|
|
|
|
bool is_new_browsing_instance,
|
|
|
|
const GURL& opener_url,
|
|
|
|
const std::string& frame_name,
|
|
|
|
const GURL& target_url,
|
2022-02-25 13:17:35 -05:00
|
|
|
const content::StoragePartitionConfig& partition_config,
|
2020-04-13 08:37:41 -07:00
|
|
|
content::SessionStorageNamespace* session_storage_namespace) override;
|
2020-03-26 19:05:45 +01:00
|
|
|
void WebContentsCreatedWithFullParams(
|
|
|
|
content::WebContents* source_contents,
|
|
|
|
int opener_render_process_id,
|
|
|
|
int opener_render_frame_id,
|
|
|
|
const content::mojom::CreateNewWindowParams& params,
|
|
|
|
content::WebContents* new_contents) override;
|
2016-08-15 21:13:18 -03:00
|
|
|
void AddNewContents(content::WebContents* source,
|
2018-09-14 17:16:22 -07:00
|
|
|
std::unique_ptr<content::WebContents> new_contents,
|
2020-05-26 13:06:26 -07:00
|
|
|
const GURL& target_url,
|
2016-08-15 21:13:18 -03:00
|
|
|
WindowOpenDisposition disposition,
|
|
|
|
const gfx::Rect& initial_rect,
|
|
|
|
bool user_gesture,
|
|
|
|
bool* was_blocked) override;
|
2014-10-24 21:46:47 +08:00
|
|
|
content::WebContents* OpenURLFromTab(
|
2014-10-24 18:06:32 +08:00
|
|
|
content::WebContents* source,
|
|
|
|
const content::OpenURLParams& params) override;
|
2015-06-25 11:07:23 +08:00
|
|
|
void BeforeUnloadFired(content::WebContents* tab,
|
|
|
|
bool proceed,
|
|
|
|
bool* proceed_to_fire_unload) override;
|
2018-10-02 14:56:09 -07:00
|
|
|
void SetContentsBounds(content::WebContents* source,
|
|
|
|
const gfx::Rect& pos) override;
|
2015-06-25 11:07:23 +08:00
|
|
|
void CloseContents(content::WebContents* source) override;
|
|
|
|
void ActivateContents(content::WebContents* contents) override;
|
2016-06-07 15:56:19 +09:00
|
|
|
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
2019-01-09 12:01:49 -08:00
|
|
|
bool HandleKeyboardEvent(
|
2014-10-24 21:46:47 +08:00
|
|
|
content::WebContents* source,
|
|
|
|
const content::NativeWebKeyboardEvent& event) override;
|
2020-11-10 09:06:56 -08:00
|
|
|
bool PlatformHandleKeyboardEvent(
|
|
|
|
content::WebContents* source,
|
|
|
|
const content::NativeWebKeyboardEvent& event);
|
2017-06-17 00:35:43 +03:00
|
|
|
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
|
|
|
content::WebContents* source,
|
|
|
|
const content::NativeWebKeyboardEvent& event) override;
|
2019-05-14 08:40:40 +02:00
|
|
|
void ContentsZoomChange(bool zoom_in) override;
|
2018-09-14 17:17:50 -07:00
|
|
|
void EnterFullscreenModeForTab(
|
2020-06-01 13:34:34 -07:00
|
|
|
content::RenderFrameHost* requesting_frame,
|
2019-10-28 18:12:35 -04:00
|
|
|
const blink::mojom::FullscreenOptions& options) override;
|
2015-05-09 17:47:40 +05:30
|
|
|
void ExitFullscreenModeForTab(content::WebContents* source) override;
|
2017-01-23 18:59:40 +09:00
|
|
|
void RendererUnresponsive(
|
|
|
|
content::WebContents* source,
|
2018-10-02 14:57:14 -07:00
|
|
|
content::RenderWidgetHost* render_widget_host,
|
|
|
|
base::RepeatingClosure hang_monitor_restarter) override;
|
2018-04-11 20:53:16 +05:30
|
|
|
void RendererResponsive(
|
|
|
|
content::WebContents* source,
|
|
|
|
content::RenderWidgetHost* render_widget_host) override;
|
2021-11-24 09:45:59 +01:00
|
|
|
bool HandleContextMenu(content::RenderFrameHost& render_frame_host,
|
2019-02-27 13:19:59 +05:30
|
|
|
const content::ContextMenuParams& params) override;
|
2015-12-20 01:23:47 +05:30
|
|
|
bool OnGoToEntryOffset(int offset) override;
|
2015-12-17 22:57:56 +05:30
|
|
|
void FindReply(content::WebContents* web_contents,
|
|
|
|
int request_id,
|
|
|
|
int number_of_matches,
|
|
|
|
const gfx::Rect& selection_rect,
|
|
|
|
int active_match_ordinal,
|
|
|
|
bool final_update) override;
|
2022-02-09 10:40:50 +01:00
|
|
|
void RequestExclusivePointerAccess(content::WebContents* web_contents,
|
|
|
|
bool user_gesture,
|
|
|
|
bool last_unlocked_by_target,
|
|
|
|
bool allowed);
|
|
|
|
void RequestToLockMouse(content::WebContents* web_contents,
|
|
|
|
bool user_gesture,
|
|
|
|
bool last_unlocked_by_target) override;
|
|
|
|
void LostMouseLock() override;
|
2021-10-28 16:23:05 +02:00
|
|
|
void RequestKeyboardLock(content::WebContents* web_contents,
|
|
|
|
bool esc_key_locked) override;
|
|
|
|
void CancelKeyboardLockRequest(content::WebContents* web_contents) override;
|
2018-09-09 16:30:28 +02:00
|
|
|
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
2018-04-17 21:44:10 -04:00
|
|
|
const GURL& security_origin,
|
2019-07-02 18:22:09 -07:00
|
|
|
blink::mojom::MediaStreamType type) override;
|
2016-01-23 18:59:47 +05:30
|
|
|
void RequestMediaAccessPermission(
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
const content::MediaStreamRequest& request,
|
2018-10-02 11:09:25 -07:00
|
|
|
content::MediaResponseCallback callback) override;
|
2017-04-27 19:28:48 -05:00
|
|
|
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
|
|
|
content::WebContents* source) override;
|
2018-09-14 17:18:14 -07:00
|
|
|
void OnAudioStateChanged(bool audible) override;
|
2020-10-21 18:44:19 -04:00
|
|
|
void UpdatePreferredSize(content::WebContents* web_contents,
|
|
|
|
const gfx::Size& pref_size) override;
|
2014-10-24 18:06:32 +08:00
|
|
|
|
2014-10-23 17:54:52 +08:00
|
|
|
// content::WebContentsObserver:
|
2019-01-12 06:30:43 +05:30
|
|
|
void BeforeUnloadFired(bool proceed,
|
|
|
|
const base::TimeTicks& proceed_time) override;
|
2022-01-27 15:56:35 +01:00
|
|
|
void OnBackgroundColorChanged() override;
|
2019-12-02 10:29:03 -08:00
|
|
|
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
|
2021-08-18 14:23:41 -04:00
|
|
|
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
|
|
|
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
|
|
|
|
content::RenderFrameHost* new_host) override;
|
|
|
|
void FrameDeleted(int frame_tree_node_id) override;
|
2014-12-09 14:38:43 -08:00
|
|
|
void RenderViewDeleted(content::RenderViewHost*) override;
|
2021-11-24 09:45:59 +01:00
|
|
|
void PrimaryMainFrameRenderProcessGone(
|
|
|
|
base::TerminationStatus status) override;
|
2019-10-18 15:57:34 -04:00
|
|
|
void DOMContentLoaded(content::RenderFrameHost* render_frame_host) override;
|
2014-12-09 14:38:43 -08:00
|
|
|
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
|
|
|
const GURL& validated_url) override;
|
|
|
|
void DidFailLoad(content::RenderFrameHost* render_frame_host,
|
|
|
|
const GURL& validated_url,
|
2020-01-29 04:01:37 -08:00
|
|
|
int error_code) override;
|
2015-05-22 15:24:34 +08:00
|
|
|
void DidStartLoading() override;
|
|
|
|
void DidStopLoading() override;
|
2018-04-26 06:17:55 -04:00
|
|
|
void DidStartNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2018-09-16 01:42:43 +10:00
|
|
|
void DidRedirectNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2021-05-19 02:27:35 -07:00
|
|
|
void ReadyToCommitNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2016-07-14 05:49:28 +05:30
|
|
|
void DidFinishNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2014-12-09 14:38:43 -08:00
|
|
|
void WebContentsDestroyed() override;
|
2015-03-05 20:09:27 +05:30
|
|
|
void NavigationEntryCommitted(
|
|
|
|
const content::LoadCommittedDetails& load_details) override;
|
2017-12-18 11:19:21 +11:00
|
|
|
void TitleWasSet(content::NavigationEntry* entry) override;
|
2015-04-18 01:25:31 +05:30
|
|
|
void DidUpdateFaviconURL(
|
2020-06-22 10:35:10 -07:00
|
|
|
content::RenderFrameHost* render_frame_host,
|
2020-03-03 13:35:05 -08:00
|
|
|
const std::vector<blink::mojom::FaviconURLPtr>& urls) override;
|
2015-05-13 01:05:56 +05:30
|
|
|
void PluginCrashed(const base::FilePath& plugin_path,
|
|
|
|
base::ProcessId plugin_pid) override;
|
2017-01-23 18:59:40 +09:00
|
|
|
void MediaStartedPlaying(const MediaPlayerInfo& video_type,
|
2019-04-20 13:20:37 -04:00
|
|
|
const content::MediaPlayerId& id) override;
|
2018-04-11 20:57:14 +05:30
|
|
|
void MediaStoppedPlaying(
|
|
|
|
const MediaPlayerInfo& video_type,
|
2019-04-20 13:20:37 -04:00
|
|
|
const content::MediaPlayerId& id,
|
2018-04-11 20:57:14 +05:30
|
|
|
content::WebContentsObserver::MediaStoppedReason reason) override;
|
2020-01-17 10:41:52 -08:00
|
|
|
void DidChangeThemeColor() override;
|
2020-05-26 13:06:26 -07:00
|
|
|
void OnCursorChanged(const content::WebCursor& cursor) override;
|
2019-06-13 14:02:56 -07:00
|
|
|
void DidAcquireFullscreen(content::RenderFrameHost* rfh) override;
|
2022-02-01 05:28:57 -05:00
|
|
|
void OnWebContentsFocused(
|
|
|
|
content::RenderWidgetHost* render_widget_host) override;
|
|
|
|
void OnWebContentsLostFocus(
|
|
|
|
content::RenderWidgetHost* render_widget_host) override;
|
2014-04-24 16:45:25 +08:00
|
|
|
|
2018-10-19 15:50:30 +02:00
|
|
|
// InspectableWebContentsDelegate:
|
2016-04-12 16:36:12 +09:00
|
|
|
void DevToolsReloadPage() override;
|
|
|
|
|
2018-10-19 15:50:30 +02:00
|
|
|
// InspectableWebContentsViewDelegate:
|
2015-10-01 11:14:19 +08:00
|
|
|
void DevToolsFocused() override;
|
|
|
|
void DevToolsOpened() override;
|
|
|
|
void DevToolsClosed() override;
|
2020-11-10 06:54:04 +09:00
|
|
|
void DevToolsResized() override;
|
2017-09-13 01:25:18 +02:00
|
|
|
|
2015-07-14 12:13:25 -07:00
|
|
|
ElectronBrowserContext* GetBrowserContext() const;
|
|
|
|
|
2019-04-03 14:22:23 -07:00
|
|
|
void OnElectronBrowserConnectionError();
|
2019-04-02 15:38:16 -07:00
|
|
|
|
2018-10-02 01:30:53 +05:30
|
|
|
#if BUILDFLAG(ENABLE_OSR)
|
2020-11-10 09:06:56 -08:00
|
|
|
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
|
2018-11-29 21:25:02 -08:00
|
|
|
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
|
2018-03-20 10:25:51 +09:00
|
|
|
#endif
|
|
|
|
|
2017-01-30 22:36:50 +05:30
|
|
|
// Called when received a synchronous message from renderer to
|
|
|
|
// get the zoom level.
|
2018-03-09 15:01:09 +05:30
|
|
|
void OnGetZoomLevel(content::RenderFrameHost* frame_host,
|
|
|
|
IPC::Message* reply_msg);
|
2017-01-30 22:36:50 +05:30
|
|
|
|
2017-10-21 22:21:24 +02:00
|
|
|
void InitZoomController(content::WebContents* web_contents,
|
2019-10-25 22:03:28 +09:00
|
|
|
const gin_helper::Dictionary& options);
|
2017-10-21 22:21:24 +02:00
|
|
|
|
2020-11-10 09:06:56 -08:00
|
|
|
// content::WebContentsDelegate:
|
|
|
|
bool CanOverscrollContent() override;
|
2021-01-21 13:02:29 -08:00
|
|
|
std::unique_ptr<content::EyeDropper> OpenEyeDropper(
|
|
|
|
content::RenderFrameHost* frame,
|
|
|
|
content::EyeDropperListener* listener) override;
|
2020-11-10 09:06:56 -08:00
|
|
|
void RunFileChooser(content::RenderFrameHost* render_frame_host,
|
|
|
|
scoped_refptr<content::FileSelectListener> listener,
|
|
|
|
const blink::mojom::FileChooserParams& params) override;
|
|
|
|
void EnumerateDirectory(content::WebContents* web_contents,
|
|
|
|
scoped_refptr<content::FileSelectListener> listener,
|
|
|
|
const base::FilePath& path) override;
|
2021-10-28 16:23:05 +02:00
|
|
|
|
|
|
|
// ExclusiveAccessContext:
|
|
|
|
Profile* GetProfile() override;
|
|
|
|
bool IsFullscreen() const override;
|
|
|
|
void EnterFullscreen(const GURL& url,
|
|
|
|
ExclusiveAccessBubbleType bubble_type,
|
|
|
|
const int64_t display_id) override;
|
|
|
|
void ExitFullscreen() override;
|
|
|
|
void UpdateExclusiveAccessExitBubbleContent(
|
|
|
|
const GURL& url,
|
|
|
|
ExclusiveAccessBubbleType bubble_type,
|
|
|
|
ExclusiveAccessBubbleHideCallback bubble_first_hide_callback,
|
|
|
|
bool force_update) override;
|
|
|
|
void OnExclusiveAccessUserInput() override;
|
|
|
|
content::WebContents* GetActiveWebContents() override;
|
|
|
|
bool CanUserExitFullscreen() const override;
|
|
|
|
bool IsExclusiveAccessBubbleDisplayed() const override;
|
|
|
|
|
2020-11-10 09:06:56 -08:00
|
|
|
bool IsFullscreenForTabOrPending(const content::WebContents* source) override;
|
|
|
|
bool TakeFocus(content::WebContents* source, bool reverse) override;
|
|
|
|
content::PictureInPictureResult EnterPictureInPicture(
|
2022-02-25 13:17:35 -05:00
|
|
|
content::WebContents* web_contents) override;
|
2020-11-10 09:06:56 -08:00
|
|
|
void ExitPictureInPicture() override;
|
|
|
|
|
|
|
|
// InspectableWebContentsDelegate:
|
|
|
|
void DevToolsSaveToFile(const std::string& url,
|
|
|
|
const std::string& content,
|
|
|
|
bool save_as) override;
|
|
|
|
void DevToolsAppendToFile(const std::string& url,
|
|
|
|
const std::string& content) override;
|
|
|
|
void DevToolsRequestFileSystems() override;
|
|
|
|
void DevToolsAddFileSystem(const std::string& type,
|
|
|
|
const base::FilePath& file_system_path) override;
|
|
|
|
void DevToolsRemoveFileSystem(
|
|
|
|
const base::FilePath& file_system_path) override;
|
|
|
|
void DevToolsIndexPath(int request_id,
|
|
|
|
const std::string& file_system_path,
|
|
|
|
const std::string& excluded_folders_message) override;
|
|
|
|
void DevToolsStopIndexing(int request_id) override;
|
|
|
|
void DevToolsSearchInPath(int request_id,
|
|
|
|
const std::string& file_system_path,
|
|
|
|
const std::string& query) override;
|
2021-06-17 15:42:51 +02:00
|
|
|
void DevToolsSetEyeDropperActive(bool active) override;
|
2020-11-10 09:06:56 -08:00
|
|
|
|
|
|
|
// InspectableWebContentsViewDelegate:
|
2022-02-09 18:58:52 -08:00
|
|
|
#if defined(TOOLKIT_VIEWS) && !BUILDFLAG(IS_MAC)
|
2021-06-08 15:22:43 -05:00
|
|
|
ui::ImageModel GetDevToolsWindowIcon() override;
|
2020-11-10 09:06:56 -08:00
|
|
|
#endif
|
2022-02-09 18:58:52 -08:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2020-11-10 09:06:56 -08:00
|
|
|
void GetDevToolsWindowWMClass(std::string* name,
|
|
|
|
std::string* class_name) override;
|
|
|
|
#endif
|
|
|
|
|
2021-06-17 15:42:51 +02:00
|
|
|
void ColorPickedInEyeDropper(int r, int g, int b, int a);
|
|
|
|
|
2020-11-10 09:06:56 -08:00
|
|
|
// DevTools index event callbacks.
|
|
|
|
void OnDevToolsIndexingWorkCalculated(int request_id,
|
|
|
|
const std::string& file_system_path,
|
|
|
|
int total_work);
|
|
|
|
void OnDevToolsIndexingWorked(int request_id,
|
|
|
|
const std::string& file_system_path,
|
|
|
|
int worked);
|
|
|
|
void OnDevToolsIndexingDone(int request_id,
|
|
|
|
const std::string& file_system_path);
|
|
|
|
void OnDevToolsSearchCompleted(int request_id,
|
|
|
|
const std::string& file_system_path,
|
|
|
|
const std::vector<std::string>& file_paths);
|
|
|
|
|
|
|
|
// Set fullscreen mode triggered by html api.
|
|
|
|
void SetHtmlApiFullscreen(bool enter_fullscreen);
|
2021-07-02 09:56:29 +09:00
|
|
|
// Update the html fullscreen flag in both browser and renderer.
|
|
|
|
void UpdateHtmlApiFullscreen(bool fullscreen);
|
2020-11-10 09:06:56 -08:00
|
|
|
|
2015-06-16 17:23:29 +08:00
|
|
|
v8::Global<v8::Value> session_;
|
2015-10-01 11:14:19 +08:00
|
|
|
v8::Global<v8::Value> devtools_web_contents_;
|
2016-01-21 23:52:23 +05:30
|
|
|
v8::Global<v8::Value> debugger_;
|
2015-06-16 17:23:29 +08:00
|
|
|
|
2017-04-27 19:28:48 -05:00
|
|
|
std::unique_ptr<ElectronJavaScriptDialogManager> dialog_manager_;
|
2016-05-23 10:59:39 +09:00
|
|
|
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
|
2018-04-18 02:45:15 +02:00
|
|
|
std::unique_ptr<FrameSubscriber> frame_subscriber_;
|
|
|
|
|
2020-01-15 15:11:51 -08:00
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
|
|
|
std::unique_ptr<extensions::ScriptExecutor> script_executor_;
|
|
|
|
#endif
|
|
|
|
|
2016-02-17 14:22:19 +05:30
|
|
|
// The host webcontents that may contain this webcontents.
|
2018-05-22 00:18:38 +02:00
|
|
|
WebContents* embedder_ = nullptr;
|
2016-02-17 14:22:19 +05:30
|
|
|
|
2021-03-15 18:43:25 -04:00
|
|
|
// Whether the guest view has been attached.
|
|
|
|
bool attached_ = false;
|
|
|
|
|
2017-01-30 16:48:40 +05:30
|
|
|
// The zoom controller for this webContents.
|
2018-05-22 00:18:38 +02:00
|
|
|
WebContentsZoomController* zoom_controller_ = nullptr;
|
2017-01-30 16:48:40 +05:30
|
|
|
|
2015-06-24 21:44:27 +08:00
|
|
|
// The type of current WebContents.
|
2020-10-27 18:51:45 +01:00
|
|
|
Type type_ = Type::kBrowserWindow;
|
2015-06-24 21:44:27 +08:00
|
|
|
|
2020-07-30 09:17:57 -07:00
|
|
|
int32_t id_;
|
|
|
|
|
2015-12-18 04:40:42 +05:30
|
|
|
// Request id used for findInPage request.
|
2020-11-17 14:15:07 -08:00
|
|
|
uint32_t find_in_page_request_id_ = 0;
|
2015-12-18 04:40:42 +05:30
|
|
|
|
2016-04-08 15:54:33 +09:00
|
|
|
// Whether background throttling is disabled.
|
2018-05-22 00:18:38 +02:00
|
|
|
bool background_throttling_ = true;
|
2016-04-08 15:54:33 +09:00
|
|
|
|
2016-09-07 10:16:52 +08:00
|
|
|
// Whether to enable devtools.
|
2018-05-22 00:18:38 +02:00
|
|
|
bool enable_devtools_ = true;
|
2016-09-05 16:27:56 +08:00
|
|
|
|
2018-02-22 15:57:03 +09:00
|
|
|
// Observers of this WebContents.
|
|
|
|
base::ObserverList<ExtendedWebContentsObserver> observers_;
|
|
|
|
|
2020-11-10 09:06:03 -08:00
|
|
|
v8::Global<v8::Value> pending_child_web_preferences_;
|
|
|
|
|
2020-11-10 09:06:56 -08:00
|
|
|
// The window that this WebContents belongs to.
|
|
|
|
base::WeakPtr<NativeWindow> owner_window_;
|
|
|
|
|
|
|
|
bool offscreen_ = false;
|
|
|
|
|
|
|
|
// Whether window is fullscreened by HTML5 api.
|
|
|
|
bool html_fullscreen_ = false;
|
|
|
|
|
|
|
|
// Whether window is fullscreened by window api.
|
|
|
|
bool native_fullscreen_ = false;
|
|
|
|
|
|
|
|
scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_;
|
|
|
|
|
2021-10-28 16:23:05 +02:00
|
|
|
std::unique_ptr<ExclusiveAccessManager> exclusive_access_manager_;
|
|
|
|
|
2021-06-17 15:42:51 +02:00
|
|
|
std::unique_ptr<DevToolsEyeDropper> eye_dropper_;
|
|
|
|
|
2020-11-10 09:06:56 -08:00
|
|
|
ElectronBrowserContext* browser_context_;
|
|
|
|
|
|
|
|
// The stored InspectableWebContents object.
|
2020-11-17 14:15:20 -08:00
|
|
|
// Notice that inspectable_web_contents_ must be placed after
|
|
|
|
// dialog_manager_, so we can make sure inspectable_web_contents_ is
|
|
|
|
// destroyed before dialog_manager_, otherwise a crash would happen.
|
|
|
|
std::unique_ptr<InspectableWebContents> inspectable_web_contents_;
|
2020-11-10 09:06:56 -08:00
|
|
|
|
|
|
|
// Maps url to file path, used by the file requests sent from devtools.
|
|
|
|
typedef std::map<std::string, base::FilePath> PathsMap;
|
|
|
|
PathsMap saved_files_;
|
|
|
|
|
|
|
|
// Map id to index job, used for file system indexing requests from devtools.
|
|
|
|
typedef std::
|
|
|
|
map<int, scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>>
|
|
|
|
DevToolsIndexingJobsMap;
|
|
|
|
DevToolsIndexingJobsMap devtools_indexing_jobs_;
|
|
|
|
|
|
|
|
scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
|
2021-01-25 17:27:25 +01:00
|
|
|
|
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
2021-01-13 09:17:11 -08:00
|
|
|
scoped_refptr<base::TaskRunner> print_task_runner_;
|
2021-01-25 17:27:25 +01:00
|
|
|
#endif
|
2020-11-10 09:06:56 -08:00
|
|
|
|
|
|
|
// Stores the frame thats currently in fullscreen, nullptr if there is none.
|
|
|
|
content::RenderFrameHost* fullscreen_frame_ = nullptr;
|
|
|
|
|
2021-01-26 19:16:21 +01:00
|
|
|
base::WeakPtrFactory<WebContents> weak_factory_{this};
|
2014-04-24 16:45:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 08:34:31 +01:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_H_
|