Google Drive App in Chrome App

Has anyone understood how to use the Google Drive API in real time in the Chrome Packaged App ?

Loading gapiin an isolated iframe result:

Uncaught TypeError: cannot read the 'prototype' property from undefined cb = gapi.loaded_0: 6

gapi.load("auth:client,drive-realtime,drive-share", function(){...});

Please see my example repo: https://github.com/damondouglas/sandbox-cpa-drive-rt

0
source share
2 answers

. , GitHub, , -, . , , . , , -, .

webview -, , API- .

https://drive.google.com/file/d/0B1es-bMybSeSVWozSkJ6OFd5YTQ/edit?usp=sharing

+3

, . , , - . , - , -, .

Google Javascript Chrome DOM, - . sessionStorage, -.

manifest.json

{
  "name": "Moo.do",
  "description": "Moo.do - Organize your way",
  "version": "0.1",
  "manifest_version": 2,
  "app": {
    "background": {
      "scripts": [ "chromeapp.js" ]
    }
  },
  "permissions": [
    "storage",
    "webview"
  ]
}

chromeapp.js

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('test.html', {
    'bounds': {
      'width': 400,
      'height': 500
    }
  });
});

test.html  

<head>
    <script src="test.js" type="text/javascript"></script>
    <style>
    body {
        margin: 0px;
    }

    .view {
        position: absolute;
        left: 0px;
        top: 0px;
    }

    #authView {
        width: 100%;
        height: 100%;
    }

    #mainView {
        width: 100%;
        height: 100%;
    }
    </style>
</head>

<body>

<webview id="mainView" class="view" src="http://www.moo.do"></webview>

</body>

</html>

test.js

function handleNewWindow(evNew)
{
    var authView = document.createElement('webview');
    authView.id = 'authView';
    authView.classList.add('view');

    document.body.appendChild(authView);

    authView.addEventListener('exit', function (e)
    {
        debugger;
    });

    authView.addEventListener('loadredirect', function (e)
    {
        debugger;
    });

    evNew.window.attach(authView);
}

document.addEventListener('DOMContentLoaded', function ()
{
    var mainView = document.getElementById('mainView');

    mainView.addEventListener('newwindow', handleNewWindow);
});
+2

Source: https://habr.com/ru/post/1546949/


All Articles