| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 | 6 |
| 7 var OptionsPage = options.OptionsPage; | 7 var Page = cr.ui.pageManager.Page; |
| 8 var PageManager = cr.ui.pageManager.PageManager; |
| 8 | 9 |
| 9 ///////////////////////////////////////////////////////////////////////////// | 10 ///////////////////////////////////////////////////////////////////////////// |
| 10 // CookiesView class: | 11 // CookiesView class: |
| 11 | 12 |
| 12 /** | 13 /** |
| 13 * Encapsulated handling of the cookies and other site data page. | 14 * Encapsulated handling of the cookies and other site data page. |
| 14 * @constructor | 15 * @constructor |
| 15 */ | 16 */ |
| 16 function CookiesView(model) { | 17 function CookiesView(model) { |
| 17 OptionsPage.call(this, 'cookies', | 18 Page.call(this, 'cookies', |
| 18 loadTimeData.getString('cookiesViewPageTabTitle'), | 19 loadTimeData.getString('cookiesViewPageTabTitle'), |
| 19 'cookies-view-page'); | 20 'cookies-view-page'); |
| 20 } | 21 } |
| 21 | 22 |
| 22 cr.addSingletonGetter(CookiesView); | 23 cr.addSingletonGetter(CookiesView); |
| 23 | 24 |
| 24 CookiesView.prototype = { | 25 CookiesView.prototype = { |
| 25 __proto__: OptionsPage.prototype, | 26 __proto__: Page.prototype, |
| 26 | 27 |
| 27 /** | 28 /** |
| 28 * The timer id of the timer set on search query change events. | 29 * The timer id of the timer set on search query change events. |
| 29 * @type {number} | 30 * @type {number} |
| 30 * @private | 31 * @private |
| 31 */ | 32 */ |
| 32 queryDelayTimerId_: 0, | 33 queryDelayTimerId_: 0, |
| 33 | 34 |
| 34 /** | 35 /** |
| 35 * The most recent search query, empty string if the query is empty. | 36 * The most recent search query, empty string if the query is empty. |
| 36 * @type {string} | 37 * @type {string} |
| 37 * @private | 38 * @private |
| 38 */ | 39 */ |
| 39 lastQuery_: '', | 40 lastQuery_: '', |
| 40 | 41 |
| 41 /** @override */ | 42 /** @override */ |
| 42 initializePage: function() { | 43 initializePage: function() { |
| 43 OptionsPage.prototype.initializePage.call(this); | 44 Page.prototype.initializePage.call(this); |
| 44 | 45 |
| 45 var searchBox = this.pageDiv.querySelector('.cookies-search-box'); | 46 var searchBox = this.pageDiv.querySelector('.cookies-search-box'); |
| 46 searchBox.addEventListener( | 47 searchBox.addEventListener( |
| 47 'search', this.handleSearchQueryChange_.bind(this)); | 48 'search', this.handleSearchQueryChange_.bind(this)); |
| 48 searchBox.onkeydown = function(e) { | 49 searchBox.onkeydown = function(e) { |
| 49 // Prevent the overlay from handling this event. | 50 // Prevent the overlay from handling this event. |
| 50 if (e.keyIdentifier == 'Enter') | 51 if (e.keyIdentifier == 'Enter') |
| 51 e.stopPropagation(); | 52 e.stopPropagation(); |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 this.pageDiv.querySelector('.remove-all-cookies-button').onclick = | 55 this.pageDiv.querySelector('.remove-all-cookies-button').onclick = |
| 55 function(e) { | 56 function(e) { |
| 56 chrome.send('removeAllCookies'); | 57 chrome.send('removeAllCookies'); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 var cookiesList = this.pageDiv.querySelector('.cookies-list'); | 60 var cookiesList = this.pageDiv.querySelector('.cookies-list'); |
| 60 options.CookiesList.decorate(cookiesList); | 61 options.CookiesList.decorate(cookiesList); |
| 61 | 62 |
| 62 this.addEventListener('visibleChange', this.handleVisibleChange_); | 63 this.addEventListener('visibleChange', this.handleVisibleChange_); |
| 63 | 64 |
| 64 this.pageDiv.querySelector('.cookies-view-overlay-confirm').onclick = | 65 this.pageDiv.querySelector('.cookies-view-overlay-confirm').onclick = |
| 65 OptionsPage.closeOverlay.bind(OptionsPage); | 66 PageManager.closeOverlay.bind(PageManager); |
| 66 }, | 67 }, |
| 67 | 68 |
| 68 /** @override */ | 69 /** @override */ |
| 69 didShowPage: function() { | 70 didShowPage: function() { |
| 70 this.pageDiv.querySelector('.cookies-search-box').value = ''; | 71 this.pageDiv.querySelector('.cookies-search-box').value = ''; |
| 71 this.lastQuery_ = ''; | 72 this.lastQuery_ = ''; |
| 72 }, | 73 }, |
| 73 | 74 |
| 74 /** | 75 /** |
| 75 * Search cookie using text in |cookies-search-box|. | 76 * Search cookie using text in |cookies-search-box|. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 96 if (this.queryDelayTimerId_) | 97 if (this.queryDelayTimerId_) |
| 97 window.clearTimeout(this.queryDelayTimerId_); | 98 window.clearTimeout(this.queryDelayTimerId_); |
| 98 | 99 |
| 99 this.queryDelayTimerId_ = window.setTimeout( | 100 this.queryDelayTimerId_ = window.setTimeout( |
| 100 this.searchCookie.bind(this), 500); | 101 this.searchCookie.bind(this), 500); |
| 101 }, | 102 }, |
| 102 | 103 |
| 103 initialized_: false, | 104 initialized_: false, |
| 104 | 105 |
| 105 /** | 106 /** |
| 106 * Handler for OptionsPage's visible property change event. | 107 * Handler for Page's visible property change event. |
| 107 * @param {Event} e Property change event. | 108 * @param {Event} e Property change event. |
| 108 * @private | 109 * @private |
| 109 */ | 110 */ |
| 110 handleVisibleChange_: function(e) { | 111 handleVisibleChange_: function(e) { |
| 111 if (!this.visible) | 112 if (!this.visible) |
| 112 return; | 113 return; |
| 113 | 114 |
| 114 chrome.send('reloadCookies'); | 115 chrome.send('reloadCookies'); |
| 115 | 116 |
| 116 if (!this.initialized_) { | 117 if (!this.initialized_) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 136 CookiesView.loadChildren = function(args) { | 137 CookiesView.loadChildren = function(args) { |
| 137 $('cookies-list').loadChildren(args[0], args[1]); | 138 $('cookies-list').loadChildren(args[0], args[1]); |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 // Export | 141 // Export |
| 141 return { | 142 return { |
| 142 CookiesView: CookiesView | 143 CookiesView: CookiesView |
| 143 }; | 144 }; |
| 144 | 145 |
| 145 }); | 146 }); |
| OLD | NEW |