1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 cr.define('options', function() {
6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
7 /** @const */ var OptionsPage = options.OptionsPage;
10 * This class is an overlay which allows the user to add or remove media
11 * galleries, and displays known media galleries.
13 * @extends {OptionsPage}
15 function MediaGalleriesManager() {
16 OptionsPage.call(this, 'manageGalleries',
17 loadTimeData.getString('manageMediaGalleriesTabTitle'),
18 'manage-media-galleries-overlay');
21 cr.addSingletonGetter(MediaGalleriesManager);
23 MediaGalleriesManager.prototype = {
24 __proto__: OptionsPage.prototype,
27 * Decorate the overlay and set up event handlers.
29 initializePage: function() {
30 OptionsPage.prototype.initializePage.call(this);
32 this.availableGalleriesList_ = $('available-galleries-list');
33 options.MediaGalleriesList.decorate(this.availableGalleriesList_);
35 $('new-media-gallery').addEventListener('click', function() {
36 chrome.send('addNewGallery');
39 $('manage-media-confirm').addEventListener(
40 'click', OptionsPage.closeOverlay.bind(OptionsPage));
42 this.addEventListener('visibleChange', this.handleVisibleChange_);
46 handleVisibleChange_: function() {
50 chrome.send('initializeMediaGalleries');
52 if (this.availableGalleriesList_)
53 this.availableGalleriesList_.redraw();
57 * @param {Array} galleries List of structs describibing galleries.
60 setAvailableMediaGalleries_: function(galleries) {
61 $('available-galleries-list').dataModel = new ArrayDataModel(galleries);
62 $('new-media-gallery').disabled = false;
63 $('media-galleries-section').hidden = false;
67 // Forward public APIs to private implementations.
69 'setAvailableMediaGalleries',
70 ].forEach(function(name) {
71 MediaGalleriesManager[name] = function() {
72 var instance = MediaGalleriesManager.getInstance();
73 return instance[name + '_'].apply(instance, arguments);
79 MediaGalleriesManager: MediaGalleriesManager