-
Notifications
You must be signed in to change notification settings - Fork 109
Add quick documentation about chrome extensions #417
Conversation
A basic example of using extensions
removed console logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great contribution. That is an awesome feature of Muon but I have no idea how to use it.
docs/tutorial/extensions.md
Outdated
|
||
In the case of the following extension.js file, shadowcodex is using the `chrome.ipcRenderer` to call the functions via a lifecycle in the renderer thread. For example a simple vuejs app is shown: | ||
|
||
> Note: In order to use `chrome.ipcRenderer` your render file must be loaded with `chrome://brave/` and this one in particular is loaded like `mainWindow.loadURL('chrome://brave/' + path.join(__dirname, '../client/index.html'))` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I try to use chrome://brave
it won't load the extension. Otherwise, when I load directly a web page it works. Do you know what is the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extensions should be loaded via the chrome-extension://
url which can be done in a new window or in a webview which requires chrome://brave/
docs/tutorial/extensions.md
Outdated
|
||
> Note: In order to use `chrome.ipcRenderer` your render file must be loaded with `chrome://brave/` and this one in particular is loaded like `mainWindow.loadURL('chrome://brave/' + path.join(__dirname, '../client/index.html'))` | ||
|
||
### Vuejs renderer lifecycle hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide this live example, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not public yet, but soon
|
||
ipcMain.on('halo', (event, arg) => { | ||
if(!hapiRegistered){ | ||
session.defaultSession.extensions.load(path.join(__dirname,`extensions/hapi`), {}, 'unpacked'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another question. Does that trigger the extension popup? Do you know how to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it doesn't you have to call it via chrome-extension://
Added part to show how to call up an extension resource. |
This is good work, docs are by far the most missing part of Muon imo (from app dev perspective). |
So after a bit of toying with the following fix:
It also exposes the remote API which is basically a gold mine right?
^executing processes from the Chrome debugging tool.. |
That will be retired so use ipcRenderer to send messages to main thread and
have main thread do the logic. Muon team will be removing the chrome.remote
references.
…On Tue, Feb 6, 2018 at 7:28 PM Kewde ***@***.***> wrote:
So after a bit of toying with the following fix:
mainWindow.loadURL('chrome://brave/' + __dirname + '/index.html');
It also exposes the remote API which is basically a gold mine right?
$ const proc = chrome.remote.require('child_process')
undefined
$ const ls = proc.exec('ls')
undefined
$ ls.pid
9233
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#417 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABSR1c57ZKj5L912xDNlP4LMQNrr6RYkks5tSPxMgaJpZM4RP5ck>
.
|
@shadowcodex is their an issue that's keeping track of the .remote() removal? |
This doesn't work very well across operating systems. On linux it will result in the following:
The second double slashes (after keyword 'brave'), they are misinterpreted as the double slash for a protocol.
Basically, it breaks the whole application. Removing the / creates an issue on Windows, so we should make use of the path.join() or url.format() functions. So if I can suggest a minor change to the way you load the URL in the BrowserWindow:
It becomes
in a consistent way. |
@kewde yeah that's a good point. You could also just do:
|
I'm hoping when I get time I'll create a full demo on extension lifecycle management and leave it up on my github. I have some more refined ways of handling extensions and could strip it down to a bare minimum for people to use. |
@bridiver what do I need to do to get this PR moved forward? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
Just added a quick documentation to the docs/tutorial folder for using extensions directly in muon.
It introduces how to get access to
chrome.ipcRenderer
, and the importantextensions.
api hooks.It also shows a sample of how to load an extension via interaction from the renderer thread.