Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: chrome/browser/resources/options2/cookies_view.js

Issue 10809005: Options: Rename chrome/browser/resources/options2 -> chrome/browser/resources/options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
7 var OptionsPage = options.OptionsPage;
8
9 /////////////////////////////////////////////////////////////////////////////
10 // CookiesView class:
11
12 /**
13 * Encapsulated handling of the cookies and other site data page.
14 * @constructor
15 */
16 function CookiesView(model) {
17 OptionsPage.call(this, 'cookies',
18 loadTimeData.getString('cookiesViewPageTabTitle'),
19 'cookies-view-page');
20 }
21
22 cr.addSingletonGetter(CookiesView);
23
24 CookiesView.prototype = {
25 __proto__: OptionsPage.prototype,
26
27 /**
28 * The timer id of the timer set on search query change events.
29 * @type {number}
30 * @private
31 */
32 queryDelayTimerId_: 0,
33
34 /**
35 * The most recent search query, empty string if the query is empty.
36 * @type {string}
37 * @private
38 */
39 lastQuery_: '',
40
41 initializePage: function() {
42 OptionsPage.prototype.initializePage.call(this);
43
44 this.pageDiv.querySelector('.cookies-search-box').addEventListener(
45 'search', this.handleSearchQueryChange_.bind(this));
46
47 this.pageDiv.querySelector('.remove-all-cookies-button').onclick =
48 function(e) {
49 chrome.send('removeAllCookies');
50 };
51
52 var cookiesList = this.pageDiv.querySelector('.cookies-list');
53 options.CookiesList.decorate(cookiesList);
54
55 this.addEventListener('visibleChange', this.handleVisibleChange_);
56
57 this.pageDiv.querySelector('.cookies-view-overlay-confirm').onclick =
58 OptionsPage.closeOverlay.bind(OptionsPage);
59 },
60
61 /**
62 * Clear search filter when the dialog is displayed.
63 * @inheritDoc
64 */
65 didShowPage: function() {
66 this.pageDiv.querySelector('.cookies-search-box').value = '';
67 },
68
69 /**
70 * Search cookie using text in |cookies-search-box|.
71 */
72 searchCookie: function() {
73 this.queryDelayTimerId_ = 0;
74 var filter = this.pageDiv.querySelector('.cookies-search-box').value;
75 if (this.lastQuery_ != filter) {
76 this.lastQuery_ = filter;
77 chrome.send('updateCookieSearchResults', [filter]);
78 }
79 },
80
81 /**
82 * Handles search query changes.
83 * @param {!Event} e The event object.
84 * @private
85 */
86 handleSearchQueryChange_: function(e) {
87 if (this.queryDelayTimerId_)
88 window.clearTimeout(this.queryDelayTimerId_);
89
90 this.queryDelayTimerId_ = window.setTimeout(
91 this.searchCookie.bind(this), 500);
92 },
93
94 initialized_: false,
95
96 /**
97 * Handler for OptionsPage's visible property change event.
98 * @param {Event} e Property change event.
99 * @private
100 */
101 handleVisibleChange_: function(e) {
102 if (!this.visible)
103 return;
104
105 // Inform the CookiesViewHandler whether we are operating in regular
106 // cookies dialog or the apps one.
107 chrome.send('setViewContext', [this.isAppContext()]);
108
109 chrome.send('reloadCookies');
110
111 if (!this.initialized_) {
112 this.initialized_ = true;
113 this.searchCookie();
114 } else {
115 this.pageDiv.querySelector('.cookies-list').redraw();
116 }
117
118 this.pageDiv.querySelector('.cookies-search-box').focus();
119 },
120
121 isAppContext: function() {
122 return false;
123 },
124 };
125
126 // CookiesViewHandler callbacks.
127 CookiesView.onTreeItemAdded = function(args) {
128 $('cookies-list').addByParentId(args[0], args[1], args[2]);
129 };
130
131 CookiesView.onTreeItemRemoved = function(args) {
132 $('cookies-list').removeByParentId(args[0], args[1], args[2]);
133 };
134
135 CookiesView.loadChildren = function(args) {
136 $('cookies-list').loadChildren(args[0], args[1]);
137 };
138
139 // Export
140 return {
141 CookiesView: CookiesView
142 };
143
144 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options2/cookies_view.html ('k') | chrome/browser/resources/options2/cookies_view_app.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698