Resource class
A resource within the inspected page, such as a document, a script, or an image.
class Resource extends ChromeObject { Resource({String url}) { if (url != null) this.url = url; } Resource.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy); /** * The URL of the resource. */ String get url => jsProxy['url']; set url(String value) => jsProxy['url'] = value; /** * Gets the content of the resource. * * Returns: * [content] Content of the resource (potentially encoded). * [encoding] Empty if content is not encoded, encoding name otherwise. * Currently, only base64 is supported. */ Future<GetResourceContentResult> getContent() { var completer = new ChromeCompleter<GetResourceContentResult>.twoArgs(GetResourceContentResult._create); jsProxy.callMethod('getContent', [completer.callback]); return completer.future; } /** * Sets the content of the resource. * * [content] New content of the resource. Only resources with the text type * are currently supported. * * [commit] True if the user has finished editing the resource, and the new * content of the resource should be persisted; false if this is a minor * change sent in progress of the user editing the resource. * * Returns: * Set to undefined if the resource content was set successfully; describes * error otherwise. */ Future<Map<String, dynamic>> setContent(String content, bool commit) { var completer = new ChromeCompleter<Map<String, dynamic>>.oneArg(mapify); jsProxy.callMethod('setContent', [content, commit, completer.callback]); return completer.future; } }
Extends
ChromeObject > Resource
Constructors
new Resource({String url}) #
Create a new instance of a ChromeObject
, which creates and delegates to
a JsObject proxy.
Resource({String url}) { if (url != null) this.url = url; }
new Resource.fromProxy(JsObject jsProxy) #
Create a new instance of a ChromeObject
, which delegates to the given
JsObject proxy.
Resource.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);
Properties
String url #
The URL of the resource.
String get url => jsProxy['url'];
set url(String value) => jsProxy['url'] = value;
Methods
Future<GetResourceContentResult> getContent() #
Gets the content of the resource.
Returns:
content
Content of the resource (potentially encoded).
encoding
Empty if content is not encoded, encoding name otherwise.
Currently, only base64 is supported.
Future<GetResourceContentResult> getContent() { var completer = new ChromeCompleter<GetResourceContentResult>.twoArgs(GetResourceContentResult._create); jsProxy.callMethod('getContent', [completer.callback]); return completer.future; }
Future<Map<String, dynamic>> setContent(String content, bool commit) #
Sets the content of the resource.
content New content of the resource. Only resources with the text type are currently supported.
commit True if the user has finished editing the resource, and the new content of the resource should be persisted; false if this is a minor change sent in progress of the user editing the resource.
Returns: Set to undefined if the resource content was set successfully; describes error otherwise.
Future<Map<String, dynamic>> setContent(String content, bool commit) { var completer = new ChromeCompleter<Map<String, dynamic>>.oneArg(mapify); jsProxy.callMethod('setContent', [content, commit, completer.callback]); return completer.future; }
String toString() #
Returns a string representation of this object.
String toString() => jsProxy.toString();