2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2014-04-24 08:45:25 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#ifndef SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_H_
|
|
|
|
#define SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_H_
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2019-04-02 22:38:16 +00:00
|
|
|
#include <map>
|
2018-09-13 00:25:56 +00:00
|
|
|
#include <memory>
|
2014-10-24 12:57:44 +00:00
|
|
|
#include <string>
|
2020-07-30 16:17:57 +00:00
|
|
|
#include <utility>
|
2015-04-17 19:55:31 +00:00
|
|
|
#include <vector>
|
2014-10-24 12:57:44 +00:00
|
|
|
|
2018-02-22 06:57:03 +00:00
|
|
|
#include "base/observer_list.h"
|
2018-10-25 06:43:50 +00:00
|
|
|
#include "base/observer_list_types.h"
|
2016-08-26 22:30:02 +00:00
|
|
|
#include "content/common/cursors/webcursor.h"
|
2020-03-26 18:05:45 +00:00
|
|
|
#include "content/common/frame.mojom.h"
|
2019-10-02 12:38:27 +00:00
|
|
|
#include "content/public/browser/devtools_agent_host.h"
|
2017-06-16 21:35:43 +00:00
|
|
|
#include "content/public/browser/keyboard_event_processing_result.h"
|
2019-08-19 20:13:24 +00:00
|
|
|
#include "content/public/browser/render_widget_host.h"
|
2017-08-07 21:09:01 +00:00
|
|
|
#include "content/public/browser/web_contents.h"
|
2014-04-25 03:22:51 +00:00
|
|
|
#include "content/public/browser/web_contents_observer.h"
|
2018-10-01 20:00:53 +00:00
|
|
|
#include "electron/buildflags/buildflags.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "electron/shell/common/api/api.mojom.h"
|
2019-10-25 13:03:28 +00:00
|
|
|
#include "gin/handle.h"
|
2020-07-30 16:17:57 +00:00
|
|
|
#include "gin/wrappable.h"
|
2020-06-22 17:35:10 +00:00
|
|
|
#include "mojo/public/cpp/bindings/receiver_set.h"
|
2018-11-09 03:42:34 +00:00
|
|
|
#include "printing/buildflags/buildflags.h"
|
2019-04-02 22:38:16 +00:00
|
|
|
#include "services/service_manager/public/cpp/binder_registry.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/api/frame_subscriber.h"
|
|
|
|
#include "shell/browser/api/save_page_handler.h"
|
|
|
|
#include "shell/browser/common_web_contents_delegate.h"
|
2020-07-30 16:17:57 +00:00
|
|
|
#include "shell/browser/event_emitter_mixin.h"
|
|
|
|
#include "shell/common/gin_helper/cleaned_up_at_exit.h"
|
|
|
|
#include "shell/common/gin_helper/constructible.h"
|
2020-07-20 18:07:02 +00:00
|
|
|
#include "shell/common/gin_helper/error_thrower.h"
|
2015-04-20 06:50:04 +00:00
|
|
|
#include "ui/gfx/image/image.h"
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2018-11-09 03:42:34 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
2020-01-31 19:20:11 +00:00
|
|
|
#include "chrome/browser/printing/print_view_manager_basic.h"
|
|
|
|
#include "components/printing/common/print_messages.h"
|
2020-04-29 06:16:10 +00:00
|
|
|
#include "printing/backend/print_backend.h" // nogncheck
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/printing/print_preview_message_handler.h"
|
2020-01-31 19:20:11 +00:00
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include "printing/backend/win_helper.h"
|
|
|
|
#endif
|
2018-11-09 03:42:34 +00:00
|
|
|
#endif
|
|
|
|
|
2020-01-15 23:11:51 +00:00
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
2020-03-05 14:56:21 +00:00
|
|
|
namespace extensions {
|
|
|
|
class ScriptExecutor;
|
|
|
|
}
|
2020-01-15 23:11:51 +00:00
|
|
|
#endif
|
|
|
|
|
2015-09-18 03:06:38 +00:00
|
|
|
namespace blink {
|
|
|
|
struct WebDeviceEmulationParams;
|
|
|
|
}
|
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
namespace gin_helper {
|
2014-11-03 14:12:56 +00:00
|
|
|
class Dictionary;
|
2019-10-25 13:03:28 +00:00
|
|
|
}
|
2014-11-03 14:12:56 +00:00
|
|
|
|
2018-04-11 08:42:14 +00:00
|
|
|
namespace network {
|
|
|
|
class ResourceRequestBody;
|
|
|
|
}
|
|
|
|
|
2020-05-11 20:42:24 +00:00
|
|
|
namespace gin {
|
|
|
|
|
2020-07-20 18:07:02 +00:00
|
|
|
class Arguments;
|
|
|
|
|
2020-05-11 20:42:24 +00:00
|
|
|
template <>
|
|
|
|
struct Converter<base::TerminationStatus> {
|
|
|
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
|
|
|
const base::TerminationStatus& status) {
|
|
|
|
switch (status) {
|
|
|
|
case base::TERMINATION_STATUS_NORMAL_TERMINATION:
|
|
|
|
return gin::ConvertToV8(isolate, "clean-exit");
|
|
|
|
case base::TERMINATION_STATUS_ABNORMAL_TERMINATION:
|
|
|
|
return gin::ConvertToV8(isolate, "abnormal-exit");
|
|
|
|
case base::TERMINATION_STATUS_PROCESS_WAS_KILLED:
|
|
|
|
return gin::ConvertToV8(isolate, "killed");
|
|
|
|
case base::TERMINATION_STATUS_PROCESS_CRASHED:
|
|
|
|
return gin::ConvertToV8(isolate, "crashed");
|
|
|
|
case base::TERMINATION_STATUS_STILL_RUNNING:
|
|
|
|
return gin::ConvertToV8(isolate, "still-running");
|
|
|
|
case base::TERMINATION_STATUS_LAUNCH_FAILED:
|
|
|
|
return gin::ConvertToV8(isolate, "launch-failed");
|
|
|
|
case base::TERMINATION_STATUS_OOM:
|
|
|
|
return gin::ConvertToV8(isolate, "oom");
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
case base::TERMINATION_STATUS_INTEGRITY_FAILURE:
|
|
|
|
return gin::ConvertToV8(isolate, "integrity-failure");
|
|
|
|
#endif
|
|
|
|
case base::TERMINATION_STATUS_MAX_ENUM:
|
|
|
|
NOTREACHED();
|
|
|
|
return gin::ConvertToV8(isolate, "");
|
|
|
|
}
|
|
|
|
NOTREACHED();
|
|
|
|
return gin::ConvertToV8(isolate, "");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gin
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
class ElectronBrowserContext;
|
|
|
|
class ElectronJavaScriptDialogManager;
|
2018-10-19 13:50:30 +00:00
|
|
|
class InspectableWebContents;
|
2017-01-30 11:18:40 +00:00
|
|
|
class WebContentsZoomController;
|
2015-06-25 06:28:13 +00:00
|
|
|
class WebViewGuestDelegate;
|
2018-05-14 15:55:39 +00:00
|
|
|
class FrameSubscriber;
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2018-10-01 20:00:53 +00:00
|
|
|
#if BUILDFLAG(ENABLE_OSR)
|
2018-11-30 05:25:02 +00:00
|
|
|
class OffScreenRenderWidgetHostView;
|
2018-03-20 01:25:51 +00:00
|
|
|
#endif
|
|
|
|
|
2015-06-25 06:28:13 +00:00
|
|
|
namespace api {
|
2015-05-29 03:12:55 +00:00
|
|
|
|
2018-02-22 06:48:53 +00:00
|
|
|
// Certain events are only in WebContentsDelegate, provide our own Observer to
|
|
|
|
// dispatch those events.
|
2018-10-25 06:43:50 +00:00
|
|
|
class ExtendedWebContentsObserver : public base::CheckedObserver {
|
2018-02-22 06:57:03 +00:00
|
|
|
public:
|
2018-02-22 07:52:08 +00:00
|
|
|
virtual void OnCloseContents() {}
|
2019-06-03 17:43:04 +00:00
|
|
|
virtual void OnDraggableRegionsUpdated(
|
|
|
|
const std::vector<mojom::DraggableRegionPtr>& regions) {}
|
2020-02-11 00:37:46 +00:00
|
|
|
virtual void OnSetContentBounds(const gfx::Rect& rect) {}
|
|
|
|
virtual void OnActivateContents() {}
|
|
|
|
virtual void OnPageTitleUpdated(const base::string16& title,
|
|
|
|
bool explicit_set) {}
|
2018-10-25 06:43:50 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
~ExtendedWebContentsObserver() override {}
|
2018-02-22 06:48:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Wrapper around the content::WebContents.
|
2020-07-30 16:17:57 +00:00
|
|
|
class WebContents : public gin::Wrappable<WebContents>,
|
|
|
|
public gin_helper::EventEmitterMixin<WebContents>,
|
|
|
|
public gin_helper::Constructible<WebContents>,
|
|
|
|
public gin_helper::CleanedUpAtExit,
|
2015-06-05 05:49:12 +00:00
|
|
|
public CommonWebContentsDelegate,
|
2019-04-02 22:38:16 +00:00
|
|
|
public content::WebContentsObserver,
|
|
|
|
public mojom::ElectronBrowser {
|
2014-04-24 08:45:25 +00:00
|
|
|
public:
|
2019-05-03 18:11:41 +00:00
|
|
|
enum class Type {
|
2016-06-14 16:32:59 +00:00
|
|
|
BACKGROUND_PAGE, // A DevTools extension background page.
|
Implement initial, experimental BrowserView API
Right now, `<webview>` is the only way to embed additional content in a
`BrowserWindow`. Unfortunately `<webview>` suffers from a [number of
problems](https://github.com/electron/electron/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20label%3Awebview%20).
To make matters worse, many of these are upstream Chromium bugs instead
of Electron-specific bugs.
For us at [Figma](https://www.figma.com), the main issue is very slow
performance.
Despite the upstream improvements to `<webview>` through the OOPIF work, it is
probable that there will continue to be `<webview>`-specific bugs in the
future.
Therefore, this introduces a `<webview>` alternative to called `BrowserView`,
which...
- is a thin wrapper around `api::WebContents` (so bugs in `BrowserView` will
likely also be bugs in `BrowserWindow` web contents)
- is instantiated in the main process like `BrowserWindow` (and unlike
`<webview>`, which lives in the DOM of a `BrowserWindow` web contents)
- needs to be added to a `BrowserWindow` to display something on the screen
This implements the most basic API. The API is expected to evolve and change in
the near future and has consequently been marked as experimental. Please do not
use this API in production unless you are prepared to deal with breaking
changes.
In the future, we will want to change the API to support multiple
`BrowserView`s per window. We will also want to consider z-ordering
auto-resizing, and possibly even nested views.
2017-04-11 17:47:30 +00:00
|
|
|
BROWSER_WINDOW, // Used by BrowserWindow.
|
|
|
|
BROWSER_VIEW, // Used by BrowserView.
|
|
|
|
REMOTE, // Thin wrap around an existing WebContents.
|
|
|
|
WEB_VIEW, // Used by <webview>.
|
|
|
|
OFF_SCREEN, // Used for offscreen rendering
|
2016-06-14 16:09:54 +00:00
|
|
|
};
|
|
|
|
|
2018-10-19 08:52:07 +00:00
|
|
|
// Create a new WebContents and return the V8 wrapper of it.
|
2019-10-25 13:03:28 +00:00
|
|
|
static gin::Handle<WebContents> Create(v8::Isolate* isolate,
|
|
|
|
const gin_helper::Dictionary& options);
|
2020-07-30 16:17:57 +00:00
|
|
|
static gin::Handle<WebContents> New(v8::Isolate* isolate,
|
|
|
|
const gin_helper::Dictionary& options);
|
2018-10-19 08:52:07 +00: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 13:03:28 +00:00
|
|
|
static gin::Handle<WebContents> CreateAndTake(
|
2018-04-18 01:44:10 +00:00
|
|
|
v8::Isolate* isolate,
|
2018-10-22 18:02:25 +00:00
|
|
|
std::unique_ptr<content::WebContents> web_contents,
|
2018-04-18 01:44:10 +00:00
|
|
|
Type type);
|
2014-10-23 06:04:13 +00:00
|
|
|
|
2020-07-16 23:16:05 +00: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 08:52:07 +00: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 13:03:28 +00:00
|
|
|
static gin::Handle<WebContents> FromOrCreate(
|
2018-10-19 08:52:07 +00:00
|
|
|
v8::Isolate* isolate,
|
|
|
|
content::WebContents* web_contents);
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2020-07-30 16:17:57 +00: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 01:17:54 +00:00
|
|
|
|
2019-06-14 02:44:36 +00:00
|
|
|
base::WeakPtr<WebContents> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
|
|
|
|
|
2018-11-08 15:57:28 +00:00
|
|
|
// Destroy the managed content::WebContents instance.
|
|
|
|
//
|
|
|
|
// Note: The |async| should only be |true| when users are expecting to use the
|
|
|
|
// webContents immediately after the call. Always pass |false| if you are not
|
|
|
|
// sure.
|
|
|
|
// See https://github.com/electron/electron/issues/8930.
|
|
|
|
//
|
|
|
|
// Note: When destroying a webContents member inside a destructor, the |async|
|
|
|
|
// should always be |false|, otherwise the destroy task might be delayed after
|
|
|
|
// normal shutdown procedure, resulting in an assertion.
|
|
|
|
// The normal pattern for calling this method in destructor is:
|
|
|
|
// api_web_contents_->DestroyWebContents(!Browser::Get()->is_shutting_down())
|
|
|
|
// See https://github.com/electron/electron/issues/15133.
|
2017-04-03 20:03:51 +00:00
|
|
|
void DestroyWebContents(bool async);
|
2017-03-18 19:40:30 +00:00
|
|
|
|
2020-05-14 13:11:45 +00:00
|
|
|
bool GetBackgroundThrottling() const;
|
2018-10-19 00:32:22 +00:00
|
|
|
void SetBackgroundThrottling(bool allowed);
|
2016-09-06 01:28:40 +00:00
|
|
|
int GetProcessID() const;
|
2017-05-15 20:29:34 +00:00
|
|
|
base::ProcessId GetOSProcessID() const;
|
2019-06-20 10:10:56 +00:00
|
|
|
base::ProcessId GetOSProcessIdForFrame(const std::string& name,
|
|
|
|
const std::string& document_url) const;
|
2016-06-14 16:09:54 +00:00
|
|
|
Type GetType() const;
|
2015-06-23 08:16:10 +00:00
|
|
|
bool Equal(const WebContents* web_contents) const;
|
2019-10-25 13:03:28 +00:00
|
|
|
void LoadURL(const GURL& url, const gin_helper::Dictionary& options);
|
2015-12-02 21:49:30 +00:00
|
|
|
void DownloadURL(const GURL& url);
|
2015-09-15 01:17:45 +00:00
|
|
|
GURL GetURL() const;
|
2014-06-28 11:36:57 +00:00
|
|
|
base::string16 GetTitle() const;
|
2014-04-24 09:00:41 +00:00
|
|
|
bool IsLoading() const;
|
2016-04-18 17:37:08 +00:00
|
|
|
bool IsLoadingMainFrame() const;
|
2014-04-24 09:00:41 +00:00
|
|
|
bool IsWaitingForResponse() const;
|
|
|
|
void Stop();
|
2015-04-26 13:28:30 +00:00
|
|
|
void ReloadIgnoringCache();
|
2015-05-11 06:30:26 +00:00
|
|
|
void GoBack();
|
|
|
|
void GoForward();
|
2015-05-11 08:44:01 +00:00
|
|
|
void GoToOffset(int offset);
|
2017-03-09 03:06:26 +00:00
|
|
|
const std::string GetWebRTCIPHandlingPolicy() const;
|
|
|
|
void SetWebRTCIPHandlingPolicy(const std::string& webrtc_ip_handling_policy);
|
2014-04-24 09:00:41 +00:00
|
|
|
bool IsCrashed() const;
|
2020-07-20 18:07:02 +00:00
|
|
|
void SetUserAgent(const std::string& user_agent);
|
2015-07-22 04:25:10 +00:00
|
|
|
std::string GetUserAgent();
|
2014-10-24 13:04:50 +00:00
|
|
|
void InsertCSS(const std::string& css);
|
2019-02-14 17:03:28 +00:00
|
|
|
v8::Local<v8::Promise> SavePage(const base::FilePath& full_file_path,
|
|
|
|
const content::SavePageType& save_type);
|
2020-07-20 18:07:02 +00:00
|
|
|
void OpenDevTools(gin::Arguments* args);
|
2014-11-03 14:12:56 +00:00
|
|
|
void CloseDevTools();
|
|
|
|
bool IsDevToolsOpened();
|
2016-01-01 05:11:21 +00:00
|
|
|
bool IsDevToolsFocused();
|
2015-06-05 09:01:17 +00:00
|
|
|
void ToggleDevTools();
|
2015-09-18 03:06:38 +00:00
|
|
|
void EnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
|
2015-08-31 09:19:19 +00:00
|
|
|
void DisableDeviceEmulation();
|
2015-04-22 07:30:10 +00:00
|
|
|
void InspectElement(int x, int y);
|
2019-02-01 18:44:24 +00:00
|
|
|
void InspectSharedWorker();
|
2019-10-02 12:38:27 +00:00
|
|
|
void InspectSharedWorkerById(const std::string& workerId);
|
|
|
|
std::vector<scoped_refptr<content::DevToolsAgentHost>> GetAllSharedWorkers();
|
2015-06-05 07:41:03 +00:00
|
|
|
void InspectServiceWorker();
|
2017-06-25 19:01:05 +00:00
|
|
|
void SetIgnoreMenuShortcuts(bool ignore);
|
2015-06-15 13:40:49 +00:00
|
|
|
void SetAudioMuted(bool muted);
|
|
|
|
bool IsAudioMuted();
|
2018-07-12 11:35:11 +00:00
|
|
|
bool IsCurrentlyAudible();
|
2016-09-08 17:01:01 +00:00
|
|
|
void SetEmbedder(const WebContents* embedder);
|
2017-11-30 07:37:26 +00:00
|
|
|
void SetDevToolsWebContents(const WebContents* devtools);
|
2020-07-16 21:11:44 +00:00
|
|
|
v8::Local<v8::Value> GetNativeView(v8::Isolate* isolate) const;
|
2020-07-20 18:07:02 +00:00
|
|
|
void IncrementCapturerCount(gin::Arguments* args);
|
|
|
|
void DecrementCapturerCount(gin::Arguments* args);
|
2020-01-25 00:43:42 +00:00
|
|
|
bool IsBeingCaptured();
|
2015-01-19 20:09:47 +00:00
|
|
|
|
2018-11-09 03:42:34 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
2020-01-31 19:20:11 +00:00
|
|
|
void OnGetDefaultPrinter(base::Value print_settings,
|
|
|
|
printing::CompletionCallback print_callback,
|
|
|
|
base::string16 device_name,
|
|
|
|
bool silent,
|
|
|
|
base::string16 default_printer);
|
2020-07-20 18:07:02 +00:00
|
|
|
void Print(gin::Arguments* args);
|
2018-11-09 03:42:34 +00:00
|
|
|
std::vector<printing::PrinterBasicInfo> GetPrinterList();
|
2015-06-09 05:07:40 +00:00
|
|
|
// Print current page as PDF.
|
2019-10-30 05:30:59 +00:00
|
|
|
v8::Local<v8::Promise> PrintToPDF(base::DictionaryValue settings);
|
2018-11-09 03:42:34 +00:00
|
|
|
#endif
|
2015-06-09 05:07:40 +00:00
|
|
|
|
2015-07-24 09:39:11 +00:00
|
|
|
// DevTools workspace api.
|
2020-07-20 18:07:02 +00:00
|
|
|
void AddWorkSpace(gin::Arguments* args, const base::FilePath& path);
|
|
|
|
void RemoveWorkSpace(gin::Arguments* args, const base::FilePath& path);
|
2015-07-24 09:39:11 +00:00
|
|
|
|
2015-01-19 20:09:47 +00:00
|
|
|
// Editing commands.
|
|
|
|
void Undo();
|
|
|
|
void Redo();
|
|
|
|
void Cut();
|
|
|
|
void Copy();
|
|
|
|
void Paste();
|
2015-05-15 07:15:19 +00:00
|
|
|
void PasteAndMatchStyle();
|
2015-01-19 20:09:47 +00:00
|
|
|
void Delete();
|
|
|
|
void SelectAll();
|
|
|
|
void Unselect();
|
|
|
|
void Replace(const base::string16& word);
|
|
|
|
void ReplaceMisspelling(const base::string16& word);
|
2020-07-20 18:07:02 +00:00
|
|
|
uint32_t FindInPage(gin::Arguments* args);
|
2015-12-17 17:27:56 +00:00
|
|
|
void StopFindInPage(content::StopFindAction action);
|
2016-06-02 17:12:38 +00:00
|
|
|
void ShowDefinitionForSelection();
|
2016-07-26 19:06:11 +00:00
|
|
|
void CopyImageAt(int x, int y);
|
2015-01-19 20:09:47 +00:00
|
|
|
|
2015-07-24 04:58:28 +00:00
|
|
|
// Focus.
|
|
|
|
void Focus();
|
2016-08-03 03:29:55 +00:00
|
|
|
bool IsFocused() const;
|
2015-07-24 04:58:28 +00:00
|
|
|
void TabTraverse(bool reverse);
|
|
|
|
|
2015-09-18 06:20:31 +00:00
|
|
|
// Send messages to browser.
|
2018-10-06 11:48:00 +00:00
|
|
|
bool SendIPCMessage(bool internal,
|
|
|
|
bool send_to_all,
|
2018-08-24 15:30:37 +00:00
|
|
|
const std::string& channel,
|
2019-10-09 17:59:08 +00:00
|
|
|
v8::Local<v8::Value> args);
|
2014-04-24 09:00:41 +00:00
|
|
|
|
2018-10-06 11:48:00 +00:00
|
|
|
bool SendIPCMessageWithSender(bool internal,
|
|
|
|
bool send_to_all,
|
2018-09-01 01:13:51 +00:00
|
|
|
const std::string& channel,
|
2019-10-09 17:59:08 +00:00
|
|
|
blink::CloneableMessage args,
|
2018-09-01 01:13:51 +00:00
|
|
|
int32_t sender_id = 0);
|
|
|
|
|
2018-12-10 00:37:42 +00:00
|
|
|
bool SendIPCMessageToFrame(bool internal,
|
|
|
|
bool send_to_all,
|
|
|
|
int32_t frame_id,
|
|
|
|
const std::string& channel,
|
2019-10-09 17:59:08 +00:00
|
|
|
v8::Local<v8::Value> args);
|
2018-12-10 00:37:42 +00:00
|
|
|
|
2020-03-12 01:07:54 +00:00
|
|
|
void PostMessage(const std::string& channel,
|
|
|
|
v8::Local<v8::Value> message,
|
|
|
|
base::Optional<v8::Local<v8::Value>> transfer);
|
|
|
|
|
2015-09-18 06:20:31 +00:00
|
|
|
// Send WebInputEvent to the page.
|
|
|
|
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
|
|
|
|
|
2015-09-18 07:57:43 +00:00
|
|
|
// Subscribe to the frame updates.
|
2020-07-20 18:07:02 +00:00
|
|
|
void BeginFrameSubscription(gin::Arguments* args);
|
2015-09-18 07:57:43 +00:00
|
|
|
void EndFrameSubscription();
|
|
|
|
|
2016-07-03 03:26:43 +00:00
|
|
|
// Dragging native items.
|
2020-07-20 18:07:02 +00:00
|
|
|
void StartDrag(const gin_helper::Dictionary& item, gin::Arguments* args);
|
2016-07-03 03:26:43 +00:00
|
|
|
|
2016-07-05 22:43:57 +00:00
|
|
|
// Captures the page with |rect|, |callback| would be called when capturing is
|
|
|
|
// done.
|
2020-07-20 18:07:02 +00:00
|
|
|
v8::Local<v8::Promise> CapturePage(gin::Arguments* args);
|
2016-07-05 22:43:57 +00:00
|
|
|
|
2015-06-25 06:28:13 +00:00
|
|
|
// Methods for creating <webview>.
|
2015-06-05 07:18:15 +00:00
|
|
|
bool IsGuest() const;
|
2018-08-16 22:57:40 +00:00
|
|
|
void AttachToIframe(content::WebContents* embedder_web_contents,
|
|
|
|
int embedder_frame_id);
|
2019-01-12 06:50:33 +00:00
|
|
|
void DetachFromOuterFrame();
|
2016-07-29 12:50:27 +00:00
|
|
|
|
2016-07-30 13:40:16 +00:00
|
|
|
// Methods for offscreen rendering
|
2016-07-28 10:10:56 +00:00
|
|
|
bool IsOffScreen() const;
|
2018-10-01 20:00:53 +00:00
|
|
|
#if BUILDFLAG(ENABLE_OSR)
|
2016-08-04 04:22:19 +00:00
|
|
|
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
2016-07-30 13:40:16 +00:00
|
|
|
void StartPainting();
|
|
|
|
void StopPainting();
|
|
|
|
bool IsPainting() const;
|
2016-07-31 10:19:56 +00:00
|
|
|
void SetFrameRate(int frame_rate);
|
2016-07-30 13:40:16 +00:00
|
|
|
int GetFrameRate() const;
|
2018-10-01 20:00:53 +00:00
|
|
|
#endif
|
2016-09-01 17:25:12 +00:00
|
|
|
void Invalidate();
|
2019-07-03 01:22:09 +00:00
|
|
|
gfx::Size GetSizeForNewRenderView(content::WebContents*) override;
|
2014-10-24 08:09:18 +00:00
|
|
|
|
2017-01-29 14:13:20 +00:00
|
|
|
// Methods for zoom handling.
|
|
|
|
void SetZoomLevel(double level);
|
2018-08-09 17:15:23 +00:00
|
|
|
double GetZoomLevel() const;
|
2020-03-13 23:13:05 +00:00
|
|
|
void SetZoomFactor(gin_helper::ErrorThrower thrower, double factor);
|
2018-08-09 17:15:23 +00:00
|
|
|
double GetZoomFactor() const;
|
2017-01-29 14:13:20 +00:00
|
|
|
|
2016-02-01 10:03:38 +00:00
|
|
|
// Callback triggered on permission response.
|
2019-10-28 22:12:35 +00:00
|
|
|
void OnEnterFullscreenModeForTab(
|
2020-06-01 20:34:34 +00:00
|
|
|
content::RenderFrameHost* requesting_frame,
|
2019-10-28 22:12:35 +00:00
|
|
|
const blink::mojom::FullscreenOptions& options,
|
|
|
|
bool allowed);
|
2016-02-01 10:03:38 +00:00
|
|
|
|
2016-03-31 00:58:23 +00:00
|
|
|
// Create window with the given disposition.
|
2018-04-18 01:44:10 +00:00
|
|
|
void OnCreateWindow(const GURL& target_url,
|
|
|
|
const content::Referrer& referrer,
|
|
|
|
const std::string& frame_name,
|
|
|
|
WindowOpenDisposition disposition,
|
2020-03-26 18:05:45 +00:00
|
|
|
const std::string& features,
|
2018-04-11 08:42:14 +00:00
|
|
|
const scoped_refptr<network::ResourceRequestBody>& body);
|
2016-03-31 00:58:23 +00:00
|
|
|
|
2018-08-10 22:19:49 +00:00
|
|
|
// Returns the preload script path of current WebContents.
|
2019-07-03 15:05:45 +00:00
|
|
|
std::vector<base::FilePath::StringType> GetPreloadPaths() const;
|
2018-08-10 22:19:49 +00:00
|
|
|
|
2015-09-22 13:56:56 +00:00
|
|
|
// Returns the web preferences of current WebContents.
|
2018-08-09 17:15:23 +00:00
|
|
|
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate) const;
|
|
|
|
v8::Local<v8::Value> GetLastWebPreferences(v8::Isolate* isolate) const;
|
2015-09-22 13:56:56 +00:00
|
|
|
|
2015-10-01 05:45:59 +00:00
|
|
|
// Returns the owner window.
|
2020-07-16 21:11:44 +00:00
|
|
|
v8::Local<v8::Value> GetOwnerBrowserWindow(v8::Isolate* isolate) const;
|
2015-10-01 05:45:59 +00:00
|
|
|
|
2017-06-30 22:47:41 +00:00
|
|
|
// Grants the child process the capability to access URLs with the origin of
|
|
|
|
// the specified URL.
|
|
|
|
void GrantOriginAccess(const GURL& url);
|
|
|
|
|
2020-05-26 13:21:38 +00:00
|
|
|
// Notifies the web page that there is user interaction.
|
|
|
|
void NotifyUserActivation();
|
|
|
|
|
2020-07-16 21:11:44 +00:00
|
|
|
v8::Local<v8::Promise> TakeHeapSnapshot(v8::Isolate* isolate,
|
|
|
|
const base::FilePath& file_path);
|
2018-09-18 18:00:31 +00:00
|
|
|
|
2015-10-01 03:14:19 +00:00
|
|
|
// Properties.
|
2020-07-30 16:17:57 +00:00
|
|
|
int32_t ID() const { return id_; }
|
2015-10-01 03:14:19 +00:00
|
|
|
v8::Local<v8::Value> Session(v8::Isolate* isolate);
|
2019-08-19 20:13:24 +00:00
|
|
|
content::WebContents* HostWebContents() const;
|
2015-10-01 03:14:19 +00:00
|
|
|
v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate);
|
2016-01-21 18:22:23 +00:00
|
|
|
v8::Local<v8::Value> Debugger(v8::Isolate* isolate);
|
2015-10-01 03:14:19 +00:00
|
|
|
|
2017-01-30 11:18:40 +00:00
|
|
|
WebContentsZoomController* GetZoomController() { return zoom_controller_; }
|
|
|
|
|
2018-02-22 06:57:03 +00:00
|
|
|
void AddObserver(ExtendedWebContentsObserver* obs) {
|
|
|
|
observers_.AddObserver(obs);
|
|
|
|
}
|
|
|
|
void RemoveObserver(ExtendedWebContentsObserver* obs) {
|
2018-11-19 16:47:04 +00:00
|
|
|
// Trying to remove from an empty collection leads to an access violation
|
|
|
|
if (observers_.might_have_observers())
|
|
|
|
observers_.RemoveObserver(obs);
|
2018-02-22 06:57:03 +00:00
|
|
|
}
|
|
|
|
|
2018-09-15 15:42:43 +00:00
|
|
|
bool EmitNavigationEvent(const std::string& event,
|
|
|
|
content::NavigationHandle* navigation_handle);
|
|
|
|
|
2020-07-30 16:17:57 +00:00
|
|
|
// this.emit(name, new Event(sender, message), args...);
|
|
|
|
template <typename... Args>
|
|
|
|
bool EmitWithSender(base::StringPiece name,
|
|
|
|
content::RenderFrameHost* sender,
|
|
|
|
electron::mojom::ElectronBrowser::InvokeCallback callback,
|
|
|
|
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)...);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MarkDestroyed();
|
|
|
|
|
2019-08-19 20:13:24 +00:00
|
|
|
WebContents* embedder() { return embedder_; }
|
|
|
|
|
2020-01-15 23:11:51 +00:00
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
|
|
|
extensions::ScriptExecutor* script_executor() {
|
|
|
|
return script_executor_.get();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-04-24 08:45:25 +00:00
|
|
|
protected:
|
2018-10-19 08:52:07 +00:00
|
|
|
// Does not manage lifetime of |web_contents|.
|
|
|
|
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
|
|
|
|
// Takes over ownership of |web_contents|.
|
2016-08-17 00:15:10 +00:00
|
|
|
WebContents(v8::Isolate* isolate,
|
2018-10-22 18:02:25 +00:00
|
|
|
std::unique_ptr<content::WebContents> web_contents,
|
2016-08-17 00:15:10 +00:00
|
|
|
Type type);
|
2018-10-19 08:52:07 +00:00
|
|
|
// Creates a new content::WebContents.
|
2019-10-25 13:03:28 +00:00
|
|
|
WebContents(v8::Isolate* isolate, const gin_helper::Dictionary& options);
|
2018-04-17 23:03:51 +00:00
|
|
|
~WebContents() override;
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2018-10-22 18:02:25 +00:00
|
|
|
void InitWithSessionAndOptions(
|
|
|
|
v8::Isolate* isolate,
|
|
|
|
std::unique_ptr<content::WebContents> web_contents,
|
2019-10-25 13:03:28 +00:00
|
|
|
gin::Handle<class Session> session,
|
|
|
|
const gin_helper::Dictionary& options);
|
2016-08-17 00:15:10 +00:00
|
|
|
|
2014-10-24 10:06:32 +00:00
|
|
|
// content::WebContentsDelegate:
|
2017-01-23 09:59:40 +00:00
|
|
|
bool DidAddMessageToConsole(content::WebContents* source,
|
2019-05-01 00:18:22 +00:00
|
|
|
blink::mojom::ConsoleMessageLevel level,
|
2017-01-23 09:59:40 +00:00
|
|
|
const base::string16& message,
|
|
|
|
int32_t line_no,
|
|
|
|
const base::string16& source_id) override;
|
2020-04-13 15:37:41 +00:00
|
|
|
bool IsWebContentsCreationOverridden(
|
|
|
|
content::SiteInstance* source_site_instance,
|
|
|
|
content::mojom::WindowContainerType window_container_type,
|
|
|
|
const GURL& opener_url,
|
|
|
|
const std::string& frame_name,
|
|
|
|
const GURL& target_url) override;
|
|
|
|
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,
|
|
|
|
const std::string& partition_id,
|
|
|
|
content::SessionStorageNamespace* session_storage_namespace) override;
|
2020-03-26 18:05:45 +00: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-16 00:13:18 +00:00
|
|
|
void AddNewContents(content::WebContents* source,
|
2018-09-15 00:16:22 +00:00
|
|
|
std::unique_ptr<content::WebContents> new_contents,
|
2020-05-26 20:06:26 +00:00
|
|
|
const GURL& target_url,
|
2016-08-16 00:13:18 +00:00
|
|
|
WindowOpenDisposition disposition,
|
|
|
|
const gfx::Rect& initial_rect,
|
|
|
|
bool user_gesture,
|
|
|
|
bool* was_blocked) override;
|
2014-10-24 13:46:47 +00:00
|
|
|
content::WebContents* OpenURLFromTab(
|
2014-10-24 10:06:32 +00:00
|
|
|
content::WebContents* source,
|
|
|
|
const content::OpenURLParams& params) override;
|
2015-06-25 03:07:23 +00:00
|
|
|
void BeforeUnloadFired(content::WebContents* tab,
|
|
|
|
bool proceed,
|
|
|
|
bool* proceed_to_fire_unload) override;
|
2018-10-02 21:56:09 +00:00
|
|
|
void SetContentsBounds(content::WebContents* source,
|
|
|
|
const gfx::Rect& pos) override;
|
2015-06-25 03:07:23 +00:00
|
|
|
void CloseContents(content::WebContents* source) override;
|
|
|
|
void ActivateContents(content::WebContents* contents) override;
|
2016-06-07 06:56:19 +00:00
|
|
|
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
2019-01-09 20:01:49 +00:00
|
|
|
bool HandleKeyboardEvent(
|
2014-10-24 13:46:47 +00:00
|
|
|
content::WebContents* source,
|
|
|
|
const content::NativeWebKeyboardEvent& event) override;
|
2017-06-16 21:35:43 +00:00
|
|
|
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
|
|
|
content::WebContents* source,
|
|
|
|
const content::NativeWebKeyboardEvent& event) override;
|
2019-05-14 06:40:40 +00:00
|
|
|
void ContentsZoomChange(bool zoom_in) override;
|
2018-09-15 00:17:50 +00:00
|
|
|
void EnterFullscreenModeForTab(
|
2020-06-01 20:34:34 +00:00
|
|
|
content::RenderFrameHost* requesting_frame,
|
2019-10-28 22:12:35 +00:00
|
|
|
const blink::mojom::FullscreenOptions& options) override;
|
2015-05-09 12:17:40 +00:00
|
|
|
void ExitFullscreenModeForTab(content::WebContents* source) override;
|
2017-01-23 09:59:40 +00:00
|
|
|
void RendererUnresponsive(
|
|
|
|
content::WebContents* source,
|
2018-10-02 21:57:14 +00:00
|
|
|
content::RenderWidgetHost* render_widget_host,
|
|
|
|
base::RepeatingClosure hang_monitor_restarter) override;
|
2018-04-11 15:23:16 +00:00
|
|
|
void RendererResponsive(
|
|
|
|
content::WebContents* source,
|
|
|
|
content::RenderWidgetHost* render_widget_host) override;
|
2019-02-27 07:49:59 +00:00
|
|
|
bool HandleContextMenu(content::RenderFrameHost* render_frame_host,
|
|
|
|
const content::ContextMenuParams& params) override;
|
2015-12-19 19:53:47 +00:00
|
|
|
bool OnGoToEntryOffset(int offset) override;
|
2015-12-17 17:27:56 +00:00
|
|
|
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;
|
2018-09-09 14:30:28 +00:00
|
|
|
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
2018-04-18 01:44:10 +00:00
|
|
|
const GURL& security_origin,
|
2019-07-03 01:22:09 +00:00
|
|
|
blink::mojom::MediaStreamType type) override;
|
2016-01-23 13:29:47 +00:00
|
|
|
void RequestMediaAccessPermission(
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
const content::MediaStreamRequest& request,
|
2018-10-02 18:09:25 +00:00
|
|
|
content::MediaResponseCallback callback) override;
|
2018-04-18 01:44:10 +00:00
|
|
|
void RequestToLockMouse(content::WebContents* web_contents,
|
|
|
|
bool user_gesture,
|
|
|
|
bool last_unlocked_by_target) override;
|
2016-05-30 12:38:09 +00:00
|
|
|
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
|
|
|
|
content::RenderFrameHost* frame,
|
|
|
|
const content::BluetoothChooser::EventHandler& handler) override;
|
2017-04-28 00:28:48 +00:00
|
|
|
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
|
|
|
content::WebContents* source) override;
|
2018-09-15 00:18:14 +00:00
|
|
|
void OnAudioStateChanged(bool audible) override;
|
2014-10-24 10:06:32 +00:00
|
|
|
|
2014-10-23 09:54:52 +00:00
|
|
|
// content::WebContentsObserver:
|
2019-01-12 01:00:43 +00:00
|
|
|
void BeforeUnloadFired(bool proceed,
|
|
|
|
const base::TimeTicks& proceed_time) override;
|
2019-12-02 18:29:03 +00:00
|
|
|
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
|
|
|
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
|
2018-12-05 08:03:39 +00:00
|
|
|
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
|
|
|
content::RenderViewHost* new_host) override;
|
2014-12-09 22:38:43 +00:00
|
|
|
void RenderViewDeleted(content::RenderViewHost*) override;
|
|
|
|
void RenderProcessGone(base::TerminationStatus status) override;
|
2019-04-02 22:38:16 +00:00
|
|
|
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
2019-10-18 19:57:34 +00:00
|
|
|
void DOMContentLoaded(content::RenderFrameHost* render_frame_host) override;
|
2014-12-09 22:38:43 +00: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 12:01:37 +00:00
|
|
|
int error_code) override;
|
2015-05-22 07:24:34 +00:00
|
|
|
void DidStartLoading() override;
|
|
|
|
void DidStopLoading() override;
|
2018-04-26 10:17:55 +00:00
|
|
|
void DidStartNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2018-09-15 15:42:43 +00:00
|
|
|
void DidRedirectNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2016-07-14 00:19:28 +00:00
|
|
|
void DidFinishNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2014-12-09 22:38:43 +00:00
|
|
|
bool OnMessageReceived(const IPC::Message& message) override;
|
|
|
|
void WebContentsDestroyed() override;
|
2015-03-05 14:39:27 +00:00
|
|
|
void NavigationEntryCommitted(
|
|
|
|
const content::LoadCommittedDetails& load_details) override;
|
2017-12-18 00:19:21 +00:00
|
|
|
void TitleWasSet(content::NavigationEntry* entry) override;
|
2015-04-17 19:55:31 +00:00
|
|
|
void DidUpdateFaviconURL(
|
2020-06-22 17:35:10 +00:00
|
|
|
content::RenderFrameHost* render_frame_host,
|
2020-03-03 21:35:05 +00:00
|
|
|
const std::vector<blink::mojom::FaviconURLPtr>& urls) override;
|
2015-05-12 19:35:56 +00:00
|
|
|
void PluginCrashed(const base::FilePath& plugin_path,
|
|
|
|
base::ProcessId plugin_pid) override;
|
2017-01-23 09:59:40 +00:00
|
|
|
void MediaStartedPlaying(const MediaPlayerInfo& video_type,
|
2019-04-20 17:20:37 +00:00
|
|
|
const content::MediaPlayerId& id) override;
|
2018-04-11 15:27:14 +00:00
|
|
|
void MediaStoppedPlaying(
|
|
|
|
const MediaPlayerInfo& video_type,
|
2019-04-20 17:20:37 +00:00
|
|
|
const content::MediaPlayerId& id,
|
2018-04-11 15:27:14 +00:00
|
|
|
content::WebContentsObserver::MediaStoppedReason reason) override;
|
2020-01-17 18:41:52 +00:00
|
|
|
void DidChangeThemeColor() override;
|
2019-04-02 22:38:16 +00:00
|
|
|
void OnInterfaceRequestFromFrame(
|
|
|
|
content::RenderFrameHost* render_frame_host,
|
|
|
|
const std::string& interface_name,
|
|
|
|
mojo::ScopedMessagePipeHandle* interface_pipe) override;
|
2020-05-26 20:06:26 +00:00
|
|
|
void OnCursorChanged(const content::WebCursor& cursor) override;
|
2019-06-13 21:02:56 +00:00
|
|
|
void DidAcquireFullscreen(content::RenderFrameHost* rfh) override;
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2018-10-19 13:50:30 +00:00
|
|
|
// InspectableWebContentsDelegate:
|
2016-04-12 07:36:12 +00:00
|
|
|
void DevToolsReloadPage() override;
|
|
|
|
|
2018-10-19 13:50:30 +00:00
|
|
|
// InspectableWebContentsViewDelegate:
|
2015-10-01 03:14:19 +00:00
|
|
|
void DevToolsFocused() override;
|
|
|
|
void DevToolsOpened() override;
|
|
|
|
void DevToolsClosed() override;
|
2017-09-12 23:25:18 +00:00
|
|
|
|
2014-04-24 08:45:25 +00:00
|
|
|
private:
|
2020-02-04 20:19:40 +00:00
|
|
|
ElectronBrowserContext* GetBrowserContext() const;
|
2015-07-14 19:13:25 +00:00
|
|
|
|
2019-04-02 22:38:16 +00:00
|
|
|
// Binds the given request for the ElectronBrowser API. When the
|
|
|
|
// RenderFrameHost is destroyed, all related bindings will be removed.
|
2020-06-22 17:35:10 +00:00
|
|
|
void BindElectronBrowser(
|
|
|
|
mojo::PendingReceiver<mojom::ElectronBrowser> receiver,
|
|
|
|
content::RenderFrameHost* render_frame_host);
|
2019-04-03 21:22:23 +00:00
|
|
|
void OnElectronBrowserConnectionError();
|
2019-04-02 22:38:16 +00:00
|
|
|
|
2018-04-18 01:44:10 +00:00
|
|
|
uint32_t GetNextRequestId() { return ++request_id_; }
|
2015-12-17 23:10:42 +00:00
|
|
|
|
2018-10-01 20:00:53 +00:00
|
|
|
#if BUILDFLAG(ENABLE_OSR)
|
2018-11-30 05:25:02 +00:00
|
|
|
OffScreenWebContentsView* GetOffScreenWebContentsView() const override;
|
|
|
|
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
|
2018-03-20 01:25:51 +00:00
|
|
|
#endif
|
|
|
|
|
2019-04-02 22:38:16 +00:00
|
|
|
// mojom::ElectronBrowser
|
|
|
|
void Message(bool internal,
|
|
|
|
const std::string& channel,
|
2019-10-09 17:59:08 +00:00
|
|
|
blink::CloneableMessage arguments) override;
|
2019-08-23 22:45:50 +00:00
|
|
|
void Invoke(bool internal,
|
|
|
|
const std::string& channel,
|
2019-10-09 17:59:08 +00:00
|
|
|
blink::CloneableMessage arguments,
|
2019-05-31 17:25:19 +00:00
|
|
|
InvokeCallback callback) override;
|
2020-03-12 01:07:54 +00:00
|
|
|
void ReceivePostMessage(const std::string& channel,
|
|
|
|
blink::TransferableMessage message) override;
|
2019-04-02 22:38:16 +00:00
|
|
|
void MessageSync(bool internal,
|
|
|
|
const std::string& channel,
|
2019-10-09 17:59:08 +00:00
|
|
|
blink::CloneableMessage arguments,
|
2019-04-02 22:38:16 +00:00
|
|
|
MessageSyncCallback callback) override;
|
2019-04-03 21:22:23 +00:00
|
|
|
void MessageTo(bool internal,
|
|
|
|
bool send_to_all,
|
|
|
|
int32_t web_contents_id,
|
|
|
|
const std::string& channel,
|
2019-10-09 17:59:08 +00:00
|
|
|
blink::CloneableMessage arguments) override;
|
|
|
|
void MessageHost(const std::string& channel,
|
|
|
|
blink::CloneableMessage arguments) override;
|
2019-06-03 17:43:04 +00:00
|
|
|
void UpdateDraggableRegions(
|
|
|
|
std::vector<mojom::DraggableRegionPtr> regions) override;
|
2019-06-04 01:18:23 +00:00
|
|
|
void SetTemporaryZoomLevel(double level) override;
|
|
|
|
void DoGetZoomLevel(DoGetZoomLevelCallback callback) override;
|
2019-04-02 22:38:16 +00:00
|
|
|
|
2017-01-30 17:06:50 +00:00
|
|
|
// Called when received a synchronous message from renderer to
|
|
|
|
// get the zoom level.
|
2018-03-09 09:31:09 +00:00
|
|
|
void OnGetZoomLevel(content::RenderFrameHost* frame_host,
|
|
|
|
IPC::Message* reply_msg);
|
2017-01-30 17:06:50 +00:00
|
|
|
|
2017-10-21 20:21:24 +00:00
|
|
|
void InitZoomController(content::WebContents* web_contents,
|
2019-10-25 13:03:28 +00:00
|
|
|
const gin_helper::Dictionary& options);
|
2017-10-21 20:21:24 +00:00
|
|
|
|
2015-06-16 09:23:29 +00:00
|
|
|
v8::Global<v8::Value> session_;
|
2015-10-01 03:14:19 +00:00
|
|
|
v8::Global<v8::Value> devtools_web_contents_;
|
2016-01-21 18:22:23 +00:00
|
|
|
v8::Global<v8::Value> debugger_;
|
2015-06-16 09:23:29 +00:00
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
std::unique_ptr<ElectronJavaScriptDialogManager> dialog_manager_;
|
2016-05-23 01:59:39 +00:00
|
|
|
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
|
2018-04-18 00:45:15 +00:00
|
|
|
std::unique_ptr<FrameSubscriber> frame_subscriber_;
|
|
|
|
|
2020-01-15 23:11:51 +00:00
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
|
|
|
std::unique_ptr<extensions::ScriptExecutor> script_executor_;
|
|
|
|
#endif
|
|
|
|
|
2016-02-17 08:52:19 +00:00
|
|
|
// The host webcontents that may contain this webcontents.
|
2018-05-21 22:18:38 +00:00
|
|
|
WebContents* embedder_ = nullptr;
|
2016-02-17 08:52:19 +00:00
|
|
|
|
2017-01-30 11:18:40 +00:00
|
|
|
// The zoom controller for this webContents.
|
2018-05-21 22:18:38 +00:00
|
|
|
WebContentsZoomController* zoom_controller_ = nullptr;
|
2017-01-30 11:18:40 +00:00
|
|
|
|
2015-06-24 13:44:27 +00:00
|
|
|
// The type of current WebContents.
|
2019-05-03 18:11:41 +00:00
|
|
|
Type type_ = Type::BROWSER_WINDOW;
|
2015-06-24 13:44:27 +00:00
|
|
|
|
2020-07-30 16:17:57 +00:00
|
|
|
int32_t id_;
|
|
|
|
|
2015-12-17 23:10:42 +00:00
|
|
|
// Request id used for findInPage request.
|
2018-05-21 22:18:38 +00:00
|
|
|
uint32_t request_id_ = 0;
|
2015-12-17 23:10:42 +00:00
|
|
|
|
2016-04-08 06:54:33 +00:00
|
|
|
// Whether background throttling is disabled.
|
2018-05-21 22:18:38 +00:00
|
|
|
bool background_throttling_ = true;
|
2016-04-08 06:54:33 +00:00
|
|
|
|
2016-09-07 02:16:52 +00:00
|
|
|
// Whether to enable devtools.
|
2018-05-21 22:18:38 +00:00
|
|
|
bool enable_devtools_ = true;
|
2016-09-05 08:27:56 +00:00
|
|
|
|
2018-02-22 06:57:03 +00:00
|
|
|
// Observers of this WebContents.
|
|
|
|
base::ObserverList<ExtendedWebContentsObserver> observers_;
|
|
|
|
|
2018-12-05 08:03:39 +00:00
|
|
|
// The ID of the process of the currently committed RenderViewHost.
|
|
|
|
// -1 means no speculative RVH has been committed yet.
|
|
|
|
int currently_committed_process_id_ = -1;
|
|
|
|
|
2019-04-02 22:38:16 +00:00
|
|
|
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*> registry_;
|
2020-06-22 17:35:10 +00:00
|
|
|
mojo::ReceiverSet<mojom::ElectronBrowser, content::RenderFrameHost*>
|
|
|
|
receivers_;
|
|
|
|
std::map<content::RenderFrameHost*, std::vector<mojo::ReceiverId>>
|
|
|
|
frame_to_receivers_map_;
|
2019-04-02 22:38:16 +00:00
|
|
|
|
2019-06-14 02:44:36 +00:00
|
|
|
base::WeakPtrFactory<WebContents> weak_factory_;
|
|
|
|
|
2014-04-24 08:45:25 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(WebContents);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#endif // SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_H_
|