WebKit2WebExtension.WebPage

g GObject.Object GObject.Object WebKit2WebExtension.WebPage WebKit2WebExtension.WebPage GObject.Object->WebKit2WebExtension.WebPage

Subclasses:None

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
  get_dom_document ()
  get_editor ()
  get_id ()
  get_main_frame ()
  get_uri ()
  send_message_to_view (message, cancellable, callback, *user_data)
  send_message_to_view_finish (result)

Virtual Methods

Inherited:GObject.Object (7)

Properties

Name Type Flags Short Description
uri str r The current active URI of the web page

Signals

Inherited:GObject.Object (1)
Name Short Description
console-message-sent Emitted when a message is sent to the console.
context-menu Emitted before a context menu is displayed in the UI Process to give the application a chance to customize the proposed menu, build its own context menu or pass user data to the UI Process.
document-loaded This signal is emitted when the DOM document of a WebKit2WebExtension.WebPage has been loaded.
form-controls-associated Emitted after form elements (or form associated elements) are associated to a particular web page. deprecated
form-controls-associated-for-frame Emitted after form elements (or form associated elements) are associated to a particular web page.
send-request This signal is emitted when request is about to be sent to the server.
user-message-received This signal is emitted when a WebKit2WebExtension.UserMessage is received from the #WebKitWebView corresponding to web_page.
will-submit-form This signal is emitted to indicate various points during form submission.

Fields

Inherited:GObject.Object (1)
Name Type Access Description
parent GObject.Object r  

Class Details

class WebKit2WebExtension.WebPage(**kwargs)
Bases:GObject.Object
Abstract:No
Structure:WebKit2WebExtension.WebPageClass
get_dom_document()
Returns:the WebKit2WebExtension.DOMDocument currently loaded, or None if no document is currently loaded.
Return type:WebKit2WebExtension.DOMDocument

Get the WebKit2WebExtension.DOMDocument currently loaded in self

get_editor()
Returns:the WebKit2WebExtension.WebEditor
Return type:WebKit2WebExtension.WebEditor

Gets the WebKit2WebExtension.WebEditor of a WebKit2WebExtension.WebPage.

New in version 2.10.

get_id()
Returns:the identifier of self
Return type:int

Get the identifier of the WebKit2WebExtension.WebPage

get_main_frame()
Returns:the WebKit2WebExtension.Frame that is the main frame of self
Return type:WebKit2WebExtension.Frame

Returns the main frame of a WebKit2WebExtension.WebPage.

New in version 2.2.

get_uri()
Returns:the current active URI of web_view or None if nothing has been loaded yet.
Return type:str

Returns the current active URI of self.

You can monitor the active URI by connecting to the notify::uri signal of self.

send_message_to_view(message, cancellable, callback, *user_data)
Parameters:

Send message to the #WebKitWebView corresponding to self. If message is floating, it’s consumed.

If you don’t expect any reply, or you simply want to ignore it, you can pass None as callback. When the operation is finished, callback will be called. You can then call WebKit2WebExtension.WebPage.send_message_to_view_finish() to get the message reply.

New in version 2.28.

send_message_to_view_finish(result)
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult
Raises:GLib.Error
Returns:a WebKit2WebExtension.UserMessage with the reply or None in case of error.
Return type:WebKit2WebExtension.UserMessage

Finish an asynchronous operation started with WebKit2WebExtension.WebPage.send_message_to_view().

New in version 2.28.

Signal Details

WebKit2WebExtension.WebPage.signals.console_message_sent(web_page, console_message)
Signal Name:

console-message-sent

Flags:

RUN_LAST

Parameters:

Emitted when a message is sent to the console. This can be a message produced by the use of JavaScript console API, a JavaScript exception, a security error or other errors, warnings, debug or log messages. The console_message contains information of the message.

New in version 2.12.

WebKit2WebExtension.WebPage.signals.context_menu(web_page, context_menu, hit_test_result)
Signal Name:

context-menu

Flags:

RUN_LAST

Parameters:
Returns:

True if the proposed context_menu has been modified, or False otherwise.

Return type:

bool

Emitted before a context menu is displayed in the UI Process to give the application a chance to customize the proposed menu, build its own context menu or pass user data to the UI Process. This signal is useful when the information available in the UI Process is not enough to build or customize the context menu, for example, to add menu entries depending on the WebKit2WebExtension.DOMNode at the coordinates of the hit_test_result. Otherwise, it’s recommended to use #WebKitWebView::context-menu signal instead.

New in version 2.8.

WebKit2WebExtension.WebPage.signals.document_loaded(web_page)
Signal Name:document-loaded
Flags:RUN_LAST
Parameters:web_page (WebKit2WebExtension.WebPage) – The object which received the signal

