Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: chrome/common/extensions/docs/examples/extensions/mappy/popup.js

Issue 8311007: Adding `content_security_policy` to the "Mappy" sample. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebasing. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var maps_key = "ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr 4K0xyVKzUdnnuFl8X9PX0w";
6
7 function gclient_geocode(address) {
8 var url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' +
9 encodeURIComponent(address) + '&sensor=false';
10 var request = new XMLHttpRequest();
11
12 request.open('GET', url, true);
13 console.log(url);
14 request.onreadystatechange = function (e) {
15 console.log(request, e);
16 if (request.readyState == 4) {
17 if (request.status == 200) {
18 var json = JSON.parse(request.responseText);
19 var latlng = json.results[0].geometry.location;
20 latlng = latlng.lat + ',' + latlng.lng;
21
22 var src = "https://maps.google.com/staticmap?center=" + latlng +
23 "&markers=" + latlng + "&zoom=14" +
24 "&size=512x512&sensor=false&key=" + maps_key;
25 var map = document.getElementById("map");
26
27 map.src = src;
28 map.addEventListener('click', function () {
29 window.close();
30 });
31 } else {
32 console.log('Unable to resolve address into lat/lng');
33 }
34 }
35 };
36 request.send(null);
37 }
38
39 function map() {
40 var address = chrome.extension.getBackgroundPage().selectedAddress;
41 if (address)
42 gclient_geocode(address);
43 }
44
45 window.onload = map;
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/examples/extensions/mappy/popup.html ('k') | chrome/common/extensions/docs/samples.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698