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

Side by Side Diff: ui/file_manager/file_manager/foreground/elements/files_safe_img.js

Issue 2269923002: Remove unused files: files_safe_img.{js,html} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused files: files_safe_img.{js,html} Created 4 years, 3 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
« no previous file with comments | « ui/file_manager/file_manager/foreground/elements/files_safe_img.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 FILES_APP_ORIGIN = 'chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj';
6
7 /**
8 * Polymer element to render an image securely inside webview.
9 * When tapped, files-safe-img-tap-inside or
10 * files-safe-img-tap-outside events are fired depending on the position
11 * of the tap.
12 */
13 var FilesSafeImg = Polymer({
14 is: 'files-safe-img',
15
16 properties: {
17 // URL accessible from webview.
18 src: {
19 type: String,
20 observer: 'onSrcChange_',
21 reflectToAttribute: true
22 }
23 },
24
25 listeners: {'src-changed': 'onSrcChange_'},
26
27 onSrcChange_: function() {
28 if (!this.src && this.webview_) {
29 // Remove webview to clean up unnecessary processes.
30 Polymer.dom(this.$.content).removeChild(this.webview_);
31 this.webview_ = null;
32 } else if (this.src && !this.webview_) {
33 // Create webview node only if src exists to save resouces.
34 var webview = document.createElement('webview');
35 this.webview_ = webview;
36 webview.partition = 'trusted';
37 webview.allowtransparency = 'true';
38 Polymer.dom(this.$.content).appendChild(webview);
39 webview.addEventListener(
40 'contentload', this.onSrcChange_.bind(this));
41 webview.src = 'foreground/elements/files_safe_img_webview_content.html';
42 } else if (this.src && this.webview_.contentWindow) {
43 this.webview_.contentWindow.postMessage(this.src, FILES_APP_ORIGIN);
44 }
45 },
46
47 created: function() {
48 /**
49 * @type {HTMLElement}
50 */
51 this.webview_ = null;
52 },
53
54 ready: function() {
55 window.addEventListener('message', function(event) {
56 if (event.origin !== FILES_APP_ORIGIN) {
57 console.error('Unknown origin.');
58 return;
59 }
60 if (event.data === 'tap-inside') {
61 this.fire('files-safe-img-tap-inside');
62 } else if (event.data === 'tap-outside') {
63 this.fire('files-safe-img-tap-outside');
64 }
65 }.bind(this));
66 }
67 });
OLDNEW
« no previous file with comments | « ui/file_manager/file_manager/foreground/elements/files_safe_img.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698