Maybe related to $wnd, but here we are basically shooting in the dark. You
should debug your code and tell us where it behaves unexpectedly otherwise
we cannot help much...

On Wed, May 3, 2017 at 12:57 PM, TimOnGmail <[email protected]> wrote:

> Ok... here's the client app side - I haven't tried running this as-is,
> since it was culled from a much bigger piece of code.  But this is the gist
> of it:
>
> package com.example;
>
> public class ChromeAPIExample {
>
>     private static final String CHROME_APP_ID = "..."; // Replace with
> actual Chrome app id
>
>     public ChromeAPIExample() {
>         initChromeListener();
>     }
>
>     private native void initChromeListener() /*-{
>
>         try {
>
>             $wnd.example = new Object();
>
>             $wnd.example.isChrome = function() {
>
>                 var isChromeBrowser = false;
>
>                 try {
>                     isChromeBrowser = (typeof chrome !== 'undefined');
>                 } catch (e) {
>                     console.log('isChrome: cannot determine if using
> chrome: ' + e);
>                 }
>
>                 return isChromeBrowser;
>             };
>
>             if (!$wnd.example.isChrome()) {
>                 console.log('initChromeListener: not using chrome;
> returning');
>                 return;
>             }
>
>             if ($wnd.example.chromePort && ($wnd.example.chromePort !=
> null)) {
>                 console.log"initChromeListener: chromePort still exists,
> returning");
>                 return;
>             }
>
>             console.log('initChromeListener: this is chrome');
>
>             var thisInstance = this;
>             var chromeAppId = @com.example.ChromeAPIExample:
> :CHROME_APP_ID;
>
>             try {
>
>                 // Check if the app is installed and enabled by opening a
> messaging port
>                 var port = chrome.runtime.connect(chromeAppId);
>
>                 if (port) {
>
>                     $wnd.example.chromePort = port;
>
>                     console.log('initChromeListener: got port: ' + port);
>
>                     port.onMessage.addListener(function(msg) {
>                         console.log('chrome listener: msg: ' + msg);
>
>                     });
>
>                 }
>
>             } catch (e) {
>                 console.log('initChromeListener: Inner Error: ' + e);
>             }
>         } catch (e2) {
>             alert('initChromeListener: Outer Error: ' + e2);
>             }
>
>     }-*/;
>
> }
>
>
>
> ... and here's a snippet of code from the Chrome app.  If the above code
> was run in GWT 2.6, the Chrome app would log the connection attempt from
> the app.  In GWT 2.8, we get a port object back from the Chrome connection
> attempt, but the Chrome app doesn't see the connection attempt:
>
> ...
>
> initialize();
>
> function initialize() {
>     chrome.runtime.onConnectExternal.addListener(onConnectExternal);
> }
>
> function onConnectExternal(port) {
>
>   logMsg('onConnectExternal: port=' + port);
>
>     port.onDisconnect.addListener(function() {
>         logMsg('Port disconnected');
>     });
> }
>
>
> - Tim
>
>
> On Tuesday, May 2, 2017 at 7:10:12 PM UTC-7, Goktug Gokdogan wrote:
>>
>> This might be related to linker changes but not sure that in which
>> version that was changed.
>>
>> Pls provide the code snippet that was working before and no longer
>> working.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "GWT Contributors" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/google-web-toolkit-contributors/87a97383-b3a1-
> 436a-832f-79594a4b1b3b%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/87a97383-b3a1-436a-832f-79594a4b1b3b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA0407SEg%2BpLy3s8kjVmkPqgBA4VQKXni_HJvMcvBp5NwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to