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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// Copyright 2018 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.
Polymer({
is: 'nux-set-as-default',
behaviors: [
WebUIListenerBehavior,
welcome.NavigationBehavior,
],
properties: {
/** @type {welcome.stepIndicatorModel} */
indicatorModel: Object,
// <if expr="is_win">
isWin10: {
type: Boolean,
value: loadTimeData.getBoolean('is_win10'),
},
// </if>
},
/** @private {welcome.NuxSetAsDefaultProxy} */
browserProxy_: null,
/** @private {boolean} */
finalized_: false,
/** @override */
ready: function() {
this.browserProxy_ = welcome.NuxSetAsDefaultProxyImpl.getInstance();
this.addWebUIListener(
'browser-default-state-changed',
this.onDefaultBrowserChange_.bind(this));
},
onRouteEnter: function() {
this.finalized_ = false;
this.browserProxy_.recordPageShown();
},
onRouteExit: function() {
if (this.finalized_) {
return;
}
this.finalized_ = true;
this.browserProxy_.recordNavigatedAwayThroughBrowserHistory();
},
onRouteUnload: function() {
if (this.finalized_) {
return;
}
this.finalized_ = true;
this.browserProxy_.recordNavigatedAway();
},
/** @private */
onDeclineClick_: function() {
if (this.finalized_) {
return;
}
this.browserProxy_.recordSkip();
this.finished_();
},
/** @private */
onSetDefaultClick_: function() {
if (this.finalized_) {
return;
}
this.browserProxy_.recordBeginSetDefault();
this.browserProxy_.setAsDefault();
},
/**
* Automatically navigate to the next onboarding step once default changed.
* @param {!welcome.DefaultBrowserInfo} status
* @private
*/
onDefaultBrowserChange_: function(status) {
if (status.isDefault) {
this.browserProxy_.recordSuccessfullySetDefault();
// Triggers toast in the containing welcome-app.
this.fire('default-browser-change');
this.finished_();
return;
}
// <if expr="is_macosx">
// On Mac OS, we do not get a notification when the default browser changes.
// This will fake the notification.
window.setTimeout(() => {
this.browserProxy_.requestDefaultBrowserState().then(
this.onDefaultBrowserChange_.bind(this));
}, 100);
// </if>
},
/** @private */
finished_: function() {
this.finalized_ = true;
welcome.navigateToNextStep();
},
});
|