@@ -154,99 +154,6 @@ if(fs.existsSync(__dirname + path.sep + ".." + path.sep + "OpenBazaar-Server" +
154154// be closed automatically when the JavaScript object is GCed.
155155var mainWindow = null ;
156156
157- if ( process . platform === "win32" ) {
158- initWin32 ( ) ;
159- }
160-
161- function initWin32 ( ) {
162- var Registry = require ( 'winreg' ) ;
163-
164- var iconPath = path . join ( process . env . LOCALAPPDATA , "app.ico" ) ;
165- registerProtocolHandlerWin32 ( 'ob' , 'URL:OpenBazaar URL' , iconPath , process . execPath ) ;
166-
167- /**
168- * To add a protocol handler, the following keys must be added to the Windows registry:
169- *
170- * HKEY_CLASSES_ROOT
171- * $PROTOCOL
172- * (Default) = "$NAME"
173- * URL Protocol = ""
174- * DefaultIcon
175- * (Default) = "$ICON"
176- * shell
177- * open
178- * command
179- * (Default) = "$COMMAND" "%1"
180- *
181- * Source: https://msdn.microsoft.com/en-us/library/aa767914.aspx
182- *
183- * However, the "HKEY_CLASSES_ROOT" key can only be written by the Administrator user.
184- * So, we instead write to "HKEY_CURRENT_USER\Software\Classes", which is inherited by
185- * "HKEY_CLASSES_ROOT" anyway, and can be written by unprivileged users.
186- */
187-
188- function registerProtocolHandlerWin32 ( protocol , name , icon , command ) {
189- var protocolKey = new Registry ( {
190- hive : Registry . HKCU , // HKEY_CURRENT_USER
191- key : '\\Software\\Classes\\' + protocol
192- } )
193-
194- setProtocol ( )
195-
196- function setProtocol ( err ) {
197- if ( err ) log . error ( err . message )
198- console . log ( protocolKey ) ;
199- protocolKey . set ( '' , Registry . REG_SZ , name , setURLProtocol )
200- }
201-
202- function setURLProtocol ( err ) {
203- if ( err ) log . error ( err . message )
204- console . log ( protocolKey ) ;
205- protocolKey . set ( 'URL Protocol' , Registry . REG_SZ , '' , setIcon )
206- }
207-
208- function setIcon ( err ) {
209- if ( err ) log . error ( err . message )
210-
211- var iconKey = new Registry ( {
212- hive : Registry . HKCU ,
213- key : '\\Software\\Classes\\' + protocol + '\\DefaultIcon'
214- } )
215- iconKey . set ( '' , Registry . REG_SZ , icon , setCommand )
216- }
217-
218- function setCommand ( err ) {
219- if ( err ) log . error ( err . message )
220-
221- var commandKey = new Registry ( {
222- hive : Registry . HKCU ,
223- key : '\\Software\\Classes\\' + protocol + '\\shell\\open\\command'
224- } )
225- commandKey . set ( '' , Registry . REG_SZ , '"' + command + '" "%1"' , done )
226- }
227-
228- function done ( err ) {
229- if ( err ) log . error ( err . message )
230- }
231- }
232- }
233-
234- var iShouldQuit = app . makeSingleInstance ( function ( commandLine , workingDirectory ) {
235- var uri = "" ;
236- if ( commandLine . length == 2 ) {
237- uri = commandLine [ 1 ] ;
238- openURL ( uri ) ;
239- }
240-
241- if ( mainWindow ) {
242- if ( mainWindow . isMinimized ( ) ) mainWindow . restore ( ) ;
243- mainWindow . show ( ) ;
244- mainWindow . focus ( ) ;
245- }
246- return true ;
247- } ) ;
248- if ( iShouldQuit ) { app . quit ( ) ; return ; }
249-
250157// Quit when all windows are closed.
251158app . on ( 'window-all-closed' , function ( ) {
252159 // On OS X it is common for applications and their menu bar
@@ -491,7 +398,7 @@ ipcMain.on('set-badge', function(event, text) {
491398 app . dock . setBadge ( String ( text ) ) ;
492399} ) ;
493400
494- function openURL ( uri ) {
401+ app . on ( 'open-url' , function ( event , uri ) {
495402 var split_uri = uri . split ( '://' ) ;
496403 uri = split_uri [ 1 ] ;
497404
@@ -503,9 +410,5 @@ function openURL(uri) {
503410 mainWindow . webContents . send ( 'external-route' , uri ) ;
504411 }
505412
506- }
507-
508- app . on ( 'open-url' , function ( event , uri ) {
509- openURL ( uri ) ;
510413 event . preventDefault ( ) ;
511- } ) ;
414+ } ) ;
0 commit comments