Chrome Apps Office Hours: Chrome Storage APIs


MALE SPEAKER: Shanghai
GDG is a very interesting developer community. FEMALE SPEAKER 1: I’m
glad somebody has asked this question. MALE SPEAKER 2: This is where
the magic happens. FEMALE SPEAKER 2: This
is primarily a question-and-answer show. So if any of you out there would
like to ask questions. MALE SPEAKER 3: All right,
welcome everybody. I guess this is the third week
of our Chrome Apps hang out. And this week we’ve got with
us Paul and Renato. We’re all back in our
home locations. So guys, why don’t I have you
introduce yourselves, for those who are just joining
us for your first time. PAUL LEWIS: Hi, I’m
Paul Lewis. I’m a developer programs
engineer for Google and I work on GPU performance type things
and also Chrome Apps as well. So, that’s me. MALE SPEAKER 3: Sweet
and next we– RENATO MANGINI: I’m
Renato Mangini, and I work from Brazil. I’m a Chrome developer
program engineer. And I work for Chrome
Apps currently. MALE SPEAKER 3: Awesome,
excellent. And so Renato, you were last
week in Mountain View with us. And then Paul you were not, but
you’re going to be joining from Mountain View next week,
isn’t that right? PAUL LEWIS: Next week and the
week after I’ll be in Mountain View, yes. MALE SPEAKER 3: Awesome, good. Well, it’ll be fun to
have you there. And I think the week after next
we’re going to have a couple of us are going
to be heading back. Renato, are you headed
back to Mountain View next week as well? Or when do you go back? RENATO MANGINI: Not been next,
but the other one. On 11th, September 11th,
I will join you– MALE SPEAKER 3: Awesome. RINADO: –in Mountain View. MALE SPEAKER 3: Very cool. Well, so in that case, why don’t
we jump in and look at some of the stuff that we’re
going to talk about this week. We asked you guys the last two
weeks what APIs you’re most interested in, what the things
that you think a really interesting and relevant. And it was kind of interesting
to see some of the results. But very clearly one of the
things you’re most interested in hearing about it is the
news storage APIs. So with the evolution of Chrome
packaged apps, you can now have the ability to use
things like Chrome Sync and Chrome local storage that
allow you to store data locally on the user’s computer,
as well as have it stored up into the cloud. So with that, why don’t I pass
it over to Renato who’s going to explain some of the new
APIs that are available. RENATO MANGINI: Excellent. Thanks, [? Pete. ?] If you’re a web developer, you
probably use it to do local storage API. The local storage API is not
Chrome specific, but it has been for a few months and it
has for some months or some years, I’m not sure. But it has some problems with
basically the most important problem it is synchronous– MALE SPEAKER 3: Mmm. OK. RENATO MANGINI: Being
synchronous, it’s a potential problem because if it’s a
storage, it does a lot of IO and you cannot count on how much
time that IO will take. So this Chrome packaged API,
specific for Chrome packaged apps, is the Chrome storage. The Chrome storage is composed
of two storage areas, the local and the sync. Both have almost the same
behavior, the same API. You can use one or the other,
depending on your requirements. But it’s simply a matter
of changing which storage you are using. The whole set of meta calls
is the same for both. The API is a pretty
much the same. It’s almost the same as the
local storage from HTML5 on the open web, except
for a few changes. First of all, you have
to have a specific permission on your manifest. And the permission is
called storage. MALE SPEAKER 3: OK, so we need
to storage permission in order to be able to use this, right? RENATO MANGINI: Exactly. MALE SPEAKER 3: OK, cool. RENATO MANGINI: And then you
just call the methods from the storage area you want to use. For example, if you want to get
a specific value from the storage, you call Chrome
dot storage dot sync or dot local– MALE SPEAKER 3: OK. RENATO MANGINI: –depending
on the storage area. MALE SPEAKER 3: Now why are
there two different ones? Like can go into? RENATO MANGINI: Yeah,
absolutely. The local one, it stores
asynchronously in your local file system. And the sync one, it does the
same as the local one if you are offline. But as soon as you get online,
or if you are already online, it does sync the keys and values
with the cloud, with your Chrome account. As long as you’re signed into
your Chrome account. MALE SPEAKER 3: OK. RENATO MANGINI: To your– MALE SPEAKER 3: So local only
ever exists on that particular user’s computer, right? So like, hey, I’ve got my
Chromebook here, and if I do dot local, it’s going to sit
there on that machine. But with dot sync, the
difference there is that it’s going to sync on this
Chromebook, but it’s also going to sync on my Chromebook
at home. It’s going to sync on
maybe my Mac or my PC on another machine. RENATO MANGINI: Yeah,
absolutely. MALE SPEAKER 3: Cool. Now, what might be some use
cases as for where I would want to use sync versus local? RENATO MANGINI: The use case for
these Chrome storages is for storing small pieces
of information, so for example, settings. I think this is the
most important and relevant use case. If you just configured your
application without the settings changes you want, and
you do it on your laptop, you don’t want to do it again
on your desktop. MALE SPEAKER 3: Right. RENATO MANGINI: It’s very
important to the user to be able to share these settings
among other computers. And also the location inside the
app that the user are, the state of the app is very
important for developers to store that state on
the sync storage. So if I’m reading a specific
article on my desktop and I have to go out, I grab my laptop
and I open it and I opened the new reader
application. It’s very good for me if the app
opens on the same page I was before. MALE SPEAKER 3: Right. So– RENATO MANGINI: We can achieve
that very easily. MALE SPEAKER 3: For stuff that
might be relevant to go across multiple machines, like so what
I’ve read in the news, maybe if I’ve got a news reader,
maybe what songs I listen to last or what playlist
I was playing with, if it’s a media application– so there’s a lot of good
cases where you’d want to sync that across. RENATO MANGINI: Yes,
absolutely. MALE SPEAKER 3: OK. PAUL LEWIS: It’s worth pointing
out at this stage that there are some limits, and
there’s a quota for the amount of data that can
be stored online. So you should check the docs
to make sure the– MALE SPEAKER 3: OK. PAUL LEWIS: –number of items
and the amount of data per item is within those limits. And that really [INAUDIBLE] for
things like these sort of settings or smaller
made value patts. MALE SPEAKER 3: Yeah,
that’s a good point. So could I store entire
news articles? So say for example, I’ve got all
the news article, it’s got a bunch of images, and maybe
there’s a video. Do I want to put that
into sync or local? RENATO MANGINI: No,
I don’t think so. MALE SPEAKER 3: OK, so probably
not to put those kinds of things there. But maybe to say I’ve read
that article, right? RENATO MANGINI: Exactly. PAUL LEWIS: Yeah. RENATO MANGINI: Yeah, the
example you mentioned before of music streaming application,
if you are going to save anything there, you save
the name or the ID of the music you were listening to, not
to music itself, just to be clear about that. MALE SPEAKER 3: All right. PAUL LEWIS: But there are also
the things like the file system API. So there are other APIS that you
could investigate if you want to actually store, say,
blogs or file data, specifically. But as we’re saying, the Chrome
[INAUDIBLE] storage is ready for these. And they’ve value patts
ready right now. MALE SPEAKER 3: OK, cool. Renato, does that about cover
what you wanted to talk about? RENATO MANGINI: Yeah, there is
one interesting method on the API that is the on change it. When you add the listener to the
on change it object, you get a call. Whenever anything on your
application storage has changed it. It’s very important for syncing
stuff and receiving the [INAUDIBLE] of change on the other
computers. MALE SPEAKER 3: OK. RENATO MANGINI: The method
is on the documentation. The URL for documentation would
probably be on your screen in a few seconds,
if it’s not yet. MALE SPEAKER 3: OK, it’s
not there yet. I got to make one quick little
update while we’re doing some of the demos. But we’ll bring those up. RENATO MANGINI: And the method
is called it’s Chrome dot stars dot on change it. And you have a method at
least on this object. And do you send it function
and that function, the callback, will be called
whenever there’s a change on your storage. But apart from that, we have
get, set, clear, remove methods, which are pretty
straightforward. And we also have the
get bytes in use. That returns you how many bytes
that have been used on our storage. MALE SPEAKER 3: OK, excellent. That’s pretty much it. MALE SPEAKER 3: And so we’ll
get the link for the URL up here in a sec. But Paul, you actually
sat down and wrote a little sample for us. Do you want to talk
about that? PAUL LEWIS: Yeah, absolutely. So what I’m going to do is I’m
going to take over from where I left off last week. And if you want to go ahead and
show what’s on my screen. MALE SPEAKER 3: All right, so
Paul your screen is up. Everybody can see your
screen right now. PAUL LEWIS: OK, awesome. So as you can see, I’m looking
at the manifest file, which is pretty much the same as we
left it last week in the Hello, World! So if this is completely new to
you, you might want to see last week’s session where we
showed Hello, World! and how to get that from nothing. And so what I’m going
to do is I’m starting from that position. What I’m going to do is I’m
going to show you how you can use the Chrome storage APIs in
your apps and just show you the minimum amount of code that
you might want to add to your apps, just to kind
of things going. So the first thing that we need
add is those permissions that Renato talked
about earlier. So permissions, and
this is an array. And we only need one
item in the array today, which is storage. So that means that we’re telling
Chrome that this particular package needs
access to those APIs. So I’m going to do is I’m going
to switch over, and I’m actually going to add in
Hello Sync to Chrome. I will fire that up now. And let’s have a look here. There’s nothing particularly
going on of interest. It’s just a blank HTML page. As I said, this is where
we left last week. So now what we need to do is we
need to find a way to put data into the Storage API and
then get back out and all those kinds of good things. So let’s add in, because we
don’t currently have any JavaScript. Now, if you remember from last
week, we couldn’t have any inline JavaScript
because of CSP. So we’re going to have
a separate app.js. And you can call that whatever
you like, it doesn’t have to be that. I’m just going to go
with that for me. And I’ve taken the liberty of
creating that file elsewhere, which you can see over here. But it’s completely empty
at the moment. Anyway, we haven’t got any means
of putting stuff into the storage, so we just
need to create a form. We’ll just put a single
input tag on that. So input, let’s put a
placeholder in there. Now let’s go ahead and
enter a value. And give it an ID. OK, and then what we want to
do is we also want output whatever the current value is. So we’re going use
a text area. We’re going to say
id=”value-out”. So we have an in and an out that
we’re going to access via JavaScript. We’re going to take the value
in that is stored in the Chrome Storage API and then
we’re going to spit out whatever the current value
is back out into the value out text area. So over in app.js, now this is
where we’re actually going to start talking to the APIs. So we’ll fire a new
[INAUDIBLE]. MALE SPEAKER 3: Hey, Paul, I
want to interrupt for one sec. There was a question that came
up last week that it got answered in the questions, but
I want to ask it of you now. What’s that editor that
you’re using there? PAUL LEWIS: It’s
Sublime Text 2. MALE SPEAKER 3: Awesome. OK. PAUL LEWIS: Yeah, it’s a
really handy editor. I mean, you’ll see as well
when I’m typing the code. You see those white lines around
the code, hopefully. MALE SPEAKER 3: Yup. PAUL LEWIS: It’s a really
useful feature of this particular ID is that you could
have inline linting, which means you can write
the JavaScript code for free, almost. So, carrying on, what I’m going
to do is I’m going to get a hold of those two
elements– the input elements and the text area. So let’s go ahead
and do that– element by ID, and value
in, and value out. I always find it interesting how
many mistakes I make when typing, almost costly
mistakes. MALE SPEAKER 3: That’s almost
always the case isn’t it? PAUL LEWIS: Certainly in
my case it is, yeah. Sorry, give me a second. MALE SPEAKER 3: Uh-oh. PAUL LEWIS: Yeah, I need
to just drop out. Can you switch back
to my screen? MALE SPEAKER 3: Your screen’s
still there, so they should still be able to see that. PAUL LEWIS: OK. OK, great. And then what I’m going to do
is I’m just going to do a valueChanged function. So whatever the value change
is we’re going to set the value out in a text to
be that new value. So this is going to be a useful
helper function that we’re going to fire off whenever
the value changes, either internally or externally
to our app. If you remember, we talked about
when the app changes externally. So if you change a value on your
machine, we’re just going to call this value
change function. So that’s sitting there,
helping us. And what we need to
do is we need to actually track the changes. The form element that I put into
the page, I’m just going to track on to the submit
event there. And let’s fire that off. And what we’re going to do is
we’re going to say when this happens, let’s grab the value
from the value in. We need to make sure that
because form submission isn’t valid in packaged apps, we need
to prevent the default action of the submit So that
stops that from happening. So all we’re interested in is
what’s the value update? And then this is the
fun bit now– storage.sync. So we’re going to do this
on the sync storage API. And what we do is we set an
object as the first parameter, which going to give it value. What I’m going to do as well is
I’m actually going to store its time stamp just for my
own interest, which is to basically say, I want you to set
my value, which is sort of [? a curve ?] values. And then– MALE SPEAKER 3: So we’re going
to add a time stamp? PAUL LEWIS: –asychronous. This is an asynchronous API. MALE SPEAKER 3: OK. PAUL LEWIS: So I’m just going
to say that when this is completed, I would like to know
about it through just a console log event. So this should capture now,
whenever I submit the form. MALE SPEAKER 3: Sweet, OK. PAUL LEWIS: OK. So now the other thing is OK,
well, we can send stuff out, but we want to know when
things have changed. And this is the event that
Renato mentioned earlier, which is the on changed. Nope add listener, not add event
listener, add listener, there we go. And that’s going to
take a function. Again, this is an async API. Now, the callback for this
takes two perimeters– changes and name space. And the second one is the
interesting one, because from the eagle eye, the long view,
you will notice that it’s on Chrome.storage, this on change
that we’re listening for. [INAUDIBLE] Chrome.storage.sync or
Chrome.storage.local. And the name space will actually
tell you whether this is a change that’s happened
in sync or in local. So you might need to distinguish
between the two. And if you do, that’s what
the name space is for. MALE SPEAKER 3: So will name
space be storage or local? Or will it be– PAUL LEWIS: It will
be sync or local. MALE SPEAKER 3: Sync
or local, OK. PAUL LEWIS: So what I’m going
to do is I’m just going to check for my value, because
that’s what I was setting up here. So if I have that then I will
want to call that helper function valueChanged with
changes.myValue, a and then interestingly, the new
value property. Now, you maybe wondering,
hang on, where did newValue come from? One of the things about the
changes object that comes in is that myValue will actually
have two properties, newValue and oldValue. So if you need to find out what
it changed from, that’s what oldValue will have, and
newValue will have your new value, pretty much what
it says on the tin. But it’s worth knowing that you
can have access to what it was and and what it isn’t in
case you to do some other calculations in that. MALE SPEAKER 3: Yeah, so that
would be really good if you needed to do any kind of like
synchronization and sort of like, oh, well, they changed
this on this machine and this on this machine, and this was
the only like thing that actually changed. PAUL LEWIS: Yeah, and if it’s
like, oh, this change actually has implications because you
change from this to this, then having access to what it
was is extremely useful in those use cases. And then the last thing that we
need to do now that we’re running for changes and we’re
submitting changes. The last thing we do need to do
is just kind of kick this whole thing off and say, well,
what is the current value? So what we can do is we can say,
Chrome.storage.sync.get. And we’re going to
ask for myValue. So we can pause there– and
I’ll show you this in a second– but we can ask for a
string, which is a specific key from the object
that we set. Or we can pass through an array,
which allows us to request multiple items. So I’m going to get back. Again, this is an async cause,
so again, I can result. RENATO MANGINI: And also, Paul,
if you pass it new, you get the whole storage,
all the keys. PAUL LEWIS: There you go. So it’s containing the
properties that I requested, and very much like before, I’m
going to pass that through to my valueChanged, which should
hopefully spit it out now, unless I’ve made a colossal
mistake, hopefully– MALE SPEAKER 3: All right,
we’re into the big test. It’s always fun. PAUL LEWIS: It’s currently
undefined, because I don’t actually have a value
in there. So if I say myValue, they’re
going to see My Value set. OK, now if I were to close
this out and hopefully relaunch it, you see that it’s
actually restored My Value, based on this set. So that is really it. That’s actually stored
up remotely. Now what we actually wanted
to do was to show you this actually working across
multiple machines. So what we’ve taken the liberty
of doing is you’ll find there’s new sample
on the GitHub repo called Hello World Sync. MALE SPEAKER 3: All right, let
me bring up the link for that. So people should be able to
see that on the screen. You can go to goo.gl/AP4Sy
is the URL for that. And it’s capital A capital P 4
capital S and then the letter y in lowercase. PAUL LEWIS: OK, awesome. So if you can see on my screen,
I have the syncable storage app open. Renato, do you have it up
on your screen as well? RENATO MANGINI: Yes, I do. PAUL LEWIS: OK, awesome. So Renato and I both
have this app open. We’re both signed in under
a test account. So as far as Chrome is
concerned, we’re sort of hooked up together. So I’m going to change this
value to Chrome Apps Rock. And I’m going to change that. And hopefully that change is
going to be reflected on Renato’s side. RENATO MANGINI: Yes,
it did, sir. PAUL LEWIS: OK, and that’s all
the way to Brazil, so the internet pipes are
working today. RENATO MANGINI: And then I
just changed it again. PAUL LEWIS: Yes, it did. RENATO MANGINI: And hopefully
you get– PAUL LEWIS: So you can see
how easy this code is to integrate, and to use, and
to store simple values. So there you go. RENATO MANGINI: You might take
note that we are both logged in with the same user. PAUL LEWIS: Yes. PAUL LEWIS: It wouldn’t
work if we were different users, of course. It’s important to note. PAUL LEWIS: It is very
important to note. It’s a combination of the app
itself, of course, and the user that you’re logged
in as into Chrome. All right, so that is this
week’s demo done. MALE SPEAKER 3: Awesome. All right, so let’s bring up
the URL for that again so people can find that
if they go to– actually, let’s bring link for
the storage documentation, if you’re looking for the
documentation on the storage APIs, goo.gl/oXODY. You can see the capitalization
there. It’s small o, everything
else is capital. If you want to go and have a
look at the storage Hello World Sync that Paul just wrote
and showed you syncing between Paul and Renato from
London all the way down to Brazil, you can grab that
just there at the URL shown on screen. And as a reminder, one of the
other places where you can always go to get any of our
Chrome app samples is the Chrome app sample site,
which is up on GitHub. The link is there. Capital G, little m, capital
U, capital X, small t. So you can go grab those
and go from there. So from there, let’s take
some questions. Last week we didn’t
get enough time for all of your questions. So this week we wanted [? to ?]
put aside a bunch of extra time for your questions,
so that you could ask your questions. If you have questions that you
want to submit, you can go and submit them on moderator, either
through the Google Developers Live site or by
going to goo.gl/klubW– so klub W. I kind of want to
make a bad joke about that, but I won’t. And I’m getting at least a
little giggle out of Paul. So with that, I’m going to take
that off screen for sec, because it’s covering
me up nicely. And let’s take look at some
of the questions. All right, so these are your
questions, and I’m looking at them here on moderator. And the first question, “I have
an app which should only be available for a small group
of people, but now I’m forced to publish it through the Chrome
Web Store to avoid errors in warning. Is there really no other way?”
And this is from Russell. Renato, do you want
to take this one? RENATO MANGINI: Yes, sure. It’s possible to use
the Chrome Web Store inside the domain. I would ask you to check with
the Chrome Web Store team and to check on documentation,
how to do that. But currently, you cannot
publish a packaged app on the Chrome Web Store. So the store’s not complete yet,
on the Chrome Web Store for packaged apps. MALE SPEAKER 3: That’s for the
new evolved package apps. For legacy packaged apps, for
the existing packaged apps, you can still publish,
correct? RENATO MANGINI: Yes,
absolutely. MALE SPEAKER 3: OK. And then just to reiterate what
Renato said there, if you’re publishing an app and you
only want it available to a small group of people, you can
do that through the Google Apps account. So you need to set up a Google
Apps account for your domain, and then you can
do it that way. RENATO MANGINI: Yeah, there are
series of frustrations. They are describe it on
the documentation of Chrome Web Store. MALE SPEAKER 3: OK. RENATO MANGINI: But you can
do it in some cases. MALE SPEAKER 3: Cool. All right. So the next question, “Any way
to update your Chrome app manually, like the
user’s notified that there’s an update? And also is there any way you
can add features like feedback from users?” Paul, do you
want to take this one? PAUL LEWIS: Sure, I mean, right
now there isn’t a way to update the Chrome
App manually. I think it’s great feedback,
and we appreciate it. So we’d recommend that you file
a request with that in. And the same thing for the
feedback from users, if it’s in app, you could consider
requests server-side, but obviously we’d recommend
you do offline first, of course, as always. But certainly, we don’t have
any announcements on integrated feedback
in tier apps. RENATO MANGINI: Yeah. Can I complete your answer? PAUL LEWIS: Of course you can. RENATO MANGINI: Regarding
feedback from users, we have the full feedback assistant
on the Chrome Web Store. So when you publish your app,
you have to review and you have the feedback option on the
Chrome Web Store that was launched I think one month
or two months ago. It’s really new, I think. It’s the same for extensions
for legacy and hosted apps. And also, we are talking about
a better integration on feedback and mechanisms and
APIs and et cetera. But it’s not there yet. So for now or for the moment,
you upload your Chrome apps, packaged apps, you can use the
current Chrome Web Store feedback system. MALE SPEAKER 3: Cool. And might as well jump in on
this, there are a bunch of great web apps and web
development tools out there that will allow you to add that
to your existing site. So they add is just sort
of like a little bit of JavaScript that you
add to your page, and they go do that. Now with those, you’re going to
need to play carefully with some of those because they may
not necessarily work exactly as you’d expect in a Chrome
packaged app because of the Content Security Policy
restrictions. But they’re at least
worth a look at. So I’m going to take this next
question, only because it’s a kind of fun question to take. We’re missing one of our
favorite, favorite team members here right now. Paul Kinlan is not with us, so
I’m going to channel Paul Kinlan for this question. “So let’s say I’ve implemented
a simple text editor as a Chrome packaged app. Is there any way to expose
this app in the open-with context menu that shows up when
the user right clicks on a text file in file manager?” And the cool thing is,
“snitsyboo,” or also known as web intents– he’s not allowed to say web
intents anymore, because he’s just so focused on
web intents– but with the web intents, you
can actually say these types of files are able to be handled
by this application so that your Chrome packaged app
can open whatever type of file that you want to be
able to open. So you’re pretty much
set with that. I don’t think it’s quite enabled
in the builds yet, but it is something we’re
working on. And it is made on the roadmap
for something we’re going to do. PAUL LEWIS: Awesome. MALE SPEAKER 3: Cool. “Will apps introduce additional
features for platform integration? I want my app to look and
feel native.” Now this is from Russell. Paul, do you want to
take this one? PAUL LEWIS: Yeah. Yeah, so when you say look and
feel native, certainly we’re looking to do things like if
you talk about task manager type stuff and alt-tab type
behaviors, that’s definitely something that we’re working
hard to get in place so that these apps, it’s not sort of
necessarily launched from Chrome, and that it feels like
it’s sitting alongside the native apps that you
guys are building. In terms of the look and feel,
ultimately this is the Chrome runtime and the browser
has the crafting the look and feel. Obviously things like web
components as they come down the line, they may enable you to
build the look and feel of [INAUDIBLE] differently. But as you’d expect from
your normal web– RENATO MANGINI: Allows you to do
whatever you want with the window, including creating a
specific type of bar that looks like a native
application or no type of bar at all. MALE SPEAKER 3: Yeah,
that’s a good point. So with the apps, because they
don’t have the address bar anything like that, should
look native. And now it’s the matter of how
you style a lot of these things for them to look. All right. “In Canary packaged apps, we’re
not sure if we can embed a web app like Gmail and
expect all of its functionality to work right. Adobe AIR lets you load an
iframe from a local file and use a parent-child bridge for
coms.” Renato, I think we talked about this one earlier. Do you want to take this one? RENATO MANGINI: Yes,
absolutely. In fact, can you share
my screen? MALE SPEAKER 3: Yeah,
give me one sec to bring up your screen. And I think we have your screen
up, otherwise we have– RENATO MANGINI: I have
the Dojo application. MALE SPEAKER 3: Now we
have your screen up. RENATO MANGINI: All right. OK. So we have two solutions for
this problem you mentioned. We have the browser
tag, and we have the sent box of iframe. The sent box of iframe, you
use it for part of your application that you want to run
stuff that cannot run on application itself, like eval,
or new function, or dynamic JavaScript, so other ways
of [INAUDIBLE] scripts. And the browser tag, I think
it’s more appropriate for what you want. And we have this sample. It’s on the GitHub Web Store. It’s called the browser tag. And what it does, and I execute
it, this is the Chrome packaged app. It looks like a browser. And if I go to Gmail, I can
actually open Gmail inside the packaged app. So yeah, it does exactly
what you mentioned. I think this is what
you were expecting. If not, please send another
question or comment on the question. All right? And the code for the sample
is also available. You can look how it’s done. It’s pretty simple. MALE SPEAKER 3: All right. Cool. Well, thank you. All right, so let’s pop down
to the next question. “Does or will the storage
APIs support shared offline storage? For example, can a packaged app
from the same developer read state from other apps from
a unified offline store?” Renato, do you want to take
this one as well? RENATO MANGINI: Yeah, this is
a very good question indeed. And currently not, we don’t
allow it now, because we use the application key to restrict your send box to storage. And I would ask you to post a
bug on it on crbug.com, so we can track it. It looks like a very
common use case. We can discuss it with
the engineer team. MALE SPEAKER 3: Cool, yeah. All right. All right, let’s take
the next question. “Can packaged apps register
themselves as the default file handler for the type of file in
the external OS, either Mac or Windows?” So I think we
addressed this one with this “snitsyboo” stuff,
with web intents. You can register to be able to
open with or be able to handle a particular file type. If we didn’t answer that,
please be sure to submit another question and we
can go from there. So the next question, “Are
packaged apps eventually coming to Android, so we can
write one app in HTML5 and have it run in the browser,
mobile, and Chrome OS?” Paul, do you want to take
this question? PAUL LEWIS: Yeah, so this has
come up the last couple of weeks as well. We’re trying to get the
desktop story right. We don’t have any announcements,
dates, times or anything like that, any of the
platforms at this stage. We understand the feedback,
and we appreciate your feedback that you want to
write the code once. And certainly it’s something
we take the engineers team. So yeah. MALE SPEAKER 3: All
right, cool. So the next question is, “When
can I write packaged apps in Dart?” Well, you can
do it today. If you write your app in Dart
and you compile it down to JavaScript. You can’t run them natively in
Dart yet, but it is something that the Dart team
is aware of. They’ve heard the ask. I’m sure there’s probably a bug
in Cr Bug that’s already been filed. If there isn’t, go file the
bug and ask all of your friends to go star it, so that
the engineering team really sees how many people are
interested in this. Those kinds of things really
do help to drive the development of these things,
helps us to prioritize and understand what’s going on. All right, so let’s take
the next question. If you have any other questions,
please be sure to post them to the moderator. But the next question is “I
have a packaged app that displays generated content
in an iframe because of the new manifests. I get a Content Security Policy
error when it executes the JavaScript code in that
iframe.” Is there any info that we can help with this? PAUL LEWIS: It may be just
looking at this that there’s some inline JavaScript. As we talked about in the demo
and last week, any JavaScript needs to be taken from
inline and taken out to a separate file. That may be the cause of
some of this stuff. It may be that the JavaScript
and the iframe is doing something like eval or creating
a new function. So I think because there are a
number of possibilities of what this JavaScript code is
doing or what might be that it’s triggered. Post on the groups. We do strive to give a developer
help on there. And obviously community can
help you to debug whatever issue you’re facing. But generally speaking, it’s
definitely worth looking at the CSP restrictions and making
sure that your code is sitting inline with that. Because that may well be the
cause of what you’re seeing. MALE SPEAKER 3: All right. Well, it looks like that’s
the end of the questions. It’s almost out of
time anyways. So with that we’ll wrap up and
say guys, thank you very much for joining us. We’ll be here again next
Tuesday, same bat time, same bat place, so 9:00 Pacific. And we look forward to talking
to you more about Chrome apps. Next week, Paul, Renato, I think
the plan is to dive into some of the sample applications
that we’ve written that really use the
storage mechanisms. Isn’t that right? RENATO MANGINI: Yes, exactly. MALE SPEAKER 3: Yeah, so we’ll
take what we learned today and put that to a real
practical use. We’ll show you some really good
use cases, how to go use it, where it’s being used. So that you can get those
ideas and sort of start forming them into your head. So with– PAUL LEWIS: Actually. MALE SPEAKER 3: Paul? PAUL LEWIS: Sorry, I’m just
going to throw in that between now and then, how about play
with the samples, have a go at coding up some of this Chrome
Storage API stuff and let us know in the questions if you
run into anything that is unexpected or whatever, and
we’ll try and help you next week alongside looking
into those samples. So, take this week as an
opportunity to kind of dilute yourselves, and then we’ll
do what we can to help you next week. MALE SPEAKER 3: Awesome. All right, well, everybody,
thanks so much. Hope you have a great week and
look forward to seeing everybody next week. Bye, guys. RENATO MANGINI: Bye-bye.

Add a Comment

Your email address will not be published. Required fields are marked *