• Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Rules
    • Help

    Do more on the web, with a fast and secure browser!

    Download Opera browser with:

    • built-in ad blocker
    • battery saver
    • free VPN
    Download Opera

    Porting Extension from Chrome : macOS Native Messaging

    Opera add-ons
    4
    15
    5942
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jerrykrinock
      jerrykrinock last edited by

      janghou, thank you very much for sharing your experience. I've been trying your various suggestions, but no success so far. Please clarify: when you got the example to work, were on running Linux or Apple macOS?

      Reply Quote 0
        1 Reply Last reply
      • jerrykrinock
        jerrykrinock last edited by

        After trying everything, I too have filed a new bug with the Opera Bug Wizard. The Opera Bug Wizard did not give me a Bug Number. All I got was this:

        DNAWIZ-3797.

        The remainder of this post is the text of my bug report.


        Summary

        I have developed browser extensions for many years, including one for Google Chrome, which uses their Native Messaging API. Even though Vivaldi does not provide any documentation, it works in Vivaldi the same as it does in Chrome, with obvious changes. I was able to install my extension and get it working in Vivaldi in less than an hour. But I cannot get it to work in Opera, and after trying every reasonable variation on the ambiguities in the documentation, I have concluded that the Native Messaging API does not work in Opera when running in mac OS (OS X). I am using Opera version 38.

        Details

        When my extension runs in Opera, the line of JavaScript code which is supposed to open a port,

        port = chrome.runtime.connectNative(hostName);
        

        executes successfully (without raising) in a try{} block, and returns what appears to be a port object, but its properties are rather empty, and my native binary does not launch, as it does when my extension runs in Google Chrome or Vivaldi.

        In looking at that documentation, I find it strange that my I am told to install my Native Messaging manifest file here:

        • /Library/Google/Chrome/NativeMessagingHosts/com.mycompany.myapplication.json

        First of all, the Google/Chrome subdirectory is owned by, you know, the wrong browser company. Second, because this path does not begin with a tilde (~) it is, eeeek, in a system-admin level directory. Because of this, I had to enter my administrator password twice in order to create the folder and put it there. Google Chrome gives you the option to put it in the user's directory instead, which I do for my Chrome extension.

        I also tried putting my Native Messaging manifest file in other reasonable locations:

        • ~/Library/Google/Chrome/NativeMessagingHosts/
        • ~/Library/Application Support/com.operasoftware.Opera/NativeMessagingHosts/
        • ~/Library/Application Support/Opera/NativeMessagingHosts/

        but none of these worked either.

        In addition to the Google/Chrome path mentioned above, there are other indications that this documentation was never thoroughly reviewed and tested, for example,

        Chrome starts the host in a separate process…

        Obviously, this should have been changed to:

        Opera starts the host in a separate process…

        To resolve this issue, Opera staff should please review the documentation and make corrections as necessary so that they can make a simple example extension which works, and post a link to it in the documentation. Maybe I'm making some silly mistake, but, you know for something like this, with multiple moving parts, a working example is essential.

        Thank you for reading.

        Jerry Krinock

        Reply Quote 0
          1 Reply Last reply
        • janghou
          janghou last edited by

          I agree, the documentation seems to be copied, and not updated. I can't imagine the path for a manifest should be a google path instead of it's own .config/opera path, although I agree that is reality, but I consider this a bug.

          What happens when you install your extensions, I can get them working using the Google Chrome path for the manifest.

          Reply Quote 0
            1 Reply Last reply
          • A Former User
            A Former User last edited by

            Hi!

            Big thanks for such a detailed investigation on this topic.

            I'm really sorry to hear this bug as well as errors in the documentation prevent you from writing great extensions for Opera.

            Now the big report is going to be reviewed by our QA team.

            Reply Quote 0
              1 Reply Last reply
            • janghou
              janghou last edited by

              @kszularz thx, maybe this can help, the bugs I filed on this issue:

              • DNA-23526
              • DNA-43909
              • DNAWIZ-3730
              Reply Quote 0
                1 Reply Last reply
              • jerrykrinock
                jerrykrinock last edited by

                @kszularz: Thank you, and please read on.

                @janghour: Sorry I didn't quite understand your first posts. As I said earlier, my extension did not launch its native messaging tool when I installed a Native Messaging manifest file in the /Library/Google/Chrome… system directory as specified in the documentation, nor when I installed it in any reasonable Opera directory. However, just now I added the ID of the extension installed in Opera to the allowed_origins in Native Messaging manifest file I have installed for Chrome,

                ~/Library/Application Support/Google/Chrome/NativeMessagingHosts

                and now, amazingly, my native messaging tool launches as expected when Opera loads my extension! My plans were to use the same native messaging tool for both Chrome and Opera, anyhow.

                So, @kszularz, although it looks ridiculous, this might work, as is. I shall update my bug at DNAWIZ-3730 after doing some more testing.

                Reply Quote 0
                  1 Reply Last reply
                • jerrykrinock
                  jerrykrinock last edited by

                  I'm not quite done yet but, so far, it looks like putting my Native Messaging manifest file in Google Chrome's Application Support folder in the user's Home directory is going to work.

                  So I've sent an update to DNAWIZ-3797 (My previous comment had wrong DNA number.)

                  Reply Quote 0
                    1 Reply Last reply
                  • shwetankdixit
                    shwetankdixit last edited by

                    Hi @jerrykrinock

                    Native messaging is supposed to work as mentioned in the documentation. I've made some minor fixes in the docs, but the point remains that right now Opera looks for the chrome directory. We're re-evaluating again on whether to change this approach or not, but so far, as you have also experienced, it works as is.

                    Reply Quote 0
                      1 Reply Last reply
                    • jerrykrinock
                      jerrykrinock last edited by

                      Thank you, @shwetankdixit. Maybe your changes have not been published yet, but in the documentation I still see this path:

                      /Library/Google/Chrome/NativeMessagingHosts/...

                      That should be corrected to:

                      ~/Library/Application Support/Google/Chrome/NativeMessagingHosts/...

                      Reply Quote 0
                        1 Reply Last reply
                      • shwetankdixit
                        shwetankdixit last edited by

                        @jerrykrinock please check again 🙂 It should be there ...

                        Reply Quote 0
                          1 Reply Last reply
                        • janghou
                          janghou last edited by

                          @shwetankdixit, I don't see anything about Linux mentioned in the documentation.

                          On my DNA-23526 bug-report I got this answer:

                          Could you try using following paths
                          /etc/chromium/native-messaging-hosts
                          or:
                          <OPERA_PROFILE_DIR>/NativeMessagingHosts
                          Profile path will be displayed on opera:about page.`
                          

                          Opera:about doesn't show anything about a google-chrome path, but mentioned path worked at that moment. Please don't blame me for filing more bug reports when it stopped working. The path really changed between versions, without documentation or rationale.

                          And it feels wrong and risky:
                          If Google-Chrome isn't installed, the google-chrome path is a path any program can create/write to.

                          And when you have Chrome installed and decide to drop it because you prefer Opera, and remove Chrome and all of it's settings, suddenly Opera fails. Doesn't make sense to me.

                          Reply Quote 0
                            1 Reply Last reply
                          • First post
                            Last post

                          Computer browsers

                          • Opera for Windows
                          • Opera for Mac
                          • Opera for Linux
                          • Opera beta version
                          • Opera USB

                          Mobile browsers

                          • Opera for Android
                          • Opera Mini
                          • Opera Touch
                          • Opera for basic phones

                          • Add-ons
                          • Opera account
                          • Wallpapers
                          • Opera Ads

                          • Help & support
                          • Opera blogs
                          • Opera forums
                          • Dev.Opera

                          • Security
                          • Privacy
                          • Cookies Policy
                          • EULA
                          • Terms of Service

                          • About Opera
                          • Press info
                          • Jobs
                          • Investors
                          • Become a partner
                          • Contact us

                          Follow Opera

                          • Opera - Facebook
                          • Opera - Twitter
                          • Opera - YouTube
                          • Opera - LinkedIn
                          • Opera - Instagram

                          © Opera Software 1995-