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

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: damn it 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 6038 matching lines...) Expand 10 before | Expand all | Expand 10 after
6049 // Copyright 2016 The Chromium Authors. All rights reserved. 6049 // Copyright 2016 The Chromium Authors. All rights reserved.
6050 // Use of this source code is governed by a BSD-style license that can be 6050 // Use of this source code is governed by a BSD-style license that can be
6051 // found in the LICENSE file. 6051 // found in the LICENSE file.
6052 Polymer({ 6052 Polymer({
6053 is: 'cr-toolbar', 6053 is: 'cr-toolbar',
6054 properties: { 6054 properties: {
6055 pageName: String, 6055 pageName: String,
6056 searchPrompt: String, 6056 searchPrompt: String,
6057 clearLabel: String, 6057 clearLabel: String,
6058 menuLabel: String, 6058 menuLabel: String,
6059 menuPromo: String,
6059 spinnerActive: Boolean, 6060 spinnerActive: Boolean,
6060 showMenu: { 6061 showMenu: {
6061 type: Boolean, 6062 type: Boolean,
6062 value: false 6063 value: false
6063 }, 6064 },
6065 showMenuPromo: {
6066 type: Boolean,
6067 value: false
6068 },
6069 closeMenuPromo: String,
6064 narrow_: { 6070 narrow_: {
6065 type: Boolean, 6071 type: Boolean,
6066 reflectToAttribute: true 6072 reflectToAttribute: true
6067 }, 6073 },
6068 showingSearch_: { 6074 showingSearch_: {
6069 type: Boolean, 6075 type: Boolean,
6070 reflectToAttribute: true 6076 reflectToAttribute: true
6071 } 6077 }
6072 }, 6078 },
6079 observers: [ 'possiblyShowMenuPromo_(showMenu, showMenuPromo, showingSearch_)' ],
6073 getSearchField: function() { 6080 getSearchField: function() {
6074 return this.$.search; 6081 return this.$.search;
6075 }, 6082 },
6076 onMenuTap_: function(e) { 6083 onClosePromoTap_: function() {
6084 this.showMenuPromo = false;
6085 },
6086 onMenuTap_: function() {
6077 this.fire('cr-menu-tap'); 6087 this.fire('cr-menu-tap');
6088 this.onClosePromoTap_();
6089 },
6090 possiblyShowMenuPromo_: function() {
6091 Polymer.RenderStatus.afterNextRender(this, function() {
6092 if (this.showMenu && this.showMenuPromo && !this.showingSearch_) {
6093 this.$$('#menuPromo').animate({
6094 opacity: [ 0, .9 ]
6095 }, {
6096 duration: 500,
6097 fill: 'forwards'
6098 });
6099 this.fire('cr-menu-promo-shown');
6100 }
6101 }.bind(this));
6102 },
6103 titleIfNotShowMenuPromo_: function(title, showMenuPromo) {
6104 return showMenuPromo ? '' : title;
6078 } 6105 }
6079 }); 6106 });
6080 6107
6108 // Copyright 2016 The Chromium Authors. All rights reserved.
6109 // Use of this source code is governed by a BSD-style license that can be
6110 // found in the LICENSE file.
6111 cr.define('md_history', function() {
6112 function BrowserService() {
6113 this.pendingDeleteItems_ = null;
6114 this.pendingDeletePromise_ = null;
6115 }
6116 BrowserService.prototype = {
6117 deleteItems: function(items) {
6118 if (this.pendingDeleteItems_ != null) {
6119 return new Promise(function(resolve, reject) {
6120 reject(items);
6121 });
6122 }
6123 var removalList = items.map(function(item) {
6124 return {
6125 url: item.url,
6126 timestamps: item.allTimestamps
6127 };
6128 });
6129 this.pendingDeleteItems_ = items;
6130 this.pendingDeletePromise_ = new PromiseResolver();
6131 chrome.send('removeVisits', removalList);
6132 return this.pendingDeletePromise_.promise;
6133 },
6134 removeBookmark: function(url) {
6135 chrome.send('removeBookmark', [ url ]);
6136 },
6137 openForeignSessionAllTabs: function(sessionTag) {
6138 chrome.send('openForeignSession', [ sessionTag ]);
6139 },
6140 openForeignSessionTab: function(sessionTag, windowId, tabId, e) {
6141 chrome.send('openForeignSession', [ sessionTag, String(windowId), String(t abId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]);
6142 },
6143 deleteForeignSession: function(sessionTag) {
6144 chrome.send('deleteForeignSession', [ sessionTag ]);
6145 },
6146 openClearBrowsingData: function() {
6147 chrome.send('clearBrowsingData');
6148 },
6149 recordHistogram: function(histogram, value, max) {
6150 chrome.send('metricsHandler:recordInHistogram', [ histogram, value, max ]) ;
6151 },
6152 recordAction: function(action) {
6153 if (action.indexOf('_') == -1) action = 'HistoryPage_' + action;
6154 chrome.send('metricsHandler:recordAction', [ action ]);
6155 },
6156 resolveDelete_: function(successful) {
6157 if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null ) {
6158 return;
6159 }
6160 if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems _); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_);
6161 this.pendingDeleteItems_ = null;
6162 this.pendingDeletePromise_ = null;
6163 },
6164 menuPromoShown: function() {
6165 chrome.send('menuPromoShown');
6166 }
6167 };
6168 cr.addSingletonGetter(BrowserService);
6169 return {
6170 BrowserService: BrowserService
6171 };
6172 });
6173
6174 function deleteComplete() {
6175 md_history.BrowserService.getInstance().resolveDelete_(true);
6176 }
6177
6178 function deleteFailed() {
6179 md_history.BrowserService.getInstance().resolveDelete_(false);
6180 }
6181
6081 // Copyright 2015 The Chromium Authors. All rights reserved. 6182 // Copyright 2015 The Chromium Authors. All rights reserved.
6082 // Use of this source code is governed by a BSD-style license that can be 6183 // Use of this source code is governed by a BSD-style license that can be
6083 // found in the LICENSE file. 6184 // found in the LICENSE file.
6084 Polymer({ 6185 Polymer({
6085 is: 'history-toolbar', 6186 is: 'history-toolbar',
6086 properties: { 6187 properties: {
6087 count: { 6188 count: {
6088 type: Number, 6189 type: Number,
6089 value: 0, 6190 value: 0,
6090 observer: 'changeToolbarView_' 6191 observer: 'changeToolbarView_'
(...skipping 21 matching lines...) Expand all
6112 type: Boolean, 6213 type: Boolean,
6113 reflectToAttribute: true 6214 reflectToAttribute: true
6114 }, 6215 },
6115 groupedRange: { 6216 groupedRange: {
6116 type: Number, 6217 type: Number,
6117 value: 0, 6218 value: 0,
6118 reflectToAttribute: true, 6219 reflectToAttribute: true,
6119 notify: true 6220 notify: true
6120 }, 6221 },
6121 queryStartTime: String, 6222 queryStartTime: String,
6122 queryEndTime: String 6223 queryEndTime: String,
6224 showMenuPromo_: {
6225 type: Boolean,
6226 value: function() {
6227 return loadTimeData.getBoolean('showMenuPromo');
6228 }
6229 }
6123 }, 6230 },
6124 changeToolbarView_: function() { 6231 changeToolbarView_: function() {
6125 this.itemsSelected_ = this.count > 0; 6232 this.itemsSelected_ = this.count > 0;
6126 }, 6233 },
6127 setSearchTerm: function(search) { 6234 setSearchTerm: function(search) {
6128 if (this.searchTerm == search) return; 6235 if (this.searchTerm == search) return;
6129 this.searchTerm = search; 6236 this.searchTerm = search;
6130 var searchField = this.$['main-toolbar'].getSearchField(); 6237 var searchField = this.$['main-toolbar'].getSearchField();
6131 searchField.showAndFocus(); 6238 searchField.showAndFocus();
6132 searchField.setValue(search); 6239 searchField.setValue(search);
6133 }, 6240 },
6241 onMenuPromoShown_: function() {
6242 md_history.BrowserService.getInstance().menuPromoShown();
6243 },
6134 onSearchChanged_: function(event) { 6244 onSearchChanged_: function(event) {
6135 this.searchTerm = event.detail; 6245 this.searchTerm = event.detail;
6136 }, 6246 },
6137 onInfoButtonTap_: function() { 6247 onInfoButtonTap_: function() {
6138 var dropdown = this.$.syncNotice.get(); 6248 var dropdown = this.$.syncNotice.get();
6139 dropdown.positionTarget = this.$$('#info-button-icon'); 6249 dropdown.positionTarget = this.$$('#info-button-icon');
6140 if (dropdown.style.display == 'none') dropdown.open(); 6250 if (dropdown.style.display == 'none') dropdown.open();
6141 }, 6251 },
6142 onClearSelectionTap_: function() { 6252 onClearSelectionTap_: function() {
6143 this.fire('unselect-all'); 6253 this.fire('unselect-all');
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
6410 } 6520 }
6411 }; 6521 };
6412 6522
6413 Polymer.PaperItemBehavior = [ Polymer.IronButtonState, Polymer.IronControlState, Polymer.PaperItemBehaviorImpl ]; 6523 Polymer.PaperItemBehavior = [ Polymer.IronButtonState, Polymer.IronControlState, Polymer.PaperItemBehaviorImpl ];
6414 6524
6415 Polymer({ 6525 Polymer({
6416 is: 'paper-item', 6526 is: 'paper-item',
6417 behaviors: [ Polymer.PaperItemBehavior ] 6527 behaviors: [ Polymer.PaperItemBehavior ]
6418 }); 6528 });
6419 6529
6420 // Copyright 2016 The Chromium Authors. All rights reserved.
6421 // Use of this source code is governed by a BSD-style license that can be
6422 // found in the LICENSE file.
6423 cr.define('md_history', function() {
6424 function BrowserService() {
6425 this.pendingDeleteItems_ = null;
6426 this.pendingDeletePromise_ = null;
6427 }
6428 BrowserService.prototype = {
6429 deleteItems: function(items) {
6430 if (this.pendingDeleteItems_ != null) {
6431 return new Promise(function(resolve, reject) {
6432 reject(items);
6433 });
6434 }
6435 var removalList = items.map(function(item) {
6436 return {
6437 url: item.url,
6438 timestamps: item.allTimestamps
6439 };
6440 });
6441 this.pendingDeleteItems_ = items;
6442 this.pendingDeletePromise_ = new PromiseResolver();
6443 chrome.send('removeVisits', removalList);
6444 return this.pendingDeletePromise_.promise;
6445 },
6446 removeBookmark: function(url) {
6447 chrome.send('removeBookmark', [ url ]);
6448 },
6449 openForeignSessionAllTabs: function(sessionTag) {
6450 chrome.send('openForeignSession', [ sessionTag ]);
6451 },
6452 openForeignSessionTab: function(sessionTag, windowId, tabId, e) {
6453 chrome.send('openForeignSession', [ sessionTag, String(windowId), String(t abId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]);
6454 },
6455 deleteForeignSession: function(sessionTag) {
6456 chrome.send('deleteForeignSession', [ sessionTag ]);
6457 },
6458 openClearBrowsingData: function() {
6459 chrome.send('clearBrowsingData');
6460 },
6461 recordHistogram: function(histogram, value, max) {
6462 chrome.send('metricsHandler:recordInHistogram', [ histogram, value, max ]) ;
6463 },
6464 recordAction: function(action) {
6465 if (action.indexOf('_') == -1) action = 'HistoryPage_' + action;
6466 chrome.send('metricsHandler:recordAction', [ action ]);
6467 },
6468 resolveDelete_: function(successful) {
6469 if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null ) {
6470 return;
6471 }
6472 if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems _); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_);
6473 this.pendingDeleteItems_ = null;
6474 this.pendingDeletePromise_ = null;
6475 }
6476 };
6477 cr.addSingletonGetter(BrowserService);
6478 return {
6479 BrowserService: BrowserService
6480 };
6481 });
6482
6483 function deleteComplete() {
6484 md_history.BrowserService.getInstance().resolveDelete_(true);
6485 }
6486
6487 function deleteFailed() {
6488 md_history.BrowserService.getInstance().resolveDelete_(false);
6489 }
6490
6491 Polymer({ 6530 Polymer({
6492 is: 'iron-collapse', 6531 is: 'iron-collapse',
6493 behaviors: [ Polymer.IronResizableBehavior ], 6532 behaviors: [ Polymer.IronResizableBehavior ],
6494 properties: { 6533 properties: {
6495 horizontal: { 6534 horizontal: {
6496 type: Boolean, 6535 type: Boolean,
6497 value: false, 6536 value: false,
6498 observer: '_horizontalChanged' 6537 observer: '_horizontalChanged'
6499 }, 6538 },
6500 opened: { 6539 opened: {
(...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after
8677 8716
8678 case HistoryRange.MONTH: 8717 case HistoryRange.MONTH:
8679 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; 8718 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH;
8680 break; 8719 break;
8681 } 8720 }
8682 break; 8721 break;
8683 } 8722 }
8684 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END); 8723 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END);
8685 } 8724 }
8686 }); 8725 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_downloads/vulcanized.html ('k') | chrome/browser/resources/md_history/app.vulcanized.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698