mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Add the "atom://" custom protocol handler.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
AtomWindow = require 'atom-window'
|
||||
ApplicationMenu = require 'application-menu'
|
||||
AtomProtocolHandler = require 'atom-protocol-handler'
|
||||
BrowserWindow = require 'browser-window'
|
||||
Menu = require 'menu'
|
||||
autoUpdater = require 'auto-updater'
|
||||
@@ -45,6 +46,7 @@ class AtomApplication
|
||||
|
||||
windows: null
|
||||
applicationMenu: null
|
||||
atomProtocolHandler: null
|
||||
resourcePath: null
|
||||
version: null
|
||||
|
||||
@@ -56,6 +58,7 @@ class AtomApplication
|
||||
@windows = []
|
||||
|
||||
@applicationMenu = new ApplicationMenu(@version, devMode)
|
||||
@atomProtocolHandler = new AtomProtocolHandler(@resourcePath)
|
||||
|
||||
@listenForArgumentsFromNewProcess()
|
||||
@setupJavaScriptArguments()
|
||||
|
||||
18
src/atom-protocol-handler.coffee
Normal file
18
src/atom-protocol-handler.coffee
Normal file
@@ -0,0 +1,18 @@
|
||||
path = require 'path'
|
||||
protocol = require 'protocol'
|
||||
|
||||
# Private: Handles requests with 'atom' protocol.
|
||||
#
|
||||
# It's created by {AtomApplication} upon instantiation, and is used to create a
|
||||
# custom resource loader by adding the 'atom' custom protocol.
|
||||
module.exports =
|
||||
class AtomProtocolHandler
|
||||
constructor: (@resourcePath) ->
|
||||
@registerAtomProtocol()
|
||||
|
||||
# Private: Creates the 'atom' custom protocol handler.
|
||||
registerAtomProtocol: ->
|
||||
protocol.registerProtocol 'atom', (request) =>
|
||||
relativePath = path.normalize(request.url.substr(7))
|
||||
filePath = path.join(@resourcePath, 'node_modules', relativePath)
|
||||
return new protocol.RequestFileJob(filePath)
|
||||
Reference in New Issue
Block a user