B2G/gecko/browser/components/places/content/controller.js
/**
   * Looks at the data on the clipboard to see if it is paste-able.
   * Paste-able data is:
   *   - in a format that the view can receive
   * @returns true if: - clipboard data is of a TYPE_X_MOZ_PLACE_* flavor,
                       - clipboard data is of type TEXT_UNICODE and
                         is a valid URI.
   */
Looks at the data on the clipboard to see if it is paste-able.
Paste-able data is:
- in a format that the view can receive
@returns true if: - clipboard data is of a TYPE_X_MOZ_PLACE_* flavor,
clipboard data is of type TEXT_UNICODE and
is a valid URI.
Looks at the data on the clipboard to see if it is paste - able . Paste - able data is : - in a format that the view can receive @returns true if : - clipboard data is of a TYPE_X_MOZ_PLACE_ * flavor clipboard data is of type TEXT_UNICODE and is a valid URI .
function PC__isClipboardDataPasteable() {
    var flavors = PlacesControllerDragHelper.placesFlavors;
    var clipboard = this.clipboard;
    var hasPlacesData =
      clipboard.hasDataMatchingFlavors(flavors, flavors.length,
                                       Ci.nsIClipboard.kGlobalClipboard);
    if (hasPlacesData)
      return this._view.insertionPoint != null;
    var xferable = Cc["@mozilla.org/widget/transferable;1"].
                   createInstance(Ci.nsITransferable);
    xferable.init(null);
    xferable.addDataFlavor(PlacesUtils.TYPE_X_MOZ_URL);
    xferable.addDataFlavor(PlacesUtils.TYPE_UNICODE);
    clipboard.getData(xferable, Ci.nsIClipboard.kGlobalClipboard);
    try {
      var data = { }, type = { };
      xferable.getAnyTransferData(type, data, { });
      data = data.value.QueryInterface(Ci.nsISupportsString).data;
      if (type.value != PlacesUtils.TYPE_X_MOZ_URL &&
          type.value != PlacesUtils.TYPE_UNICODE)
        return false;
      var unwrappedNodes = PlacesUtils.unwrapNodes(data, type.value);
      return this._view.insertionPoint != null;
    }
    catch (e) {
      return false;
    }
  }
function PC__isClipboardDataPasteable ( ) { var flavors = PlacesControllerDragHelper . placesFlavors ; var clipboard = this . clipboard ; var hasPlacesData = clipboard . hasDataMatchingFlavors ( flavors , flavors . length , Ci . nsIClipboard . kGlobalClipboard ) ; if ( hasPlacesData ) return this . _view . insertionPoint != null ; var xferable = Cc [ "@mozilla.org/widget/transferable;1" ] . createInstance ( Ci . nsITransferable ) ; xferable . init ( null ) ; xferable . addDataFlavor ( PlacesUtils . TYPE_X_MOZ_URL ) ; xferable . addDataFlavor ( PlacesUtils . TYPE_UNICODE ) ; clipboard . getData ( xferable , Ci . nsIClipboard . kGlobalClipboard ) ; try { var data = { } , type = { } ; xferable . getAnyTransferData ( type , data , { } ) ; data = data . value . QueryInterface ( Ci . nsISupportsString ) . data ; if ( type . value != PlacesUtils . TYPE_X_MOZ_URL && type . value != PlacesUtils . TYPE_UNICODE ) return false ; var unwrappedNodes = PlacesUtils . unwrapNodes ( data , type . value ) ; return this . _view . insertionPoint != null ; } catch ( e ) { return false ; } }
Looks at the data on the clipboard to see if it is paste-able.
Looks at the data on the clipboard to see if it is paste - able .
// if the clipboard contains TYPE_X_MOZ_PLACE_* data, it is definitely // pasteable, with no need to unwrap all the nodes. // if the clipboard doesn't have TYPE_X_MOZ_PLACE_* data, we also allow // pasting of valid "text/unicode" and "text/x-moz-url" data // getAnyTransferData will throw if no data is available. // unwrapNodes() will throw if the data blob is malformed. // getAnyTransferData or unwrapNodes failed