googlechrome / chrome-extensions-samples Goto Github PK
View Code? Open in Web Editor NEWChrome Extensions Samples
Home Page: https://developer.chrome.com/docs/extensions
License: Apache License 2.0
Chrome Extensions Samples
Home Page: https://developer.chrome.com/docs/extensions
License: Apache License 2.0
Try http://free.worldweatheronline.com/feed/weather.ashx?format=json&num_of_days=5&key=78b33b52eb213218120708&q= and you'll see this
error message
{ "data": { "error": [ {"msg": "User account is in suspended mode. Contact support team at [email protected]" } ] }}
This URL is used in https://github.com/GoogleChrome/chrome-app-samples/blob/master/weather/weather.js
The readme link to the url-handler demo app on the cromw web store is not recognized (and produces a rather strange 404 message).
I love using GMail in Chrome. There are lots of great built-in Chrome extensions (e.g., boomerang) and the keyboard shortcuts make purging email a breeze. The problem --- at least in my view --- is that using gmail in a Chrome tab is not nearly as convenient as having a standalone app that appears in the cmd
+tab
(or ctrl
+tab
) sequence and can easily be minimized.
I started to try and make my own GMail standalone app to get this started, but after browsing around the examples a bit I'm guessing there are some pretty obvious and difficult security issues that I'd have to deal with so I bailed on doing this myself. I'm adding it here as a feature request as I think many people --- myself included --- would really like this quite a bit.
This example does not work correctly due to an issue in Chrome for Windows.
https://code.google.com/p/chromium/issues/detail?id=170595
Perhaps a warning would be nice so people don't spend their time trying to make it work.
Browser app
If you install the browser app (the sample that shows how to use the webview tag in an app to create a mini browser), run it and then visit www.youtube.com and try to watch any video, a black rectangle is shown in place of video. I can hear the audio though.
I have two problems, I am trying to use the sample https://github.com/GoogleChrome/chrome-app-samples/tree/master/push-messaging-roundtrip-sample, in this example is used the function chrome.pushMessaging.getChannelId.
For using this option it is mandatory to sign in to Chrome or Chromium browser, originally I could not sign in with the mail of my company, [email protected], after an update of Chrome and Chromium the problem was solved.
The problem right now is that if I sign in with my gmail account I can obtain the ChannelId without problems, but if I sign in with my sanmina account I dont get channel, so I imagine the problem is related with the managment of my company in the policies but I am not sure, I hope somebody could have a more clear idea, thanks in advance.
Like additional information, in Chromium I can not get the ChannelId even with my gmail account, I am using archlinux.
EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:".
Any ideas?
.
.
I'm trying to get tcpserver working. I do the following (after a cold start of chrome)
start tcp server from the apps launcher page
In the chrome console window there is an immediate error
Cannot call method 'isConnected' of undefined line 92 of main.js
press the start button in the tcp window
Then from an external program:
open the socket - this works
send 4 echo messages and wait for the reply - this works
close the socket - now chrome loops ( I guess) CPU goes to 75% an I have to kill chrome
Hi,
chrome.experimental.identity.getAuthToken in Google Drive Uploader and Identity seems not working. Works with launchWebAuthFlow.
Regards
On Chrome version 27 (stable), I can't get this sample to load properly.
Could not load extension from '/Users/<username>/src/chrome-app-samples/multicast'. Invalid value for 'permissions[socket]'.
If I remove the socket['udp-multicast-membership'] permission, the app will load (though I don't think it works properly).
I tried embedding the google-analytics-bundle.js in my app but frequently sendEvent would throw exceptions. Other times it would work fine. Perhaps it is not up-to-date?
I'm trying the Google Drive Uploader sample. When using XMLHttpRequest at the initialization I get;
Refused to load the image 'unsafe:blob:chrome-extension%3A//nmcjkdfiebdhjfleemldkdbhiijibegc/546a257a-1542-4519-9fbc-bf6ff6c0184f' because it violates the following Content Security Policy directive: "img-src 'self' data: chrome-extension-resource:"
Then when images are cached in the filesystem I get
"Refused to load the image 'unsafe:filesystem:chrome-extension://nmcjkdfiebdhjfleemldkdbhiijibegc/temporary/test/icon_10_generic_list.png' because it violates the following Content Security Policy directive: "img-src 'self' data: chrome-extension-resource:"
I'm using the angular 1.2.0-rc.2. Strange that CSP is enabled on the filesystem for the app, or I am missing a directive for content security policy in the manifest?
manifest.json:
{
"name": "__MSG_appName__",
"version": "1",
"manifest_version": 2,
"description": "__MSG_appDescription__",
"icons": {
"16": "images/icon-16.png",
"128": "images/icon-128.png"
},
"default_locale": "en",
"app": {
"background": {
"scripts": ["scripts/background.js"]
}
},
"permissions": [
"identity",
{"fileSystem": ["write", "retainEntries"]},
"storage",
"https://docs.google.com/feeds/",
"https://docs.googleusercontent.com/",
"https://spreadsheets.google.com/feeds/",
"https://ssl.gstatic.com/",
"https://www.googleapis.com/"
],
"oauth2": {
"client_id": "388835528582.apps.googleusercontent.com",
"scopes": [
"https://docs.google.com/feeds/",
"https://docs.googleusercontent.com/",
"https://spreadsheets.google.com/feeds/",
"https://www.googleapis.com/auth/drive"
]
}
}
I've found that removing the 'unsafe:' at L 4440/angular.js this[key] = value = 'unsafe:'+normalizedVal; will work.
I'm on Versjon 31.0.1632.7 canary Aura
Further debugging gives; imgSrcSanitizationWhitelist reg exp = '/^\s*(https?|ftp|file):|data:image//'.
It seems like the 'filesystem:chrome-extension:' scheme in the url will not match. Should be file:// scheme instead??
Seems like its a bug in angular.js; angular/angular.js#3889
When loading chrome-app-samples/multicast/ into chrome Version 25.0.1364.160, I get:
Uncaught TypeError: Cannot read property 'onMessage' of undefined index.js:186
I am trying to run this example code:
https://github.com/GoogleChrome/chrome-app-samples/tree/master/filesystem-access
as well as this:
https://github.com/GoogleChrome/chrome-app-samples/tree/master/storage
I am not able to get either of them to run in my browser: Chrome 26.0.1410.65 Mac Lion 10.7.5
Here is a stack overflow question to confirm if this is a bug before posting here, but didn't get much love over there (http://stackoverflow.com/questions/16307967/google-chrome-file-system-api-bug-in-sample-code)
:(
Can you add support for gapi.client.load call in gapi-chrome-apps.js?
Or give a hint how to modify current script to get it working?
Currently there is support for gapi.client.request() only.
I launch this APP through Chrome/Toos/Extensions and Load unpacked extension,
the APP failed because getDevices method undefined.
However, this APP can run correctly if I install from Chrome WebStore and launch through Chrome APP Launcher.
What is the difference between these two APP launching method ?
dart2js is now CSP compliant and js-interop does not require localstorage anymore, so, in theory, we should be good to write ChromeApps in Dart.
https://github.com/GoogleChrome/chrome-app-samples/tree/master/udp
Check out icon*.png files. They are empty.
Would it be possible to add support for the Dymo labelwriter 400 in this project?
There is a label printer app here that lets you print labels on chrome OS using a dymo 450. I also have a Dymo 400 i would like to use. I tried to modify the code but could not figure it our.
Is there any way to modify the code so i can also use a dymo 400 on chrome OS?
Is there any safe place where we can put our Client Secret Id's inside the application? I think that having it here is a terrible idea (Github Auth sample); anyone that sees that repo might think putting their client Id's there is a good idea and carry that practice to their applications whenever the Identity API gets out of Beta.
At the beginning I thought the manifest.json was a good option, but you can easily get its contents with chrome.runtime.getManifest(). I hope we can really avoid having to set up a server for each of our apps...
Seems like some of the submodules are not tracked properly...
$ git -c diff.mnemonicprefix=false -c core.quotepath=false clone --recursive [email protected]:GoogleChrome/chrome-app-samples.git /Users/kowalskif/Desktop/GIT/google-chrome/chrome-app-samples
No submodule mapping found in .gitmodules for path 'clock/tests/lib/js-imagediff'
Cloning into '/Users/kowalskif/Desktop/GIT/google-chrome/chrome-app-samples'...
Completed with errors, see above
The Context Menu Sample displays the wrong context menu if you do the right sequence of clicks. The clicks needed to reproduce this issue are:
I am running Windows 8.0 64-bit and Google Chrome Version 32.0.1700.6 dev-m Aura.
I found no mention of this issue in the README.md
or in the open github issues for this repository.
Hi,
This is more of a question is it possible to load gmail with Chrome extensions like yesware using the browser example or a simple webview?
I want support single repo for web and chromeOS project but have problem with test running on ChromeOS app. Could you please advise something to resolve the problem. Thank you
I've tested Weather application and frameless-window application
Both of them are using:
-webkit-app-region: drag;
and both of them doesn't work for me.
I couldn't drag window with my mouse.
I'm running Chrome 23.0.1271.95/Windows 7
I have tried to interface sample app with a USB device(Dymo 450 Turbo label printer) on 3 difference machines.
any suggestion? please help.
Thank you.
This is the section of the readme to which I refer:
Webintents:
- [explicit-webintents](https://github.com/GoogleChrome/chrome-app- samples/tree/master/explicit-webintents)
- webintents
EDIT: I noticed web intents are being deprecated, maybe you should mention that.
Rich Notification API example on Ubuntu 12.04 LTS only shows the standard notification under any set of input parameters.
Hi @hmin,
The systemInfo example needs a README.md file - something like https://github.com/GoogleChrome/chrome-app-samples/tree/master/camera-capture
Also, it would be good for you to maintain this example if/when the API changes as part of your commits to Chrome.
P
Not an issue per say...
diff --git a/webserver/index.html b/webserver/index.html
index 311c283..3c3dc0b 100644
--- a/webserver/index.html
+++ b/webserver/index.html
@@ -68,6 +68,7 @@
<select id="hosts">
<option value="127.0.0.1">lo - 127.0.0.1</option>
</select>
+ <input type="text" id="port" value="8080"/><br />
<button id="start" class="btn btn-primary btn-large" disabled>Start</button>
<button id="stop" class="btn btn-warning btn-large" disabled>Stop</button>
</p>
diff --git a/webserver/index.js b/webserver/index.js
index 49d2f1e..85a6fc3 100644
--- a/webserver/index.js
+++ b/webserver/index.js
@@ -2,6 +2,7 @@ onload = function() {
var start = document.getElementById("start");
var stop = document.getElementById("stop");
var hosts = document.getElementById("hosts");
+ var port = document.getElementById("port");
var directory = document.getElementById("directory");
var socket = chrome.experimental.socket || chrome.socket;
@@ -30,13 +31,13 @@ onload = function() {
logger.textContent += log + "\n";
}
- var writeErrorResponse = function(socketId, errorCode) {
+ var writeErrorResponse = function(socketId, errorCode, keepAlive) {
var file = { size: 0 };
console.info("writeErrorResponse:: begin... ");
console.info("writeErrorResponse:: file = " + file);
- var contentType = "text/plain"; //(file.type === "") ? "text/plain" : file.type;
+ var contentType = "text/plain"; //(file.type === "") ? "text/plain" : file.type;
var contentLength = file.size;
- var header = stringToUint8Array("HTTP/1.0 " +errorCode+ " Not Found\nContent-length: " + file.size + "\nContent-type:" + contentType + "\n\n");
+ var header = stringToUint8Array("HTTP/1.0 " + errorCode + " Not Found\nContent-length: " + file.size + "\nContent-type:" + contentType + ( keepAlive ? "\nConnection: keep-alive" : "") + "\n\n");
console.info("writeErrorResponse:: Done setting header...");
var outputBuffer = new ArrayBuffer(header.byteLength + file.size);
var view = new Uint8Array(outputBuffer)
@@ -44,8 +45,12 @@ onload = function() {
console.info("writeErrorResponse:: Done setting view...");
socket.write(socketId, outputBuffer, function(writeInfo) {
console.log("WRITE", writeInfo);
- socket.destroy(socketId);
- socket.accept(socketInfo.socketId, onAccept);
+ if (keepAlive) {
+ readFromSocket(socketId);
+ } else {
+ socket.destroy(socketId);
+ socket.accept(socketInfo.socketId, onAccept);
+ }
});
console.info("writeErrorResponse::filereader:: end onload...");
@@ -53,10 +58,10 @@ onload = function() {
};
- var write200Response = function(socketId, file) {
+ var write200Response = function(socketId, file, keepAlive) {
var contentType = (file.type === "") ? "text/plain" : file.type;
var contentLength = file.size;
- var header = stringToUint8Array("HTTP/1.0 200 OK\nContent-length: " + file.size + "\nContent-type:" + contentType + "\n\n");
+ var header = stringToUint8Array("HTTP/1.0 200 OK\nContent-length: " + file.size + "\nContent-type:" + contentType + ( keepAlive ? "\nConnection: keep-alive" : "") + "\n\n");
var outputBuffer = new ArrayBuffer(header.byteLength + file.size);
var view = new Uint8Array(outputBuffer)
view.set(header, 0);
@@ -66,8 +71,12 @@ onload = function() {
view.set(new Uint8Array(e.target.result), header.byteLength);
socket.write(socketId, outputBuffer, function(writeInfo) {
console.log("WRITE", writeInfo);
- socket.destroy(socketId);
- socket.accept(socketInfo.socketId, onAccept);
+ if (keepAlive) {
+ readFromSocket(socketId);
+ } else {
+ socket.destroy(socketId);
+ socket.accept(socketInfo.socketId, onAccept);
+ }
});
};
@@ -76,34 +85,48 @@ onload = function() {
var onAccept = function(acceptInfo) {
console.log("ACCEPT", acceptInfo)
+ readFromSocket(acceptInfo.socketId);
+ };
+
+ var readFromSocket = function(socketId) {
// Read in the data
- socket.read(acceptInfo.socketId, function(readInfo) {
+ socket.read(socketId, function(readInfo) {
console.log("READ", readInfo);
// Parse the request.
var data = arrayBufferToString(readInfo.data);
if(data.indexOf("GET ") == 0) {
+ var keepAlive = false;
+ if (data.indexOf("Connection: keep-alive") != -1) {
+ keepAlive = true;
+ }
+
// we can only deal with GET requests
var uriEnd = data.indexOf(" ", 4);
if(uriEnd < 0) { /* throw a wobbler */ return; }
var uri = data.substring(4, uriEnd);
+ // strip qyery string
+ var q = uri.indexOf("?");
+ if (q != -1) {
+ uri = uri.substring(0, q);
+ }
var file = filesMap[uri];
if(!!file == false) {
- console.warn("File does not exist...");
- writeErrorResponse(acceptInfo.socketId, 404); /* File does not exist */
+ console.warn("File does not exist..." + uri);
+ writeErrorResponse(socketId, 404, keepAlive);
return;
}
logToScreen("GET 200 " + uri);
- write200Response(acceptInfo.socketId, file);
+ write200Response(socketId, file, keepAlive);
}
else {
// Throw an error
- socket.destroy(acceptInfo.socketId);
+ socket.destroy(socketId);
}
- });
+ });
};
directory.onchange = function(e) {
- if(socketInfo) socket.destroy(socketInfo.socketId);
+ if (socketInfo) socket.destroy(socketInfo.socketId);
var files = e.target.files;
@@ -121,7 +144,7 @@ onload = function() {
start.onclick = function() {
socket.create("tcp", {}, function(_socketInfo) {
socketInfo = _socketInfo;
- socket.listen(socketInfo.socketId, hosts.value, 8080, 20, function(result) {
+ socket.listen(socketInfo.socketId, hosts.value, parseInt(port.value), 50, function(result) {
console.log("LISTENING:", result);
socket.accept(socketInfo.socketId, onAccept);
});
diff --git a/webserver/main.js b/webserver/main.js
index dd28a88..c11dc6a 100644
--- a/webserver/main.js
+++ b/webserver/main.js
@@ -7,6 +7,6 @@
chrome.app.runtime.onLaunched.addListener(function(intentData) {
chrome.app.window.create('index.html', {
width: 500,
- height: 550
+ height: 640
});
});
Even when css3d
is added to the requirements in manifest.json
, CSS renders in 2d inside of a <webview>
. Is this a known issue? Is webgl
not supported in <webview>
as well?
See the issue in aschwartz/chrome-chromeless for more information.
It works great on Mac using the same AP (which allows multicast UDP). https://github.com/GoogleChrome/chrome-app-samples/tree/master/mdns-browser
#!/usr/bin/env python
import socket
TCP_IP = '127.0.0.1'
TCP_PORT = 8888
BUFFER_SIZE = 1024
MESSAGE = "Hello, World!"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
data = s.recv(BUFFER_SIZE)
s.close()
print "received data:", data
I have seen in the code that server does call write for received message.
From the code,
tcpserver/main.js line 67:
try {
tcpConnection.sendMessage(Commands.run(cmd[0], cmd.slice(1)));
} catch (ex) {
tcpConnection.sendMessage(ex);
}
$ uname -a
Linux 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
The keyboard-handler example only seems to pick up on key events when it has focus. Is it possible, or will it ever be possible, to get it to recognise the events even when it doesn't have focus?
I want to create an app which uses keyboard shortcuts to interact with the app even when it doesn't have focus (specifically media keys on a music app).
There might be a "Save As" bug in the "Filesystem Access" app and the "Simple Text Editor" app, under Windows 7 anyway. When you try to save a new file with the same name
as an already existing file, the new one does not replace the old one.
Instead the new one is inserted into the old one and fragments of the
old may still remain.
Suppose you start with the two line file (newFile.txt):
newline1
newline2
and suppose there is another 6 line file (oldFile.txt) already saved on disk:
oldline1
oldline2
oldline3
oldline4
oldline5
oldline6
Now you use the Filesystem Access app, to load the two-line file
"newFile.txt". Then you choose "Save As" and give the name of the 6
line file (oldFile.txt). You get a message asking if you want to
replace the old file. You choose "yes" and the file is saved. But it
turns out that the old file was not replaced. The new file is inserted
into the old file and there are still fragments of the old file
remaining. The "oldFile.txt" is now the 7 line file:
newline1
newline2
oldline3
oldline4
oldline5
oldline6
This may be the desired behaviour, but it's not what I was expecting.
This is what I get in the console:
pushMessaging.getChannelId: 1
at Guestbook.initialize (chrome-extension://pclhfkljokicifohhjodckkdjfagcjei/Guestbook.js:75:24)
at chrome-extension://pclhfkljokicifohhjodckkdjfagcjei/background.js:10:11 lastError:29
set
I'm not sure what exactly it means. Any help? I'm using your sample but not being able to come up with a solution to get the channel id.
The usb-label-printer app stops printing after one go. The app needs te be reloaded or the dymo reconnected to print another label. Does anyone else have this problem?
Finally I could have working the example provided push-messaging-roundtrip-sample at https://github.com/GoogleChrome/chrome-app-samples/tree/master/push-messaging-roundtrip-sample, in this example the intention is to prove the push messaging, I would like how to get in the XMLHttpRequest the email of the user who is logged for using the application, I hope somebody could help me
Hi
i want to create webview / browser app
but i want to automatically enable kiosk printing & kiosk mode ?
is that possible ?
thanks.
The problem is that there is no handler for 404 cases, so I hacked one in:
On or near line 78 of index.js, inside the onAccept function, add the writeErrorResponse call:
if(!!file == false) {
console.warn("File does not exist...");
// added - handle writing the response with status code 404
writeErrorResponse(acceptInfo.socketId, 404); /* File does not exist */
return;
}
Add this function to index.js, above the onAccept function on or near line 57:
var writeErrorResponse = function(socketId, errorCode) {
var file = { size: 0 };
console.info("writeErrorResponse:: begin... ");
console.info("writeErrorResponse:: file = " + file);
var contentType = "text/plain"; //(file.type === "") ? "text/plain" : file.type;
var contentLength = file.size;
var header = stringToUint8Array("HTTP/1.0 " +errorCode+ " Not Found\nContent-length: " + file.size + "\nContent-type:" + contentType + "\n\n");
console.info("writeErrorResponse:: Done setting header...");
var outputBuffer = new ArrayBuffer(header.byteLength + file.size);
var view = new Uint8Array(outputBuffer)
view.set(header, 0);
console.info("writeErrorResponse:: Done setting view...");
socket.write(socketId, outputBuffer, function(writeInfo) {
console.log("WRITE", writeInfo);
socket.destroy(socketId);
socket.accept(socketInfo.socketId, onAccept);
});
console.info("writeErrorResponse::filereader:: end onload...");
console.info("writeErrorResponse:: end...");
};
I solved the issue in my copy, and I've included the code above. Not sure if this is the right approach for getting code committed. Hope this helps!
James
I'm trying to integrate a website(call it site-A) through webview in my app. But when I want to input some non-english characters into site-A's textbox, it doesn't input anything. It seems like the input methods are incompatible. I have tried Chinese/Japanese input methods and they are all broken.
I tried with native input tag and it worked fine. This issue only happen inside webview.
Is this Chrome bug? How should I fix it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.