| 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 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview PromiseResolver is a helper class that allows creating a | 6 * @fileoverview PromiseResolver is a helper class that allows creating a |
| 7 * Promise that will be fulfilled (resolved or rejected) some time later. | 7 * Promise that will be fulfilled (resolved or rejected) some time later. |
| 8 * | 8 * |
| 9 * Example: | 9 * Example: |
| 10 * var resolver = new PromiseResolver(); | 10 * var resolver = new PromiseResolver(); |
| (...skipping 11431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11442 */ | 11442 */ |
| 11443 deleteForeignSession: function(sessionTag) { | 11443 deleteForeignSession: function(sessionTag) { |
| 11444 chrome.send('deleteForeignSession', [sessionTag]); | 11444 chrome.send('deleteForeignSession', [sessionTag]); |
| 11445 }, | 11445 }, |
| 11446 | 11446 |
| 11447 openClearBrowsingData: function() { | 11447 openClearBrowsingData: function() { |
| 11448 chrome.send('clearBrowsingData'); | 11448 chrome.send('clearBrowsingData'); |
| 11449 }, | 11449 }, |
| 11450 | 11450 |
| 11451 /** | 11451 /** |
| 11452 * @param {string} histogram |
| 11453 * @param {number} value |
| 11454 * @param {number} max |
| 11455 */ |
| 11456 recordHistogram: function(histogram, value, max) { |
| 11457 chrome.send('metricsHandler:recordInHistogram', [histogram, value, max]); |
| 11458 }, |
| 11459 |
| 11460 /** |
| 11452 * Record an action in UMA. | 11461 * Record an action in UMA. |
| 11453 * @param {string} actionDesc The name of the action to be logged. | 11462 * @param {string} actionDesc The name of the action to be logged. |
| 11454 */ | 11463 */ |
| 11455 recordAction: function(actionDesc) { | 11464 recordAction: function(actionDesc) { |
| 11456 chrome.send('metricsHandler:recordAction', [actionDesc]); | 11465 chrome.send('metricsHandler:recordAction', [actionDesc]); |
| 11457 }, | 11466 }, |
| 11458 | 11467 |
| 11459 /** | 11468 /** |
| 11460 * @param {boolean} successful | 11469 * @param {boolean} successful |
| 11461 * @private | 11470 * @private |
| (...skipping 2893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14355 Polymer({ | 14364 Polymer({ |
| 14356 is: 'history-list-container', | 14365 is: 'history-list-container', |
| 14357 | 14366 |
| 14358 properties: { | 14367 properties: { |
| 14359 // The path of the currently selected page. | 14368 // The path of the currently selected page. |
| 14360 selectedPage_: String, | 14369 selectedPage_: String, |
| 14361 | 14370 |
| 14362 // Whether domain-grouped history is enabled. | 14371 // Whether domain-grouped history is enabled. |
| 14363 grouped: Boolean, | 14372 grouped: Boolean, |
| 14364 | 14373 |
| 14374 /** @type {HistoryRange} */ |
| 14375 groupedRange: {type: Number, observer: 'groupedRangeChanged_'}, |
| 14376 |
| 14365 /** @type {!QueryState} */ | 14377 /** @type {!QueryState} */ |
| 14366 queryState: Object, | 14378 queryState: Object, |
| 14367 | 14379 |
| 14368 /** @type {!QueryResult} */ | 14380 /** @type {!QueryResult} */ |
| 14369 queryResult: Object, | 14381 queryResult: Object, |
| 14370 }, | 14382 }, |
| 14371 | 14383 |
| 14372 observers: [ | |
| 14373 'groupedRangeChanged_(queryState.range)', | |
| 14374 ], | |
| 14375 | |
| 14376 listeners: { | 14384 listeners: { |
| 14377 'history-list-scrolled': 'closeMenu_', | 14385 'history-list-scrolled': 'closeMenu_', |
| 14378 'load-more-history': 'loadMoreHistory_', | 14386 'load-more-history': 'loadMoreHistory_', |
| 14379 'toggle-menu': 'toggleMenu_', | 14387 'toggle-menu': 'toggleMenu_', |
| 14380 }, | 14388 }, |
| 14381 | 14389 |
| 14382 /** | 14390 /** |
| 14383 * @param {HistoryQuery} info An object containing information about the | 14391 * @param {HistoryQuery} info An object containing information about the |
| 14384 * query. | 14392 * query. |
| 14385 * @param {!Array<HistoryEntry>} results A list of results. | 14393 * @param {!Array<HistoryEntry>} results A list of results. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14423 this.set('queryState.querying', true); | 14431 this.set('queryState.querying', true); |
| 14424 this.set('queryState.incremental', incremental); | 14432 this.set('queryState.incremental', incremental); |
| 14425 | 14433 |
| 14426 var lastVisitTime = 0; | 14434 var lastVisitTime = 0; |
| 14427 if (incremental) { | 14435 if (incremental) { |
| 14428 var lastVisit = this.queryResult.results.slice(-1)[0]; | 14436 var lastVisit = this.queryResult.results.slice(-1)[0]; |
| 14429 lastVisitTime = lastVisit ? lastVisit.time : 0; | 14437 lastVisitTime = lastVisit ? lastVisit.time : 0; |
| 14430 } | 14438 } |
| 14431 | 14439 |
| 14432 var maxResults = | 14440 var maxResults = |
| 14433 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; | 14441 this.groupedRange == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; |
| 14434 chrome.send('queryHistory', [ | 14442 chrome.send('queryHistory', [ |
| 14435 queryState.searchTerm, queryState.groupedOffset, queryState.range, | 14443 queryState.searchTerm, queryState.groupedOffset, queryState.range, |
| 14436 lastVisitTime, maxResults | 14444 lastVisitTime, maxResults |
| 14437 ]); | 14445 ]); |
| 14438 }, | 14446 }, |
| 14439 | 14447 |
| 14440 historyDeleted: function() { | 14448 historyDeleted: function() { |
| 14441 // Do not reload the list when there are items checked. | 14449 // Do not reload the list when there are items checked. |
| 14442 if (this.getSelectedItemCount() > 0) | 14450 if (this.getSelectedItemCount() > 0) |
| 14443 return; | 14451 return; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 14466 return; | 14474 return; |
| 14467 this.$.dialog.get().then(function(dialog) { | 14475 this.$.dialog.get().then(function(dialog) { |
| 14468 dialog.showModal(); | 14476 dialog.showModal(); |
| 14469 }); | 14477 }); |
| 14470 }, | 14478 }, |
| 14471 | 14479 |
| 14472 /** | 14480 /** |
| 14473 * @param {HistoryRange} range | 14481 * @param {HistoryRange} range |
| 14474 * @private | 14482 * @private |
| 14475 */ | 14483 */ |
| 14476 groupedRangeChanged_: function(range) { | 14484 groupedRangeChanged_: function(range, oldRange) { |
| 14477 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? | 14485 this.selectedPage_ = range == HistoryRange.ALL_TIME ? |
| 14478 'infinite-list' : 'grouped-list'; | 14486 'infinite-list' : 'grouped-list'; |
| 14479 | 14487 |
| 14488 if (oldRange == undefined) |
| 14489 return; |
| 14490 |
| 14480 this.queryHistory(false); | 14491 this.queryHistory(false); |
| 14492 this.fire('history-view-changed'); |
| 14481 }, | 14493 }, |
| 14482 | 14494 |
| 14483 /** @private */ | 14495 /** @private */ |
| 14484 loadMoreHistory_: function() { this.queryHistory(true); }, | 14496 loadMoreHistory_: function() { this.queryHistory(true); }, |
| 14485 | 14497 |
| 14486 /** | 14498 /** |
| 14487 * @param {HistoryQuery} info | 14499 * @param {HistoryQuery} info |
| 14488 * @param {!Array<HistoryEntry>} results | 14500 * @param {!Array<HistoryEntry>} results |
| 14489 * @private | 14501 * @private |
| 14490 */ | 14502 */ |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14714 /** | 14726 /** |
| 14715 * An array of synced devices with synced tab data. | 14727 * An array of synced devices with synced tab data. |
| 14716 * @type {!Array<!ForeignDeviceInternal>} | 14728 * @type {!Array<!ForeignDeviceInternal>} |
| 14717 */ | 14729 */ |
| 14718 syncedDevices_: { | 14730 syncedDevices_: { |
| 14719 type: Array, | 14731 type: Array, |
| 14720 value: function() { return []; } | 14732 value: function() { return []; } |
| 14721 }, | 14733 }, |
| 14722 | 14734 |
| 14723 /** @private */ | 14735 /** @private */ |
| 14724 signInState_: { | 14736 signInState: { |
| 14725 type: Boolean, | 14737 type: Boolean, |
| 14726 value: loadTimeData.getBoolean('isUserSignedIn'), | 14738 observer: 'signInStateChanged_', |
| 14727 }, | 14739 }, |
| 14728 | 14740 |
| 14729 /** @private */ | 14741 /** @private */ |
| 14730 guestSession_: { | 14742 guestSession_: { |
| 14731 type: Boolean, | 14743 type: Boolean, |
| 14732 value: loadTimeData.getBoolean('isGuestSession'), | 14744 value: loadTimeData.getBoolean('isGuestSession'), |
| 14733 }, | 14745 }, |
| 14734 | 14746 |
| 14735 /** @private */ | 14747 /** @private */ |
| 14736 fetchingSyncedTabs_: { | 14748 fetchingSyncedTabs_: { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14902 */ | 14914 */ |
| 14903 tabSyncDisabled: function() { | 14915 tabSyncDisabled: function() { |
| 14904 this.fetchingSyncedTabs_ = false; | 14916 this.fetchingSyncedTabs_ = false; |
| 14905 this.clearDisplayedSyncedDevices_(); | 14917 this.clearDisplayedSyncedDevices_(); |
| 14906 }, | 14918 }, |
| 14907 | 14919 |
| 14908 /** | 14920 /** |
| 14909 * Get called when user's sign in state changes, this will affect UI of synced | 14921 * Get called when user's sign in state changes, this will affect UI of synced |
| 14910 * tabs page. Sign in promo gets displayed when user is signed out, and | 14922 * tabs page. Sign in promo gets displayed when user is signed out, and |
| 14911 * different messages are shown when there are no synced tabs. | 14923 * different messages are shown when there are no synced tabs. |
| 14912 * @param {boolean} isUserSignedIn | 14924 * @param {boolean} signInState |
| 14913 */ | 14925 */ |
| 14914 updateSignInState: function(isUserSignedIn) { | 14926 signInStateChanged_: function() { |
| 14915 // If user's sign in state didn't change, then don't change message or | 14927 this.fire('history-view-changed'); |
| 14916 // update UI. | |
| 14917 if (this.signInState_ == isUserSignedIn) | |
| 14918 return; | |
| 14919 | |
| 14920 this.signInState_ = isUserSignedIn; | |
| 14921 | 14928 |
| 14922 // User signed out, clear synced device list and show the sign in promo. | 14929 // User signed out, clear synced device list and show the sign in promo. |
| 14923 if (!isUserSignedIn) { | 14930 if (!this.signInState) { |
| 14924 this.clearDisplayedSyncedDevices_(); | 14931 this.clearDisplayedSyncedDevices_(); |
| 14925 return; | 14932 return; |
| 14926 } | 14933 } |
| 14927 // User signed in, show the loading message when querying for synced | 14934 // User signed in, show the loading message when querying for synced |
| 14928 // devices. | 14935 // devices. |
| 14929 this.fetchingSyncedTabs_ = true; | 14936 this.fetchingSyncedTabs_ = true; |
| 14930 }, | 14937 }, |
| 14931 | 14938 |
| 14932 searchTermChanged: function(searchTerm) { | 14939 searchTermChanged: function(searchTerm) { |
| 14933 this.clearDisplayedSyncedDevices_(); | 14940 this.clearDisplayedSyncedDevices_(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15005 | 15012 |
| 15006 }); | 15013 }); |
| 15007 // Copyright 2016 The Chromium Authors. All rights reserved. | 15014 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 15008 // Use of this source code is governed by a BSD-style license that can be | 15015 // Use of this source code is governed by a BSD-style license that can be |
| 15009 // found in the LICENSE file. | 15016 // found in the LICENSE file. |
| 15010 | 15017 |
| 15011 Polymer({ | 15018 Polymer({ |
| 15012 is: 'history-side-bar', | 15019 is: 'history-side-bar', |
| 15013 | 15020 |
| 15014 properties: { | 15021 properties: { |
| 15015 selectedPage: { | 15022 selectedPage: {type: String, notify: true}, |
| 15016 type: String, | |
| 15017 notify: true | |
| 15018 }, | |
| 15019 | 15023 |
| 15020 route: Object, | 15024 route: Object, |
| 15021 | 15025 |
| 15022 showFooter: Boolean, | 15026 showFooter: Boolean, |
| 15023 | 15027 |
| 15024 // If true, the sidebar is contained within an app-drawer. | 15028 // If true, the sidebar is contained within an app-drawer. |
| 15025 drawer: { | 15029 drawer: {type: Boolean, reflectToAttribute: true}, |
| 15026 type: Boolean, | |
| 15027 reflectToAttribute: true | |
| 15028 }, | |
| 15029 }, | |
| 15030 | |
| 15031 /** @private */ | |
| 15032 onSelectorActivate_: function() { | |
| 15033 this.fire('history-close-drawer'); | |
| 15034 }, | 15030 }, |
| 15035 | 15031 |
| 15036 /** | 15032 /** |
| 15033 * @private |
| 15034 */ |
| 15035 onSelectorActivate_: function() { this.fire('history-close-drawer'); }, |
| 15036 |
| 15037 /** |
| 15037 * Relocates the user to the clear browsing data section of the settings page. | 15038 * Relocates the user to the clear browsing data section of the settings page. |
| 15038 * @param {Event} e | 15039 * @param {Event} e |
| 15039 * @private | 15040 * @private |
| 15040 */ | 15041 */ |
| 15041 onClearBrowsingDataTap_: function(e) { | 15042 onClearBrowsingDataTap_: function(e) { |
| 15043 md_history.BrowserService.getInstance().recordAction( |
| 15044 'HistoryPage_InitClearBrowsingData'); |
| 15042 md_history.BrowserService.getInstance().openClearBrowsingData(); | 15045 md_history.BrowserService.getInstance().openClearBrowsingData(); |
| 15043 e.preventDefault(); | 15046 e.preventDefault(); |
| 15044 }, | 15047 }, |
| 15045 | 15048 |
| 15046 /** | 15049 /** |
| 15047 * @param {Object} route | 15050 * @param {Object} route |
| 15048 * @private | 15051 * @private |
| 15049 */ | 15052 */ |
| 15050 getQueryString_: function(route) { | 15053 getQueryString_: function(route) { return window.location.search; } |
| 15051 return window.location.search; | |
| 15052 } | |
| 15053 }); | 15054 }); |
| 15054 // Copyright 2016 The Chromium Authors. All rights reserved. | 15055 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 15055 // Use of this source code is governed by a BSD-style license that can be | 15056 // Use of this source code is governed by a BSD-style license that can be |
| 15056 // found in the LICENSE file. | 15057 // found in the LICENSE file. |
| 15057 | 15058 |
| 15058 Polymer({ | 15059 Polymer({ |
| 15059 is: 'history-app', | 15060 is: 'history-app', |
| 15060 | 15061 |
| 15061 properties: { | 15062 properties: { |
| 15062 showSidebarFooter: Boolean, | 15063 showSidebarFooter: Boolean, |
| 15063 | 15064 |
| 15064 // The id of the currently selected page. | 15065 // The id of the currently selected page. |
| 15065 selectedPage_: {type: String, value: 'history', observer: 'unselectAll'}, | 15066 selectedPage_: {type: String, observer: 'unselectAll'}, |
| 15066 | 15067 |
| 15067 // Whether domain-grouped history is enabled. | 15068 // Whether domain-grouped history is enabled. |
| 15068 grouped_: {type: Boolean, reflectToAttribute: true}, | 15069 grouped_: {type: Boolean, reflectToAttribute: true}, |
| 15069 | 15070 |
| 15070 /** @type {!QueryState} */ | 15071 /** @type {!QueryState} */ |
| 15071 queryState_: { | 15072 queryState_: { |
| 15072 type: Object, | 15073 type: Object, |
| 15073 value: function() { | 15074 value: function() { |
| 15074 return { | 15075 return { |
| 15075 // Whether the most recent query was incremental. | 15076 // Whether the most recent query was incremental. |
| 15076 incremental: false, | 15077 incremental: false, |
| 15077 // A query is initiated by page load. | 15078 // A query is initiated by page load. |
| 15078 querying: true, | 15079 querying: true, |
| 15079 queryingDisabled: false, | 15080 queryingDisabled: false, |
| 15080 _range: HistoryRange.ALL_TIME, | 15081 _range: HistoryRange.ALL_TIME, |
| 15081 searchTerm: '', | 15082 searchTerm: '', |
| 15082 // TODO(calamity): Make history toolbar buttons change the offset | 15083 // TODO(calamity): Make history toolbar buttons change the offset |
| 15083 groupedOffset: 0, | 15084 groupedOffset: 0, |
| 15084 | 15085 |
| 15085 set range(val) { this._range = Number(val); }, | 15086 set range(val) { this._range = Number(val); }, |
| 15086 get range() { return this._range; }, | 15087 get range() { return this._range; }, |
| 15087 }; | 15088 }; |
| 15088 } | 15089 } |
| 15089 }, | 15090 }, |
| 15090 | 15091 |
| 15091 /** @type {!QueryResult} */ | 15092 /** @type {!QueryResult} */ |
| 15092 queryResult_: { | 15093 queryResult_: { |
| 15093 type: Object, | 15094 type: Object, |
| 15094 value: function() { | 15095 value: function() { |
| 15095 return { | 15096 return { |
| 15096 info: null, | 15097 info: null, |
| 15097 results: null, | 15098 results: null, |
| 15098 sessionList: null, | 15099 sessionList: null, |
| 15099 }; | 15100 }; |
| 15100 } | 15101 } |
| 15101 }, | 15102 }, |
| 15102 | 15103 |
| 15103 // Route data for the current page. | 15104 // Route data for the current page. |
| 15104 routeData_: Object, | 15105 routeData_: Object, |
| 15105 | 15106 |
| 15106 // The query params for the page. | 15107 // The query params for the page. |
| 15107 queryParams_: Object, | 15108 queryParams_: Object, |
| 15108 | 15109 |
| 15109 // True if the window is narrow enough for the page to have a drawer. | 15110 // True if the window is narrow enough for the page to have a drawer. |
| 15110 hasDrawer_: Boolean, | 15111 hasDrawer_: Boolean, |
| 15112 |
| 15113 isUserSignedIn_: { |
| 15114 type: Boolean, |
| 15115 // Updated on synced-device-manager attach by chrome.sending |
| 15116 // 'otherDevicesInitialized'. |
| 15117 value: loadTimeData.getBoolean('isUserSignedIn'), |
| 15118 }, |
| 15111 }, | 15119 }, |
| 15112 | 15120 |
| 15113 observers: [ | 15121 observers: [ |
| 15114 // routeData_.page <=> selectedPage | 15122 // routeData_.page <=> selectedPage |
| 15115 'routeDataChanged_(routeData_.page)', | 15123 'routeDataChanged_(routeData_.page)', |
| 15116 'selectedPageChanged_(selectedPage_)', | 15124 'selectedPageChanged_(selectedPage_)', |
| 15117 | 15125 |
| 15118 // queryParams_.q <=> queryState.searchTerm | 15126 // queryParams_.q <=> queryState.searchTerm |
| 15119 'searchTermChanged_(queryState_.searchTerm)', | 15127 'searchTermChanged_(queryState_.searchTerm)', |
| 15120 'searchQueryParamChanged_(queryParams_.q)', | 15128 'searchQueryParamChanged_(queryParams_.q)', |
| 15121 | 15129 |
| 15122 ], | 15130 ], |
| 15123 | 15131 |
| 15124 // TODO(calamity): Replace these event listeners with data bound properties. | 15132 // TODO(calamity): Replace these event listeners with data bound properties. |
| 15125 listeners: { | 15133 listeners: { |
| 15126 'cr-menu-tap': 'onMenuTap_', | 15134 'cr-menu-tap': 'onMenuTap_', |
| 15127 'history-checkbox-select': 'checkboxSelected', | 15135 'history-checkbox-select': 'checkboxSelected', |
| 15128 'unselect-all': 'unselectAll', | 15136 'unselect-all': 'unselectAll', |
| 15129 'delete-selected': 'deleteSelected', | 15137 'delete-selected': 'deleteSelected', |
| 15130 'search-domain': 'searchDomain_', | 15138 'search-domain': 'searchDomain_', |
| 15131 'history-close-drawer': 'closeDrawer_', | 15139 'history-close-drawer': 'closeDrawer_', |
| 15140 'history-view-changed': 'recordHistoryView_', |
| 15132 }, | 15141 }, |
| 15133 | 15142 |
| 15134 /** @override */ | 15143 /** @override */ |
| 15135 ready: function() { | 15144 ready: function() { |
| 15136 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 15145 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
| 15137 | 15146 |
| 15138 cr.ui.decorate('command', cr.ui.Command); | 15147 cr.ui.decorate('command', cr.ui.Command); |
| 15139 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); | 15148 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); |
| 15140 document.addEventListener('command', this.onCommand_.bind(this)); | 15149 document.addEventListener('command', this.onCommand_.bind(this)); |
| 15141 | 15150 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15186 * @private | 15195 * @private |
| 15187 */ | 15196 */ |
| 15188 unselectAll: function() { | 15197 unselectAll: function() { |
| 15189 var listContainer = | 15198 var listContainer = |
| 15190 /** @type {HistoryListContainerElement} */ (this.$.history); | 15199 /** @type {HistoryListContainerElement} */ (this.$.history); |
| 15191 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); | 15200 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); |
| 15192 listContainer.unselectAllItems(toolbar.count); | 15201 listContainer.unselectAllItems(toolbar.count); |
| 15193 toolbar.count = 0; | 15202 toolbar.count = 0; |
| 15194 }, | 15203 }, |
| 15195 | 15204 |
| 15196 deleteSelected: function() { | 15205 deleteSelected: function() { this.$.history.deleteSelectedWithPrompt(); }, |
| 15197 this.$.history.deleteSelectedWithPrompt(); | |
| 15198 }, | |
| 15199 | 15206 |
| 15200 /** | 15207 /** |
| 15201 * @param {HistoryQuery} info An object containing information about the | 15208 * @param {HistoryQuery} info An object containing information about the |
| 15202 * query. | 15209 * query. |
| 15203 * @param {!Array<HistoryEntry>} results A list of results. | 15210 * @param {!Array<HistoryEntry>} results A list of results. |
| 15204 */ | 15211 */ |
| 15205 historyResult: function(info, results) { | 15212 historyResult: function(info, results) { |
| 15206 this.set('queryState_.querying', false); | 15213 this.set('queryState_.querying', false); |
| 15207 this.set('queryResult_.info', info); | 15214 this.set('queryResult_.info', info); |
| 15208 this.set('queryResult_.results', results); | 15215 this.set('queryResult_.results', results); |
| 15209 var listContainer = | 15216 var listContainer = |
| 15210 /** @type {HistoryListContainerElement} */ (this.$['history']); | 15217 /** @type {HistoryListContainerElement} */ (this.$['history']); |
| 15211 listContainer.historyResult(info, results); | 15218 listContainer.historyResult(info, results); |
| 15212 }, | 15219 }, |
| 15213 | 15220 |
| 15214 /** | 15221 /** |
| 15215 * Focuses the search bar in the toolbar. | 15222 * Focuses the search bar in the toolbar. |
| 15216 */ | 15223 */ |
| 15217 focusToolbarSearchField: function() { | 15224 focusToolbarSearchField: function() { this.$.toolbar.showSearchField(); }, |
| 15218 this.$.toolbar.showSearchField(); | |
| 15219 }, | |
| 15220 | 15225 |
| 15221 /** | 15226 /** |
| 15222 * Fired when the user presses 'More from this site'. | 15227 * Fired when the user presses 'More from this site'. |
| 15223 * @param {{detail: {domain: string}}} e | 15228 * @param {{detail: {domain: string}}} e |
| 15224 */ | 15229 */ |
| 15225 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, | 15230 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, |
| 15226 | 15231 |
| 15227 /** | 15232 /** |
| 15228 * @param {Event} e | 15233 * @param {Event} e |
| 15229 * @private | 15234 * @private |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15294 */ | 15299 */ |
| 15295 historyDeleted: function() { | 15300 historyDeleted: function() { |
| 15296 this.$.history.historyDeleted(); | 15301 this.$.history.historyDeleted(); |
| 15297 }, | 15302 }, |
| 15298 | 15303 |
| 15299 /** | 15304 /** |
| 15300 * Update sign in state of synced device manager after user logs in or out. | 15305 * Update sign in state of synced device manager after user logs in or out. |
| 15301 * @param {boolean} isUserSignedIn | 15306 * @param {boolean} isUserSignedIn |
| 15302 */ | 15307 */ |
| 15303 updateSignInState: function(isUserSignedIn) { | 15308 updateSignInState: function(isUserSignedIn) { |
| 15304 var syncedDeviceManagerElem = | 15309 this.isUserSignedIn_ = isUserSignedIn; |
| 15305 /** @type {HistorySyncedDeviceManagerElement} */this | |
| 15306 .$$('history-synced-device-manager'); | |
| 15307 if (syncedDeviceManagerElem) | |
| 15308 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); | |
| 15309 }, | 15310 }, |
| 15310 | 15311 |
| 15311 /** | 15312 /** |
| 15312 * @param {string} selectedPage | 15313 * @param {string} selectedPage |
| 15313 * @return {boolean} | 15314 * @return {boolean} |
| 15314 * @private | 15315 * @private |
| 15315 */ | 15316 */ |
| 15316 syncedTabsSelected_: function(selectedPage) { | 15317 syncedTabsSelected_: function(selectedPage) { |
| 15317 return selectedPage == 'syncedTabs'; | 15318 return selectedPage == 'syncedTabs'; |
| 15318 }, | 15319 }, |
| 15319 | 15320 |
| 15320 /** | 15321 /** |
| 15321 * @param {boolean} querying | 15322 * @param {boolean} querying |
| 15322 * @param {boolean} incremental | 15323 * @param {boolean} incremental |
| 15323 * @param {string} searchTerm | 15324 * @param {string} searchTerm |
| 15324 * @return {boolean} Whether a loading spinner should be shown (implies the | 15325 * @return {boolean} Whether a loading spinner should be shown (implies the |
| 15325 * backend is querying a new search term). | 15326 * backend is querying a new search term). |
| 15326 * @private | 15327 * @private |
| 15327 */ | 15328 */ |
| 15328 shouldShowSpinner_: function(querying, incremental, searchTerm) { | 15329 shouldShowSpinner_: function(querying, incremental, searchTerm) { |
| 15329 return querying && !incremental && searchTerm != ''; | 15330 return querying && !incremental && searchTerm != ''; |
| 15330 }, | 15331 }, |
| 15331 | 15332 |
| 15332 /** | 15333 /** |
| 15333 * @param {string} page | 15334 * @param {string} page |
| 15334 * @private | 15335 * @private |
| 15335 */ | 15336 */ |
| 15336 routeDataChanged_: function(page) { | 15337 routeDataChanged_: function(page) { this.selectedPage_ = page; }, |
| 15337 this.selectedPage_ = page; | |
| 15338 }, | |
| 15339 | 15338 |
| 15340 /** | 15339 /** |
| 15341 * @param {string} selectedPage | 15340 * @param {string} selectedPage |
| 15342 * @private | 15341 * @private |
| 15343 */ | 15342 */ |
| 15344 selectedPageChanged_: function(selectedPage) { | 15343 selectedPageChanged_: function(selectedPage) { |
| 15345 this.set('routeData_.page', selectedPage); | 15344 this.set('routeData_.page', selectedPage); |
| 15345 this.recordHistoryView_(); |
| 15346 }, | 15346 }, |
| 15347 | 15347 |
| 15348 /** | 15348 /** |
| 15349 * This computed binding is needed to make the iron-pages selector update when | 15349 * This computed binding is needed to make the iron-pages selector update when |
| 15350 * the synced-device-manager is instantiated for the first time. Otherwise the | 15350 * the synced-device-manager is instantiated for the first time. Otherwise the |
| 15351 * fallback selection will continue to be used after the corresponding item is | 15351 * fallback selection will continue to be used after the corresponding item is |
| 15352 * added as a child of iron-pages. | 15352 * added as a child of iron-pages. |
| 15353 * @param {string} selectedPage | 15353 * @param {string} selectedPage |
| 15354 * @param {Array} items | 15354 * @param {Array} items |
| 15355 * @return {string} | 15355 * @return {string} |
| 15356 * @private | 15356 * @private |
| 15357 */ | 15357 */ |
| 15358 getSelectedPage_: function(selectedPage, items) { | 15358 getSelectedPage_: function(selectedPage, items) { return selectedPage; }, |
| 15359 return selectedPage; | |
| 15360 }, | |
| 15361 | 15359 |
| 15362 /** @private */ | 15360 /** @private */ |
| 15363 closeDrawer_: function() { | 15361 closeDrawer_: function() { |
| 15364 var drawer = this.$$('#drawer'); | 15362 var drawer = this.$$('#drawer'); |
| 15365 if (drawer) | 15363 if (drawer) |
| 15366 drawer.close(); | 15364 drawer.close(); |
| 15367 }, | 15365 }, |
| 15366 |
| 15367 /** @private */ |
| 15368 recordHistoryView_: function() { |
| 15369 var histogramValue = HistoryViewHistogram.END; |
| 15370 switch (this.selectedPage_) { |
| 15371 case 'syncedTabs': |
| 15372 histogramValue = this.isUserSignedIn_ ? |
| 15373 HistoryViewHistogram.SYNCED_TABS : |
| 15374 HistoryViewHistogram.SIGNIN_PROMO; |
| 15375 break; |
| 15376 default: |
| 15377 switch (this.queryState_.range) { |
| 15378 case HistoryRange.ALL_TIME: |
| 15379 histogramValue = HistoryViewHistogram.HISTORY; |
| 15380 break; |
| 15381 case HistoryRange.WEEK: |
| 15382 histogramValue = HistoryViewHistogram.GROUPED_WEEK; |
| 15383 break; |
| 15384 case HistoryRange.MONTH: |
| 15385 histogramValue = HistoryViewHistogram.GROUPED_MONTH; |
| 15386 break; |
| 15387 } |
| 15388 break; |
| 15389 } |
| 15390 |
| 15391 md_history.BrowserService.getInstance().recordHistogram( |
| 15392 'History.HistoryView', histogramValue, HistoryViewHistogram.END |
| 15393 ); |
| 15394 }, |
| 15368 }); | 15395 }); |
| OLD | NEW |