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

Side by Side Diff: chrome/browser/resources/md_bookmarks/item.js

Issue 2872163002: MD Bookmarks: Add 'Open' command, to open in either the BMM or in new tabs (Closed)
Patch Set: Rebase Created 3 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Polymer({ 5 Polymer({
6 is: 'bookmarks-item', 6 is: 'bookmarks-item',
7 7
8 behaviors: [ 8 behaviors: [
9 bookmarks.StoreClient, 9 bookmarks.StoreClient,
10 ], 10 ],
(...skipping 11 matching lines...) Expand all
22 }, 22 },
23 23
24 /** @private */ 24 /** @private */
25 isSelectedItem_: { 25 isSelectedItem_: {
26 type: Boolean, 26 type: Boolean,
27 reflectToAttribute: true, 27 reflectToAttribute: true,
28 }, 28 },
29 29
30 /** @private */ 30 /** @private */
31 isFolder_: Boolean, 31 isFolder_: Boolean,
32
33 /** @private */
34 openItemUrl_: String,
32 }, 35 },
33 36
34 observers: [ 37 observers: [
35 'updateFavicon_(item_.url)', 38 'updateFavicon_(item_.url)',
36 ], 39 ],
37 40
38 listeners: { 41 listeners: {
39 'click': 'onClick_', 42 'click': 'onClick_',
40 'dblclick': 'onDblClick_', 43 'dblclick': 'onDblClick_',
41 'contextmenu': 'onContextMenu_', 44 'contextmenu': 'onContextMenu_',
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 onItemIdChanged_: function() { 102 onItemIdChanged_: function() {
100 // TODO(tsergeant): Add a histogram to measure whether this assertion fails 103 // TODO(tsergeant): Add a histogram to measure whether this assertion fails
101 // for real users. 104 // for real users.
102 assert(this.getState().nodes[this.itemId]); 105 assert(this.getState().nodes[this.itemId]);
103 this.updateFromStore(); 106 this.updateFromStore();
104 }, 107 },
105 108
106 /** @private */ 109 /** @private */
107 onItemChanged_: function() { 110 onItemChanged_: function() {
108 this.isFolder_ = !this.item_.url; 111 this.isFolder_ = !this.item_.url;
112 if (this.item_.url)
113 this.openItemUrl_ = this.item_.url;
114 else
115 this.openItemUrl_ = 'chrome://bookmarks/?id=' + this.itemId;
109 }, 116 },
110 117
111 /** 118 /**
112 * @param {Event} e 119 * @param {MouseEvent} e
113 * @private 120 * @private
114 */ 121 */
115 onClick_: function(e) { 122 onClick_: function(e) {
116 this.dispatch(bookmarks.actions.selectItem( 123 if (e.detail == 1) {
calamity 2017/05/17 05:09:23 Comment explaining what this is for. (What _is_ th
tsergeant 2017/05/17 07:04:38 When you double click, the browser fires two click
calamity 2017/05/19 03:47:58 Acknowledged.
117 this.itemId, e.ctrlKey, e.shiftKey, this.getState())); 124 this.dispatch(bookmarks.actions.selectItem(
125 this.itemId, e.ctrlKey, e.shiftKey, this.getState()));
126 }
118 e.stopPropagation(); 127 e.stopPropagation();
128 e.preventDefault();
119 }, 129 },
120 130
121 /** 131 /**
122 * @param {Event} e 132 * @param {MouseEvent} e
123 * @private 133 * @private
124 */ 134 */
125 onDblClick_: function(e) { 135 onDblClick_: function(e) {
126 if (!this.item_.url) { 136 var commandManager = bookmarks.CommandManager.getInstance();
127 this.dispatch( 137 var itemSet = this.getState().selection.items;
128 bookmarks.actions.selectFolder(this.item_.id, this.getState().nodes)); 138 if (commandManager.canExecute(Command.OPEN, itemSet))
129 } else { 139 commandManager.handle(Command.OPEN, itemSet);
130 chrome.tabs.create({url: this.item_.url});
131 }
132 }, 140 },
133 141
134 /** 142 /**
135 * @param {string} url 143 * @param {string} url
136 * @private 144 * @private
137 */ 145 */
138 updateFavicon_: function(url) { 146 updateFavicon_: function(url) {
139 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); 147 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url);
140 }, 148 },
141 }); 149 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698