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

Side by Side Diff: chrome/browser/resources/options2/browser_options_profile_list.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.browser_options', function() {
6 /** @const */ var DeletableItem = options.DeletableItem;
7 /** @const */ var DeletableItemList = options.DeletableItemList;
8 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
9
10 /**
11 * Creates a new profile list item.
12 * @param {Object} profileInfo The profile this item respresents.
13 * @constructor
14 * @extends {cr.ui.DeletableItem}
15 */
16 function ProfileListItem(profileInfo) {
17 var el = cr.doc.createElement('div');
18 el.profileInfo_ = profileInfo;
19 ProfileListItem.decorate(el);
20 return el;
21 }
22
23 /**
24 * Decorates an element as a profile list item.
25 * @param {!HTMLElement} el The element to decorate.
26 */
27 ProfileListItem.decorate = function(el) {
28 el.__proto__ = ProfileListItem.prototype;
29 el.decorate();
30 };
31
32 ProfileListItem.prototype = {
33 __proto__: DeletableItem.prototype,
34
35 /**
36 * @type {string} the file path of this profile list item.
37 */
38 get profilePath() {
39 return this.profileInfo_.filePath;
40 },
41
42 /** @inheritDoc */
43 decorate: function() {
44 DeletableItem.prototype.decorate.call(this);
45
46 var profileInfo = this.profileInfo_;
47
48 var iconEl = this.ownerDocument.createElement('img');
49 iconEl.className = 'profile-img';
50 iconEl.src = profileInfo.iconURL;
51 this.contentElement.appendChild(iconEl);
52
53 var nameEl = this.ownerDocument.createElement('div');
54 if (profileInfo.isCurrentProfile)
55 nameEl.classList.add('profile-item-current');
56 this.contentElement.appendChild(nameEl);
57
58 var displayName = profileInfo.name;
59 if (profileInfo.isCurrentProfile) {
60 displayName = loadTimeData.getStringF('profilesListItemCurrent',
61 profileInfo.name);
62 }
63 nameEl.textContent = displayName;
64
65 // Ensure that the button cannot be tabbed to for accessibility reasons.
66 this.closeButtonElement.tabIndex = -1;
67 },
68 };
69
70 var ProfileList = cr.ui.define('list');
71
72 ProfileList.prototype = {
73 __proto__: DeletableItemList.prototype,
74
75 /** @inheritDoc */
76 decorate: function() {
77 DeletableItemList.prototype.decorate.call(this);
78 this.selectionModel = new ListSingleSelectionModel();
79 },
80
81 /** @inheritDoc */
82 createItem: function(pageInfo) {
83 var item = new ProfileListItem(pageInfo);
84 return item;
85 },
86
87 /** @inheritDoc */
88 deleteItemAtIndex: function(index) {
89 ManageProfileOverlay.showDeleteDialog(this.dataModel.item(index));
90 },
91
92 /** @inheritDoc */
93 activateItemAtIndex: function(index) {
94 // Don't allow the user to edit a profile that is not current.
95 var profileInfo = this.dataModel.item(index);
96 if (profileInfo.isCurrentProfile)
97 ManageProfileOverlay.showManageDialog(profileInfo);
98 },
99 };
100
101 return {
102 ProfileList: ProfileList
103 };
104 });
105
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698