Skip to content

Commit

Permalink
add webview geolocation sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Istiaque Ahmed committed Jul 9, 2013
1 parent 3135958 commit 4d336f5
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions tests/chrome-apps/webview_geolocation/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New style simple (chromium) platform app.
40 changes: 40 additions & 0 deletions tests/chrome-apps/webview_geolocation/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--
* Copyright 2013 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<head>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<div>
<div>Embedder</div>

<!--
<div style="display: inline-block">
<div>Guest 0 does geo request from top level and iframe</div>
<webview id="webview0" src="http://jsbin.com/egekod/6" style="border: 1px solid gray; height: 320px;"></webview>
</div>
-->

<div style="display: inline-block">
<div>Guest</div>
<webview id="webview1" src="http://jsbin.com/egekod/1" style="border: 1px solid gray; height: 320px;"></webview>
</div>
<!--
<div style="display: inline-block">
<div>Guest 2 has iframe in it</div>
<webview id="webview2" src="http://jsbin.com/egekod/1" style="border: 1px solid gray; height: 320px;"></webview>
</div>
<div style="display: inline-block">
<div>Guest 3 has geo request in both top level and iframe</div>
<webview id="webview3" src="http://jsbin.com/egekod/2" style="border: 1px solid gray; height: 320px;"></webview>
</div>
<div style="display: inline-block">
<div>Guest 4 does geo request simultaneously in both top level and iframe</div>
<webview id="webview4" src="http://jsbin.com/omiriw/1" style="border: 1px solid gray; height: 320px;"></webview>
</div>
-->
</body>
</html>
44 changes: 44 additions & 0 deletions tests/chrome-apps/webview_geolocation/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
window.onload = function() {
var webview1 = document.getElementById('webview1');
webview1.addEventListener('permissionrequest', function(e) {
window.console.log('Embedder got permissionrequest (1)');
window.console.log('permissionrequest.type: ' + e.type);
//e.request.allow();
//e.request.deny();
window.console.log('going to preventDefault');
e.preventDefault();
});
//document.querySelector('webview').src = 'http://jsbin.com/azayiv/1';
if (1 ==1) return;

var webview2 = document.getElementById('webview2');
webview2.addEventListener('permissionrequest', function(e) {
window.console.log('Embedder got permissionrequest (2)');
window.console.log('permissionrequest.type: ' + e.type);
e.request.allow();
//e.request.deny();
});

var webview3 = document.getElementById('webview3');
webview3.addEventListener('permissionrequest', function(e) {
window.console.log('Embedder got permissionrequest (3)');
window.console.log('permissionrequest.type: ' + e.type);
e.request.allow();
//e.request.deny();
});

var webview4 = document.getElementById('webview4');
webview4.addEventListener('permissionrequest', function(e) {
window.console.log('Embedder got permissionrequest (4)');
window.console.log('permissionrequest.type: ' + e.type);
e.request.allow();
//e.request.deny();
});

var webview0 = document.getElementById('webview0');
webview0.addEventListener('permissionrequest', function(e) {
window.console.log('Embedder got permissionrequest (0)');
window.console.log('permissionrequest.type: ' + e.type);
e.request.allow();
});
};
15 changes: 15 additions & 0 deletions tests/chrome-apps/webview_geolocation/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"manifest_version": 2,
"name": "Webview.guest.geolocation",
"version": "1",
"minimum_chrome_version": "23",
"permissions": [
"webview",
"geolocation"
],
"app": {
"background": {
"scripts": ["test.js"]
}
}
}
10 changes: 10 additions & 0 deletions tests/chrome-apps/webview_geolocation/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Listens for the app launching then creates the window
*
* @see http://developer.chrome.com/trunk/apps/app.runtime.html
* @see http://developer.chrome.com/trunk/apps/app.window.html
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('main.html',
{width: 500, height: 300});
});

0 comments on commit 4d336f5

Please sign in to comment.