nsIWebProgressListener
出典: MDC
このページは翻訳中です。
翻訳作業に参加する場合は、履歴にある翻訳者と連絡·調整してください。
目次 |
[編集] 概要
nsIWebProgressListener インタフェースは全ての子 nsIWebProgress インスタンスと同じように nsIWebProgress インスタンスのコンテクストで非同期リクエストの読み込みに関連づけられた進捗状態をリッスンしたいクライアントによって実装されます。nsIWebProgress.idl は nsIWebProgress インスタンスの親子関係を記述しています。
nsIWebProgressListener は uriloader/base/nsIWebProgressListener.idl で定義されています。これは scriptable で
unknown version of Mozilla から凍結されています。
[編集] インターフェースコード
[scriptable, uuid(570F39D1-EFD0-11d3-B093-00A024FFC08C)]
interface nsIWebProgressListener : nsISupports
{
const unsigned long STATE_START = 0x00000001;
const unsigned long STATE_REDIRECTING = 0x00000002;
const unsigned long STATE_TRANSFERRING = 0x00000004;
const unsigned long STATE_NEGOTIATING = 0x00000008;
const unsigned long STATE_STOP = 0x00000010;
const unsigned long STATE_IS_REQUEST = 0x00010000;
const unsigned long STATE_IS_DOCUMENT = 0x00020000;
const unsigned long STATE_IS_NETWORK = 0x00040000;
const unsigned long STATE_IS_WINDOW = 0x00080000;
const unsigned long STATE_RESTORING = 0x01000000;
const unsigned long STATE_IS_INSECURE = 0x00000004;
const unsigned long STATE_IS_BROKEN = 0x00000001;
const unsigned long STATE_IS_SECURE = 0x00000002;
const unsigned long STATE_SECURE_HIGH = 0x00040000;
const unsigned long STATE_SECURE_MED = 0x00010000;
const unsigned long STATE_SECURE_LOW = 0x00020000;
void onStateChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in unsigned long aStateFlags,
in nsresult aStatus);
void onProgressChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in long aCurSelfProgress,
in long aMaxSelfProgress,
in long aCurTotalProgress,
in long aMaxTotalProgress);
void onLocationChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in nsIURI aLocation);
void onStatusChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in nsresult aStatus,
in wstring aMessage);
void onSecurityChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in unsigned long aState);
};
[編集] 定数
[編集] 状態遷移フラグ(State Transition Flags)
These flags indicate the various states that requests may transition through as they are being loaded. These flags are mutually exclusive.
For any given request, onStateChange is called once with the STATE_START flag, zero or more times with the STATE_TRANSFERRING flag or once with the STATE_REDIRECTING flag, and then finally once with the STATE_STOP flag.
- NOTE: For document requests, a second
STATE_STOPis generated (see the description ofSTATE_IS_WINDOWfor more details).
STATE_START- This flag indicates the start of a request. This flag is set when a request is initiated. The request is complete when
onStateChangeis called for the same request with theSTATE_STOPflag set.
- This flag indicates the start of a request. This flag is set when a request is initiated. The request is complete when
STATE_REDIRECTING- This flag indicates that a request is being redirected. The request passed to
onStateChangeis the request that is being redirected. When a redirect occurs, a new request is generated automatically to process the new request. Expect a correspondingSTATE_STARTevent for the new request, and aSTATE_STOPfor the redirected request.
- This flag indicates that a request is being redirected. The request passed to
STATE_TRANSFERRING- This flag indicates that data for a request is being transferred to an end consumer. This flag indicates that the request has been targeted, and that the user may start seeing content corresponding to the request.
STATE_NEGOTIATING- This flag is not used.
STATE_STOP- This flag indicates the completion of a request. The
aStatusparameter toonStateChangeindicates the final status of the request.
- This flag indicates the completion of a request. The
[編集] 状態種類フラグ(State Type Flags)
These flags further describe the entity for which the state transition is occuring. These flags are NOT mutually exclusive (i.e., an onStateChange event may indicate some combination of these flags).
STATE_IS_REQUEST- This flag indicates that the state transition is for a request, which includes but is not limited to document requests. (See below for a description of document requests.) Other types of requests, such as requests for inline content (e.g., images and stylesheets) are considered normal requests.
STATE_IS_DOCUMENT- This flag indicates that the state transition is for a document request. This flag is set in addition to
STATE_IS_REQUEST. A document request supports thensIChannelinterface and it'sloadFlagsattribute includes thensIChannel::LOAD_DOCUMENT_URIflag. - A document request does not complete until all requests associated with the loading of its corresponding document have completed. This includes other document requests (e.g., corresponding to HTML <iframe> elements). The document corresponding to a document request is available via the DOMWindow attribute of
onStateChange'saWebProgressparameter.
- This flag indicates that the state transition is for a document request. This flag is set in addition to
STATE_IS_NETWORK- This flag indicates that the state transition corresponds to the start or stop of activity in the indicated
nsIWebProgressinstance. This flag is accompanied by eitherSTATE_STARTorSTATE_STOP, and it may be combined with other State Type Flags. - Unlike
STATE_IS_WINDOW, this flag is only set when activity within thensIWebProgressinstance being observed starts or stops. If activity only occurs in a childnsIWebProgressinstance, then this flag will be set to indicate the start and stop of that activity. - For example, in the case of navigation within a single frame of a HTML frameset, a
nsIWebProgressListenerinstance attached to thensIWebProgressof the frameset window will receive onStateChange calls with theSTATE_IS_NETWORKflag set to indicate the start and stop of said navigation. In other words, an observer of an outer window can determine when activity, that may be constrained to a child window or set of child windows, starts and stops.
- This flag indicates that the state transition corresponds to the start or stop of activity in the indicated
STATE_IS_WINDOW- This flag indicates that the state transition corresponds to the start or stop of activity in the indicated nsIWebProgress instance. This flag is accompanied by either
STATE_STARTorSTATE_STOP, and it may be combined with other State Type Flags. - This flag is similar to
STATE_IS_DOCUMENT. However, when a document request completes, twoonStateChangecalls withSTATE_STOPare generated. The document request is passed as aRequest to both calls. The first hasSTATE_IS_REQUESTandSTATE_IS_DOCUMENTset, and the second has theSTATE_IS_WINDOWflag set (and possibly theSTATE_IS_NETWORKflag set as well - see above for a description of when theSTATE_IS_NETWORKflag may be set). This secondSTATE_STOPevent may be useful as a way to partition the work that occurs when a document request completes.
- This flag indicates that the state transition corresponds to the start or stop of activity in the indicated nsIWebProgress instance. This flag is accompanied by either
[編集] 状態変更フラグ(State Modifier Flags)
These flags further describe the transition which is occuring. These flags are NOT mutually exclusive (i.e., an onStateChange event may indicate some combination of these flags).
STATE_RESTORING- This flag indicates that the state transition corresponds to the start or stop of activity for restoring a previously-rendered presentation. As such, there is no actual network activity associated with this request, and any modifications made to the document or presentation when it was originally loaded will still be present.
[編集] 状態セキュリティフラグ(State Security Flags)
These flags describe the security state reported by a call to the onSecurityChange method. These flags are mutually exclusive.
STATE_IS_INSECURE- This flag indicates that the data corresponding to the request was received over an insecure channel.
STATE_IS_BROKEN- This flag indicates an unknown security state. This may mean that the request is being loaded as part of a page in which some content was received over an insecure channel.
STATE_IS_SECURE- This flag indicates that the data corresponding to the request was received over a secure channel. The degree of security is expressed by
STATE_SECURE_HIGH,STATE_SECURE_MED, orSTATE_SECURE_LOW.
- This flag indicates that the data corresponding to the request was received over a secure channel. The degree of security is expressed by
[編集] セキュリティ強度フラグ(Security Strength Flags)
These flags describe the security strength and accompany STATE_IS_SECURE in a call to the onSecurityChange method. These flags are mutually exclusive.
These flags are not meant to provide a precise description of data transfer security. These are instead intended as a rough indicator that may be used to, for example, color code a security indicator or otherwise provide basic data transfer security feedback to the user.
STATE_SECURE_HIGH- This flag indicates a high degree of security.
STATE_SECURE_MED- This flag indicates a medium degree of security.
STATE_SECURE_LOW- This flag indicates a low degree of security.
[編集] メソッド
[編集] onStateChange
void onStateChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in unsigned long aStateFlags,
in nsresult aStatus);
Notification indicating the state has changed for one of the requests associated with aWebProgress.
[編集] パラメータ
aWebProgress- The
nsIWebProgressinstance that fired the notification
aRequest- The
nsIRequestthat has changed state. This parameter may benull. Need more information on what NULL means.
aStateFlags- Flags indicating the new state. This value is a combination of one of the State Transition Flags and one or more of the State Type Flags defined above. Any undefined bits are reserved for future use.
aStatus- Error status code associated with the state change; this indicates whether or not the request was successful. This parameter should be ignored unless
aStateFlagsincludes theSTATE_STOPbit.
aStatus may be a success code even for server generated errors, such as the HTTP 404 error. In such cases, the request itself should be queried for extended error information (e.g., for HTTP requests see nsIHttpChannel).[編集] onProgressChange
void onProgressChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in long aCurSelfProgress,
in long aMaxSelfProgress,
in long aCurTotalProgress,
in long aMaxTotalProgress);
Notification that the progress has changed for one of the requests associated with aWebProgress. Progress totals are reset to zero when all requests in aWebProgress complete (corresponding to onStateChange being called with aStateFlags including the STATE_STOP and STATE_IS_WINDOW flags).
[編集] パラメータ
aWebProgress- The
nsIWebProgressinstance that fired the notification.
- The
aRequest- The
nsIRequestthat has new progress.
- The
aCurSelfProgress- The current progress for
aRequest.
- The current progress for
aMaxSelfProgress- The maximum progress for
aRequest.
- The maximum progress for
aCurTotalProgress- The current progress for all requests associated with
aWebProgress.
- The current progress for all requests associated with
aMaxTotalProgress- The total progress for all requests associated with
aWebProgress. -
- NOTE: If any progress value is unknown, or if its value would exceed the maximum value of type long, then its value is replaced with -1.
- NOTE: If the object also implements
nsIWebProgressListener2and the caller knows about that interface, this function will not be called. Instead,nsIWebProgressListener2::onProgressChange64will be called.
- The total progress for all requests associated with
[編集] onLocationChange
void onLocationChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in nsIURI aLocation);
Called when the location of the window being watched changes. This is not when a load is requested, but rather once it is verified that the load is going to occur in the given window. For instance, a load that starts in a window might send progress and status messages for the new site, but it will not send the onLocationChange until we are sure that we are loading this new page here.
[編集] パラメータ
aWebProgress- The
nsIWebProgressinstance that fired the notification.
- The
aRequest- The associated
nsIRequest. This may be null in some cases.
- The associated
aLocation- The URI of the location that is being loaded.
[編集] onStatusChange
void onStatusChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in nsresult aStatus,
in wstring aMessage);
Notification that the status of a request has changed. The status message is intended to be displayed to the user (e.g., in the status bar of the browser).
[編集] パラメータ
aWebProgress- The
nsIWebProgressinstance that fired the notification.
- The
aRequest- The
nsIRequestthat has new status.
- The
aStatus- This value is not an error code. Instead, it is a numeric value that indicates the current status of the request. This interface does not define the set of possible status codes.
- NOTE: Some status values are defined by
nsITransportandnsISocketTransport.
- NOTE: Some status values are defined by
- This value is not an error code. Instead, it is a numeric value that indicates the current status of the request. This interface does not define the set of possible status codes.
aMessage- Localized text corresponding to
aStatus.
- Localized text corresponding to
[編集] onSecurityChange
void onSecurityChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in unsigned long aState);
Notification called for security progress. This method will be called on security transitions (eg HTTP -> HTTPS, HTTPS -> HTTP, FOO -> HTTPS) and after document load completion. It might also be called if an error occurs during network loading.
- NOTE: These notifications will only occur if a security package is installed.
[編集] パラメータ
aWebProgress- The
nsIWebProgressinstance that fired the notification.
- The
aRequest- The
nsIRequestthat has new security state.
- The
aState- A value composed of the Security State Flags and the Security Strength Flags listed above. Any undefined bits are reserved for future use.