       window.localStorage.removeItem key
     catch e
       callback "Unable to load copied file"
+
+  haveTempFile: ->
+    try
+      key = "cfm-tempfile"
+      return !!(JSON.parse window.localStorage.getItem key)
+    catch e
+      return false
+
+  saveTempFile: (callback) ->
+    @_event 'getContent', { shared: @_sharedMetadata() }, (stringContent) =>
+      currentContent = @_createOrUpdateCurrentContent stringContent
+      try
+        key = "cfm-tempfile"
+        value = JSON.stringify
+          stringContent: stringContent
+        window.localStorage.setItem key, value
+        metadata = new CloudMetadata
+          name: currentContent.name
+          type: CloudMetadata.File
+        @_fileChanged 'savedFile', currentContent, metadata, {saved: true}, ""
+        callback? null
+      catch e
+        callback "Unable to temporarily save copied file"
+
+  openAndClearTempFile: ->
+    @_event 'willOpenFile', {op: "openAndClearTempFile"}
+    try
+      key = "cfm-tempfile"
+      tempFile = JSON.parse window.localStorage.getItem key
+      content = cloudContentFactory.createEnvelopedCloudContent tempFile.stringContent
+      metadata = new CloudMetadata
+        name: tempFile.name
+        type: CloudMetadata.File
+      @_fileOpened content, metadata, {dirty: true, openedContent: content.clone()}
+      window.localStorage.removeItem key
+    catch e
+      callback "Unable to load temp file"
 
   _sharedMetadata: ->
     @state.currentContent?.getSharedMetadata() or {}

      if not @state.dirty
        callback newLangCode
      else
        @confirm tr('~CONFIRM.CHANGE_LANGUAGE'), -> callback newLangCode

  showBlockingModal: (modalProps) ->
    @_ui.showBlockingModal modalProps

    else if hashParams.newInFolderParams
      [providerName, folder] = hashParams.newInFolderParams.split ':'
      @createNewInFolder providerName, folder
    else if @haveTempFile()
      @openAndClearTempFile()
    else
      # give providers a chance to process url params
      for provider in @state.availableProviders
