]> khamidou — GitHub mirrors - electron.git/commitdiff
linux: Don't use clipboard module in renderer process
authorCheng Zhao <zcbenz@gmail.com>
Tue, 9 Jun 2015 10:25:24 +0000 (18:25 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 10 Jun 2015 03:57:28 +0000 (11:57 +0800)
atom/common/api/lib/clipboard.coffee

index 44dadb8cd9ee52810897bf8d1019c77b80fef064..9a7a6abfa47fb17168aa626886b89514dbf3f592 100644 (file)
@@ -1,12 +1,17 @@
-binding = process.atomBinding 'clipboard'
-module.exports =
-  availableFormats: (type='standard') -> binding._availableFormats type
-  has: (format, type='standard') -> binding._has format, type
-  read: (format, type='standard') -> binding._read format, type
-  readText: (type='standard') -> binding._readText type
-  writeText: (text, type='standard') -> binding._writeText text, type
-  readHtml: (type='standard') -> binding._readHtml type
-  writeHtml: (markup, type='standard') -> binding._writeHtml markup, type
-  readImage: (type='standard') -> binding._readImage type
-  writeImage: (image, type='standard') -> binding._writeImage image, type
-  clear: (type='standard') -> binding._clear type
+if process.platform is 'linux' and process.type is 'renderer'
+  # On Linux we could not access clipboard in renderer process.
+  module.exports = require('remote').require 'clipboard'
+else
+  binding = process.atomBinding 'clipboard'
+
+  module.exports =
+    availableFormats: (type='standard') -> binding._availableFormats type
+    has: (format, type='standard') -> binding._has format, type
+    read: (format, type='standard') -> binding._read format, type
+    readText: (type='standard') -> binding._readText type
+    writeText: (text, type='standard') -> binding._writeText text, type
+    readHtml: (type='standard') -> binding._readHtml type
+    writeHtml: (markup, type='standard') -> binding._writeHtml markup, type
+    readImage: (type='standard') -> binding._readImage type
+    writeImage: (image, type='standard') -> binding._writeImage image, type
+    clear: (type='standard') -> binding._clear type