OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 * 'android-apps-page' is the settings page for enabling android apps. | 7 * 'android-apps-subpage' is the settings subpage for managing android apps. |
8 */ | 8 */ |
9 | 9 |
10 Polymer({ | 10 Polymer({ |
11 is: 'settings-android-apps-page', | 11 is: 'settings-android-apps-subpage', |
12 | 12 |
13 behaviors: [I18nBehavior, PrefsBehavior], | 13 behaviors: [I18nBehavior, PrefsBehavior], |
14 | 14 |
15 properties: { | 15 properties: { |
16 /** Preferences state. */ | 16 /** Preferences state. */ |
17 prefs: Object, | 17 prefs: Object, |
18 | 18 |
19 /** @private {!AndroidAppsInfo|undefined} */ | 19 /** @private {!AndroidAppsInfo|undefined} */ |
20 androidAppsInfo_: Object, | 20 androidAppsInfo: Object, |
| 21 |
| 22 /** @private */ |
| 23 dialogBody_: { |
| 24 type: String, |
| 25 value: function() { |
| 26 return this.i18nAdvanced( |
| 27 'androidAppsDisableDialogMessage', |
| 28 {substitutions: [], tags: ['br']}); |
| 29 } |
| 30 } |
21 }, | 31 }, |
22 | 32 |
23 /** @private {?settings.AndroidAppsBrowserProxy} */ | 33 /** @private {?settings.AndroidAppsBrowserProxy} */ |
24 browserProxy_: null, | 34 browserProxy_: null, |
25 | 35 |
26 /** @override */ | 36 /** @override */ |
27 created: function() { | 37 created: function() { |
28 this.browserProxy_ = settings.AndroidAppsBrowserProxyImpl.getInstance(); | 38 this.browserProxy_ = settings.AndroidAppsBrowserProxyImpl.getInstance(); |
29 }, | 39 }, |
30 | 40 |
31 /** @override */ | |
32 ready: function() { | |
33 cr.addWebUIListener( | |
34 'android-apps-info-update', this.androidAppsInfoUpdate_.bind(this)); | |
35 this.browserProxy_.requestAndroidAppsInfo(); | |
36 }, | |
37 | |
38 /** | |
39 * @param {AndroidAppsInfo} info | |
40 * @private | |
41 */ | |
42 androidAppsInfoUpdate_: function(info) { | |
43 this.androidAppsInfo_ = info; | |
44 }, | |
45 | |
46 /** | 41 /** |
47 * @param {Event} event | 42 * @param {Event} event |
48 * @private | 43 * @private |
49 */ | 44 */ |
50 onManageAndroidAppsKeydown_: function(event) { | 45 onManageAndroidAppsKeydown_: function(event) { |
51 if (event.key != 'Enter' && event.key != ' ') | 46 if (event.key != 'Enter' && event.key != ' ') |
52 return; | 47 return; |
53 this.browserProxy_.showAndroidAppsSettings(true /** keyboardAction */); | 48 this.browserProxy_.showAndroidAppsSettings(true /** keyboardAction */); |
54 event.stopPropagation(); | 49 event.stopPropagation(); |
55 }, | 50 }, |
56 | 51 |
57 /** @private */ | 52 /** @private */ |
58 onManageAndroidAppsTap_: function(event) { | 53 onManageAndroidAppsTap_: function(event) { |
59 this.browserProxy_.showAndroidAppsSettings(false /** keyboardAction */); | 54 this.browserProxy_.showAndroidAppsSettings(false /** keyboardAction */); |
60 }, | 55 }, |
61 | 56 |
62 /** | 57 /** |
63 * @return {string} | 58 * @return {boolean} |
64 * @private | 59 * @private |
65 */ | 60 */ |
66 getDialogBody_: function() { | 61 allowRemove_: function() { |
67 return this.i18nAdvanced( | 62 return this.prefs.arc.enabled.enforcement != |
68 'androidAppsDisableDialogMessage', {substitutions: [], tags: ['br']}); | 63 chrome.settingsPrivate.Enforcement.ENFORCED; |
69 }, | 64 }, |
70 | 65 |
71 /** | 66 /** |
72 * Handles the change event for the arc.enabled checkbox. Shows a | 67 * Shows a confirmation dialog when disabling android apps. |
73 * confirmation dialog when disabling the preference. | |
74 * @param {Event} event | 68 * @param {Event} event |
75 * @private | 69 * @private |
76 */ | 70 */ |
77 onArcEnabledChange_: function(event) { | 71 onRemoveTap_: function(event) { |
78 if (event.target.checked) { | |
79 /** @type {!SettingsCheckboxElement} */ (event.target).sendPrefChange(); | |
80 return; | |
81 } | |
82 this.$.confirmDisableDialog.showModal(); | 72 this.$.confirmDisableDialog.showModal(); |
83 }, | 73 }, |
84 | 74 |
85 /** | 75 /** |
86 * Handles the shared proxy confirmation dialog 'Confirm' button. | 76 * Handles the shared proxy confirmation dialog 'Confirm' button. |
87 * @private | 77 * @private |
88 */ | 78 */ |
89 onConfirmDisableDialogConfirm_: function() { | 79 onConfirmDisableDialogConfirm_: function() { |
90 /** @type {!SettingsCheckboxElement} */ (this.$.enabled).sendPrefChange(); | 80 this.setPrefValue('arc.enabled', false); |
91 this.$.confirmDisableDialog.close(); | 81 this.$.confirmDisableDialog.close(); |
| 82 settings.navigateToPreviousRoute(); |
92 }, | 83 }, |
93 | 84 |
94 /** | 85 /** |
95 * Handles the shared proxy confirmation dialog 'Cancel' button or a cancel | 86 * Handles the shared proxy confirmation dialog 'Cancel' button or a cancel |
96 * event. | 87 * event. |
97 * @private | 88 * @private |
98 */ | 89 */ |
99 onConfirmDisableDialogCancel_: function() { | 90 onConfirmDisableDialogCancel_: function() { |
100 /** @type {!SettingsCheckboxElement} */ (this.$.enabled).resetToPrefValue(); | |
101 this.$.confirmDisableDialog.close(); | 91 this.$.confirmDisableDialog.close(); |
102 }, | 92 }, |
103 | |
104 /** | |
105 * @param {!Event} e | |
106 * @private | |
107 */ | |
108 stopPropagation_: function(e) { | |
109 e.stopPropagation(); | |
110 }, | |
111 }); | 93 }); |
OLD | NEW |