1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// Copyright 2017 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.
cr.define('extensions', function() {
'use strict';
const PackDialogAlert = Polymer({
is: 'extensions-pack-dialog-alert',
properties: {
/** @private {chrome.developerPrivate.PackDirectoryResponse} */
model: Object,
/** @private */
title_: String,
/** @private */
message_: String,
/** @private {?string} */
cancelLabel_: String,
/**
* This needs to be initialized to trigger data-binding.
* @private {?string}
*/
confirmLabel_: {
type: String,
value: '',
}
},
/** @return {string} */
get returnValue() {
return /** @type {!CrDialogElement} */ (this.$.dialog)
.getNative()
.returnValue;
},
/** @override */
ready: function() {
// Initialize button label values for initial html binding.
this.cancelLabel_ = null;
this.confirmLabel_ = null;
switch (this.model.status) {
case chrome.developerPrivate.PackStatus.WARNING:
this.title_ = loadTimeData.getString('packDialogWarningTitle');
this.cancelLabel_ = loadTimeData.getString('cancel');
this.confirmLabel_ =
loadTimeData.getString('packDialogProceedAnyway');
break;
case chrome.developerPrivate.PackStatus.ERROR:
this.title_ = loadTimeData.getString('packDialogErrorTitle');
this.cancelLabel_ = loadTimeData.getString('ok');
break;
case chrome.developerPrivate.PackStatus.SUCCESS:
this.title_ = loadTimeData.getString('packDialogTitle');
this.cancelLabel_ = loadTimeData.getString('ok');
break;
default:
assertNotReached();
return;
}
},
/** @override */
attached: function() {
this.$.dialog.showModal();
},
/**
* @return {string}
* @private
*/
getCancelButtonClass_: function() {
return this.confirmLabel_ ? 'cancel-button' : 'action-button';
},
/** @private */
onCancelTap_: function() {
this.$.dialog.cancel();
},
/** @private */
onConfirmTap_: function() {
// The confirm button should only be available in WARNING state.
assert(this.model.status === chrome.developerPrivate.PackStatus.WARNING);
this.$.dialog.close();
}
});
return {PackDialogAlert: PackDialogAlert};
});
|