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 5375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5386 } | 5386 } |
5387 }); | 5387 }); |
5388 | 5388 |
5389 // Copyright 2016 The Chromium Authors. All rights reserved. | 5389 // Copyright 2016 The Chromium Authors. All rights reserved. |
5390 // Use of this source code is governed by a BSD-style license that can be | 5390 // Use of this source code is governed by a BSD-style license that can be |
5391 // found in the LICENSE file. | 5391 // found in the LICENSE file. |
5392 Polymer({ | 5392 Polymer({ |
5393 is: 'cr-lazy-render', | 5393 is: 'cr-lazy-render', |
5394 "extends": 'template', | 5394 "extends": 'template', |
5395 behaviors: [ Polymer.Templatizer ], | 5395 behaviors: [ Polymer.Templatizer ], |
5396 renderPromise_: null, | |
5397 child_: null, | 5396 child_: null, |
5398 get: function() { | 5397 get: function() { |
5399 if (!this.renderPromise_) { | 5398 if (!this.child_) this.render_(); |
5400 this.renderPromise_ = new Promise(function(resolve) { | 5399 return this.child_; |
5401 this._debounceTemplate(function() { | |
5402 this.render_(); | |
5403 this.renderPromise_ = null; | |
5404 resolve(this.getIfExists()); | |
5405 }.bind(this)); | |
5406 }.bind(this)); | |
5407 } | |
5408 return this.renderPromise_; | |
5409 }, | 5400 }, |
5410 getIfExists: function() { | 5401 getIfExists: function() { |
5411 return this.child_; | 5402 return this.child_; |
5412 }, | 5403 }, |
5413 render_: function() { | 5404 render_: function() { |
5414 if (!this.ctor) this.templatize(this); | 5405 if (!this.ctor) this.templatize(this); |
5415 var parentNode = this.parentNode; | 5406 var parentNode = this.parentNode; |
5416 if (parentNode && !this.child_) { | 5407 if (parentNode && !this.child_) { |
5417 var instance = this.stamp({}); | 5408 var instance = this.stamp({}); |
5418 this.child_ = instance.root.firstElementChild; | 5409 this.child_ = instance.root.firstElementChild; |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6137 if (this.searchTerm == search) return; | 6128 if (this.searchTerm == search) return; |
6138 this.searchTerm = search; | 6129 this.searchTerm = search; |
6139 var searchField = this.$['main-toolbar'].getSearchField(); | 6130 var searchField = this.$['main-toolbar'].getSearchField(); |
6140 searchField.showAndFocus(); | 6131 searchField.showAndFocus(); |
6141 searchField.setValue(search); | 6132 searchField.setValue(search); |
6142 }, | 6133 }, |
6143 onSearchChanged_: function(event) { | 6134 onSearchChanged_: function(event) { |
6144 this.searchTerm = event.detail; | 6135 this.searchTerm = event.detail; |
6145 }, | 6136 }, |
6146 onInfoButtonTap_: function() { | 6137 onInfoButtonTap_: function() { |
6147 this.$.syncNotice.get().then(function(dropdown) { | 6138 var dropdown = this.$.syncNotice.get(); |
6148 dropdown.positionTarget = this.$$('#info-button-icon'); | 6139 dropdown.positionTarget = this.$$('#info-button-icon'); |
6149 if (dropdown.style.display == 'none') dropdown.open(); | 6140 if (dropdown.style.display == 'none') dropdown.open(); |
6150 }.bind(this)); | |
6151 }, | 6141 }, |
6152 onClearSelectionTap_: function() { | 6142 onClearSelectionTap_: function() { |
6153 this.fire('unselect-all'); | 6143 this.fire('unselect-all'); |
6154 }, | 6144 }, |
6155 onDeleteTap_: function() { | 6145 onDeleteTap_: function() { |
6156 this.fire('delete-selected'); | 6146 this.fire('delete-selected'); |
6157 }, | 6147 }, |
6158 get searchBar() { | 6148 get searchBar() { |
6159 return this.$['main-toolbar'].getSearchField(); | 6149 return this.$['main-toolbar'].getSearchField(); |
6160 }, | 6150 }, |
(...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8123 }, | 8113 }, |
8124 unselectAllItems: function(count) { | 8114 unselectAllItems: function(count) { |
8125 var selectedList = this.getSelectedList_(); | 8115 var selectedList = this.getSelectedList_(); |
8126 if (selectedList) selectedList.unselectAllItems(count); | 8116 if (selectedList) selectedList.unselectAllItems(count); |
8127 }, | 8117 }, |
8128 deleteSelectedWithPrompt: function() { | 8118 deleteSelectedWithPrompt: function() { |
8129 if (!loadTimeData.getBoolean('allowDeletingHistory')) return; | 8119 if (!loadTimeData.getBoolean('allowDeletingHistory')) return; |
8130 var browserService = md_history.BrowserService.getInstance(); | 8120 var browserService = md_history.BrowserService.getInstance(); |
8131 browserService.recordAction('RemoveSelected'); | 8121 browserService.recordAction('RemoveSelected'); |
8132 if (this.queryState.searchTerm != '') browserService.recordAction('SearchRes
ultRemove'); | 8122 if (this.queryState.searchTerm != '') browserService.recordAction('SearchRes
ultRemove'); |
8133 this.$.dialog.get().then(function(dialog) { | 8123 this.$.dialog.get().showModal(); |
8134 dialog.showModal(); | |
8135 }); | |
8136 }, | 8124 }, |
8137 groupedRangeChanged_: function(range, oldRange) { | 8125 groupedRangeChanged_: function(range, oldRange) { |
8138 this.selectedPage_ = range == HistoryRange.ALL_TIME ? 'infinite-list' : 'gro
uped-list'; | 8126 this.selectedPage_ = range == HistoryRange.ALL_TIME ? 'infinite-list' : 'gro
uped-list'; |
8139 if (oldRange == undefined) return; | 8127 if (oldRange == undefined) return; |
8140 this.queryHistory(false); | 8128 this.queryHistory(false); |
8141 this.fire('history-view-changed'); | 8129 this.fire('history-view-changed'); |
8142 }, | 8130 }, |
8143 loadMoreHistory_: function() { | 8131 loadMoreHistory_: function() { |
8144 this.queryHistory(true); | 8132 this.queryHistory(true); |
8145 }, | 8133 }, |
(...skipping 18 matching lines...) Expand all Loading... |
8164 md_history.BrowserService.getInstance().recordAction('CancelRemoveSelected')
; | 8152 md_history.BrowserService.getInstance().recordAction('CancelRemoveSelected')
; |
8165 var dialog = assert(this.$.dialog.getIfExists()); | 8153 var dialog = assert(this.$.dialog.getIfExists()); |
8166 dialog.close(); | 8154 dialog.close(); |
8167 }, | 8155 }, |
8168 closeMenu_: function() { | 8156 closeMenu_: function() { |
8169 var menu = this.$.sharedMenu.getIfExists(); | 8157 var menu = this.$.sharedMenu.getIfExists(); |
8170 if (menu) menu.closeMenu(); | 8158 if (menu) menu.closeMenu(); |
8171 }, | 8159 }, |
8172 toggleMenu_: function(e) { | 8160 toggleMenu_: function(e) { |
8173 var target = e.detail.target; | 8161 var target = e.detail.target; |
8174 return this.$.sharedMenu.get().then(function(menu) { | 8162 var menu = this.$.sharedMenu.get(); |
8175 menu.toggleMenu(target, e.detail); | 8163 menu.toggleMenu(target, e.detail); |
8176 }); | |
8177 }, | 8164 }, |
8178 onMoreFromSiteTap_: function() { | 8165 onMoreFromSiteTap_: function() { |
8179 md_history.BrowserService.getInstance().recordAction('EntryMenuShowMoreFromS
ite'); | 8166 md_history.BrowserService.getInstance().recordAction('EntryMenuShowMoreFromS
ite'); |
8180 var menu = assert(this.$.sharedMenu.getIfExists()); | 8167 var menu = assert(this.$.sharedMenu.getIfExists()); |
8181 this.fire('search-domain', { | 8168 this.fire('search-domain', { |
8182 domain: menu.itemData.item.domain | 8169 domain: menu.itemData.item.domain |
8183 }); | 8170 }); |
8184 menu.closeMenu(); | 8171 menu.closeMenu(); |
8185 }, | 8172 }, |
8186 onRemoveFromHistoryTap_: function() { | 8173 onRemoveFromHistoryTap_: function() { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8352 }; | 8339 }; |
8353 }, | 8340 }, |
8354 onSignInTap_: function() { | 8341 onSignInTap_: function() { |
8355 chrome.send('startSignInFlow'); | 8342 chrome.send('startSignInFlow'); |
8356 }, | 8343 }, |
8357 onListScroll_: function() { | 8344 onListScroll_: function() { |
8358 var menu = this.$.menu.getIfExists(); | 8345 var menu = this.$.menu.getIfExists(); |
8359 if (menu) menu.closeMenu(); | 8346 if (menu) menu.closeMenu(); |
8360 }, | 8347 }, |
8361 onToggleMenu_: function(e) { | 8348 onToggleMenu_: function(e) { |
8362 this.$.menu.get().then(function(menu) { | 8349 var menu = this.$.menu.get(); |
8363 menu.toggleMenu(e.detail.target, e.detail.tag); | 8350 menu.toggleMenu(e.detail.target, e.detail.tag); |
8364 if (menu.menuOpen) { | 8351 if (menu.menuOpen) { |
8365 md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HIST
OGRAM_NAME, SyncedTabsHistogram.SHOW_SESSION_MENU, SyncedTabsHistogram.LIMIT); | 8352 md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOG
RAM_NAME, SyncedTabsHistogram.SHOW_SESSION_MENU, SyncedTabsHistogram.LIMIT); |
8366 } | 8353 } |
8367 }); | |
8368 }, | 8354 }, |
8369 onOpenAllTap_: function() { | 8355 onOpenAllTap_: function() { |
8370 var menu = assert(this.$.menu.getIfExists()); | 8356 var menu = assert(this.$.menu.getIfExists()); |
8371 var browserService = md_history.BrowserService.getInstance(); | 8357 var browserService = md_history.BrowserService.getInstance(); |
8372 browserService.recordHistogram(SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogr
am.OPEN_ALL, SyncedTabsHistogram.LIMIT); | 8358 browserService.recordHistogram(SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogr
am.OPEN_ALL, SyncedTabsHistogram.LIMIT); |
8373 browserService.openForeignSessionAllTabs(menu.itemData); | 8359 browserService.openForeignSessionAllTabs(menu.itemData); |
8374 menu.closeMenu(); | 8360 menu.closeMenu(); |
8375 }, | 8361 }, |
8376 onDeleteSessionTap_: function() { | 8362 onDeleteSessionTap_: function() { |
8377 var menu = assert(this.$.menu.getIfExists()); | 8363 var menu = assert(this.$.menu.getIfExists()); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8691 | 8677 |
8692 case HistoryRange.MONTH: | 8678 case HistoryRange.MONTH: |
8693 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; | 8679 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; |
8694 break; | 8680 break; |
8695 } | 8681 } |
8696 break; | 8682 break; |
8697 } | 8683 } |
8698 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); | 8684 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); |
8699 } | 8685 } |
8700 }); | 8686 }); |
OLD | NEW |