Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / handler_options.js
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 cr.define('options', function() {
6   /** @const */ var Page = cr.ui.pageManager.Page;
7   /** @const */ var PageManager = cr.ui.pageManager.PageManager;
8
9   /////////////////////////////////////////////////////////////////////////////
10   // HandlerOptions class:
11
12   /**
13    * Encapsulated handling of handler options page.
14    * @constructor
15    */
16   function HandlerOptions() {
17     this.activeNavTab = null;
18     Page.call(this,
19               'handlers',
20               loadTimeData.getString('handlersPageTabTitle'),
21               'handler-options');
22   }
23
24   cr.addSingletonGetter(HandlerOptions);
25
26   HandlerOptions.prototype = {
27     __proto__: Page.prototype,
28
29     /**
30      * The handlers list.
31      * @type {options.HandlersList}
32      * @private
33      */
34     handlersList_: null,
35
36     /** @override */
37     initializePage: function() {
38       Page.prototype.initializePage.call(this);
39
40       this.createHandlersList_();
41
42       $('handler-options-overlay-confirm').onclick =
43           PageManager.closeOverlay.bind(PageManager);
44     },
45
46     /**
47      * Creates, decorates and initializes the handlers list.
48      * @private
49      */
50     createHandlersList_: function() {
51       this.handlersList_ = $('handlers-list');
52       options.HandlersList.decorate(this.handlersList_);
53       this.handlersList_.autoExpands = true;
54
55       this.ignoredHandlersList_ = $('ignored-handlers-list');
56       options.IgnoredHandlersList.decorate(this.ignoredHandlersList_);
57       this.ignoredHandlersList_.autoExpands = true;
58     },
59   };
60
61   /**
62    * Sets the list of handlers shown by the view.
63    * @param {Array} Handlers to be shown in the view.
64    */
65   HandlerOptions.setHandlers = function(handlers) {
66     $('handlers-list').setHandlers(handlers);
67   };
68
69   /**
70    * Sets the list of ignored handlers shown by the view.
71    * @param {Array} Handlers to be shown in the view.
72    */
73   HandlerOptions.setIgnoredHandlers = function(handlers) {
74     $('ignored-handlers-section').hidden = handlers.length == 0;
75     $('ignored-handlers-list').setHandlers(handlers);
76   };
77
78   return {
79     HandlerOptions: HandlerOptions
80   };
81 });