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. 4 5/** 6 * @typedef {{ 7 * default_handler: number, 8 * handlers: Array, 9 * has_policy_recommendations: boolean, 10 * is_default_handler_set_by_user: boolean, 11 * protocol: string 12 * }} 13 * @see chrome/browser/ui/webui/options/handler_options_handler.cc 14 */ 15var Handlers; 16 17cr.define('options', function() { 18 /** @const */ var Page = cr.ui.pageManager.Page; 19 /** @const */ var PageManager = cr.ui.pageManager.PageManager; 20 21 ///////////////////////////////////////////////////////////////////////////// 22 // HandlerOptions class: 23 24 /** 25 * Encapsulated handling of handler options page. 26 * @constructor 27 * @extends {cr.ui.pageManager.Page} 28 */ 29 function HandlerOptions() { 30 this.activeNavTab = null; 31 Page.call(this, 32 'handlers', 33 loadTimeData.getString('handlersPageTabTitle'), 34 'handler-options'); 35 } 36 37 cr.addSingletonGetter(HandlerOptions); 38 39 HandlerOptions.prototype = { 40 __proto__: Page.prototype, 41 42 /** 43 * The handlers list. 44 * @type {options.HandlersList} 45 * @private 46 */ 47 handlersList_: null, 48 49 /** @override */ 50 initializePage: function() { 51 Page.prototype.initializePage.call(this); 52 53 this.createHandlersList_(); 54 55 $('handler-options-overlay-confirm').onclick = 56 PageManager.closeOverlay.bind(PageManager); 57 }, 58 59 /** 60 * Creates, decorates and initializes the handlers list. 61 * @private 62 */ 63 createHandlersList_: function() { 64 var handlersList = $('handlers-list'); 65 options.HandlersList.decorate(handlersList); 66 this.handlersList_ = assertInstanceof(handlersList, options.HandlersList); 67 this.handlersList_.autoExpands = true; 68 69 var ignoredHandlersList = $('ignored-handlers-list'); 70 options.IgnoredHandlersList.decorate(ignoredHandlersList); 71 this.ignoredHandlersList_ = assertInstanceof(ignoredHandlersList, 72 options.IgnoredHandlersList); 73 this.ignoredHandlersList_.autoExpands = true; 74 }, 75 }; 76 77 /** 78 * Sets the list of handlers shown by the view. 79 * @param {Array.<Handlers>} handlers Handlers to be shown in the view. 80 */ 81 HandlerOptions.setHandlers = function(handlers) { 82 $('handlers-list').setHandlers(handlers); 83 }; 84 85 /** 86 * Sets the list of ignored handlers shown by the view. 87 * @param {Array} handlers Handlers to be shown in the view. 88 */ 89 HandlerOptions.setIgnoredHandlers = function(handlers) { 90 $('ignored-handlers-section').hidden = handlers.length == 0; 91 $('ignored-handlers-list').setHandlers(handlers); 92 }; 93 94 return { 95 HandlerOptions: HandlerOptions 96 }; 97}); 98