bf6e4b1247
* chore: bump chromium in DEPS to 46d2d82e84d73806da623c5333dae4dd218172df * chore: bump chromium in DEPS to cbafe74731a5d1e59844ca59e0fc28f4a5f80a33 * chore: bump chromium in DEPS to d5dcd6b5cc76f4e1732083d775cdd7b533f0abe9 * Update patches * update for lint * Fix compilation errors * chore: bump chromium in DEPS to 1c19360fdaaf65d4ed006736c7f9804104095990 * Replace removed constant * chore: bump chromium in DEPS to 3b6639f5da26c1772c5d4f3ba634aca65df75fec * chore: bump chromium in DEPS to cc6b1b930d4b5eca06701820dac54fa0f41e8999 * chore: bump chromium in DEPS to 7d1445641ad1032c67f731ba6ff7798f29349ade * chore: bump chromium in DEPS to 6f7e5e79cefe982ad84a88927565a88db2e592be * chore: bump chromium in DEPS to bfb25dafff19cb41bf9781331d19ef0be819d1e4 * chore: bump chromium in DEPS to 1a8196b39f0e0cdc4935fd122fff5625d5fab06e * chore: bump chromium in DEPS to 9a03d8d2bb38ad8c0cbb9550ca81b2f94ff60c15 * chore: bump chromium in DEPS to 4c67f3505dab2d5457adb418cd3270a4f3236fd0 * chore: bump chromium in DEPS to 652394e7626fc1ae895a53fb34c64070494e648e * chore: bump chromium in DEPS to 07653652c58cc019af7f833bd63eb0c2eceaab5e * chore: bump chromium in DEPS to 451a1c5fec1fb073a5bae12a033bb342c72c905f * chore: bump chromium in DEPS to 86cdba00e233899a232868b412b333d08db63478 * chore: bump chromium in DEPS to 7c322faad1aee8abef2330d74aabf09ecf8c11af * Update patches * chore: bump chromium in DEPS to d0044fae7efc29eb201cfdd5fdbed77d48aba212 * Replace IsProcessingUserGesture with HasTransientUserActivation4baa9a6e85
* Fix 10.15 sdk build0eaa6db358
* Remove CancelPrerender5eb3329719
* Remove no longer used WebFloatPoint43ab96ce6b
* Use base::span<const uint8_t> for devtools messages in content/public21e19401af
* Update renamed header files * TODO: update with upstream changes This code needs to be updated to handle the changes made in:19be6547a9
* chore: bump chromium in DEPS to 82e5a2c6bd33c2e53634a09fbcbc9fcac1e7ff93 * chore: bump chromium in DEPS to 91f877cadd2995201c276e952b3bf2c60b226c64 * chore: bump chromium in DEPS to 43fcd2ab2677a06d38246b42761dc5b40cf87177 * chore: bump chromium in DEPS to e30957dcb710c0977a7ff95b8d3cf65843df12ca * chore: bump chromium in DEPS to 6a8335a56db12aae2fd06296f82579d804d92217 * chore: bump chromium in DEPS to a4a436cbc28ace88d71752f8f479e59559e54e46 * chore: bump chromium in DEPS to 982bbd0e4b2e1d57d515f384f6483ffc0d7073ad * chore: bump chromium in DEPS to 92bb7a99f84ffcdf41d4edca57e90b1f0c7c6c8b * update patches * add checkout_google_benchmark gclient var * FIXME: workaround grit bug * chore: bump chromium in DEPS to d3623fc53615739e6b59340a5d349e4b397cb7c5 * update patches * Remove color arg from DidChangeThemeColor(). https://chromium-review.googlesource.com/c/chromium/src/+/1982623 * update CreateFileURLLoader with new suffix CL: https://chromium-review.googlesource.com/c/chromium/src/+/1981414 * add node patch for removal of task API in v8 CL: https://chromium-review.googlesource.com/c/v8/v8/+/1868620 * add disable_secure_dns param for WillCreateURLLoaderFactory CL: https://chromium-review.googlesource.com/c/chromium/src/+/1888099 * switch to mojo-ified PrintMsg_PrintPreview CL: https://chromium-review.googlesource.com/c/chromium/src/+/1972307 * chore: bump chromium in DEPS to e7a6d173632660b6aeb9806e9132c34a315331c2 * update missing chrome/browser/ssl:proto dependency after chrome removal CL: https://chromium-review.googlesource.com/c/chromium/src/+/1986082 * chore: add libvulkan.so to the linux manifest CL: https://chromium-review.googlesource.com/c/chromium/src/+/1973042 * revert DidChangeThemeColor ternary change due to templates * match Chrome's mojo-ified implementation in geolocation_permission_context.cc CL: https://chromium-review.googlesource.com/c/chromium/src/+/1963371 * add vulkan-1.dll to zips2d6f74c6d4
* add bug link to fixme_grit_conflicts.patch * Introduce device.mojom.DeviceService https://chromium-review.googlesource.com/c/chromium/src/+/1956277 * PDF Compositor rename to Print Compositor https://chromium-review.googlesource.com/c/chromium/src/+/1981135 * chore: bump chromium_version 00362ea584735b4acf4c5a0e1912d7987f8645ab * chore: update patches * Use a virtual base class to provide GetWidget(). https://chromium-review.googlesource.com/c/chromium/src/+/1996948 * [base] Remove usage of base::CurrentThread https://chromium-review.googlesource.com/c/chromium/src/+/1962019 * chore: gn format * Revert "ci: Use Visual Studio Build Tools instead of VS Studio (#21771)" This reverts commit9c1310dadc
. * fix: trigger resize when iframe requests fullscreen * fix: Locking scheme registry is not necessary https://chromium-review.googlesource.com/c/chromium/src/+/1973198 * chore: bump chromium f707f1d6d428f84cf14b64bc2ca74372e25c6ce7 * chore: update patches * ui/base/clipboard: Remove redundant ANSI format functions https://chromium-review.googlesource.com/c/chromium/src/+/1992015 * [base] Prepare //chrome for Value::GetList() switch https://chromium-review.googlesource.com/c/chromium/src/+/1962255 Co-authored-by: John Kleinschmidt <jkleinsc@github.com> Co-authored-by: loc <andy@slack-corp.com> Co-authored-by: Jeremy Apthorp <nornagon@nornagon.net> Co-authored-by: Robo <hop2deep@gmail.com>
593 lines
23 KiB
C++
593 lines
23 KiB
C++
// Copyright (c) 2014 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef SHELL_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
|
|
#define SHELL_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "base/observer_list.h"
|
|
#include "base/observer_list_types.h"
|
|
#include "content/common/cursors/webcursor.h"
|
|
#include "content/public/browser/devtools_agent_host.h"
|
|
#include "content/public/browser/keyboard_event_processing_result.h"
|
|
#include "content/public/browser/render_widget_host.h"
|
|
#include "content/public/browser/web_contents.h"
|
|
#include "content/public/browser/web_contents_observer.h"
|
|
#include "content/public/common/favicon_url.h"
|
|
#include "electron/buildflags/buildflags.h"
|
|
#include "electron/shell/common/api/api.mojom.h"
|
|
#include "gin/handle.h"
|
|
#include "mojo/public/cpp/bindings/binding_set.h"
|
|
#include "printing/buildflags/buildflags.h"
|
|
#include "services/service_manager/public/cpp/binder_registry.h"
|
|
#include "shell/browser/api/frame_subscriber.h"
|
|
#include "shell/browser/api/save_page_handler.h"
|
|
#include "shell/browser/common_web_contents_delegate.h"
|
|
#include "shell/common/gin_helper/trackable_object.h"
|
|
#include "ui/gfx/image/image.h"
|
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
|
#include "printing/backend/print_backend.h"
|
|
#include "shell/browser/printing/print_preview_message_handler.h"
|
|
#endif
|
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
|
#include "extensions/browser/script_executor.h"
|
|
#endif
|
|
|
|
namespace blink {
|
|
struct WebDeviceEmulationParams;
|
|
}
|
|
|
|
namespace gin_helper {
|
|
class Dictionary;
|
|
}
|
|
|
|
namespace network {
|
|
class ResourceRequestBody;
|
|
}
|
|
|
|
namespace electron {
|
|
|
|
class AtomBrowserContext;
|
|
class AtomJavaScriptDialogManager;
|
|
class InspectableWebContents;
|
|
class WebContentsZoomController;
|
|
class WebViewGuestDelegate;
|
|
class FrameSubscriber;
|
|
|
|
#if BUILDFLAG(ENABLE_OSR)
|
|
class OffScreenRenderWidgetHostView;
|
|
#endif
|
|
|
|
namespace api {
|
|
|
|
// Certain events are only in WebContentsDelegate, provide our own Observer to
|
|
// dispatch those events.
|
|
class ExtendedWebContentsObserver : public base::CheckedObserver {
|
|
public:
|
|
virtual void OnCloseContents() {}
|
|
virtual void OnRendererResponsive() {}
|
|
virtual void OnDraggableRegionsUpdated(
|
|
const std::vector<mojom::DraggableRegionPtr>& regions) {}
|
|
|
|
protected:
|
|
~ExtendedWebContentsObserver() override {}
|
|
};
|
|
|
|
// Wrapper around the content::WebContents.
|
|
class WebContents : public gin_helper::TrackableObject<WebContents>,
|
|
public CommonWebContentsDelegate,
|
|
public content::WebContentsObserver,
|
|
public mojom::ElectronBrowser {
|
|
public:
|
|
enum class Type {
|
|
BACKGROUND_PAGE, // A DevTools extension background page.
|
|
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
|
|
};
|
|
|
|
// Create a new WebContents and return the V8 wrapper of it.
|
|
static gin::Handle<WebContents> Create(v8::Isolate* isolate,
|
|
const gin_helper::Dictionary& options);
|
|
|
|
// Create a new V8 wrapper for an existing |web_content|.
|
|
//
|
|
// The lifetime of |web_contents| will be managed by this class.
|
|
static gin::Handle<WebContents> CreateAndTake(
|
|
v8::Isolate* isolate,
|
|
std::unique_ptr<content::WebContents> web_contents,
|
|
Type type);
|
|
|
|
// Get the V8 wrapper of |web_content|, return empty handle if not wrapped.
|
|
static gin::Handle<WebContents> From(v8::Isolate* isolate,
|
|
content::WebContents* web_content);
|
|
|
|
// 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.
|
|
static gin::Handle<WebContents> FromOrCreate(
|
|
v8::Isolate* isolate,
|
|
content::WebContents* web_contents);
|
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
|
|
|
base::WeakPtr<WebContents> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
|
|
|
|
// 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.
|
|
void DestroyWebContents(bool async);
|
|
|
|
void SetBackgroundThrottling(bool allowed);
|
|
int GetProcessID() const;
|
|
base::ProcessId GetOSProcessID() const;
|
|
base::ProcessId GetOSProcessIdForFrame(const std::string& name,
|
|
const std::string& document_url) const;
|
|
Type GetType() const;
|
|
bool Equal(const WebContents* web_contents) const;
|
|
void LoadURL(const GURL& url, const gin_helper::Dictionary& options);
|
|
void DownloadURL(const GURL& url);
|
|
GURL GetURL() const;
|
|
base::string16 GetTitle() const;
|
|
bool IsLoading() const;
|
|
bool IsLoadingMainFrame() const;
|
|
bool IsWaitingForResponse() const;
|
|
void Stop();
|
|
void ReloadIgnoringCache();
|
|
void GoBack();
|
|
void GoForward();
|
|
void GoToOffset(int offset);
|
|
const std::string GetWebRTCIPHandlingPolicy() const;
|
|
void SetWebRTCIPHandlingPolicy(const std::string& webrtc_ip_handling_policy);
|
|
bool IsCrashed() const;
|
|
void SetUserAgent(const std::string& user_agent, gin_helper::Arguments* args);
|
|
std::string GetUserAgent();
|
|
void InsertCSS(const std::string& css);
|
|
v8::Local<v8::Promise> SavePage(const base::FilePath& full_file_path,
|
|
const content::SavePageType& save_type);
|
|
void OpenDevTools(gin_helper::Arguments* args);
|
|
void CloseDevTools();
|
|
bool IsDevToolsOpened();
|
|
bool IsDevToolsFocused();
|
|
void ToggleDevTools();
|
|
void EnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
|
|
void DisableDeviceEmulation();
|
|
void InspectElement(int x, int y);
|
|
void InspectSharedWorker();
|
|
void InspectSharedWorkerById(const std::string& workerId);
|
|
std::vector<scoped_refptr<content::DevToolsAgentHost>> GetAllSharedWorkers();
|
|
void InspectServiceWorker();
|
|
void SetIgnoreMenuShortcuts(bool ignore);
|
|
void SetAudioMuted(bool muted);
|
|
bool IsAudioMuted();
|
|
bool IsCurrentlyAudible();
|
|
void SetEmbedder(const WebContents* embedder);
|
|
void SetDevToolsWebContents(const WebContents* devtools);
|
|
v8::Local<v8::Value> GetNativeView() const;
|
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
|
void Print(gin_helper::Arguments* args);
|
|
std::vector<printing::PrinterBasicInfo> GetPrinterList();
|
|
// Print current page as PDF.
|
|
v8::Local<v8::Promise> PrintToPDF(base::DictionaryValue settings);
|
|
#endif
|
|
|
|
// DevTools workspace api.
|
|
void AddWorkSpace(gin_helper::Arguments* args, const base::FilePath& path);
|
|
void RemoveWorkSpace(gin_helper::Arguments* args, const base::FilePath& path);
|
|
|
|
// Editing commands.
|
|
void Undo();
|
|
void Redo();
|
|
void Cut();
|
|
void Copy();
|
|
void Paste();
|
|
void PasteAndMatchStyle();
|
|
void Delete();
|
|
void SelectAll();
|
|
void Unselect();
|
|
void Replace(const base::string16& word);
|
|
void ReplaceMisspelling(const base::string16& word);
|
|
uint32_t FindInPage(gin_helper::Arguments* args);
|
|
void StopFindInPage(content::StopFindAction action);
|
|
void ShowDefinitionForSelection();
|
|
void CopyImageAt(int x, int y);
|
|
|
|
// Focus.
|
|
void Focus();
|
|
bool IsFocused() const;
|
|
void TabTraverse(bool reverse);
|
|
|
|
// Send messages to browser.
|
|
bool SendIPCMessage(bool internal,
|
|
bool send_to_all,
|
|
const std::string& channel,
|
|
v8::Local<v8::Value> args);
|
|
|
|
bool SendIPCMessageWithSender(bool internal,
|
|
bool send_to_all,
|
|
const std::string& channel,
|
|
blink::CloneableMessage args,
|
|
int32_t sender_id = 0);
|
|
|
|
bool SendIPCMessageToFrame(bool internal,
|
|
bool send_to_all,
|
|
int32_t frame_id,
|
|
const std::string& channel,
|
|
v8::Local<v8::Value> args);
|
|
|
|
// Send WebInputEvent to the page.
|
|
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
|
|
|
|
// Subscribe to the frame updates.
|
|
void BeginFrameSubscription(gin_helper::Arguments* args);
|
|
void EndFrameSubscription();
|
|
|
|
// Dragging native items.
|
|
void StartDrag(const gin_helper::Dictionary& item,
|
|
gin_helper::Arguments* args);
|
|
|
|
// Captures the page with |rect|, |callback| would be called when capturing is
|
|
// done.
|
|
v8::Local<v8::Promise> CapturePage(gin_helper::Arguments* args);
|
|
|
|
// Methods for creating <webview>.
|
|
bool IsGuest() const;
|
|
void AttachToIframe(content::WebContents* embedder_web_contents,
|
|
int embedder_frame_id);
|
|
void DetachFromOuterFrame();
|
|
|
|
// Methods for offscreen rendering
|
|
bool IsOffScreen() const;
|
|
#if BUILDFLAG(ENABLE_OSR)
|
|
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
|
void StartPainting();
|
|
void StopPainting();
|
|
bool IsPainting() const;
|
|
void SetFrameRate(int frame_rate);
|
|
int GetFrameRate() const;
|
|
#endif
|
|
void Invalidate();
|
|
gfx::Size GetSizeForNewRenderView(content::WebContents*) override;
|
|
|
|
// Methods for zoom handling.
|
|
void SetZoomLevel(double level);
|
|
double GetZoomLevel() const;
|
|
void SetZoomFactor(double factor);
|
|
double GetZoomFactor() const;
|
|
|
|
// Callback triggered on permission response.
|
|
void OnEnterFullscreenModeForTab(
|
|
content::WebContents* source,
|
|
const GURL& origin,
|
|
const blink::mojom::FullscreenOptions& options,
|
|
bool allowed);
|
|
|
|
// Create window with the given disposition.
|
|
void OnCreateWindow(const GURL& target_url,
|
|
const content::Referrer& referrer,
|
|
const std::string& frame_name,
|
|
WindowOpenDisposition disposition,
|
|
const std::vector<std::string>& features,
|
|
const scoped_refptr<network::ResourceRequestBody>& body);
|
|
|
|
// Returns the preload script path of current WebContents.
|
|
std::vector<base::FilePath::StringType> GetPreloadPaths() const;
|
|
|
|
// Returns the web preferences of current WebContents.
|
|
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate) const;
|
|
v8::Local<v8::Value> GetLastWebPreferences(v8::Isolate* isolate) const;
|
|
|
|
// Returns the owner window.
|
|
v8::Local<v8::Value> GetOwnerBrowserWindow() const;
|
|
|
|
// Grants the child process the capability to access URLs with the origin of
|
|
// the specified URL.
|
|
void GrantOriginAccess(const GURL& url);
|
|
|
|
v8::Local<v8::Promise> TakeHeapSnapshot(const base::FilePath& file_path);
|
|
|
|
// Properties.
|
|
int32_t ID() const;
|
|
v8::Local<v8::Value> Session(v8::Isolate* isolate);
|
|
content::WebContents* HostWebContents() const;
|
|
v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate);
|
|
v8::Local<v8::Value> Debugger(v8::Isolate* isolate);
|
|
|
|
WebContentsZoomController* GetZoomController() { return zoom_controller_; }
|
|
|
|
void AddObserver(ExtendedWebContentsObserver* obs) {
|
|
observers_.AddObserver(obs);
|
|
}
|
|
void RemoveObserver(ExtendedWebContentsObserver* obs) {
|
|
// Trying to remove from an empty collection leads to an access violation
|
|
if (observers_.might_have_observers())
|
|
observers_.RemoveObserver(obs);
|
|
}
|
|
|
|
bool EmitNavigationEvent(const std::string& event,
|
|
content::NavigationHandle* navigation_handle);
|
|
|
|
WebContents* embedder() { return embedder_; }
|
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
|
extensions::ScriptExecutor* script_executor() {
|
|
return script_executor_.get();
|
|
}
|
|
#endif
|
|
|
|
protected:
|
|
// Does not manage lifetime of |web_contents|.
|
|
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
|
|
// Takes over ownership of |web_contents|.
|
|
WebContents(v8::Isolate* isolate,
|
|
std::unique_ptr<content::WebContents> web_contents,
|
|
Type type);
|
|
// Creates a new content::WebContents.
|
|
WebContents(v8::Isolate* isolate, const gin_helper::Dictionary& options);
|
|
~WebContents() override;
|
|
|
|
void InitWithSessionAndOptions(
|
|
v8::Isolate* isolate,
|
|
std::unique_ptr<content::WebContents> web_contents,
|
|
gin::Handle<class Session> session,
|
|
const gin_helper::Dictionary& options);
|
|
|
|
// content::WebContentsDelegate:
|
|
bool DidAddMessageToConsole(content::WebContents* source,
|
|
blink::mojom::ConsoleMessageLevel level,
|
|
const base::string16& message,
|
|
int32_t line_no,
|
|
const base::string16& source_id) override;
|
|
void WebContentsCreated(content::WebContents* source_contents,
|
|
int opener_render_process_id,
|
|
int opener_render_frame_id,
|
|
const std::string& frame_name,
|
|
const GURL& target_url,
|
|
content::WebContents* new_contents) override;
|
|
void AddNewContents(content::WebContents* source,
|
|
std::unique_ptr<content::WebContents> new_contents,
|
|
WindowOpenDisposition disposition,
|
|
const gfx::Rect& initial_rect,
|
|
bool user_gesture,
|
|
bool* was_blocked) override;
|
|
content::WebContents* OpenURLFromTab(
|
|
content::WebContents* source,
|
|
const content::OpenURLParams& params) override;
|
|
void BeforeUnloadFired(content::WebContents* tab,
|
|
bool proceed,
|
|
bool* proceed_to_fire_unload) override;
|
|
void SetContentsBounds(content::WebContents* source,
|
|
const gfx::Rect& pos) override;
|
|
void CloseContents(content::WebContents* source) override;
|
|
void ActivateContents(content::WebContents* contents) override;
|
|
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
|
bool HandleKeyboardEvent(
|
|
content::WebContents* source,
|
|
const content::NativeWebKeyboardEvent& event) override;
|
|
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
|
content::WebContents* source,
|
|
const content::NativeWebKeyboardEvent& event) override;
|
|
void ContentsZoomChange(bool zoom_in) override;
|
|
void EnterFullscreenModeForTab(
|
|
content::WebContents* source,
|
|
const GURL& origin,
|
|
const blink::mojom::FullscreenOptions& options) override;
|
|
void ExitFullscreenModeForTab(content::WebContents* source) override;
|
|
void RendererUnresponsive(
|
|
content::WebContents* source,
|
|
content::RenderWidgetHost* render_widget_host,
|
|
base::RepeatingClosure hang_monitor_restarter) override;
|
|
void RendererResponsive(
|
|
content::WebContents* source,
|
|
content::RenderWidgetHost* render_widget_host) override;
|
|
bool HandleContextMenu(content::RenderFrameHost* render_frame_host,
|
|
const content::ContextMenuParams& params) override;
|
|
bool OnGoToEntryOffset(int offset) override;
|
|
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;
|
|
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
|
const GURL& security_origin,
|
|
blink::mojom::MediaStreamType type) override;
|
|
void RequestMediaAccessPermission(
|
|
content::WebContents* web_contents,
|
|
const content::MediaStreamRequest& request,
|
|
content::MediaResponseCallback callback) override;
|
|
void RequestToLockMouse(content::WebContents* web_contents,
|
|
bool user_gesture,
|
|
bool last_unlocked_by_target) override;
|
|
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
|
|
content::RenderFrameHost* frame,
|
|
const content::BluetoothChooser::EventHandler& handler) override;
|
|
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
|
content::WebContents* source) override;
|
|
void OnAudioStateChanged(bool audible) override;
|
|
|
|
// content::WebContentsObserver:
|
|
void BeforeUnloadFired(bool proceed,
|
|
const base::TimeTicks& proceed_time) override;
|
|
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
|
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
|
|
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
|
content::RenderViewHost* new_host) override;
|
|
void RenderViewDeleted(content::RenderViewHost*) override;
|
|
void RenderProcessGone(base::TerminationStatus status) override;
|
|
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
|
void DOMContentLoaded(content::RenderFrameHost* render_frame_host) override;
|
|
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
|
const GURL& validated_url) override;
|
|
void DidFailLoad(content::RenderFrameHost* render_frame_host,
|
|
const GURL& validated_url,
|
|
int error_code,
|
|
const base::string16& error_description) override;
|
|
void DidStartLoading() override;
|
|
void DidStopLoading() override;
|
|
void DidStartNavigation(
|
|
content::NavigationHandle* navigation_handle) override;
|
|
void DidRedirectNavigation(
|
|
content::NavigationHandle* navigation_handle) override;
|
|
void DidFinishNavigation(
|
|
content::NavigationHandle* navigation_handle) override;
|
|
bool OnMessageReceived(const IPC::Message& message) override;
|
|
void WebContentsDestroyed() override;
|
|
void NavigationEntryCommitted(
|
|
const content::LoadCommittedDetails& load_details) override;
|
|
void TitleWasSet(content::NavigationEntry* entry) override;
|
|
void DidUpdateFaviconURL(
|
|
const std::vector<content::FaviconURL>& urls) override;
|
|
void PluginCrashed(const base::FilePath& plugin_path,
|
|
base::ProcessId plugin_pid) override;
|
|
void MediaStartedPlaying(const MediaPlayerInfo& video_type,
|
|
const content::MediaPlayerId& id) override;
|
|
void MediaStoppedPlaying(
|
|
const MediaPlayerInfo& video_type,
|
|
const content::MediaPlayerId& id,
|
|
content::WebContentsObserver::MediaStoppedReason reason) override;
|
|
void DidChangeThemeColor() override;
|
|
void OnInterfaceRequestFromFrame(
|
|
content::RenderFrameHost* render_frame_host,
|
|
const std::string& interface_name,
|
|
mojo::ScopedMessagePipeHandle* interface_pipe) override;
|
|
void DidAcquireFullscreen(content::RenderFrameHost* rfh) override;
|
|
|
|
// InspectableWebContentsDelegate:
|
|
void DevToolsReloadPage() override;
|
|
|
|
// InspectableWebContentsViewDelegate:
|
|
void DevToolsFocused() override;
|
|
void DevToolsOpened() override;
|
|
void DevToolsClosed() override;
|
|
|
|
private:
|
|
AtomBrowserContext* GetBrowserContext() const;
|
|
|
|
// Binds the given request for the ElectronBrowser API. When the
|
|
// RenderFrameHost is destroyed, all related bindings will be removed.
|
|
void BindElectronBrowser(mojom::ElectronBrowserRequest request,
|
|
content::RenderFrameHost* render_frame_host);
|
|
void OnElectronBrowserConnectionError();
|
|
|
|
uint32_t GetNextRequestId() { return ++request_id_; }
|
|
|
|
#if BUILDFLAG(ENABLE_OSR)
|
|
OffScreenWebContentsView* GetOffScreenWebContentsView() const override;
|
|
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
|
|
#endif
|
|
|
|
// mojom::ElectronBrowser
|
|
void Message(bool internal,
|
|
const std::string& channel,
|
|
blink::CloneableMessage arguments) override;
|
|
void Invoke(bool internal,
|
|
const std::string& channel,
|
|
blink::CloneableMessage arguments,
|
|
InvokeCallback callback) override;
|
|
void MessageSync(bool internal,
|
|
const std::string& channel,
|
|
blink::CloneableMessage arguments,
|
|
MessageSyncCallback callback) override;
|
|
void MessageTo(bool internal,
|
|
bool send_to_all,
|
|
int32_t web_contents_id,
|
|
const std::string& channel,
|
|
blink::CloneableMessage arguments) override;
|
|
void MessageHost(const std::string& channel,
|
|
blink::CloneableMessage arguments) override;
|
|
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
|
void DereferenceRemoteJSObject(const std::string& context_id,
|
|
int object_id,
|
|
int ref_count) override;
|
|
#endif
|
|
void UpdateDraggableRegions(
|
|
std::vector<mojom::DraggableRegionPtr> regions) override;
|
|
void SetTemporaryZoomLevel(double level) override;
|
|
void DoGetZoomLevel(DoGetZoomLevelCallback callback) override;
|
|
|
|
// Called when we receive a CursorChange message from chromium.
|
|
void OnCursorChange(const content::WebCursor& cursor);
|
|
|
|
// Called when received a synchronous message from renderer to
|
|
// get the zoom level.
|
|
void OnGetZoomLevel(content::RenderFrameHost* frame_host,
|
|
IPC::Message* reply_msg);
|
|
|
|
void InitZoomController(content::WebContents* web_contents,
|
|
const gin_helper::Dictionary& options);
|
|
|
|
v8::Global<v8::Value> session_;
|
|
v8::Global<v8::Value> devtools_web_contents_;
|
|
v8::Global<v8::Value> debugger_;
|
|
|
|
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
|
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
|
|
std::unique_ptr<FrameSubscriber> frame_subscriber_;
|
|
|
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
|
std::unique_ptr<extensions::ScriptExecutor> script_executor_;
|
|
#endif
|
|
|
|
// The host webcontents that may contain this webcontents.
|
|
WebContents* embedder_ = nullptr;
|
|
|
|
// The zoom controller for this webContents.
|
|
WebContentsZoomController* zoom_controller_ = nullptr;
|
|
|
|
// The type of current WebContents.
|
|
Type type_ = Type::BROWSER_WINDOW;
|
|
|
|
// Request id used for findInPage request.
|
|
uint32_t request_id_ = 0;
|
|
|
|
// Whether background throttling is disabled.
|
|
bool background_throttling_ = true;
|
|
|
|
// Whether to enable devtools.
|
|
bool enable_devtools_ = true;
|
|
|
|
// Observers of this WebContents.
|
|
base::ObserverList<ExtendedWebContentsObserver> observers_;
|
|
|
|
// 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;
|
|
|
|
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*> registry_;
|
|
mojo::BindingSet<mojom::ElectronBrowser, content::RenderFrameHost*> bindings_;
|
|
std::map<content::RenderFrameHost*, std::vector<mojo::BindingId>>
|
|
frame_to_bindings_map_;
|
|
|
|
base::WeakPtrFactory<WebContents> weak_factory_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(WebContents);
|
|
};
|
|
|
|
} // namespace api
|
|
|
|
} // namespace electron
|
|
|
|
#endif // SHELL_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
|