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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/extensions/mappy/popup.js
diff --git a/chrome/common/extensions/docs/examples/extensions/mappy/popup.js b/chrome/common/extensions/docs/examples/extensions/mappy/popup.js
new file mode 100644
index 0000000000000000000000000000000000000000..45663c3b5f8b4ecbd5bc59cab73fdcbc69a84052
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/extensions/mappy/popup.js
@@ -0,0 +1,45 @@
+// Copyright (c) 2011 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.
+
+var maps_key = "ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w";
+
+function gclient_geocode(address) {
+ var url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' +
+ encodeURIComponent(address) + '&sensor=false';
+ var request = new XMLHttpRequest();
+
+ request.open('GET', url, true);
+ console.log(url);
+ request.onreadystatechange = function (e) {
+ console.log(request, e);
+ if (request.readyState == 4) {
+ if (request.status == 200) {
+ var json = JSON.parse(request.responseText);
+ var latlng = json.results[0].geometry.location;
+ latlng = latlng.lat + ',' + latlng.lng;
+
+ var src = "https://maps.google.com/staticmap?center=" + latlng +
+ "&markers=" + latlng + "&zoom=14" +
+ "&size=512x512&sensor=false&key=" + maps_key;
+ var map = document.getElementById("map");
+
+ map.src = src;
+ map.addEventListener('click', function () {
+ window.close();
+ });
+ } else {
+ console.log('Unable to resolve address into lat/lng');
+ }
+ }
+ };
+ request.send(null);
+}
+
+function map() {
+ var address = chrome.extension.getBackgroundPage().selectedAddress;
+ if (address)
+ gclient_geocode(address);
+}
+
+window.onload = map;
« 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