Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * 'settings-downloads-page' is the settings page containing downloads | 7 * 'settings-downloads-page' is the settings page containing downloads |
| 8 * settings. | 8 * settings. |
| 9 * | 9 * |
| 10 * Example: | 10 * Example: |
| 11 * | 11 * |
| 12 * <iron-animated-pages> | 12 * <iron-animated-pages> |
| 13 * <settings-downloads-page prefs="{{prefs}}"> | 13 * <settings-downloads-page prefs="{{prefs}}"> |
| 14 * </settings-downloads-page> | 14 * </settings-downloads-page> |
| 15 * ... other pages ... | 15 * ... other pages ... |
| 16 * </iron-animated-pages> | 16 * </iron-animated-pages> |
| 17 */ | 17 */ |
| 18 Polymer({ | 18 Polymer({ |
| 19 is: 'settings-downloads-page', | 19 is: 'settings-downloads-page', |
| 20 | 20 |
| 21 behaviors: [WebUIListenerBehavior], | |
| 22 | |
| 21 properties: { | 23 properties: { |
| 22 /** | 24 /** |
| 23 * Preferences state. | 25 * Preferences state. |
| 24 */ | 26 */ |
| 25 prefs: { | 27 prefs: { |
| 26 type: Object, | 28 type: Object, |
| 27 notify: true, | 29 notify: true, |
| 28 }, | 30 }, |
| 29 | 31 |
| 30 /** | 32 /** |
| 31 * Dictionary defining page visibility. | 33 * Dictionary defining page visibility. |
| 32 * @type {!DownloadsPageVisibility} | 34 * @type {!DownloadsPageVisibility} |
| 33 */ | 35 */ |
| 34 pageVisibility: Object, | 36 pageVisibility: Object, |
| 37 | |
| 38 /** @private */ | |
| 39 autoOpenDownloads_: { | |
| 40 type: Boolean, | |
| 41 value: false, | |
| 42 }, | |
| 43 }, | |
| 44 | |
| 45 /** @override */ | |
| 46 attached: function() { | |
| 47 this.addWebUIListener('auto-open-downloads-changed', function(autoOpen) { | |
| 48 this.autoOpenDownloads_ = autoOpen; | |
| 49 }.bind(this)); | |
| 50 | |
| 51 chrome.send('initializeDownloads'); | |
|
Dan Beam
2017/02/27 05:50:36
don't chrome.send() directly
tommycli
2017/02/28 00:47:26
Done.
| |
| 35 }, | 52 }, |
| 36 | 53 |
| 37 /** @private */ | 54 /** @private */ |
| 38 selectDownloadLocation_: function() { | 55 selectDownloadLocation_: function() { |
| 39 chrome.send('selectDownloadLocation'); | 56 chrome.send('selectDownloadLocation'); |
| 40 }, | 57 }, |
| 41 | 58 |
| 42 // <if expr="chromeos"> | 59 // <if expr="chromeos"> |
| 43 /** | 60 /** |
| 44 * @param {string} path | 61 * @param {string} path |
| 45 * @return {string} The download location string that is suitable to display | 62 * @return {string} The download location string that is suitable to display |
| 46 * in the UI. | 63 * in the UI. |
| 47 * @private | 64 * @private |
| 48 */ | 65 */ |
| 49 getDownloadLocation_: function(path) { | 66 getDownloadLocation_: function(path) { |
| 50 // Replace /special/drive-<hash>/root with "Google Drive" for remote files, | 67 // Replace /special/drive-<hash>/root with "Google Drive" for remote files, |
| 51 // /home/chronos/user/Downloads or /home/chronos/u-<hash>/Downloads with | 68 // /home/chronos/user/Downloads or /home/chronos/u-<hash>/Downloads with |
| 52 // "Downloads" for local paths, and '/' with ' \u203a ' (angled quote sign) | 69 // "Downloads" for local paths, and '/' with ' \u203a ' (angled quote sign) |
| 53 // everywhere. It is used only for display purpose. | 70 // everywhere. It is used only for display purpose. |
| 54 path = path.replace(/^\/special\/drive[^\/]*\/root/, 'Google Drive'); | 71 path = path.replace(/^\/special\/drive[^\/]*\/root/, 'Google Drive'); |
| 55 path = path.replace(/^\/home\/chronos\/(user|u-[^\/]*)\//, ''); | 72 path = path.replace(/^\/home\/chronos\/(user|u-[^\/]*)\//, ''); |
| 56 path = path.replace(/\//g, ' \u203a '); | 73 path = path.replace(/\//g, ' \u203a '); |
| 57 return path; | 74 return path; |
| 58 }, | 75 }, |
| 59 // </if> | 76 // </if> |
| 77 | |
| 78 onClearAutoOpenFileTypesTap_: function() { | |
| 79 chrome.send('resetAutoOpenFileTypes'); | |
|
Dan Beam
2017/02/27 05:50:36
use a browser proxy
tommycli
2017/02/28 00:47:26
Done.
| |
| 80 }, | |
| 60 }); | 81 }); |
| OLD | NEW |