summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/md_extensions/sidebar.js
blob: 622c5ec3ada68aacad544a66042d0a361752bf01 (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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright 2015 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() {
  /** @interface */
  var SidebarDelegate = function() {};

  SidebarDelegate.prototype = {
    /**
     * Toggles whether or not the profile is in developer mode.
     * @param {boolean} inDevMode
     */
    setProfileInDevMode: assertNotReached,

    /** Opens the dialog to load unpacked extensions. */
    loadUnpacked: assertNotReached,

    /** Opens the dialog to pack an extension. */
    packExtension: assertNotReached,

    /** Updates all extensions. */
    updateAllExtensions: assertNotReached,
  };

  /** @interface */
  var SidebarScrollDelegate = function() {};

  SidebarScrollDelegate.prototype = {
    /** Scrolls to the extensions section. */
    scrollToExtensions: assertNotReached,

    /** Scrolls to the apps section. */
    scrollToApps: assertNotReached,

    /** Scrolls to the websites section. */
    scrollToWebsites: assertNotReached,
  };

  var Sidebar = Polymer({
    is: 'extensions-sidebar',

    properties: {
      inDevMode: {
        type: Boolean,
        value: false,
      },

      hideExtensionsButton: {
        type: Boolean,
        value: false,
      },

      hideAppsButton: {
        type: Boolean,
        value: false,
      },

      hideWebsitesButton: {
        type: Boolean,
        value: false,
      },
    },

    behaviors: [
      I18nBehavior,
    ],

    /** @param {extensions.SidebarDelegate} delegate */
    setDelegate: function(delegate) {
      /** @private {extensions.SidebarDelegate} */
      this.delegate_ = delegate;
    },

    /** @param {extensions.SidebarScrollDelegate} scrollDelegate */
    setScrollDelegate: function(scrollDelegate) {
      /** @private {extensions.SidebarScrollDelegate} */
      this.scrollDelegate_ = scrollDelegate;
    },

    /** @private */
    onExtensionsTap_: function() {
      this.scrollDelegate_.scrollToExtensions();
    },

    /** @private */
    onAppsTap_: function() {
      this.scrollDelegate_.scrollToApps();
    },

    /** @private */
    onWebsitesTap_: function() {
      this.scrollDelegate_.scrollToWebsites();
    },

    /** @private */
    onDevModeChange_: function() {
      this.delegate_.setProfileInDevMode(
          this.$['developer-mode-checkbox'].checked);
    },

    /** @private */
    onLoadUnpackedTap_: function() {
      this.delegate_.loadUnpacked();
    },

    /** @private */
    onPackTap_: function() {
      this.delegate_.packExtension();
    },

    /** @private */
    onUpdateNowTap_: function() {
      this.delegate_.updateAllExtensions();
    },
  });

  return {
    Sidebar: Sidebar,
    SidebarDelegate: SidebarDelegate,
    SidebarScrollDelegate: SidebarScrollDelegate,
  };
});