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.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
|
|
|
|
#define ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
|
|
|
|
|
2014-10-24 12:57:44 +00:00
|
|
|
#include <string>
|
2015-04-17 19:55:31 +00:00
|
|
|
#include <vector>
|
2014-10-24 12:57:44 +00:00
|
|
|
|
2015-09-18 07:57:43 +00:00
|
|
|
#include "atom/browser/api/frame_subscriber.h"
|
2015-10-14 04:41:31 +00:00
|
|
|
#include "atom/browser/api/save_page_handler.h"
|
2015-06-24 06:36:05 +00:00
|
|
|
#include "atom/browser/api/trackable_object.h"
|
2015-06-05 05:49:12 +00:00
|
|
|
#include "atom/browser/common_web_contents_delegate.h"
|
2016-08-26 22:30:02 +00:00
|
|
|
#include "content/common/cursors/webcursor.h"
|
2017-02-19 20:43:17 +00:00
|
|
|
#include "content/public/browser/notification_observer.h"
|
|
|
|
#include "content/public/browser/notification_registrar.h"
|
2014-04-25 03:22:51 +00:00
|
|
|
#include "content/public/browser/web_contents_observer.h"
|
2015-08-30 18:52:01 +00:00
|
|
|
#include "content/public/common/favicon_url.h"
|
2014-04-24 08:45:25 +00:00
|
|
|
#include "native_mate/handle.h"
|
2015-04-20 06:50:04 +00:00
|
|
|
#include "ui/gfx/image/image.h"
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2015-09-18 03:06:38 +00:00
|
|
|
namespace blink {
|
|
|
|
struct WebDeviceEmulationParams;
|
|
|
|
}
|
|
|
|
|
2014-11-02 15:32:33 +00:00
|
|
|
namespace brightray {
|
2014-11-03 11:45:09 +00:00
|
|
|
class InspectableWebContents;
|
2014-11-02 14:34:22 +00:00
|
|
|
}
|
|
|
|
|
2016-10-09 23:30:38 +00:00
|
|
|
namespace content {
|
|
|
|
class ResourceRequestBodyImpl;
|
|
|
|
}
|
|
|
|
|
2014-11-03 14:12:56 +00:00
|
|
|
namespace mate {
|
2015-06-05 09:01:17 +00:00
|
|
|
class Arguments;
|
2014-11-03 14:12:56 +00:00
|
|
|
class Dictionary;
|
|
|
|
}
|
|
|
|
|
2014-04-24 08:45:25 +00:00
|
|
|
namespace atom {
|
|
|
|
|
2015-06-25 06:28:13 +00:00
|
|
|
struct SetSizeParams;
|
2015-07-14 19:13:25 +00:00
|
|
|
class AtomBrowserContext;
|
2017-01-30 11:18:40 +00:00
|
|
|
class WebContentsZoomController;
|
2015-06-25 06:28:13 +00:00
|
|
|
class WebViewGuestDelegate;
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2015-06-25 06:28:13 +00:00
|
|
|
namespace api {
|
2015-05-29 03:12:55 +00:00
|
|
|
|
2015-06-24 09:58:12 +00:00
|
|
|
class WebContents : public mate::TrackableObject<WebContents>,
|
2015-06-05 05:49:12 +00:00
|
|
|
public CommonWebContentsDelegate,
|
2017-02-19 20:43:17 +00:00
|
|
|
public content::WebContentsObserver,
|
|
|
|
public content::NotificationObserver {
|
2014-04-24 08:45:25 +00:00
|
|
|
public:
|
2016-06-14 16:09:54 +00:00
|
|
|
enum Type {
|
2016-06-14 16:32:59 +00:00
|
|
|
BACKGROUND_PAGE, // A DevTools extension background page.
|
2016-06-14 16:09:54 +00:00
|
|
|
BROWSER_WINDOW, // Used by BrowserWindow.
|
|
|
|
REMOTE, // Thin wrap around an existing WebContents.
|
2016-06-14 16:27:36 +00:00
|
|
|
WEB_VIEW, // Used by <webview>.
|
2016-07-31 10:19:56 +00:00
|
|
|
OFF_SCREEN, // Used for offscreen rendering
|
2016-06-14 16:09:54 +00:00
|
|
|
};
|
|
|
|
|
2015-06-10 12:07:14 +00:00
|
|
|
// For node.js callback function type: function(error, buffer)
|
2015-07-24 09:39:11 +00:00
|
|
|
using PrintToPDFCallback =
|
|
|
|
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>;
|
2015-06-10 03:34:16 +00:00
|
|
|
|
2014-10-23 06:04:13 +00:00
|
|
|
// Create from an existing WebContents.
|
|
|
|
static mate::Handle<WebContents> CreateFrom(
|
|
|
|
v8::Isolate* isolate, content::WebContents* web_contents);
|
2016-08-17 00:15:10 +00:00
|
|
|
static mate::Handle<WebContents> CreateFrom(
|
|
|
|
v8::Isolate* isolate, content::WebContents* web_contents, Type type);
|
2014-10-23 06:04:13 +00:00
|
|
|
|
|
|
|
// Create a new WebContents.
|
|
|
|
static mate::Handle<WebContents> Create(
|
|
|
|
v8::Isolate* isolate, const mate::Dictionary& options);
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2016-04-25 01:17:54 +00:00
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
2016-08-02 09:08:12 +00:00
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
2016-04-25 01:17:54 +00:00
|
|
|
|
2016-09-06 01:28:40 +00:00
|
|
|
int64_t GetID() const;
|
|
|
|
int GetProcessID() 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;
|
2014-11-06 19:29:41 +00:00
|
|
|
void LoadURL(const GURL& url, const mate::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;
|
2016-06-22 06:57:51 +00:00
|
|
|
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
|
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);
|
2015-10-14 04:41:31 +00:00
|
|
|
bool SavePage(const base::FilePath& full_file_path,
|
|
|
|
const content::SavePageType& save_type,
|
|
|
|
const SavePageHandler::SavePageCallback& callback);
|
2015-06-05 09:01:17 +00:00
|
|
|
void OpenDevTools(mate::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);
|
2015-06-05 07:41:03 +00:00
|
|
|
void InspectServiceWorker();
|
2015-04-30 13:15:19 +00:00
|
|
|
void HasServiceWorker(const base::Callback<void(bool)>&);
|
|
|
|
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
|
2015-06-15 13:40:49 +00:00
|
|
|
void SetAudioMuted(bool muted);
|
|
|
|
bool IsAudioMuted();
|
2015-06-13 13:23:45 +00:00
|
|
|
void Print(mate::Arguments* args);
|
2016-09-08 17:01:01 +00:00
|
|
|
void SetEmbedder(const WebContents* embedder);
|
2015-01-19 20:09:47 +00:00
|
|
|
|
2015-06-09 05:07:40 +00:00
|
|
|
// Print current page as PDF.
|
2015-06-10 03:34:16 +00:00
|
|
|
void PrintToPDF(const base::DictionaryValue& setting,
|
2015-06-13 08:02:16 +00:00
|
|
|
const PrintToPDFCallback& callback);
|
2015-06-09 05:07:40 +00:00
|
|
|
|
2015-07-24 09:39:11 +00:00
|
|
|
// DevTools workspace api.
|
2015-09-07 08:12:31 +00:00
|
|
|
void AddWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
|
|
|
void RemoveWorkSpace(mate::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);
|
2016-03-08 04:40:10 +00:00
|
|
|
uint32_t FindInPage(mate::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.
|
2016-05-29 03:10:32 +00:00
|
|
|
bool SendIPCMessage(bool all_frames,
|
|
|
|
const base::string16& channel,
|
2014-06-28 11:36:57 +00:00
|
|
|
const base::ListValue& args);
|
2014-04-24 09:00:41 +00:00
|
|
|
|
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.
|
2016-06-21 00:15:39 +00:00
|
|
|
void BeginFrameSubscription(mate::Arguments* args);
|
2015-09-18 07:57:43 +00:00
|
|
|
void EndFrameSubscription();
|
|
|
|
|
2016-07-03 03:26:43 +00:00
|
|
|
// Dragging native items.
|
2016-07-03 04:58:31 +00:00
|
|
|
void StartDrag(const mate::Dictionary& item, mate::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.
|
|
|
|
void CapturePage(mate::Arguments* args);
|
|
|
|
|
2015-06-25 06:28:13 +00:00
|
|
|
// Methods for creating <webview>.
|
2015-05-29 03:12:55 +00:00
|
|
|
void SetSize(const SetSizeParams& params);
|
2015-06-05 07:18:15 +00:00
|
|
|
bool IsGuest() const;
|
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;
|
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;
|
2016-09-01 17:25:12 +00:00
|
|
|
void Invalidate();
|
2014-10-24 08:09:18 +00:00
|
|
|
|
2017-01-29 14:13:20 +00:00
|
|
|
// Methods for zoom handling.
|
|
|
|
void SetZoomLevel(double level);
|
|
|
|
double GetZoomLevel();
|
|
|
|
void SetZoomFactor(double factor);
|
|
|
|
double GetZoomFactor();
|
|
|
|
|
2016-02-01 10:03:38 +00:00
|
|
|
// Callback triggered on permission response.
|
|
|
|
void OnEnterFullscreenModeForTab(content::WebContents* source,
|
|
|
|
const GURL& origin,
|
|
|
|
bool allowed);
|
|
|
|
|
2016-03-31 00:58:23 +00:00
|
|
|
// Create window with the given disposition.
|
2016-10-09 23:30:38 +00:00
|
|
|
void OnCreateWindow(
|
|
|
|
const GURL& target_url,
|
|
|
|
const std::string& frame_name,
|
|
|
|
WindowOpenDisposition disposition,
|
2017-01-23 08:44:42 +00:00
|
|
|
const std::vector<std::string>& features,
|
2016-10-09 23:30:38 +00:00
|
|
|
const scoped_refptr<content::ResourceRequestBodyImpl>& body);
|
2016-03-31 00:58:23 +00:00
|
|
|
|
2015-09-22 13:56:56 +00:00
|
|
|
// Returns the web preferences of current WebContents.
|
|
|
|
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
|
|
|
|
|
2015-10-01 05:45:59 +00:00
|
|
|
// Returns the owner window.
|
|
|
|
v8::Local<v8::Value> GetOwnerBrowserWindow();
|
|
|
|
|
2015-10-01 03:14:19 +00:00
|
|
|
// Properties.
|
2016-05-17 12:56:47 +00:00
|
|
|
int32_t ID() const;
|
2015-10-01 03:14:19 +00:00
|
|
|
v8::Local<v8::Value> Session(v8::Isolate* isolate);
|
2016-02-17 08:52:19 +00:00
|
|
|
content::WebContents* HostWebContents();
|
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_; }
|
|
|
|
|
2014-04-24 08:45:25 +00:00
|
|
|
protected:
|
2016-08-17 00:15:10 +00:00
|
|
|
WebContents(v8::Isolate* isolate,
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
Type type);
|
2015-09-04 16:44:22 +00:00
|
|
|
WebContents(v8::Isolate* isolate, const mate::Dictionary& options);
|
2014-10-23 06:04:13 +00:00
|
|
|
~WebContents();
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2016-08-17 00:15:10 +00:00
|
|
|
void InitWithSessionAndOptions(v8::Isolate* isolate,
|
|
|
|
content::WebContents *web_contents,
|
|
|
|
mate::Handle<class Session> session,
|
|
|
|
const mate::Dictionary& options);
|
|
|
|
|
2014-10-24 10:06:32 +00:00
|
|
|
// content::WebContentsDelegate:
|
2017-01-23 09:59:40 +00:00
|
|
|
bool DidAddMessageToConsole(content::WebContents* source,
|
|
|
|
int32_t level,
|
|
|
|
const base::string16& message,
|
|
|
|
int32_t line_no,
|
|
|
|
const base::string16& source_id) override;
|
2016-08-16 00:13:18 +00:00
|
|
|
void WebContentsCreated(content::WebContents* source_contents,
|
2017-01-23 09:59:40 +00:00
|
|
|
int opener_render_process_id,
|
2016-08-16 00:13:18 +00:00
|
|
|
int opener_render_frame_id,
|
|
|
|
const std::string& frame_name,
|
|
|
|
const GURL& target_url,
|
|
|
|
content::WebContents* new_contents) override;
|
|
|
|
void AddNewContents(content::WebContents* source,
|
|
|
|
content::WebContents* new_contents,
|
|
|
|
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;
|
|
|
|
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 06:56:19 +00:00
|
|
|
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
2015-06-24 14:23:38 +00:00
|
|
|
bool IsPopupOrPanel(const content::WebContents* source) const override;
|
2014-10-24 13:46:47 +00:00
|
|
|
void HandleKeyboardEvent(
|
|
|
|
content::WebContents* source,
|
|
|
|
const content::NativeWebKeyboardEvent& event) override;
|
2016-12-06 22:41:18 +00:00
|
|
|
bool PreHandleKeyboardEvent(content::WebContents* source,
|
|
|
|
const content::NativeWebKeyboardEvent& event,
|
|
|
|
bool* is_keyboard_shortcut) override;
|
2015-05-09 12:17:40 +00:00
|
|
|
void EnterFullscreenModeForTab(content::WebContents* source,
|
2015-05-08 06:18:15 +00:00
|
|
|
const GURL& origin) 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,
|
|
|
|
const content::WebContentsUnresponsiveState& unresponsive_state) override;
|
2015-06-25 03:07:23 +00:00
|
|
|
void RendererResponsive(content::WebContents* source) override;
|
2015-10-31 13:39:07 +00:00
|
|
|
bool HandleContextMenu(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;
|
2016-02-26 10:17:28 +00:00
|
|
|
bool CheckMediaAccessPermission(
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
const GURL& security_origin,
|
|
|
|
content::MediaStreamType type) override;
|
2016-01-23 13:29:47 +00:00
|
|
|
void RequestMediaAccessPermission(
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
const content::MediaStreamRequest& request,
|
|
|
|
const content::MediaResponseCallback& callback) override;
|
2016-02-01 09:43:49 +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;
|
2014-10-24 10:06:32 +00:00
|
|
|
|
2014-10-23 09:54:52 +00:00
|
|
|
// content::WebContentsObserver:
|
2015-06-25 03:07:23 +00:00
|
|
|
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
2016-12-28 23:44:44 +00:00
|
|
|
void RenderViewCreated(content::RenderViewHost*) override;
|
2014-12-09 22:38:43 +00:00
|
|
|
void RenderViewDeleted(content::RenderViewHost*) override;
|
|
|
|
void RenderProcessGone(base::TerminationStatus status) override;
|
2015-04-29 13:49:31 +00:00
|
|
|
void DocumentLoadedInFrame(
|
|
|
|
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,
|
|
|
|
int error_code,
|
2015-09-02 07:16:49 +00:00
|
|
|
const base::string16& error_description,
|
|
|
|
bool was_ignored_by_handler) override;
|
2015-05-22 07:24:34 +00:00
|
|
|
void DidStartLoading() override;
|
|
|
|
void DidStopLoading() override;
|
2015-04-08 13:44:47 +00:00
|
|
|
void DidGetResourceResponseStart(
|
|
|
|
const content::ResourceRequestDetails& details) override;
|
2014-12-09 22:38:43 +00:00
|
|
|
void DidGetRedirectForResourceRequest(
|
2014-10-24 15:05:25 +00:00
|
|
|
const content::ResourceRedirectDetails& details) override;
|
2017-02-19 20:43:17 +00:00
|
|
|
void DidStartNavigation(
|
|
|
|
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;
|
2015-04-05 09:20:42 +00:00
|
|
|
void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
|
2015-04-17 19:55:31 +00:00
|
|
|
void DidUpdateFaviconURL(
|
|
|
|
const std::vector<content::FaviconURL>& 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,
|
|
|
|
const MediaPlayerId& id) override;
|
|
|
|
void MediaStoppedPlaying(const MediaPlayerInfo& video_type,
|
|
|
|
const MediaPlayerId& id) override;
|
2015-12-22 22:16:00 +00:00
|
|
|
void DidChangeThemeColor(SkColor theme_color) override;
|
2014-04-24 08:45:25 +00:00
|
|
|
|
2017-02-19 20:43:17 +00:00
|
|
|
// content::NotificationObserver:
|
|
|
|
void Observe(int type,
|
|
|
|
const content::NotificationSource& source,
|
|
|
|
const content::NotificationDetails& details) override;
|
|
|
|
|
2016-04-12 07:36:12 +00:00
|
|
|
// brightray::InspectableWebContentsDelegate:
|
|
|
|
void DevToolsReloadPage() override;
|
|
|
|
|
2015-10-01 03:14:19 +00:00
|
|
|
// brightray::InspectableWebContentsViewDelegate:
|
|
|
|
void DevToolsFocused() override;
|
|
|
|
void DevToolsOpened() override;
|
|
|
|
void DevToolsClosed() override;
|
|
|
|
|
2014-04-24 08:45:25 +00:00
|
|
|
private:
|
2017-02-19 20:43:17 +00:00
|
|
|
struct LoadURLParams {
|
|
|
|
LoadURLParams() : params(GURL()), id(0) {}
|
|
|
|
|
|
|
|
content::NavigationController::LoadURLParams params;
|
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
2015-07-14 19:13:25 +00:00
|
|
|
AtomBrowserContext* GetBrowserContext() const;
|
|
|
|
|
2016-03-08 04:40:10 +00:00
|
|
|
uint32_t GetNextRequestId() {
|
2015-12-17 23:10:42 +00:00
|
|
|
return ++request_id_;
|
|
|
|
}
|
|
|
|
|
2016-01-31 01:27:14 +00:00
|
|
|
// Called when we receive a CursorChange message from chromium.
|
2016-01-30 05:33:55 +00:00
|
|
|
void OnCursorChange(const content::WebCursor& cursor);
|
|
|
|
|
2014-04-25 08:13:16 +00:00
|
|
|
// Called when received a message from renderer.
|
2014-06-28 11:36:57 +00:00
|
|
|
void OnRendererMessage(const base::string16& channel,
|
|
|
|
const base::ListValue& args);
|
2014-04-25 08:13:16 +00:00
|
|
|
|
|
|
|
// Called when received a synchronous message from renderer.
|
2014-06-28 11:36:57 +00:00
|
|
|
void OnRendererMessageSync(const base::string16& channel,
|
2014-04-25 08:13:16 +00:00
|
|
|
const base::ListValue& args,
|
|
|
|
IPC::Message* message);
|
|
|
|
|
2017-01-30 17:06:50 +00:00
|
|
|
// Called when received a synchronous message from renderer to
|
|
|
|
// set temporary zoom level.
|
|
|
|
void OnSetTemporaryZoomLevel(double level, IPC::Message* reply_msg);
|
|
|
|
|
|
|
|
// Called when received a synchronous message from renderer to
|
|
|
|
// get the zoom level.
|
|
|
|
void OnGetZoomLevel(IPC::Message* reply_msg);
|
|
|
|
|
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
|
|
|
|
2016-05-23 01:59:39 +00:00
|
|
|
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
|
2015-05-29 03:12:55 +00:00
|
|
|
|
2016-02-17 08:52:19 +00:00
|
|
|
// The host webcontents that may contain this webcontents.
|
|
|
|
WebContents* embedder_;
|
|
|
|
|
2017-01-30 11:18:40 +00:00
|
|
|
// The zoom controller for this webContents.
|
|
|
|
WebContentsZoomController* zoom_controller_;
|
|
|
|
|
2015-06-24 13:44:27 +00:00
|
|
|
// The type of current WebContents.
|
|
|
|
Type type_;
|
|
|
|
|
2015-12-17 23:10:42 +00:00
|
|
|
// Request id used for findInPage request.
|
2016-03-08 04:40:10 +00:00
|
|
|
uint32_t request_id_;
|
2015-12-17 23:10:42 +00:00
|
|
|
|
2016-04-08 06:54:33 +00:00
|
|
|
// Whether background throttling is disabled.
|
|
|
|
bool background_throttling_;
|
|
|
|
|
2016-09-07 02:16:52 +00:00
|
|
|
// Whether to enable devtools.
|
|
|
|
bool enable_devtools_;
|
2016-09-05 08:27:56 +00:00
|
|
|
|
2017-02-19 20:43:17 +00:00
|
|
|
// Container to hold url parms for deferred load when
|
|
|
|
// there is a pending navigation entry.
|
|
|
|
LoadURLParams deferred_load_url_;
|
|
|
|
content::NotificationRegistrar registrar_;
|
|
|
|
|
2014-04-24 08:45:25 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(WebContents);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_H_
|