summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/welcome/landing_view.js
blob: 94f6d4ad5e7b59e4e8edd2d2249746380c838bc9 (plain)
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
// 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: 'landing-view',

  behaviors: [welcome.NavigationBehavior],

  properties: {
    /** @private */
    signinAllowed_: {
      type: Boolean,
      value: () => loadTimeData.getBoolean('signinAllowed'),
    }
  },

  /** @private {?welcome.LandingViewProxy} */
  landingViewProxy_: null,

  /** @private {boolean} */
  finalized_: false,

  /** @override */
  ready() {
    this.landingViewProxy_ = welcome.LandingViewProxyImpl.getInstance();
  },

  onRouteEnter: function() {
    this.finalized_ = false;
    this.landingViewProxy_.recordPageShown();
  },

  onRouteUnload: function() {
    // Clicking on 'Returning user' will change the URL.
    if (this.finalized_) {
      return;
    }
    this.finalized_ = true;
    this.landingViewProxy_.recordNavigatedAway();
  },

  /** @private */
  onExistingUserClick_: function() {
    this.finalized_ = true;
    this.landingViewProxy_.recordExistingUser();
    if (this.signinAllowed_) {
      welcome.WelcomeBrowserProxyImpl.getInstance().handleActivateSignIn(
        'chrome://welcome/returning-user');
    } else {
      welcome.navigateTo(welcome.Routes.RETURNING_USER, 1);
    }
  },

  /** @private */
  onNewUserClick_: function() {
    this.finalized_ = true;
    this.landingViewProxy_.recordNewUser();
    welcome.navigateTo(welcome.Routes.NEW_USER, 1);
  }
});