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

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

Issue 2360193002: [MD History] Hide empty synced device cards. (Closed)
Patch Set: Created 4 years, 2 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 6457 matching lines...) Expand 10 before | Expand all | Expand 10 after
6468 lastFocus_: null, 6468 lastFocus_: null,
6469 attached: function() { 6469 attached: function() {
6470 window.addEventListener('resize', this.closeMenu.bind(this)); 6470 window.addEventListener('resize', this.closeMenu.bind(this));
6471 }, 6471 },
6472 closeMenu: function() { 6472 closeMenu: function() {
6473 if (this.root.activeElement == null) { 6473 if (this.root.activeElement == null) {
6474 this.$.dropdown.restoreFocusOnClose = false; 6474 this.$.dropdown.restoreFocusOnClose = false;
6475 } 6475 }
6476 this.menuOpen = false; 6476 this.menuOpen = false;
6477 }, 6477 },
6478 openMenu: function(anchor, itemData) { 6478 openMenu: function(anchor, opt_itemData) {
6479 if (this.lastAnchor_ == anchor && this.menuOpen) return; 6479 if (this.lastAnchor_ == anchor && this.menuOpen) return;
6480 if (this.menuOpen) this.closeMenu(); 6480 if (this.menuOpen) this.closeMenu();
6481 this.itemData = itemData; 6481 this.itemData = opt_itemData || null;
6482 this.lastAnchor_ = anchor; 6482 this.lastAnchor_ = anchor;
6483 this.$.dropdown.restoreFocusOnClose = true; 6483 this.$.dropdown.restoreFocusOnClose = true;
6484 var focusableChildren = Polymer.dom(this).querySelectorAll('[tabindex]:not([ disabled]):not([hidden]),' + 'button:not([disabled]):not([hidden])'); 6484 var focusableChildren = Polymer.dom(this).querySelectorAll('[tabindex]:not([ disabled]):not([hidden]),' + 'button:not([disabled]):not([hidden])');
6485 if (focusableChildren.length > 0) { 6485 if (focusableChildren.length > 0) {
6486 this.$.dropdown.focusTarget = focusableChildren[0]; 6486 this.$.dropdown.focusTarget = focusableChildren[0];
6487 this.firstFocus_ = focusableChildren[0]; 6487 this.firstFocus_ = focusableChildren[0];
6488 this.lastFocus_ = focusableChildren[focusableChildren.length - 1]; 6488 this.lastFocus_ = focusableChildren[focusableChildren.length - 1];
6489 } 6489 }
6490 this.$.dropdown.positionTarget = anchor; 6490 this.$.dropdown.positionTarget = anchor;
6491 this.menuOpen = true; 6491 this.menuOpen = true;
6492 }, 6492 },
6493 toggleMenu: function(anchor, itemData) { 6493 toggleMenu: function(anchor, opt_itemData) {
6494 if (anchor == this.lastAnchor_ && this.menuOpen) this.closeMenu(); else this .openMenu(anchor, itemData); 6494 if (anchor == this.lastAnchor_ && this.menuOpen) this.closeMenu(); else this .openMenu(anchor, opt_itemData);
6495 }, 6495 },
6496 onTabPressed_: function(e) { 6496 onTabPressed_: function(e) {
6497 if (!this.firstFocus_ || !this.lastFocus_) return; 6497 if (!this.firstFocus_ || !this.lastFocus_) return;
6498 var toFocus; 6498 var toFocus;
6499 var keyEvent = e.detail.keyboardEvent; 6499 var keyEvent = e.detail.keyboardEvent;
6500 if (keyEvent.shiftKey && keyEvent.target == this.firstFocus_) toFocus = this .lastFocus_; else if (!keyEvent.shiftKey && keyEvent.target == this.lastFocus_) toFocus = this.firstFocus_; 6500 if (keyEvent.shiftKey && keyEvent.target == this.firstFocus_) toFocus = this .lastFocus_; else if (!keyEvent.shiftKey && keyEvent.target == this.lastFocus_) toFocus = this.firstFocus_;
6501 if (!toFocus) return; 6501 if (!toFocus) return;
6502 e.preventDefault(); 6502 e.preventDefault();
6503 toFocus.focus(); 6503 toFocus.focus();
6504 }, 6504 },
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after
8636 if (guestSession) return true; 8636 if (guestSession) return true;
8637 return signInState && syncedDevicesLength == 0; 8637 return signInState && syncedDevicesLength == 0;
8638 }, 8638 },
8639 showSignInGuide: function(signInState, guestSession) { 8639 showSignInGuide: function(signInState, guestSession) {
8640 var show = !signInState && !guestSession; 8640 var show = !signInState && !guestSession;
8641 if (show) { 8641 if (show) {
8642 md_history.BrowserService.getInstance().recordAction('Signin_Impression_Fr omRecentTabs'); 8642 md_history.BrowserService.getInstance().recordAction('Signin_Impression_Fr omRecentTabs');
8643 } 8643 }
8644 return show; 8644 return show;
8645 }, 8645 },
8646 noSyncedTabsMessage: function(fetchingSyncedTabs) { 8646 noSyncedTabsMessage: function() {
8647 return loadTimeData.getString(fetchingSyncedTabs ? 'loading' : 'noSyncedResu lts'); 8647 var stringName = this.fetchingSyncedTabs_ ? 'loading' : 'noSyncedResults';
8648 if (this.searchTerm !== '') stringName = 'noSearchResults';
8649 return loadTimeData.getString(stringName);
8648 }, 8650 },
8649 updateSyncedDevices: function(sessionList) { 8651 updateSyncedDevices: function(sessionList) {
8650 this.fetchingSyncedTabs_ = false; 8652 this.fetchingSyncedTabs_ = false;
8651 if (!sessionList) return; 8653 if (!sessionList) return;
8652 if (sessionList.length > 0 && !this.hasSeenForeignData_) { 8654 if (sessionList.length > 0 && !this.hasSeenForeignData_) {
8653 this.hasSeenForeignData_ = true; 8655 this.hasSeenForeignData_ = true;
8654 md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOG RAM_NAME, SyncedTabsHistogram.HAS_FOREIGN_DATA, SyncedTabsHistogram.LIMIT); 8656 md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOG RAM_NAME, SyncedTabsHistogram.HAS_FOREIGN_DATA, SyncedTabsHistogram.LIMIT);
8655 } 8657 }
8656 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length); 8658 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length);
8657 for (var i = 0; i < updateCount; i++) { 8659 for (var i = 0; i < updateCount; i++) {
8658 var oldDevice = this.syncedDevices_[i]; 8660 var oldDevice = this.syncedDevices_[i];
8659 if (oldDevice.tag != sessionList[i].tag || oldDevice.timestamp != sessionL ist[i].timestamp) { 8661 if (oldDevice.tag != sessionList[i].tag || oldDevice.timestamp != sessionL ist[i].timestamp) {
8660 this.splice('syncedDevices_', i, 1, this.createInternalDevice_(sessionLi st[i])); 8662 device = this.createInternalDevice_(sessionList[i]);
8663 if (device.tabs.length != 0) this.splice('syncedDevices_', i, 1, device) ;
8661 } 8664 }
8662 } 8665 }
8663 if (sessionList.length >= this.syncedDevices_.length) { 8666 if (sessionList.length >= this.syncedDevices_.length) {
8664 for (var i = updateCount; i < sessionList.length; i++) { 8667 for (var i = updateCount; i < sessionList.length; i++) {
8665 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i])); 8668 device = this.createInternalDevice_(sessionList[i]);
8669 if (device.tabs.length != 0) this.push('syncedDevices_', device);
8666 } 8670 }
8667 } else { 8671 } else {
8668 this.splice('syncedDevices_', updateCount, this.syncedDevices_.length - up dateCount); 8672 this.splice('syncedDevices_', updateCount, this.syncedDevices_.length - up dateCount);
8669 } 8673 }
8670 }, 8674 },
8671 tabSyncDisabled: function() { 8675 tabSyncDisabled: function() {
8672 this.fetchingSyncedTabs_ = false; 8676 this.fetchingSyncedTabs_ = false;
8673 this.clearDisplayedSyncedDevices_(); 8677 this.clearDisplayedSyncedDevices_();
8674 }, 8678 },
8675 signInStateChanged_: function() { 8679 signInStateChanged_: function() {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
8940 8944
8941 case HistoryRange.MONTH: 8945 case HistoryRange.MONTH:
8942 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; 8946 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH;
8943 break; 8947 break;
8944 } 8948 }
8945 break; 8949 break;
8946 } 8950 }
8947 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END); 8951 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END);
8948 } 8952 }
8949 }); 8953 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698