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

Side by Side Diff: chrome/test/data/extensions/platform_apps/web_view/download/embedder.js

Issue 13037003: permissionrequest API for guest Download. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync @tott Created 7 years, 8 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 2013 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 embedder = {};
6 embedder.baseGuestURL = '';
7 embedder.guestURL = '';
8
9 /** @private */
10 embedder.setUpGuest_ = function() {
11 document.querySelector('#webview-tag-container').innerHTML =
12 '<webview style="width: 100px; height: 100px;"' +
13 ' src="' + embedder.guestURL + '"' +
14 '></webview>';
15 var webview = document.querySelector('webview');
16 if (!webview) {
17 chrome.test.fail('No <webview> element created');
18 return null;
19 }
20
21 webview.addEventListener('permissionrequest', function(e) {
22 if (e.permission == 'download') {
23 var url = e.url;
24 if (url.indexOf('expect-deny.zip') != -1) {
25 e.request.deny();
26 } else if (url.indexOf('expect-allow.zip') != -1) {
27 e.request.allow();
28 } else {
29 // Ignore.
30 }
31 }
32 });
33 return webview;
34 };
35
36 onload = function() {
37 chrome.test.getConfig(function(config) {
38 embedder.baseGuestURL = 'http://localhost:' + config.testServer.port;
39 embedder.guestURL = embedder.baseGuestURL +
40 '/files/extensions/platform_apps/web_view/download/guest.html';
41 embedder.setUpGuest_();
42 });
43 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698