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

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

Issue 2313823002: MD History: Remove shadow root from <history-searched-label> (Closed)
Patch Set: Fix tests 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 6667 matching lines...) Expand 10 before | Expand all | Expand 10 after
6678 } 6678 }
6679 } 6679 }
6680 }); 6680 });
6681 6681
6682 // Copyright 2016 The Chromium Authors. All rights reserved. 6682 // Copyright 2016 The Chromium Authors. All rights reserved.
6683 // Use of this source code is governed by a BSD-style license that can be 6683 // Use of this source code is governed by a BSD-style license that can be
6684 // found in the LICENSE file. 6684 // found in the LICENSE file.
6685 cr.define('cr.icon', function() { 6685 cr.define('cr.icon', function() {
6686 function getSupportedScaleFactors() { 6686 function getSupportedScaleFactors() {
6687 var supportedScaleFactors = []; 6687 var supportedScaleFactors = [];
6688 if (!cr.isIOS) {
6689 supportedScaleFactors.push(1);
6690 }
6688 if (cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux) { 6691 if (cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux) {
6689 supportedScaleFactors.push(1);
6690 supportedScaleFactors.push(2); 6692 supportedScaleFactors.push(2);
6691 } else { 6693 } else {
6692 supportedScaleFactors.push(window.devicePixelRatio); 6694 supportedScaleFactors.push(window.devicePixelRatio);
6693 } 6695 }
6694 return supportedScaleFactors; 6696 return supportedScaleFactors;
6695 } 6697 }
6696 function getProfileAvatarIcon(path) { 6698 function getImageSet(path) {
6697 var chromeThemePath = 'chrome://theme';
6698 var isDefaultAvatar = path.slice(0, chromeThemePath.length) == chromeThemePa th;
6699 return isDefaultAvatar ? imageset(path + '@scalefactorx') : url(path);
6700 }
6701 function imageset(path) {
6702 var supportedScaleFactors = getSupportedScaleFactors(); 6699 var supportedScaleFactors = getSupportedScaleFactors();
6703 var replaceStartIndex = path.indexOf('scalefactor'); 6700 var replaceStartIndex = path.indexOf('scalefactor');
6704 if (replaceStartIndex < 0) return url(path); 6701 if (replaceStartIndex < 0) return url(path);
6705 var s = ''; 6702 var s = '';
6706 for (var i = 0; i < supportedScaleFactors.length; ++i) { 6703 for (var i = 0; i < supportedScaleFactors.length; ++i) {
6707 var scaleFactor = supportedScaleFactors[i]; 6704 var scaleFactor = supportedScaleFactors[i];
6708 var pathWithScaleFactor = path.substr(0, replaceStartIndex) + scaleFactor + path.substr(replaceStartIndex + 'scalefactor'.length); 6705 var pathWithScaleFactor = path.substr(0, replaceStartIndex) + scaleFactor + path.substr(replaceStartIndex + 'scalefactor'.length);
6709 s += url(pathWithScaleFactor) + ' ' + scaleFactor + 'x'; 6706 s += url(pathWithScaleFactor) + ' ' + scaleFactor + 'x';
6710 if (i != supportedScaleFactors.length - 1) s += ', '; 6707 if (i != supportedScaleFactors.length - 1) s += ', ';
6711 } 6708 }
6712 return '-webkit-image-set(' + s + ')'; 6709 return '-webkit-image-set(' + s + ')';
6713 } 6710 }
6711 function getImage(path) {
6712 var chromeThemePath = 'chrome://theme';
6713 var isChromeThemeUrl = path.slice(0, chromeThemePath.length) == chromeThemeP ath;
6714 return isChromeThemeUrl ? getImageSet(path + '@scalefactorx') : url(path);
6715 }
6714 var FAVICON_URL_REGEX = /\.ico$/i; 6716 var FAVICON_URL_REGEX = /\.ico$/i;
6715 function getFaviconImageSet(url, opt_size, opt_type) { 6717 function getFavicon(url, opt_size, opt_type) {
6716 var size = opt_size || 16; 6718 var size = opt_size || 16;
6717 var type = opt_type || 'favicon'; 6719 var type = opt_type || 'favicon';
6718 return imageset('chrome://' + type + '/size/' + size + '@scalefactorx/' + (F AVICON_URL_REGEX.test(url) ? 'iconurl/' : '') + url); 6720 return getImageSet('chrome://' + type + '/size/' + size + '@scalefactorx/' + (FAVICON_URL_REGEX.test(url) ? 'iconurl/' : '') + url);
6719 } 6721 }
6720 return { 6722 return {
6721 getSupportedScaleFactors: getSupportedScaleFactors, 6723 getImage: getImage,
6722 getProfileAvatarIcon: getProfileAvatarIcon, 6724 getFavicon: getFavicon
6723 getFaviconImageSet: getFaviconImageSet
6724 }; 6725 };
6725 }); 6726 });
6726 6727
6727 // Copyright 2016 The Chromium Authors. All rights reserved. 6728 // Copyright 2016 The Chromium Authors. All rights reserved.
6728 // Use of this source code is governed by a BSD-style license that can be 6729 // Use of this source code is governed by a BSD-style license that can be
6729 // found in the LICENSE file. 6730 // found in the LICENSE file.
6730 Polymer({ 6731 Polymer({
6731 is: 'history-searched-label', 6732 is: 'history-searched-label',
6732 properties: { 6733 properties: {
6733 title: String, 6734 title: String,
6734 searchTerm: String 6735 searchTerm: String
6735 }, 6736 },
6736 observers: [ 'setSearchedTextToBold_(title, searchTerm)' ], 6737 observers: [ 'setSearchedTextToBold_(title, searchTerm)' ],
6737 setSearchedTextToBold_: function() { 6738 setSearchedTextToBold_: function() {
6738 var i = 0; 6739 var i = 0;
6739 var titleElem = this.$.container;
6740 var titleText = this.title; 6740 var titleText = this.title;
6741 if (this.searchTerm == '' || this.searchTerm == null) { 6741 if (this.searchTerm == '' || this.searchTerm == null) {
6742 titleElem.textContent = titleText; 6742 this.textContent = titleText;
6743 return; 6743 return;
6744 } 6744 }
6745 var re = new RegExp(quoteString(this.searchTerm), 'gim'); 6745 var re = new RegExp(quoteString(this.searchTerm), 'gim');
6746 var match; 6746 var match;
6747 titleElem.textContent = ''; 6747 this.textContent = '';
6748 while (match = re.exec(titleText)) { 6748 while (match = re.exec(titleText)) {
6749 if (match.index > i) titleElem.appendChild(document.createTextNode(titleTe xt.slice(i, match.index))); 6749 if (match.index > i) this.appendChild(document.createTextNode(titleText.sl ice(i, match.index)));
6750 i = re.lastIndex; 6750 i = re.lastIndex;
6751 var b = document.createElement('b'); 6751 var b = document.createElement('b');
6752 b.textContent = titleText.substring(match.index, i); 6752 b.textContent = titleText.substring(match.index, i);
6753 titleElem.appendChild(b); 6753 this.appendChild(b);
6754 } 6754 }
6755 if (i < titleText.length) titleElem.appendChild(document.createTextNode(titl eText.slice(i))); 6755 if (i < titleText.length) this.appendChild(document.createTextNode(titleText .slice(i)));
6756 } 6756 }
6757 }); 6757 });
6758 6758
6759 // Copyright 2015 The Chromium Authors. All rights reserved. 6759 // Copyright 2015 The Chromium Authors. All rights reserved.
6760 // Use of this source code is governed by a BSD-style license that can be 6760 // Use of this source code is governed by a BSD-style license that can be
6761 // found in the LICENSE file. 6761 // found in the LICENSE file.
6762 cr.define('md_history', function() { 6762 cr.define('md_history', function() {
6763 var HistoryItem = Polymer({ 6763 var HistoryItem = Polymer({
6764 is: 'history-item', 6764 is: 'history-item',
6765 properties: { 6765 properties: {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
6837 if (this.index == undefined) return; 6837 if (this.index == undefined) return;
6838 browserService.recordHistogram('HistoryPage.ClickPosition', this.index, UM A_MAX_BUCKET_VALUE); 6838 browserService.recordHistogram('HistoryPage.ClickPosition', this.index, UM A_MAX_BUCKET_VALUE);
6839 if (this.index <= UMA_MAX_SUBSET_BUCKET_VALUE) { 6839 if (this.index <= UMA_MAX_SUBSET_BUCKET_VALUE) {
6840 browserService.recordHistogram('HistoryPage.ClickPositionSubset', this.i ndex, UMA_MAX_SUBSET_BUCKET_VALUE); 6840 browserService.recordHistogram('HistoryPage.ClickPositionSubset', this.i ndex, UMA_MAX_SUBSET_BUCKET_VALUE);
6841 } 6841 }
6842 }, 6842 },
6843 onLinkRightClick_: function() { 6843 onLinkRightClick_: function() {
6844 md_history.BrowserService.getInstance().recordAction('EntryLinkRightClick' ); 6844 md_history.BrowserService.getInstance().recordAction('EntryLinkRightClick' );
6845 }, 6845 },
6846 showIcon_: function() { 6846 showIcon_: function() {
6847 this.$.icon.style.backgroundImage = cr.icon.getFaviconImageSet(this.item.u rl); 6847 this.$.icon.style.backgroundImage = cr.icon.getFavicon(this.item.url);
6848 }, 6848 },
6849 selectionNotAllowed_: function() { 6849 selectionNotAllowed_: function() {
6850 return !loadTimeData.getBoolean('allowDeletingHistory'); 6850 return !loadTimeData.getBoolean('allowDeletingHistory');
6851 }, 6851 },
6852 cardTitle_: function(numberOfItems, historyDate, search) { 6852 cardTitle_: function(numberOfItems, historyDate, search) {
6853 if (!search) return this.item.dateRelativeDay; 6853 if (!search) return this.item.dateRelativeDay;
6854 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; 6854 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults';
6855 return loadTimeData.getStringF('foundSearchResults', numberOfItems, loadTi meData.getString(resultId), search); 6855 return loadTimeData.getStringF('foundSearchResults', numberOfItems, loadTi meData.getString(resultId), search);
6856 }, 6856 },
6857 cropItemTitle_: function(title) { 6857 cropItemTitle_: function(title) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
7086 }, 0); 7086 }, 0);
7087 }, 7087 },
7088 needsTimeGap_: function(groupIndex, domainIndex, itemIndex) { 7088 needsTimeGap_: function(groupIndex, domainIndex, itemIndex) {
7089 var visits = this.groupedHistoryData_[groupIndex].domains[domainIndex].visit s; 7089 var visits = this.groupedHistoryData_[groupIndex].domains[domainIndex].visit s;
7090 return md_history.HistoryItem.needsTimeGap(visits, itemIndex, this.searchedT erm); 7090 return md_history.HistoryItem.needsTimeGap(visits, itemIndex, this.searchedT erm);
7091 }, 7091 },
7092 pathForItem_: function(groupIndex, domainIndex, itemIndex) { 7092 pathForItem_: function(groupIndex, domainIndex, itemIndex) {
7093 return [ 'groupedHistoryData_', groupIndex, 'domains', domainIndex, 'visits' , itemIndex ].join('.'); 7093 return [ 'groupedHistoryData_', groupIndex, 'domains', domainIndex, 'visits' , itemIndex ].join('.');
7094 }, 7094 },
7095 getWebsiteIconStyle_: function(domain) { 7095 getWebsiteIconStyle_: function(domain) {
7096 return 'background-image: ' + cr.icon.getFaviconImageSet(domain.visits[0].ur l); 7096 return 'background-image: ' + cr.icon.getFavicon(domain.visits[0].url);
7097 }, 7097 },
7098 getDropdownIcon_: function(expanded) { 7098 getDropdownIcon_: function(expanded) {
7099 return expanded ? 'cr:expand-less' : 'cr:expand-more'; 7099 return expanded ? 'cr:expand-less' : 'cr:expand-more';
7100 } 7100 }
7101 }); 7101 });
7102 7102
7103 (function() { 7103 (function() {
7104 var IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/); 7104 var IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);
7105 var IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8; 7105 var IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8;
7106 var DEFAULT_PHYSICAL_COUNT = 3; 7106 var DEFAULT_PHYSICAL_COUNT = 3;
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
8340 toggleTabCard: function() { 8340 toggleTabCard: function() {
8341 var histogramValue = this.$.collapse.opened ? SyncedTabsHistogram.COLLAPSE_S ESSION : SyncedTabsHistogram.EXPAND_SESSION; 8341 var histogramValue = this.$.collapse.opened ? SyncedTabsHistogram.COLLAPSE_S ESSION : SyncedTabsHistogram.EXPAND_SESSION;
8342 md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOGRA M_NAME, histogramValue, SyncedTabsHistogram.LIMIT); 8342 md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOGRA M_NAME, histogramValue, SyncedTabsHistogram.LIMIT);
8343 this.$.collapse.toggle(); 8343 this.$.collapse.toggle();
8344 this.$['dropdown-indicator'].icon = this.$.collapse.opened ? 'cr:expand-less ' : 'cr:expand-more'; 8344 this.$['dropdown-indicator'].icon = this.$.collapse.opened ? 'cr:expand-less ' : 'cr:expand-more';
8345 }, 8345 },
8346 updateIcons_: function() { 8346 updateIcons_: function() {
8347 this.async(function() { 8347 this.async(function() {
8348 var icons = Polymer.dom(this.root).querySelectorAll('.website-icon'); 8348 var icons = Polymer.dom(this.root).querySelectorAll('.website-icon');
8349 for (var i = 0; i < this.tabs.length; i++) { 8349 for (var i = 0; i < this.tabs.length; i++) {
8350 icons[i].style.backgroundImage = cr.icon.getFaviconImageSet(this.tabs[i] .url); 8350 icons[i].style.backgroundImage = cr.icon.getFavicon(this.tabs[i].url);
8351 } 8351 }
8352 }); 8352 });
8353 }, 8353 },
8354 isWindowSeparatorIndex_: function(index, separatorIndexes) { 8354 isWindowSeparatorIndex_: function(index, separatorIndexes) {
8355 return this.separatorIndexes.indexOf(index) != -1; 8355 return this.separatorIndexes.indexOf(index) != -1;
8356 }, 8356 },
8357 getCollapseIcon_: function(opened) { 8357 getCollapseIcon_: function(opened) {
8358 return opened ? 'cr:expand-less' : 'cr:expand-more'; 8358 return opened ? 'cr:expand-less' : 'cr:expand-more';
8359 }, 8359 },
8360 getCollapseTitle_: function(opened) { 8360 getCollapseTitle_: function(opened) {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
8790 8790
8791 case HistoryRange.MONTH: 8791 case HistoryRange.MONTH:
8792 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; 8792 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH;
8793 break; 8793 break;
8794 } 8794 }
8795 break; 8795 break;
8796 } 8796 }
8797 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END); 8797 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END);
8798 } 8798 }
8799 }); 8799 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698