This signal is emitted when the DOM document of a WebKit2WebExtension.WebPage has been loaded.

You can wait for this signal to get the DOM document with WebKit2WebExtension.WebPage.get_dom_document().

WebKit2WebExtension.WebPage.signals.form_controls_associated(web_page, elements)
Signal Name:

form-controls-associated

Flags:

RUN_LAST, DEPRECATED

Parameters:

Emitted after form elements (or form associated elements) are associated to a particular web page. This is useful to implement form auto filling for web pages where form fields are added dynamically. This signal might be emitted multiple times for the same web page.

Note that this signal could be also emitted when form controls are moved between forms. In that case, the elements array carries the list of those elements which have moved.

Clients should take a reference to the members of the elements array if it is desired to keep them alive after the signal handler returns.

New in version 2.16.

Deprecated since version 2.26: , use WebKit2WebExtension.WebPage ::form-controls-associated-for-frame instead.

WebKit2WebExtension.WebPage.signals.form_controls_associated_for_frame(web_page, elements, frame)
Signal Name:

form-controls-associated-for-frame

Flags:

RUN_LAST

Parameters:

Emitted after form elements (or form associated elements) are associated to a particular web page. This is useful to implement form auto filling for web pages where form fields are added dynamically. This signal might be emitted multiple times for the same web page.

Note that this signal could be also emitted when form controls are moved between forms. In that case, the elements array carries the list of those elements which have moved.

Clients should take a reference to the members of the elements array if it is desired to keep them alive after the signal handler returns.

New in version 2.26.

WebKit2WebExtension.WebPage.signals.send_request(web_page, request, redirected_response)
Signal Name:

send-request

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to continue emission of the event.

Return type:

bool

This signal is emitted when request is about to be sent to the server. This signal can be used to modify the WebKit2WebExtension.URIRequest that will be sent to the server. You can also cancel the resource load operation by connecting to this signal and returning True.

In case of a server redirection this signal is emitted again with the request argument containing the new request to be sent to the server due to the redirection and the redirected_response parameter containing the response received by the server for the initial request.

Modifications to the WebKit2WebExtension.URIRequest and its associated Soup.MessageHeaders will be taken into account when the request is sent over the network.

WebKit2WebExtension.WebPage.signals.user_message_received(web_page, message)
Signal Name:

user-message-received

Flags:

RUN_LAST

Parameters:
Returns:

True if the message was handled, or False otherwise.

Return type:

bool

This signal is emitted when a WebKit2WebExtension.UserMessage is received from the #WebKitWebView corresponding to web_page. You can reply to the message using WebKit2WebExtension.UserMessage.send_reply().

You can handle the user message asynchronously by calling GObject.Object.ref() on message and returning True. If the last reference of message is removed and the message has been replied, the operation in the #WebKitWebView will finish with error WebKit2WebExtension.UserMessageError.USER_MESSAGE_UNHANDLED_MESSAGE.

New in version 2.28.

WebKit2WebExtension.WebPage.signals.will_submit_form(web_page, form, step, source_frame, target_frame, text_field_names, text_field_values)
Signal Name:

will-submit-form

Flags:

RUN_LAST

Parameters:

This signal is emitted to indicate various points during form submission. step indicates the current stage of form submission.

If this signal is emitted with WebKit2WebExtension.FormSubmissionStep.SEND_DOM_EVENT, then the DOM submit event is about to be emitted. JavaScript code may rely on the submit event to detect that the user has clicked on a submit button, and to possibly cancel the form submission before WebKit2WebExtension.FormSubmissionStep.COMPLETE. However, beware that, for historical reasons, the submit event is not emitted at all if the form submission is triggered by JavaScript. For these reasons, WebKit2WebExtension.FormSubmissionStep.SEND_DOM_EVENT may not be used to reliably detect whether a form will be submitted. Instead, use it to detect if a user has clicked on a form’s submit button even if JavaScript later cancels the form submission, or to read the values of the form’s fields even if JavaScript later clears certain fields before submitting. This may be needed, for example, to implement a robust browser password manager, as some misguided websites may use such techniques to attempt to thwart password managers.

If this signal is emitted with WebKit2WebExtension.FormSubmissionStep.COMPLETE, the form will imminently be submitted. It can no longer be cancelled. This event always occurs immediately before a form is submitted to its target, so use this event to reliably detect when a form is submitted. This event occurs after WebKit2WebExtension.FormSubmissionStep.SEND_DOM_EVENT if that event is emitted.

New in version 2.20.

Property Details

WebKit2WebExtension.WebPage.props.uri
Name:uri
Type:str
Default Value:None
Flags:READABLE

The current active URI of the WebKit2WebExtension.WebPage.