nsISupports
Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)Implemented by: "@mozilla.org/browser/annotation-service;1"
. To use this service, use:
var annotationService = Components.classes["@mozilla.org/browser/annotation-service;1"] .getService(Components.interfaces.nsIAnnotationService);
Note: The annotation service is not thread-safe. You should only use it from the main thread.
void setPageAnnotation(in |
void setItemAnnotation(in long long aItemId, in AUTF8String aName, in |
void setPageAnnotationString(in |
boolean setItemAnnotationString(in long long aItemId, in AUTF8String aName, in AString aValue, in long aFlags, in unsigned short aExpiration); |
void setPageAnnotationInt32(in |
void setItemAnnotationInt32(in long long aItemId, in AUTF8String aName, in long aValue, in long aFlags, in unsigned short aExpiration); |
void setPageAnnotationInt64(in |
void setItemAnnotationInt64(in long long aItemId, in AUTF8String aName, in long long aValue, in long aFlags, in unsigned short aExpiration); |
void setPageAnnotationDouble(in |
void setItemAnnotationDouble(in long long aItemId, in AUTF8String aName, in double aValue, in long aFlags, in unsigned short aExpiration); |
void setPageAnnotationBinary(in |
void setItemAnnotationBinary(in long long aItemId, in AUTF8String aName,[const, array, size_is(aDataLen)] in octet aData, in unsigned long aDataLen, in AUTF8String aMimeType, in long aFlags, in unsigned short aExpiration); |
|
|
AString getPageAnnotationString(in |
AString getItemAnnotationString(in long long aItemId, in AUTF8String aName); |
long getPageAnnotationInt32(in |
long getItemAnnotationInt32(in long long aItemId, in AUTF8String aName); |
long long getPageAnnotationInt64(in |
long long getItemAnnotationInt64(in long long aItemId, in AUTF8String aName); |
double getPageAnnotationDouble(in |
double getItemAnnotationDouble(in long long aItemId, in AUTF8String aName); |
void getPageAnnotationBinary(in |
void getItemAnnotationBinary(in long long aItemId, in AUTF8String aName,[array, size_is(aDataLen)] out octet aData, out unsigned long aDataLen, out AUTF8String aMimeType); |
void getPageAnnotationInfo(in |
void getItemAnnotationInfo(in long long aItemId, in AUTF8String aName, out long aFlags, out unsigned short aExpiration, out AUTF8String aMimeType, out unsigned short aType); |
PRUint16 getPageAnnotationType(in |
PRUint16 getItemAnnotationType(in long long aItemId, in AUTF8String aName); |
void getPagesWithAnnotation(in AUTF8String name, [optional] out unsigned long resultCount, [retval, array, size_is(resultCount)] out |
void getItemsWithAnnotation(in AUTF8String name, [optional] out unsigned long resultCount, [retval, array, size_is(resultCount)] out long long results); |
void getPageAnnotationNames(in [optional] out unsigned long count, [retval, array, size_is(count)] out |
void getItemAnnotationNames(in long long aItemId, [optional] out unsigned long count, [retval, array, size_is(count)] out |
boolean pageHasAnnotation(in |
boolean itemHasAnnotation(in long long aItemId, in AUTF8String aName); |
void removePageAnnotation(in |
void removeItemAnnotation(in long long aItemId, in AUTF8String aName); |
void removePageAnnotations(in |
void removeItemAnnotations(in long long aItemId); |
void copyPageAnnotations(in |
void copyItemAnnotations(in long long aSourceItemId, in long long aDestItemId, in boolean aOverwriteDest); |
void addObserver(in |
void removeObserver(in |
|
Constant | Value | Description |
EXPIRE_SESSION |
0 | For temporary data that can be discarded when the user exits. Removed at application exit. |
EXPIRE_WEEKS |
2 | For general page settings, things the user is interested in seeing if they come back to this page some time in the near future. Removed at 30 days. |
EXPIRE_MONTHS |
3 | Something that the user will be interested in seeing in their history like favicons . If they haven't visited a page in a couple of months, they probably aren't interested in many other annotations, the positions of things, or other stuff you create, so put that in the weeks policy. Removed at 180 days. |
EXPIRE_NEVER |
4 | For data that should never expire as long as the URI is in the database. |
EXPIRE_WITH_HISTORY |
5 | For annotations that only live as long as the URI is in history (For example, has > 0 visits). This is only valid for page annotations. |
EXPIRE_DAYS |
6 | For short-lived temporary data that you still want to outlast a session. Removed at 7 days. |
TYPE_INT32 |
1 | INT32 type constant. |
TYPE_DOUBLE |
2 | DOUBLE type constant. |
TYPE_STRING |
3 | STRING type constant. |
TYPE_BINARY |
4 | BINARY type constant. |
TYPE_INT64 |
5 | INT64 type constant. |
EXPIRE_NEVER
in bug 319455.This method sets an annotation for given URI, overwriting any previous annotation with the same URL/name. IT IS YOUR JOB TO NAMESPACE YOUR ANNOTATION NAMES. Use the form "namespace/value"
, so your name would be like "bills_extension/page_state"
or "history/thumbnail"
.
Do not use characters that are not valid in URLs such as spaces, ":"
, commas, or most other symbols. You should stick to ASCII letters and numbers plus "_"
, "-"
, and "/"
.
The annotation "favicon" is special. Favicons are stored in the favicon service, but are special cased in the protocol handler so they look like annotations. Do not set favicons using this service, it will not work.
Binary annotations should be set using setItemAnnotationBinary()
or setPageAnnotationBinary()
. For other types, only C++ consumers may use the type-specific methods.
void setPageAnnotation( in nsIURI aURI, in AUTF8String aName, in nsIVariant aValue, in long aFlags, in unsigned short aExpiration );
aURI
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.Note: ALL PAGE ANNOTATIONS WILL GET DELETED WHEN THE PAGE IS REMOVED FROM HISTORY IF THE PAGE IS NOT BOOKMARKED.
This means that if you create an annotation on an unvisited URI, it will get deleted when the browser shuts down. Otherwise, URIs can exist in history as annotations but the user has no way of knowing it, potentially violating their privacy expectations about actions such as Clear history. If there is an important annotation that the user or extension wants to keep, you should add a bookmark for the page and use an EXPIRE_NEVER annotation. This will ensure the annotation exists until the item is removed by the user.
This method sets an annotation for given item, overwriting any previous annotation with the same URL/name. IT IS YOUR JOB TO NAMESPACE YOUR ANNOTATION NAMES. Use the form "namespace/value"
, so your name would be like "bills_extension/page_state"
or "history/thumbnail"
.
Do not use characters that are not valid in URLs such as spaces, ":"
, commas, or most other symbols. You should stick to ASCII letters and numbers plus "_"
, "-"
, and "/"
.
The annotation "favicon" is special. Favicons are stored in the favicon service, but are special cased in the protocol handler so they look like annotations. Do not set favicons using this service, it will not work.
Binary annotations should be set using setItemAnnotationBinary()
or setPageAnnotationBinary()
. For other types, only C++ consumers may use the type-specific methods.
void setItemAnnotation( in long long aItemId, in AUTF8String aName, in nsIVariant aValue, in long aFlags, in unsigned short aExpiration );
aItemID
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.Note: ALL ITEM ANNOTATIONS WILL GET DELETED WHEN THE BOOKMARK IS REMOVED.
This method sets an annotation for given URI by taking a String
as input value, overwriting any previous annotation with the same URL/name. IT IS YOUR JOB TO NAMESPACE YOUR ANNOTATION NAMES. Use the form "namespace/value"
, so your name would be like "bills_extension/page_state"
or "history/thumbnail"
.
Do not use characters that are not valid in URLs such as spaces, ":"
, commas, or most other symbols. You should stick to ASCII letters and numbers plus "_"
, "-"
, and "/"
.
The annotation "favicon" is special. Favicons are stored in the favicon service, but are special cased in the protocol handler so they look like annotations. Do not set favicons using this service, it will not work.
Binary annotations should be set using setItemAnnotationBinary()
or setPageAnnotationBinary()
. For other types, only C++ consumers may use the type-specific methods.
void setPageAnnotationString( in nsIURI aURI, in AUTF8String aName, in AString aValue, in long aFlags, in unsigned short aExpiration );
aURI
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.Note: ALL PAGE ANNOTATIONS WILL GET DELETED WHEN THE PAGE IS REMOVED FROM HISTORY IF THE PAGE IS NOT BOOKMARKED.
This means that if you create an annotation on an unvisited URI, it will get deleted when the browser shuts down. Otherwise, URIs can exist in history as annotations but the user has no way of knowing it, potentially violating their privacy expectations about actions such as Clear history. If there is an important annotation that the user or extension wants to keep, you should add a bookmark for the page and use an EXPIRE_NEVER annotation. This will ensure the annotation exists until the item is removed by the user.
This method sets an annotation for given item by taking a String
as input value, overwriting any previous annotation with the same URL/name. IT IS YOUR JOB TO NAMESPACE YOUR ANNOTATION NAMES. Use the form "namespace/value"
, so your name would be like "bills_extension/page_state"
or "history/thumbnail"
.
Do not use characters that are not valid in URLs such as spaces, ":"
, commas, or most other symbols. You should stick to ASCII letters and numbers plus "_"
, "-"
, and "/"
.
The annotation "favicon" is special. Favicons are stored in the favicon service, but are special cased in the protocol handler so they look like annotations. Do not set favicons using this service, it will not work.
Binary annotations should be set using setItemAnnotationBinary()
. For other types, only C++ consumers may use the type-specific methods.
void setPageAnnotation( in long long aItemId, in AUTF8String aName, in AString aValue, in long aFlags, in unsigned short aExpiration );
aItemID
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.Note: ALL ITEM ANNOTATIONS WILL GET DELETED WHEN THE BOOKMARK IS REMOVED.
This method sets an annotation for given URI, just like setPageAnnotationString()
, but takes an Int32
as an input.
void setPageAnnotationInt32( in nsIURI aURI, in AUTF8String aName, in long aValue, in long aFlags, in unsigned short aExpiration );
aURI
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.This method sets an annotation for given item, just like setItemAnnotationString()
, but takes an Int32
as an input.
void setItemAnnotationInt32( in long long aItemId, in AUTF8String aName, in long aValue, in long aFlags, in unsigned short aExpiration );
aItemId
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.This method sets an annotation for given URI, just like setPageAnnotationString()
, but takes an Int64
as an input.
void setPageAnnotationInt64( in nsIURI aURI, in AUTF8String aName, in long long aValue, in long aFlags, in unsigned short aExpiration );
aURI
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.This method sets an annotation for given item, just like setItemAnnotationString()
, but takes an Int64
as an input.
void setItemAnnotationInt64( in long long aItemId, in AUTF8String aName, in long long aValue, in long aFlags, in unsigned short aExpiration );
aItemId
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.This method sets an annotation for given URI, just like setPageAnnotationString()
, but takes an Double
as an input.
void setPageAnnotationDouble( in nsIURI aURI, in AUTF8String aName, in double aValue, in long aFlags, in unsigned short aExpiration );
aURI
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.This method sets an annotation for given item, just like setItemAnnotationString()
, but takes an Double
as an input.
void setItemAnnotationDouble( in long long aItemId, in AUTF8String aName, in double aValue, in long aFlags, in unsigned short aExpiration );
aItemId
aName
aValue
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.This method sets an annotation for given URI, just like setPageAnnotationString()
, but takes Binary
data as an input. You MUST supply a valid MIME
type.
void setPageAnnotationBinary( in nsIURI aURI, in AUTF8String aName, [const,array,size_is(aDataLen)] in octet aData, in unsigned long aDataLen, in AUTF8String aMimeType, in long aFlags, in unsigned short aExpiration );
aURI
aName
aData
aDataLen
aMimeType
MIME
type of the data to store. MUST be supplied.aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.This method sets an annotation for given item, just like setItemAnnotationString()
, but takes Binary
data as an input. You MUST supply a valid MIME
type.
void setItemAnnotationBinary( in long long aItemId, in AUTF8String aName, [const,array,size_is(aDataLen)] in octet aData, in unsigned long aDataLen, in AUTF8String aMimeType, in long aFlags, in unsigned short aExpiration );
aItemId
aName
aData
aDataLen
aMimeType
MIME
type of the data to store. MUST be supplied.aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.This method retrieves the value of a given URI annotation. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
nsIVariant getPageAnnotation( in nsIURI aURI, in AUTF8String aName );
aURI
aName
Returns a page annotation.
This method retrieves the value of a given item annotation. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
nsIVariant getItemAnnotation( in long long aItemId, in AUTF8String aName );
aItemId
aName
Returns an item annotation.
This method retrieves the value of a given URI annotation in String
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
AString getPageAnnotationString( in nsIURI aURI, in AUTF8String aName );
aURI
aName
Returns a String
value page annotation.
This method retrieves the value of a given item annotation in String
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
AString getItemAnnotationString( in long long aItemId, in AUTF8String aName );
aItemId
aName
Returns a String
value item annotation.
This method retrieves the value of a given URI annotation in a Int32
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
long getPageAnnotationInt32( in nsIURI aURI, in AUTF8String aName );
aURI
aName
Returns an Int32
value page annotation.
This method retrieves the value of a given item annotation in a Int32
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
long getItemAnnotationInt32( in long long aItemId, in AUTF8String aName );
aItemId
aName
Returns an Int32
value item annotation.
This method retrieves the value of a given URI annotation in a Int64
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
long long getPageAnnotationInt64( in nsIURI aURI, in AUTF8String aName );
aURI
aName
Returns an Int64
value page annotation.
This method retrieves the value of a given item annotation in a Int64
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
long long getItemAnnotationInt64( in long long aItemId, in AUTF8String aName );
aItemId
aName
Returns an Int64
value item annotation.
This method retrieves the value of a given URI annotation in Double
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
double getPageAnnotationDouble( in nsIURI aURI, in AUTF8String aName );
aURI
aName
Returns a Double
value page annotation.
This method retrieves the value of a given item annotation in Double
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
double getItemAnnotationDouble( in long long aItemId, in AUTF8String aName );
aItemId
aName
Returns a Double
value item annotation.
This method retrieves the value of a given URI annotation in a Binary
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type. This also returns the MIME
type.
void getPageAnnotationBinary( in nsIURI aURI, in AUTF8String aName, [array,size_is(aDataLen)] out octet aData, out unsigned long aDataLen, out AUTF8String aMimeType );
aURI
aName
aData
aDataLen
aMimeType
MIME
type of the data to be retrieved.Returns a Binary
value and a MIME
type page annotation.
This method retrieves the value of a given item annotation in a Binary
format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary()
or getItemAnnotationBinary()
should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type. This also returns the MIME
type.
void getItemAnnotationBinary( in long long aItemId, in AUTF8String aName, [array,size_is(aDataLen)] out octet aData, out unsigned long aDataLen, out AUTF8String aMimeType );
aItemId
aName
aData
aDataLen
aMimeType
MIME
type of the data to be retrieved.Returns a Binary
value and a MIME
type item annotation.
This method retrieves info about an existing annotation for the given URI.
void getPageAnnotationInfo( in nsIURI aURI, in AUTF8String aName, out PRInt32 aFlags, out unsigned short aExpiration, out AUTF8String aMimeType, out unsigned short aType );
aURI
aName
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.aMimeType
MIME
type of the data to be retrieved. Default to "0"
if value was not binary data.aType
TYPE_*
constansts defined above.This method retrieves info about an existing annotation for the given item.
void getItemAnnotationInfo( in long long aItemId, in AUTF8String aName, out long aFlags, out unsigned short aExpiration, out AUTF8String aMimeType, out unsigned short aType );
aItemId
aName
aFlags
"0"
for now, some flags will be defined in the future.aExpiration
EXPIRE_*
constant value defined above.aMimeType
MIME
type of the data to be retrieved. Default to "0"
if value was not binary data.aType
TYPE_*
constansts defined above.This method retrieves the type of an existing annotation. Use getAnnotationInfo()
method, if you need this along with the mime-type etc. It throwns an exception if the annotation is not set.
PRUint16 getPageAnnotationType( in nsIURI aURI, in AUTF8String aName );
aURI
aName
Returns one of the TYPE_*
constants defined above.
This method retrieves the type of an existing annotation. Use getAnnotationInfo()
method, if you need this along with the mime-type etc. It throwns an exception if the annotation is not set.
PRUint16 getPageAnnotationType( in long long aItemId, in AUTF8String aName );
aURI
aName
Returns one of the TYPE_*
constants defined above.
This method returns a list of all URIs having a given annotation.
void getPagesWithAnnotation( in AUTF8String name, [optional] out unsigned long resultCount, [retval, array, size_is(resultCount)] out nsIURI results );
name
resultCount
Optionalresults
This method returns a list of all items having a given annotation.
void getItemsWithAnnotation( in AUTF8String name, [optional] out unsigned long resultCount, [retval, array, size_is(resultCount)] out long long results );
name
resultCount
Optionalresults
This method retrieves the names of all annotations for the given URI.
void getPageAnnotationNames( in nsIURI aURI, [optional] out unsigned long count, [retval, array, size_is(count)] out nsIVariant result );
aURI
count
Optionalresult
This method retrieves the names of all annotations for the given item.
void getItemAnnotationNames( in long long aItemId, [optional] out unsigned long count, [retval, array, size_is(count)] out nsIVariant result );
aItemId
count
Optionalresult
This method tests for annotation existance for given URI.
boolean pageHasAnnotation( in nsIURI aURI, in AUTF8String aName );
aURI
aName
Returns true
, if an annotation exists for given URI, otherwise returns false
.
This method tests for annotation existance for given item.
boolean itemHasAnnotation( in long long aItemId, in AUTF8String aName );
aItemId
aName
Returns true
, if an annotation exists for given item, otherwise returns false
.
This method removes a specific annotation for given URI. Succeeds even if the annotation is not found.
void removePageAnnotation( in nsIURI aURI, in AUTF8String aName );
aURI
aName
This method removes a specific annotation for given item. Succeeds even if the annotation is not found.
void removeItemAnnotation( in long long aItemId, in AUTF8String aName );
aItemId
aName
This method removes all annotations for the given URI. We may want some other similar functions to get annotations with given flags (once we have flags defined).
void removePageAnnotations( in nsIURI aURI );
aURI
This method removes all annotations for the given item. We may want some other similar functions to get annotations with given flags (once we have flags defined).
void removeItemAnnotations( in long long aItemId );
aItemId
This method copies all annotations from the source to the destination URI. If the destination already has an annotation with the same name as one on the source, it will be overwritten if aOverwriteDest
is set. Otherwise, the destination URIs will be preferred.
All the source annotations will stay as-is. If you don't want them any more, use removePageAnnotations()
on that URI.
void copyPageAnnotations( in nsIURI aSourceURI, in nsIURI aDestURI, in boolean aOverwriteDest );
aSourceItemId
aDestItemId
aOverwriteDest
true
, or else set it to false
.This method copies all annotations from the source to the destination item. If the destination already has an annotation with the same name as one on the source, it will be overwritten if aOverwriteDest
is set. Otherwise, the destination URIs will be preferred.
All the source annotations will stay as-is. If you don't want them any more, use removePageAnnotations()
on that URI.
void copyItemAnnotations( in long long aSourceItemId, in long long aDestItemId, in boolean aOverwriteDest );
aSourceItemId
aDestItemId
aOverwriteDest
true
or else false
.This method adds an annotation observer. The annotation service will keep an owning reference to the observer object.
void addObserver( in nsIAnnotationObserver aObserver );
aObserver
This method removes an annotaton observer previously registered by addObserver()
method.
void removeObserver( in nsIAnnotationObserver aObserver );
aObserver
This method returns a URI that can be used to access the given binary annotation. This method does NOT check that the annotation exists. Also, note that you can only load URIs for annotations that have have a valid MIME
type set by setPageAnnotationBinary()
or setItemAnnotationBinary()
methods. No non-URI valid chars in name, especially colon, which will mess up parsing.
nsIURI getAnnotationURI( in nsIURI aURI, in AUTF8String aName );
aURI
aName
Returns a URI that can be used to access the given binary annotation.