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

Side by Side Diff: chrome/browser/resources/md_history/app.crisper.js

Issue 2280513002: MD History: promote menu button to show clear browsing data in narrow mode (Closed)
Patch Set: go full vanilla Created 4 years, 3 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 function PromiseResolver() { 4 function PromiseResolver() {
5 this.resolve_; 5 this.resolve_;
6 this.reject_; 6 this.reject_;
7 this.promise_ = new Promise(function(resolve, reject) { 7 this.promise_ = new Promise(function(resolve, reject) {
8 this.resolve_ = resolve; 8 this.resolve_ = resolve;
9 this.reject_ = reject; 9 this.reject_ = reject;
10 }.bind(this)); 10 }.bind(this));
(...skipping 5369 matching lines...) Expand 10 before | Expand all | Expand 10 after
5380 } 5380 }
5381 }); 5381 });
5382 5382
5383 // Copyright 2016 The Chromium Authors. All rights reserved. 5383 // Copyright 2016 The Chromium Authors. All rights reserved.
5384 // Use of this source code is governed by a BSD-style license that can be 5384 // Use of this source code is governed by a BSD-style license that can be
5385 // found in the LICENSE file. 5385 // found in the LICENSE file.
5386 Polymer({ 5386 Polymer({
5387 is: 'cr-lazy-render', 5387 is: 'cr-lazy-render',
5388 "extends": 'template', 5388 "extends": 'template',
5389 behaviors: [ Polymer.Templatizer ], 5389 behaviors: [ Polymer.Templatizer ],
5390 _renderPromise: null, 5390 renderPromise_: null,
5391 _child: null, 5391 child_: null,
5392 get: function() { 5392 get: function() {
5393 if (!this._renderPromise) { 5393 if (!this.renderPromise_) {
5394 this._renderPromise = new Promise(function(resolve) { 5394 this.renderPromise_ = new Promise(function(resolve) {
5395 this._debounceTemplate(function() { 5395 this._debounceTemplate(function() {
5396 this._render(); 5396 this.render_();
5397 this._renderPromise = null; 5397 this.renderPromise_ = null;
5398 resolve(this.getIfExists()); 5398 resolve(this.getIfExists());
5399 }.bind(this)); 5399 }.bind(this));
5400 }.bind(this)); 5400 }.bind(this));
5401 } 5401 }
5402 return this._renderPromise; 5402 return this.renderPromise_;
5403 }, 5403 },
5404 getIfExists: function() { 5404 getIfExists: function() {
5405 return this._child; 5405 return this.child_;
5406 }, 5406 },
5407 _render: function() { 5407 render_: function() {
5408 if (!this.ctor) this.templatize(this); 5408 if (!this.ctor) this.templatize(this);
5409 var parentNode = this.parentNode; 5409 var parentNode = this.parentNode;
5410 if (parentNode && !this._child) { 5410 if (parentNode && !this.child_) {
5411 var instance = this.stamp({}); 5411 var instance = this.stamp({});
5412 this._child = instance.root.querySelector('*'); 5412 this.child_ = instance.root.firstElementChild;
5413 parentNode.insertBefore(instance.root, this); 5413 parentNode.insertBefore(instance.root, this);
5414 } 5414 }
5415 }, 5415 },
5416 _forwardParentProp: function(prop, value) { 5416 _forwardParentProp: function(prop, value) {
5417 if (this._child) this._child._templateInstance[prop] = value; 5417 if (this.child_) this.child_._templateInstance[prop] = value;
5418 }, 5418 },
5419 _forwardParentPath: function(path, value) { 5419 _forwardParentPath: function(path, value) {
5420 if (this._child) this._child._templateInstance.notifyPath(path, value, true) ; 5420 if (this.child_) this.child_._templateInstance.notifyPath(path, value, true) ;
5421 } 5421 }
5422 }); 5422 });
5423 5423
5424 (function() { 5424 (function() {
5425 'use strict'; 5425 'use strict';
5426 Polymer.IronA11yAnnouncer = Polymer({ 5426 Polymer.IronA11yAnnouncer = Polymer({
5427 is: 'iron-a11y-announcer', 5427 is: 'iron-a11y-announcer',
5428 properties: { 5428 properties: {
5429 mode: { 5429 mode: {
5430 type: String, 5430 type: String,
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
6052 // Copyright 2016 The Chromium Authors. All rights reserved. 6052 // Copyright 2016 The Chromium Authors. All rights reserved.
6053 // Use of this source code is governed by a BSD-style license that can be 6053 // Use of this source code is governed by a BSD-style license that can be
6054 // found in the LICENSE file. 6054 // found in the LICENSE file.
6055 Polymer({ 6055 Polymer({
6056 is: 'cr-toolbar', 6056 is: 'cr-toolbar',
6057 properties: { 6057 properties: {
6058 pageName: String, 6058 pageName: String,
6059 searchPrompt: String, 6059 searchPrompt: String,
6060 clearLabel: String, 6060 clearLabel: String,
6061 menuLabel: String, 6061 menuLabel: String,
6062 menuPromo: String,
6062 spinnerActive: Boolean, 6063 spinnerActive: Boolean,
6063 showMenu: { 6064 showMenu: {
6064 type: Boolean, 6065 type: Boolean,
6065 value: false 6066 value: false
6066 }, 6067 },
6068 showMenuPromo: {
6069 type: Boolean,
6070 value: false
6071 },
6072 closeMenuPromo: String,
6067 narrow_: { 6073 narrow_: {
6068 type: Boolean, 6074 type: Boolean,
6069 reflectToAttribute: true 6075 reflectToAttribute: true
6070 }, 6076 },
6071 showingSearch_: { 6077 showingSearch_: {
6072 type: Boolean, 6078 type: Boolean,
6073 reflectToAttribute: true 6079 reflectToAttribute: true
6074 } 6080 }
6075 }, 6081 },
6082 observers: [ 'possiblyShowMenuPromo_(showMenu, showMenuPromo, showingSearch_)' ],
6076 getSearchField: function() { 6083 getSearchField: function() {
6077 return this.$.search; 6084 return this.$.search;
6078 }, 6085 },
6079 onMenuTap_: function(e) { 6086 onClosePromoTap_: function() {
6087 this.showMenuPromo = false;
6088 },
6089 onMenuTap_: function() {
6080 this.fire('cr-menu-tap'); 6090 this.fire('cr-menu-tap');
6091 this.onClosePromoTap_();
6092 },
6093 possiblyShowMenuPromo_: function() {
6094 Polymer.RenderStatus.afterNextRender(this, function() {
6095 if (this.showMenu && this.showMenuPromo && !this.showingSearch_) {
6096 this.$$('#menuPromo').animate({
6097 opacity: [ 0, .9 ]
6098 }, {
6099 duration: 500,
6100 fill: 'forwards'
6101 });
6102 }
6103 }.bind(this));
6104 },
6105 titleIfNotShowMenuPromo_: function(title, showMenuPromo) {
6106 return showMenuPromo ? '' : title;
6081 } 6107 }
6082 }); 6108 });
6083 6109
6110 // Copyright 2016 The Chromium Authors. All rights reserved.
6111 // Use of this source code is governed by a BSD-style license that can be
6112 // found in the LICENSE file.
6113 cr.define('md_history', function() {
6114 function BrowserService() {
6115 this.pendingDeleteItems_ = null;
6116 this.pendingDeletePromise_ = null;
6117 }
6118 BrowserService.prototype = {
6119 deleteItems: function(items) {
6120 if (this.pendingDeleteItems_ != null) {
6121 return new Promise(function(resolve, reject) {
6122 reject(items);
6123 });
6124 }
6125 var removalList = items.map(function(item) {
6126 return {
6127 url: item.url,
6128 timestamps: item.allTimestamps
6129 };
6130 });
6131 this.pendingDeleteItems_ = items;
6132 this.pendingDeletePromise_ = new PromiseResolver();
6133 chrome.send('removeVisits', removalList);
6134 return this.pendingDeletePromise_.promise;
6135 },
6136 removeBookmark: function(url) {
6137 chrome.send('removeBookmark', [ url ]);
6138 },
6139 openForeignSessionAllTabs: function(sessionTag) {
6140 chrome.send('openForeignSession', [ sessionTag ]);
6141 },
6142 openForeignSessionTab: function(sessionTag, windowId, tabId, e) {
6143 chrome.send('openForeignSession', [ sessionTag, String(windowId), String(t abId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]);
6144 },
6145 deleteForeignSession: function(sessionTag) {
6146 chrome.send('deleteForeignSession', [ sessionTag ]);
6147 },
6148 openClearBrowsingData: function() {
6149 chrome.send('clearBrowsingData');
6150 },
6151 recordHistogram: function(histogram, value, max) {
6152 chrome.send('metricsHandler:recordInHistogram', [ histogram, value, max ]) ;
6153 },
6154 recordAction: function(action) {
6155 if (action.indexOf('_') == -1) action = 'HistoryPage_' + action;
6156 chrome.send('metricsHandler:recordAction', [ action ]);
6157 },
6158 resolveDelete_: function(successful) {
6159 if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null ) {
6160 return;
6161 }
6162 if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems _); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_);
6163 this.pendingDeleteItems_ = null;
6164 this.pendingDeletePromise_ = null;
6165 },
6166 menuPromoShown: function() {
6167 chrome.send('menuPromoShown');
6168 }
6169 };
6170 cr.addSingletonGetter(BrowserService);
6171 return {
6172 BrowserService: BrowserService
6173 };
6174 });
6175
6176 function deleteComplete() {
6177 md_history.BrowserService.getInstance().resolveDelete_(true);
6178 }
6179
6180 function deleteFailed() {
6181 md_history.BrowserService.getInstance().resolveDelete_(false);
6182 }
6183
6084 // Copyright 2015 The Chromium Authors. All rights reserved. 6184 // Copyright 2015 The Chromium Authors. All rights reserved.
6085 // Use of this source code is governed by a BSD-style license that can be 6185 // Use of this source code is governed by a BSD-style license that can be
6086 // found in the LICENSE file. 6186 // found in the LICENSE file.
6087 Polymer({ 6187 Polymer({
6088 is: 'history-toolbar', 6188 is: 'history-toolbar',
6089 properties: { 6189 properties: {
6090 count: { 6190 count: {
6091 type: Number, 6191 type: Number,
6092 value: 0, 6192 value: 0,
6093 observer: 'changeToolbarView_' 6193 observer: 'changeToolbarView_'
(...skipping 21 matching lines...) Expand all
6115 type: Boolean, 6215 type: Boolean,
6116 reflectToAttribute: true 6216 reflectToAttribute: true
6117 }, 6217 },
6118 groupedRange: { 6218 groupedRange: {
6119 type: Number, 6219 type: Number,
6120 value: 0, 6220 value: 0,
6121 reflectToAttribute: true, 6221 reflectToAttribute: true,
6122 notify: true 6222 notify: true
6123 }, 6223 },
6124 queryStartTime: String, 6224 queryStartTime: String,
6125 queryEndTime: String 6225 queryEndTime: String,
6226 showMenuPromo_: {
6227 type: Boolean,
6228 value: function() {
6229 return loadTimeData.getBoolean('showMenuPromo');
6230 }
6231 }
6126 }, 6232 },
6127 changeToolbarView_: function() { 6233 changeToolbarView_: function() {
6128 this.itemsSelected_ = this.count > 0; 6234 this.itemsSelected_ = this.count > 0;
6129 }, 6235 },
6130 setSearchTerm: function(search) { 6236 setSearchTerm: function(search) {
6131 if (this.searchTerm == search) return; 6237 if (this.searchTerm == search) return;
6132 this.searchTerm = search; 6238 this.searchTerm = search;
6133 var searchField = this.$['main-toolbar'].getSearchField(); 6239 var searchField = this.$['main-toolbar'].getSearchField();
6134 searchField.showAndFocus(); 6240 searchField.showAndFocus();
6135 searchField.setValue(search); 6241 searchField.setValue(search);
6136 }, 6242 },
6243 onMenuPromoShown_: function() {
6244 md_history.BrowserService.getInstance().menuPromoShown();
6245 },
6137 onSearchChanged_: function(event) { 6246 onSearchChanged_: function(event) {
6138 this.searchTerm = event.detail; 6247 this.searchTerm = event.detail;
6139 }, 6248 },
6140 onInfoButtonTap_: function() { 6249 onInfoButtonTap_: function() {
6141 this.$.syncNotice.get().then(function(dropdown) { 6250 this.$.syncNotice.get().then(function(dropdown) {
6142 dropdown.positionTarget = this.$$('#info-button-icon'); 6251 dropdown.positionTarget = this.$$('#info-button-icon');
6143 if (dropdown.style.display == 'none') dropdown.open(); 6252 if (dropdown.style.display == 'none') dropdown.open();
6144 }.bind(this)); 6253 }.bind(this));
6145 }, 6254 },
6146 onClearSelectionTap_: function() { 6255 onClearSelectionTap_: function() {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
6414 } 6523 }
6415 }; 6524 };
6416 6525
6417 Polymer.PaperItemBehavior = [ Polymer.IronButtonState, Polymer.IronControlState, Polymer.PaperItemBehaviorImpl ]; 6526 Polymer.PaperItemBehavior = [ Polymer.IronButtonState, Polymer.IronControlState, Polymer.PaperItemBehaviorImpl ];
6418 6527
6419 Polymer({ 6528 Polymer({
6420 is: 'paper-item', 6529 is: 'paper-item',
6421 behaviors: [ Polymer.PaperItemBehavior ] 6530 behaviors: [ Polymer.PaperItemBehavior ]
6422 }); 6531 });
6423 6532
6424 // Copyright 2016 The Chromium Authors. All rights reserved.
6425 // Use of this source code is governed by a BSD-style license that can be
6426 // found in the LICENSE file.
6427 cr.define('md_history', function() {
6428 function BrowserService() {
6429 this.pendingDeleteItems_ = null;
6430 this.pendingDeletePromise_ = null;
6431 }
6432 BrowserService.prototype = {
6433 deleteItems: function(items) {
6434 if (this.pendingDeleteItems_ != null) {
6435 return new Promise(function(resolve, reject) {
6436 reject(items);
6437 });
6438 }
6439 var removalList = items.map(function(item) {
6440 return {
6441 url: item.url,
6442 timestamps: item.allTimestamps
6443 };
6444 });
6445 this.pendingDeleteItems_ = items;
6446 this.pendingDeletePromise_ = new PromiseResolver();
6447 chrome.send('removeVisits', removalList);
6448 return this.pendingDeletePromise_.promise;
6449 },
6450 removeBookmark: function(url) {
6451 chrome.send('removeBookmark', [ url ]);
6452 },
6453 openForeignSessionAllTabs: function(sessionTag) {
6454 chrome.send('openForeignSession', [ sessionTag ]);
6455 },
6456 openForeignSessionTab: function(sessionTag, windowId, tabId, e) {
6457 chrome.send('openForeignSession', [ sessionTag, String(windowId), String(t abId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]);
6458 },
6459 deleteForeignSession: function(sessionTag) {
6460 chrome.send('deleteForeignSession', [ sessionTag ]);
6461 },
6462 openClearBrowsingData: function() {
6463 chrome.send('clearBrowsingData');
6464 },
6465 recordHistogram: function(histogram, value, max) {
6466 chrome.send('metricsHandler:recordInHistogram', [ histogram, value, max ]) ;
6467 },
6468 recordAction: function(action) {
6469 if (action.indexOf('_') == -1) action = 'HistoryPage_' + action;
6470 chrome.send('metricsHandler:recordAction', [ action ]);
6471 },
6472 resolveDelete_: function(successful) {
6473 if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null ) {
6474 return;
6475 }
6476 if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems _); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_);
6477 this.pendingDeleteItems_ = null;
6478 this.pendingDeletePromise_ = null;
6479 }
6480 };
6481 cr.addSingletonGetter(BrowserService);
6482 return {
6483 BrowserService: BrowserService
6484 };
6485 });
6486
6487 function deleteComplete() {
6488 md_history.BrowserService.getInstance().resolveDelete_(true);
6489 }
6490
6491 function deleteFailed() {
6492 md_history.BrowserService.getInstance().resolveDelete_(false);
6493 }
6494
6495 Polymer({ 6533 Polymer({
6496 is: 'iron-collapse', 6534 is: 'iron-collapse',
6497 behaviors: [ Polymer.IronResizableBehavior ], 6535 behaviors: [ Polymer.IronResizableBehavior ],
6498 properties: { 6536 properties: {
6499 horizontal: { 6537 horizontal: {
6500 type: Boolean, 6538 type: Boolean,
6501 value: false, 6539 value: false,
6502 observer: '_horizontalChanged' 6540 observer: '_horizontalChanged'
6503 }, 6541 },
6504 opened: { 6542 opened: {
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after
8685 8723
8686 case HistoryRange.MONTH: 8724 case HistoryRange.MONTH:
8687 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; 8725 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH;
8688 break; 8726 break;
8689 } 8727 }
8690 break; 8728 break;
8691 } 8729 }
8692 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END); 8730 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END);
8693 } 8731 }
8694 }); 8732 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698