electron/atom/browser/api/atom_api_web_contents.h

502 lines
19 KiB
C
Raw Normal View History

// 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.
#ifndef ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
#define ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
#include <memory>
2014-10-24 20:57:44 +08:00
#include <string>
#include <vector>
2014-10-24 20:57:44 +08:00
#include "atom/browser/api/frame_subscriber.h"
2015-10-14 12:41:31 +08:00
#include "atom/browser/api/save_page_handler.h"
2015-06-24 14:36:05 +08:00
#include "atom/browser/api/trackable_object.h"
2015-06-05 13:49:12 +08:00
#include "atom/browser/common_web_contents_delegate.h"
2017-05-19 21:35:13 +02:00
#include "atom/browser/ui/autofill_popup.h"
2018-02-22 15:57:03 +09:00
#include "base/observer_list.h"
2016-08-26 15:30:02 -07:00
#include "content/common/cursors/webcursor.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/web_contents.h"
2014-04-25 11:22:51 +08:00
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/favicon_url.h"
#include "electron/buildflags/buildflags.h"
2014-04-24 16:45:25 +08:00
#include "native_mate/handle.h"
#include "printing/backend/print_backend.h"
#include "ui/gfx/image/image.h"
2014-04-24 16:45:25 +08:00
namespace blink {
struct WebDeviceEmulationParams;
}
2014-11-02 07:32:33 -08:00
namespace brightray {
2014-11-03 19:45:09 +08:00
class InspectableWebContents;
2014-11-02 06:34:22 -08:00
}
namespace mate {
2015-06-05 17:01:17 +08:00
class Arguments;
class Dictionary;
2018-04-17 21:44:10 -04:00
} // namespace mate
namespace network {
class ResourceRequestBody;
}
2014-04-24 16:45:25 +08:00
namespace atom {
2015-07-14 12:13:25 -07:00
class AtomBrowserContext;
2017-04-27 19:28:48 -05:00
class AtomJavaScriptDialogManager;
class WebContentsZoomController;
class WebViewGuestDelegate;
2018-05-14 17:55:39 +02:00
class FrameSubscriber;
2014-04-24 16:45:25 +08:00
#if BUILDFLAG(ENABLE_OSR)
class OffScreenWebContentsView;
2018-05-15 03:59:22 +02:00
class OffScreenRenderWidgetHostView;
#endif
namespace api {
// Certain events are only in WebContentsDelegate, provide our own Observer to
// dispatch those events.
class ExtendedWebContentsObserver {
2018-02-22 15:57:03 +09:00
public:
virtual void OnCloseContents() {}
virtual void OnRendererResponsive() {}
};
// Wrapper around the content::WebContents.
2015-06-24 17:58:12 +08:00
class WebContents : public mate::TrackableObject<WebContents>,
2015-06-05 13:49:12 +08:00
public CommonWebContentsDelegate,
public content::WebContentsObserver {
2014-04-24 16:45:25 +08:00
public:
enum Type {
2016-06-14 09:32:59 -07: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 20:47:30 +03: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
};
2015-06-10 20:07:14 +08:00
// For node.js callback function type: function(error, buffer)
using PrintToPDFCallback =
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>;
2015-06-10 11:34:16 +08:00
// Create from an existing WebContents.
static mate::Handle<WebContents> CreateFrom(
2018-04-17 21:44:10 -04:00
v8::Isolate* isolate,
content::WebContents* web_contents);
static mate::Handle<WebContents> CreateFrom(
2018-04-17 21:44:10 -04:00
v8::Isolate* isolate,
content::WebContents* web_contents,
Type type);
// Create a new WebContents.
2018-04-17 21:44:10 -04:00
static mate::Handle<WebContents> Create(v8::Isolate* isolate,
const mate::Dictionary& options);
2014-04-24 16:45:25 +08:00
2016-04-25 10:17:54 +09:00
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
2016-04-25 10:17:54 +09:00
// Notifies to destroy any guest web contents before destroying self.
void DestroyWebContents(bool async);
int GetProcessID() const;
2017-05-15 13:29:34 -07:00
base::ProcessId GetOSProcessID() const;
Type GetType() const;
2015-06-23 16:16:10 +08:00
bool Equal(const WebContents* web_contents) const;
void LoadURL(const GURL& url, const mate::Dictionary& options);
void DownloadURL(const GURL& url);
GURL GetURL() const;
2014-06-28 19:36:57 +08:00
base::string16 GetTitle() const;
bool IsLoading() const;
bool IsLoadingMainFrame() const;
bool IsWaitingForResponse() const;
void Stop();
2015-04-26 21:28:30 +08:00
void ReloadIgnoringCache();
void GoBack();
void GoForward();
2015-05-11 16:44:01 +08:00
void GoToOffset(int offset);
2017-03-08 22:06:26 -05:00
const std::string GetWebRTCIPHandlingPolicy() const;
void SetWebRTCIPHandlingPolicy(const std::string& webrtc_ip_handling_policy);
bool IsCrashed() const;
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
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);
2015-10-14 12:41:31 +08:00
bool SavePage(const base::FilePath& full_file_path,
const content::SavePageType& save_type,
const SavePageHandler::SavePageCallback& callback);
2015-06-05 17:01:17 +08:00
void OpenDevTools(mate::Arguments* args);
void CloseDevTools();
bool IsDevToolsOpened();
bool IsDevToolsFocused();
2015-06-05 17:01:17 +08:00
void ToggleDevTools();
void EnableDeviceEmulation(const blink::WebDeviceEmulationParams& 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);
void InspectServiceWorker();
2018-04-17 21:44:10 -04:00
void HasServiceWorker(const base::Callback<void(bool)>&);
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
void SetIgnoreMenuShortcuts(bool ignore);
2015-06-15 21:40:49 +08:00
void SetAudioMuted(bool muted);
bool IsAudioMuted();
bool IsCurrentlyAudible();
void Print(mate::Arguments* args);
2017-05-18 10:26:22 -07:00
std::vector<printing::PrinterBasicInfo> GetPrinterList();
void SetEmbedder(const WebContents* embedder);
void SetDevToolsWebContents(const WebContents* devtools);
2017-08-21 19:50:12 +09:00
v8::Local<v8::Value> GetNativeView() const;
2015-01-19 12:09:47 -08:00
// Print current page as PDF.
2015-06-10 11:34:16 +08:00
void PrintToPDF(const base::DictionaryValue& setting,
2015-06-13 16:02:16 +08:00
const PrintToPDFCallback& callback);
// DevTools workspace api.
2015-09-07 16:12:31 +08:00
void AddWorkSpace(mate::Arguments* args, const base::FilePath& path);
void RemoveWorkSpace(mate::Arguments* args, const base::FilePath& path);
2015-01-19 12:09:47 -08:00
// Editing commands.
void Undo();
void Redo();
void Cut();
void Copy();
void Paste();
void PasteAndMatchStyle();
2015-01-19 12:09:47 -08:00
void Delete();
void SelectAll();
void Unselect();
void Replace(const base::string16& word);
void ReplaceMisspelling(const base::string16& word);
2016-03-07 20:40:10 -08:00
uint32_t FindInPage(mate::Arguments* args);
2015-12-17 22:57:56 +05:30
void StopFindInPage(content::StopFindAction action);
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();
bool IsFocused() const;
2015-07-24 12:58:28 +08:00
void TabTraverse(bool reverse);
2015-09-18 14:20:31 +08:00
// Send messages to browser.
bool SendIPCMessage(bool all_frames,
const std::string& channel,
2014-06-28 19:36:57 +08:00
const base::ListValue& args);
bool SendIPCMessageWithSender(bool all_frames,
const std::string& channel,
const base::ListValue& args,
int32_t sender_id = 0);
2015-09-18 14:20:31 +08:00
// Send WebInputEvent to the page.
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
// Subscribe to the frame updates.
void BeginFrameSubscription(mate::Arguments* args);
void EndFrameSubscription();
2016-07-03 12:26:43 +09:00
// Dragging native items.
2016-07-03 13:58:31 +09:00
void StartDrag(const mate::Dictionary& item, mate::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.
void CapturePage(mate::Arguments* args);
// Methods for creating <webview>.
2015-06-05 15:18:15 +08:00
bool IsGuest() const;
void AttachToIframe(content::WebContents* embedder_web_contents,
int embedder_frame_id);
2016-07-29 14:50:27 +02:00
// Methods for offscreen rendering
bool IsOffScreen() const;
#if BUILDFLAG(ENABLE_OSR)
2016-08-04 13:22:19 +09:00
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
void StartPainting();
void StopPainting();
bool IsPainting() const;
2016-07-31 12:19:56 +02:00
void SetFrameRate(int frame_rate);
int GetFrameRate() const;
#endif
void Invalidate();
2017-05-11 23:48:14 +02:00
gfx::Size GetSizeForNewRenderView(content::WebContents*) const override;
2014-10-24 16:09:18 +08:00
// Methods for zoom handling.
void SetZoomLevel(double level);
double GetZoomLevel() const;
void SetZoomFactor(double factor);
double GetZoomFactor() const;
2016-02-01 15:33:38 +05:30
// Callback triggered on permission response.
void OnEnterFullscreenModeForTab(content::WebContents* source,
const GURL& origin,
feat: upgrade to Chromium 68.0.3440.128 and Node 10.11.0 (#14677) * Update to Chromium 68.0.3440.128 and Node 10.10.0 * update v8, ffmpeg, chromium, crashpad, boringssl, and webrtc patches * fix SSL_get_tlsext_status_type patch * pass encryption_modes_supported to CdmInfo * kNoSandbox moved into service_manager * bump CHROME_VERSION_STRING TODO: automatically pull in the real chrome version * PathService -> base::PathService * net::X509Certificate::Equals -> net::X509Certificate::EqualsExcludingChain * use content::ChildProcessTerminationInfo * GetHandle() -> GetProcess().Handle() * ScopedNestableTaskAllower doesn't take an argument * net::HttpAuthCache::ClearEntriesAddedWithin -> ClearAllEntries * std::unique_ptr<WebContents> * blink::WebFullscreenOptions * OnAudioStateChanged doesn't take a WebContents * content::RESULT_CODE_NORMAL_EXIT -> service_manager::RESULT_CODE_NORMAL_EXIT * MessageLoopCurrent * WasResized -> SynchronizeVisualProperties * SetTimeStamp takes a base::TimeTicks * ExecuteScriptInIsolatedWorld is single-script only * DispatchNonPersistentCloseEvent takes a callback now * expose URLRequestContextGetter::{Add,Remove}Observer * test: remove no longer existing Chromium test deps cc_blink_unittests has been removed in https://chromium-review.googlesource.com/1053765 mojo_common_unittests has been removed in https://chromium-review.googlesource.com/1028000 * SetFdLimit -> IncreaseFdLimitTo NOTE: the behaviour of this API has changed slightly, and we should mention that in the notes. * MessageLoop::QuitWhenIdleClosure -> RunLoop::QuitCurrentWhenIdleClosureDeprecated * certificate_transparency moved out of net/ pending a clearer decision about what to do with CT in the mean time, copy CreateLogVerifiersForKnownLogs from deleted chromium source * add secure_origin_whitelist to chrome source list NOTE: is this something we actually want? cc @deepak1556 * DrainBackgroundTasks -> DrainTasks * use new node options parser * fix disable_scroll_begin_dcheck.patch * ViewsDelegate::CreateWebContents went away see https://chromium-review.googlesource.com/c/chromium/src/+/1031314 * kZygoteProcess moved into service_manager * test: minor improvements to the Node spec - reformat some parts - better failures reporting with `expect` - skip some tests instead of marking them as passed * chromium removed *_posix.cc from the source filters * test: fix :electron_tests compilation * better crash diagnostics in ffmpeg test * fix: enable back a DCHECK in viz::ServerSharedBitmapManager Fixes #14327. Backports https://chromium-review.googlesource.com/802574. * chore: update linux sysroots * chore: remove obsolete "install-sysroot.py" script * test: fix frame-subscriber test on Mac * disable OSR for now * test: make before-input-event test more robust * test: make run-as-node --inspect test more robust on windows * roll node to v10.11.0 * avoid duplicate files when building a zip * disable failing assert in beginFrameSubscription dirty-rectangle test * experiment with is_cfi = false * fix: build torque with x64 toolchain Co-Authored-By: Alexey Kuzmin <github@alexeykuzmin.com> * test: disable the "app.relaunch" test on Linux * chore: bump node to get header tar file * chore: bump node to fix tar.py line endings
2018-10-03 19:02:14 -07:00
const blink::WebFullscreenOptions& options,
2016-02-01 15:33:38 +05:30
bool allowed);
// 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,
const std::vector<std::string>& features,
const scoped_refptr<network::ResourceRequestBody>& body);
// Returns the preload script path of current WebContents.
v8::Local<v8::Value> GetPreloadPath(v8::Isolate* isolate) 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;
2015-10-01 13:45:59 +08:00
// Returns the owner window.
v8::Local<v8::Value> GetOwnerBrowserWindow() const;
2015-10-01 13:45:59 +08:00
// Grants the child process the capability to access URLs with the origin of
// the specified URL.
void GrantOriginAccess(const GURL& url);
bool TakeHeapSnapshot(const base::FilePath& file_path,
const std::string& channel);
2015-10-01 11:14:19 +08:00
// Properties.
2016-05-17 21:56:47 +09:00
int32_t ID() const;
2015-10-01 11:14:19 +08:00
v8::Local<v8::Value> Session(v8::Isolate* isolate);
content::WebContents* HostWebContents();
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);
2015-10-01 11:14:19 +08:00
WebContentsZoomController* GetZoomController() { return zoom_controller_; }
2018-02-22 15:57:03 +09:00
void AddObserver(ExtendedWebContentsObserver* obs) {
observers_.AddObserver(obs);
}
void RemoveObserver(ExtendedWebContentsObserver* obs) {
observers_.RemoveObserver(obs);
}
bool EmitNavigationEvent(const std::string& event,
content::NavigationHandle* navigation_handle);
2014-04-24 16:45:25 +08:00
protected:
WebContents(v8::Isolate* isolate,
content::WebContents* web_contents,
Type type);
2015-09-05 01:44:22 +09:00
WebContents(v8::Isolate* isolate, const mate::Dictionary& options);
~WebContents() override;
2014-04-24 16:45:25 +08:00
void InitWithSessionAndOptions(v8::Isolate* isolate,
2018-04-17 21:44:10 -04:00
content::WebContents* web_contents,
mate::Handle<class Session> session,
const mate::Dictionary& options);
2014-10-24 18:06:32 +08:00
// content::WebContentsDelegate:
2017-01-23 18:59:40 +09:00
bool DidAddMessageToConsole(content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
2018-04-17 21:44:10 -04:00
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,
feat: upgrade to Chromium 68.0.3440.128 and Node 10.11.0 (#14677) * Update to Chromium 68.0.3440.128 and Node 10.10.0 * update v8, ffmpeg, chromium, crashpad, boringssl, and webrtc patches * fix SSL_get_tlsext_status_type patch * pass encryption_modes_supported to CdmInfo * kNoSandbox moved into service_manager * bump CHROME_VERSION_STRING TODO: automatically pull in the real chrome version * PathService -> base::PathService * net::X509Certificate::Equals -> net::X509Certificate::EqualsExcludingChain * use content::ChildProcessTerminationInfo * GetHandle() -> GetProcess().Handle() * ScopedNestableTaskAllower doesn't take an argument * net::HttpAuthCache::ClearEntriesAddedWithin -> ClearAllEntries * std::unique_ptr<WebContents> * blink::WebFullscreenOptions * OnAudioStateChanged doesn't take a WebContents * content::RESULT_CODE_NORMAL_EXIT -> service_manager::RESULT_CODE_NORMAL_EXIT * MessageLoopCurrent * WasResized -> SynchronizeVisualProperties * SetTimeStamp takes a base::TimeTicks * ExecuteScriptInIsolatedWorld is single-script only * DispatchNonPersistentCloseEvent takes a callback now * expose URLRequestContextGetter::{Add,Remove}Observer * test: remove no longer existing Chromium test deps cc_blink_unittests has been removed in https://chromium-review.googlesource.com/1053765 mojo_common_unittests has been removed in https://chromium-review.googlesource.com/1028000 * SetFdLimit -> IncreaseFdLimitTo NOTE: the behaviour of this API has changed slightly, and we should mention that in the notes. * MessageLoop::QuitWhenIdleClosure -> RunLoop::QuitCurrentWhenIdleClosureDeprecated * certificate_transparency moved out of net/ pending a clearer decision about what to do with CT in the mean time, copy CreateLogVerifiersForKnownLogs from deleted chromium source * add secure_origin_whitelist to chrome source list NOTE: is this something we actually want? cc @deepak1556 * DrainBackgroundTasks -> DrainTasks * use new node options parser * fix disable_scroll_begin_dcheck.patch * ViewsDelegate::CreateWebContents went away see https://chromium-review.googlesource.com/c/chromium/src/+/1031314 * kZygoteProcess moved into service_manager * test: minor improvements to the Node spec - reformat some parts - better failures reporting with `expect` - skip some tests instead of marking them as passed * chromium removed *_posix.cc from the source filters * test: fix :electron_tests compilation * better crash diagnostics in ffmpeg test * fix: enable back a DCHECK in viz::ServerSharedBitmapManager Fixes #14327. Backports https://chromium-review.googlesource.com/802574. * chore: update linux sysroots * chore: remove obsolete "install-sysroot.py" script * test: fix frame-subscriber test on Mac * disable OSR for now * test: make before-input-event test more robust * test: make run-as-node --inspect test more robust on windows * roll node to v10.11.0 * avoid duplicate files when building a zip * disable failing assert in beginFrameSubscription dirty-rectangle test * experiment with is_cfi = false * fix: build torque with x64 toolchain Co-Authored-By: Alexey Kuzmin <github@alexeykuzmin.com> * test: disable the "app.relaunch" test on Linux * chore: bump node to get header tar file * chore: bump node to fix tar.py line endings
2018-10-03 19:02:14 -07:00
std::unique_ptr<content::WebContents> new_contents,
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;
void BeforeUnloadFired(content::WebContents* tab,
bool proceed,
bool* proceed_to_fire_unload) override;
void MoveContents(content::WebContents* source,
const gfx::Rect& pos) override;
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;
2015-06-24 22:23:38 +08:00
bool IsPopupOrPanel(const content::WebContents* source) const override;
2014-10-24 21:46:47 +08:00
void HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
feat: upgrade to Chromium 68.0.3440.128 and Node 10.11.0 (#14677) * Update to Chromium 68.0.3440.128 and Node 10.10.0 * update v8, ffmpeg, chromium, crashpad, boringssl, and webrtc patches * fix SSL_get_tlsext_status_type patch * pass encryption_modes_supported to CdmInfo * kNoSandbox moved into service_manager * bump CHROME_VERSION_STRING TODO: automatically pull in the real chrome version * PathService -> base::PathService * net::X509Certificate::Equals -> net::X509Certificate::EqualsExcludingChain * use content::ChildProcessTerminationInfo * GetHandle() -> GetProcess().Handle() * ScopedNestableTaskAllower doesn't take an argument * net::HttpAuthCache::ClearEntriesAddedWithin -> ClearAllEntries * std::unique_ptr<WebContents> * blink::WebFullscreenOptions * OnAudioStateChanged doesn't take a WebContents * content::RESULT_CODE_NORMAL_EXIT -> service_manager::RESULT_CODE_NORMAL_EXIT * MessageLoopCurrent * WasResized -> SynchronizeVisualProperties * SetTimeStamp takes a base::TimeTicks * ExecuteScriptInIsolatedWorld is single-script only * DispatchNonPersistentCloseEvent takes a callback now * expose URLRequestContextGetter::{Add,Remove}Observer * test: remove no longer existing Chromium test deps cc_blink_unittests has been removed in https://chromium-review.googlesource.com/1053765 mojo_common_unittests has been removed in https://chromium-review.googlesource.com/1028000 * SetFdLimit -> IncreaseFdLimitTo NOTE: the behaviour of this API has changed slightly, and we should mention that in the notes. * MessageLoop::QuitWhenIdleClosure -> RunLoop::QuitCurrentWhenIdleClosureDeprecated * certificate_transparency moved out of net/ pending a clearer decision about what to do with CT in the mean time, copy CreateLogVerifiersForKnownLogs from deleted chromium source * add secure_origin_whitelist to chrome source list NOTE: is this something we actually want? cc @deepak1556 * DrainBackgroundTasks -> DrainTasks * use new node options parser * fix disable_scroll_begin_dcheck.patch * ViewsDelegate::CreateWebContents went away see https://chromium-review.googlesource.com/c/chromium/src/+/1031314 * kZygoteProcess moved into service_manager * test: minor improvements to the Node spec - reformat some parts - better failures reporting with `expect` - skip some tests instead of marking them as passed * chromium removed *_posix.cc from the source filters * test: fix :electron_tests compilation * better crash diagnostics in ffmpeg test * fix: enable back a DCHECK in viz::ServerSharedBitmapManager Fixes #14327. Backports https://chromium-review.googlesource.com/802574. * chore: update linux sysroots * chore: remove obsolete "install-sysroot.py" script * test: fix frame-subscriber test on Mac * disable OSR for now * test: make before-input-event test more robust * test: make run-as-node --inspect test more robust on windows * roll node to v10.11.0 * avoid duplicate files when building a zip * disable failing assert in beginFrameSubscription dirty-rectangle test * experiment with is_cfi = false * fix: build torque with x64 toolchain Co-Authored-By: Alexey Kuzmin <github@alexeykuzmin.com> * test: disable the "app.relaunch" test on Linux * chore: bump node to get header tar file * chore: bump node to fix tar.py line endings
2018-10-03 19:02:14 -07:00
void EnterFullscreenModeForTab(
content::WebContents* source,
const GURL& origin,
const blink::WebFullscreenOptions& options) override;
void ExitFullscreenModeForTab(content::WebContents* source) override;
2017-01-23 18:59:40 +09:00
void RendererUnresponsive(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host) override;
void RendererResponsive(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host) override;
2015-10-31 19:09:07 +05:30
bool HandleContextMenu(const content::ContextMenuParams& params) override;
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;
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
2018-04-17 21:44:10 -04:00
const GURL& security_origin,
content::MediaStreamType type) override;
2016-01-23 18:59:47 +05:30
void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback) override;
2018-04-17 21:44:10 -04:00
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;
2017-04-27 19:28:48 -05:00
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) override;
feat: upgrade to Chromium 68.0.3440.128 and Node 10.11.0 (#14677) * Update to Chromium 68.0.3440.128 and Node 10.10.0 * update v8, ffmpeg, chromium, crashpad, boringssl, and webrtc patches * fix SSL_get_tlsext_status_type patch * pass encryption_modes_supported to CdmInfo * kNoSandbox moved into service_manager * bump CHROME_VERSION_STRING TODO: automatically pull in the real chrome version * PathService -> base::PathService * net::X509Certificate::Equals -> net::X509Certificate::EqualsExcludingChain * use content::ChildProcessTerminationInfo * GetHandle() -> GetProcess().Handle() * ScopedNestableTaskAllower doesn't take an argument * net::HttpAuthCache::ClearEntriesAddedWithin -> ClearAllEntries * std::unique_ptr<WebContents> * blink::WebFullscreenOptions * OnAudioStateChanged doesn't take a WebContents * content::RESULT_CODE_NORMAL_EXIT -> service_manager::RESULT_CODE_NORMAL_EXIT * MessageLoopCurrent * WasResized -> SynchronizeVisualProperties * SetTimeStamp takes a base::TimeTicks * ExecuteScriptInIsolatedWorld is single-script only * DispatchNonPersistentCloseEvent takes a callback now * expose URLRequestContextGetter::{Add,Remove}Observer * test: remove no longer existing Chromium test deps cc_blink_unittests has been removed in https://chromium-review.googlesource.com/1053765 mojo_common_unittests has been removed in https://chromium-review.googlesource.com/1028000 * SetFdLimit -> IncreaseFdLimitTo NOTE: the behaviour of this API has changed slightly, and we should mention that in the notes. * MessageLoop::QuitWhenIdleClosure -> RunLoop::QuitCurrentWhenIdleClosureDeprecated * certificate_transparency moved out of net/ pending a clearer decision about what to do with CT in the mean time, copy CreateLogVerifiersForKnownLogs from deleted chromium source * add secure_origin_whitelist to chrome source list NOTE: is this something we actually want? cc @deepak1556 * DrainBackgroundTasks -> DrainTasks * use new node options parser * fix disable_scroll_begin_dcheck.patch * ViewsDelegate::CreateWebContents went away see https://chromium-review.googlesource.com/c/chromium/src/+/1031314 * kZygoteProcess moved into service_manager * test: minor improvements to the Node spec - reformat some parts - better failures reporting with `expect` - skip some tests instead of marking them as passed * chromium removed *_posix.cc from the source filters * test: fix :electron_tests compilation * better crash diagnostics in ffmpeg test * fix: enable back a DCHECK in viz::ServerSharedBitmapManager Fixes #14327. Backports https://chromium-review.googlesource.com/802574. * chore: update linux sysroots * chore: remove obsolete "install-sysroot.py" script * test: fix frame-subscriber test on Mac * disable OSR for now * test: make before-input-event test more robust * test: make run-as-node --inspect test more robust on windows * roll node to v10.11.0 * avoid duplicate files when building a zip * disable failing assert in beginFrameSubscription dirty-rectangle test * experiment with is_cfi = false * fix: build torque with x64 toolchain Co-Authored-By: Alexey Kuzmin <github@alexeykuzmin.com> * test: disable the "app.relaunch" test on Linux * chore: bump node to get header tar file * chore: bump node to fix tar.py line endings
2018-10-03 19:02:14 -07:00
void OnAudioStateChanged(bool audible) override;
2014-10-24 18:06:32 +08:00
// content::WebContentsObserver:
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
void RenderViewCreated(content::RenderViewHost*) override;
void RenderViewDeleted(content::RenderViewHost*) override;
void RenderProcessGone(base::TerminationStatus status) override;
2015-04-29 19:19:31 +05:30
void DocumentLoadedInFrame(
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;
2015-05-22 15:24:34 +08:00
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;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* frame_host) 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;
2017-01-23 18:59:40 +09:00
void MediaStartedPlaying(const MediaPlayerInfo& video_type,
const MediaPlayerId& id) override;
void MediaStoppedPlaying(
const MediaPlayerInfo& video_type,
const MediaPlayerId& id,
content::WebContentsObserver::MediaStoppedReason reason) override;
void DidChangeThemeColor(SkColor theme_color) override;
2014-04-24 16:45:25 +08:00
// brightray::InspectableWebContentsDelegate:
void DevToolsReloadPage() override;
2015-10-01 11:14:19 +08:00
// brightray::InspectableWebContentsViewDelegate:
void DevToolsFocused() override;
void DevToolsOpened() override;
void DevToolsClosed() override;
2017-09-13 01:25:18 +02:00
#if defined(TOOLKIT_VIEWS)
2017-11-13 16:13:54 +09:00
void ShowAutofillPopup(content::RenderFrameHost* frame_host,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels);
#endif
2014-04-24 16:45:25 +08:00
private:
2018-03-09 15:01:09 +05:30
struct FrameDispatchHelper;
2015-07-14 12:13:25 -07:00
AtomBrowserContext* GetBrowserContext() const;
2018-04-17 21:44:10 -04:00
uint32_t GetNextRequestId() { return ++request_id_; }
2015-12-18 04:40:42 +05:30
#if BUILDFLAG(ENABLE_OSR)
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
2018-05-15 03:59:22 +02:00
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
#endif
// Called when we receive a CursorChange message from chromium.
void OnCursorChange(const content::WebCursor& cursor);
2017-05-19 21:52:18 +02:00
// Called when received a message from renderer.
2018-03-09 15:01:09 +05:30
void OnRendererMessage(content::RenderFrameHost* frame_host,
const std::string& channel,
2014-06-28 19:36:57 +08:00
const base::ListValue& args);
// Called when received a synchronous message from renderer.
2018-03-09 15:01:09 +05:30
void OnRendererMessageSync(content::RenderFrameHost* frame_host,
const std::string& channel,
const base::ListValue& args,
IPC::Message* message);
// Called when received a message from renderer to be forwarded.
void OnRendererMessageTo(content::RenderFrameHost* frame_host,
bool send_to_all,
int32_t web_contents_id,
const std::string& channel,
const base::ListValue& args);
// Called when received a synchronous message from renderer to
// set temporary zoom level.
2018-03-09 15:01:09 +05:30
void OnSetTemporaryZoomLevel(content::RenderFrameHost* frame_host,
double level,
IPC::Message* reply_msg);
// 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);
void InitZoomController(content::WebContents* web_contents,
const mate::Dictionary& options);
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_;
2017-04-27 19:28:48 -05:00
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
2016-05-23 10:59:39 +09:00
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
std::unique_ptr<FrameSubscriber> frame_subscriber_;
// The host webcontents that may contain this webcontents.
WebContents* embedder_ = nullptr;
// The zoom controller for this webContents.
WebContentsZoomController* zoom_controller_ = nullptr;
2015-06-24 21:44:27 +08:00
// The type of current WebContents.
Type type_ = BROWSER_WINDOW;
2015-06-24 21:44:27 +08:00
2015-12-18 04:40:42 +05:30
// Request id used for findInPage request.
uint32_t request_id_ = 0;
2015-12-18 04:40:42 +05:30
// Whether background throttling is disabled.
bool background_throttling_ = true;
2016-09-07 10:16:52 +08:00
// Whether to enable devtools.
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_;
2014-04-24 16:45:25 +08:00
DISALLOW_COPY_AND_ASSIGN(WebContents);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_