OLD | NEW |
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 Loading... |
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, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6837 if (this.index == undefined) return; | 6838 if (this.index == undefined) return; |
6838 browserService.recordHistogram('HistoryPage.ClickPosition', this.index, UM
A_MAX_BUCKET_VALUE); | 6839 browserService.recordHistogram('HistoryPage.ClickPosition', this.index, UM
A_MAX_BUCKET_VALUE); |
6839 if (this.index <= UMA_MAX_SUBSET_BUCKET_VALUE) { | 6840 if (this.index <= UMA_MAX_SUBSET_BUCKET_VALUE) { |
6840 browserService.recordHistogram('HistoryPage.ClickPositionSubset', this.i
ndex, UMA_MAX_SUBSET_BUCKET_VALUE); | 6841 browserService.recordHistogram('HistoryPage.ClickPositionSubset', this.i
ndex, UMA_MAX_SUBSET_BUCKET_VALUE); |
6841 } | 6842 } |
6842 }, | 6843 }, |
6843 onLinkRightClick_: function() { | 6844 onLinkRightClick_: function() { |
6844 md_history.BrowserService.getInstance().recordAction('EntryLinkRightClick'
); | 6845 md_history.BrowserService.getInstance().recordAction('EntryLinkRightClick'
); |
6845 }, | 6846 }, |
6846 showIcon_: function() { | 6847 showIcon_: function() { |
6847 this.$.icon.style.backgroundImage = cr.icon.getFaviconImageSet(this.item.u
rl); | 6848 this.$.icon.style.backgroundImage = cr.icon.getFavicon(this.item.url); |
6848 }, | 6849 }, |
6849 selectionNotAllowed_: function() { | 6850 selectionNotAllowed_: function() { |
6850 return !loadTimeData.getBoolean('allowDeletingHistory'); | 6851 return !loadTimeData.getBoolean('allowDeletingHistory'); |
6851 }, | 6852 }, |
6852 cardTitle_: function(numberOfItems, historyDate, search) { | 6853 cardTitle_: function(numberOfItems, historyDate, search) { |
6853 if (!search) return this.item.dateRelativeDay; | 6854 if (!search) return this.item.dateRelativeDay; |
6854 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; | 6855 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; |
6855 return loadTimeData.getStringF('foundSearchResults', numberOfItems, loadTi
meData.getString(resultId), search); | 6856 return loadTimeData.getStringF('foundSearchResults', numberOfItems, loadTi
meData.getString(resultId), search); |
6856 }, | 6857 }, |
6857 cropItemTitle_: function(title) { | 6858 cropItemTitle_: function(title) { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7086 }, 0); | 7087 }, 0); |
7087 }, | 7088 }, |
7088 needsTimeGap_: function(groupIndex, domainIndex, itemIndex) { | 7089 needsTimeGap_: function(groupIndex, domainIndex, itemIndex) { |
7089 var visits = this.groupedHistoryData_[groupIndex].domains[domainIndex].visit
s; | 7090 var visits = this.groupedHistoryData_[groupIndex].domains[domainIndex].visit
s; |
7090 return md_history.HistoryItem.needsTimeGap(visits, itemIndex, this.searchedT
erm); | 7091 return md_history.HistoryItem.needsTimeGap(visits, itemIndex, this.searchedT
erm); |
7091 }, | 7092 }, |
7092 pathForItem_: function(groupIndex, domainIndex, itemIndex) { | 7093 pathForItem_: function(groupIndex, domainIndex, itemIndex) { |
7093 return [ 'groupedHistoryData_', groupIndex, 'domains', domainIndex, 'visits'
, itemIndex ].join('.'); | 7094 return [ 'groupedHistoryData_', groupIndex, 'domains', domainIndex, 'visits'
, itemIndex ].join('.'); |
7094 }, | 7095 }, |
7095 getWebsiteIconStyle_: function(domain) { | 7096 getWebsiteIconStyle_: function(domain) { |
7096 return 'background-image: ' + cr.icon.getFaviconImageSet(domain.visits[0].ur
l); | 7097 return 'background-image: ' + cr.icon.getFavicon(domain.visits[0].url); |
7097 }, | 7098 }, |
7098 getDropdownIcon_: function(expanded) { | 7099 getDropdownIcon_: function(expanded) { |
7099 return expanded ? 'cr:expand-less' : 'cr:expand-more'; | 7100 return expanded ? 'cr:expand-less' : 'cr:expand-more'; |
7100 } | 7101 } |
7101 }); | 7102 }); |
7102 | 7103 |
7103 (function() { | 7104 (function() { |
7104 var IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/); | 7105 var IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/); |
7105 var IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8; | 7106 var IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8; |
7106 var DEFAULT_PHYSICAL_COUNT = 3; | 7107 var DEFAULT_PHYSICAL_COUNT = 3; |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8340 toggleTabCard: function() { | 8341 toggleTabCard: function() { |
8341 var histogramValue = this.$.collapse.opened ? SyncedTabsHistogram.COLLAPSE_S
ESSION : SyncedTabsHistogram.EXPAND_SESSION; | 8342 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); | 8343 md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOGRA
M_NAME, histogramValue, SyncedTabsHistogram.LIMIT); |
8343 this.$.collapse.toggle(); | 8344 this.$.collapse.toggle(); |
8344 this.$['dropdown-indicator'].icon = this.$.collapse.opened ? 'cr:expand-less
' : 'cr:expand-more'; | 8345 this.$['dropdown-indicator'].icon = this.$.collapse.opened ? 'cr:expand-less
' : 'cr:expand-more'; |
8345 }, | 8346 }, |
8346 updateIcons_: function() { | 8347 updateIcons_: function() { |
8347 this.async(function() { | 8348 this.async(function() { |
8348 var icons = Polymer.dom(this.root).querySelectorAll('.website-icon'); | 8349 var icons = Polymer.dom(this.root).querySelectorAll('.website-icon'); |
8349 for (var i = 0; i < this.tabs.length; i++) { | 8350 for (var i = 0; i < this.tabs.length; i++) { |
8350 icons[i].style.backgroundImage = cr.icon.getFaviconImageSet(this.tabs[i]
.url); | 8351 icons[i].style.backgroundImage = cr.icon.getFavicon(this.tabs[i].url); |
8351 } | 8352 } |
8352 }); | 8353 }); |
8353 }, | 8354 }, |
8354 isWindowSeparatorIndex_: function(index, separatorIndexes) { | 8355 isWindowSeparatorIndex_: function(index, separatorIndexes) { |
8355 return this.separatorIndexes.indexOf(index) != -1; | 8356 return this.separatorIndexes.indexOf(index) != -1; |
8356 }, | 8357 }, |
8357 getCollapseIcon_: function(opened) { | 8358 getCollapseIcon_: function(opened) { |
8358 return opened ? 'cr:expand-less' : 'cr:expand-more'; | 8359 return opened ? 'cr:expand-less' : 'cr:expand-more'; |
8359 }, | 8360 }, |
8360 getCollapseTitle_: function(opened) { | 8361 getCollapseTitle_: function(opened) { |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8790 | 8791 |
8791 case HistoryRange.MONTH: | 8792 case HistoryRange.MONTH: |
8792 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; | 8793 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; |
8793 break; | 8794 break; |
8794 } | 8795 } |
8795 break; | 8796 break; |
8796 } | 8797 } |
8797 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); | 8798 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); |
8798 } | 8799 } |
8799 }); | 8800 }); |
OLD | NEW |