| 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 11421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11432 */ | 11432 */ |
| 11433 deleteForeignSession: function(sessionTag) { | 11433 deleteForeignSession: function(sessionTag) { |
| 11434 chrome.send('deleteForeignSession', [sessionTag]); | 11434 chrome.send('deleteForeignSession', [sessionTag]); |
| 11435 }, | 11435 }, |
| 11436 | 11436 |
| 11437 openClearBrowsingData: function() { | 11437 openClearBrowsingData: function() { |
| 11438 chrome.send('clearBrowsingData'); | 11438 chrome.send('clearBrowsingData'); |
| 11439 }, | 11439 }, |
| 11440 | 11440 |
| 11441 /** | 11441 /** |
| 11442 * @param {string} histogram |
| 11443 * @param {number} value |
| 11444 * @param {number} max |
| 11445 */ |
| 11446 recordHistogram: function(histogram, value, max) { |
| 11447 chrome.send('metricsHandler:recordInHistogram', [histogram, value, max]); |
| 11448 }, |
| 11449 |
| 11450 /** |
| 11442 * Record an action in UMA. | 11451 * Record an action in UMA. |
| 11443 * @param {string} actionDesc The name of the action to be logged. | 11452 * @param {string} actionDesc The name of the action to be logged. |
| 11444 */ | 11453 */ |
| 11445 recordAction: function(actionDesc) { | 11454 recordAction: function(actionDesc) { |
| 11446 chrome.send('metricsHandler:recordAction', [actionDesc]); | 11455 chrome.send('metricsHandler:recordAction', [actionDesc]); |
| 11447 }, | 11456 }, |
| 11448 | 11457 |
| 11449 /** | 11458 /** |
| 11450 * @param {boolean} successful | 11459 * @param {boolean} successful |
| 11451 * @private | 11460 * @private |
| (...skipping 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14346 Polymer({ | 14355 Polymer({ |
| 14347 is: 'history-list-container', | 14356 is: 'history-list-container', |
| 14348 | 14357 |
| 14349 properties: { | 14358 properties: { |
| 14350 // The path of the currently selected page. | 14359 // The path of the currently selected page. |
| 14351 selectedPage_: String, | 14360 selectedPage_: String, |
| 14352 | 14361 |
| 14353 // Whether domain-grouped history is enabled. | 14362 // Whether domain-grouped history is enabled. |
| 14354 grouped: Boolean, | 14363 grouped: Boolean, |
| 14355 | 14364 |
| 14365 /** @type {HistoryRange} */ |
| 14366 groupedRange: {type: Number, observer: 'groupedRangeChanged_'}, |
| 14367 |
| 14356 /** @type {!QueryState} */ | 14368 /** @type {!QueryState} */ |
| 14357 queryState: Object, | 14369 queryState: Object, |
| 14358 | 14370 |
| 14359 /** @type {!QueryResult} */ | 14371 /** @type {!QueryResult} */ |
| 14360 queryResult: Object, | 14372 queryResult: Object, |
| 14361 }, | 14373 }, |
| 14362 | 14374 |
| 14363 observers: [ | |
| 14364 'groupedRangeChanged_(queryState.range)', | |
| 14365 ], | |
| 14366 | |
| 14367 listeners: { | 14375 listeners: { |
| 14368 'history-list-scrolled': 'closeMenu_', | 14376 'history-list-scrolled': 'closeMenu_', |
| 14369 'load-more-history': 'loadMoreHistory_', | 14377 'load-more-history': 'loadMoreHistory_', |
| 14370 'toggle-menu': 'toggleMenu_', | 14378 'toggle-menu': 'toggleMenu_', |
| 14371 }, | 14379 }, |
| 14372 | 14380 |
| 14373 /** | 14381 /** |
| 14374 * @param {HistoryQuery} info An object containing information about the | 14382 * @param {HistoryQuery} info An object containing information about the |
| 14375 * query. | 14383 * query. |
| 14376 * @param {!Array<HistoryEntry>} results A list of results. | 14384 * @param {!Array<HistoryEntry>} results A list of results. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14414 this.set('queryState.querying', true); | 14422 this.set('queryState.querying', true); |
| 14415 this.set('queryState.incremental', incremental); | 14423 this.set('queryState.incremental', incremental); |
| 14416 | 14424 |
| 14417 var lastVisitTime = 0; | 14425 var lastVisitTime = 0; |
| 14418 if (incremental) { | 14426 if (incremental) { |
| 14419 var lastVisit = this.queryResult.results.slice(-1)[0]; | 14427 var lastVisit = this.queryResult.results.slice(-1)[0]; |
| 14420 lastVisitTime = lastVisit ? lastVisit.time : 0; | 14428 lastVisitTime = lastVisit ? lastVisit.time : 0; |
| 14421 } | 14429 } |
| 14422 | 14430 |
| 14423 var maxResults = | 14431 var maxResults = |
| 14424 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; | 14432 this.groupedRange == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; |
| 14425 chrome.send('queryHistory', [ | 14433 chrome.send('queryHistory', [ |
| 14426 queryState.searchTerm, queryState.groupedOffset, queryState.range, | 14434 queryState.searchTerm, queryState.groupedOffset, queryState.range, |
| 14427 lastVisitTime, maxResults | 14435 lastVisitTime, maxResults |
| 14428 ]); | 14436 ]); |
| 14429 }, | 14437 }, |
| 14430 | 14438 |
| 14431 /** @return {number} */ | 14439 /** @return {number} */ |
| 14432 getSelectedItemCount: function() { | 14440 getSelectedItemCount: function() { |
| 14433 return this.getSelectedList_().selectedPaths.size; | 14441 return this.getSelectedList_().selectedPaths.size; |
| 14434 }, | 14442 }, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 14447 return; | 14455 return; |
| 14448 this.$.dialog.get().then(function(dialog) { | 14456 this.$.dialog.get().then(function(dialog) { |
| 14449 dialog.showModal(); | 14457 dialog.showModal(); |
| 14450 }); | 14458 }); |
| 14451 }, | 14459 }, |
| 14452 | 14460 |
| 14453 /** | 14461 /** |
| 14454 * @param {HistoryRange} range | 14462 * @param {HistoryRange} range |
| 14455 * @private | 14463 * @private |
| 14456 */ | 14464 */ |
| 14457 groupedRangeChanged_: function(range) { | 14465 groupedRangeChanged_: function(range, oldRange) { |
| 14458 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? | 14466 this.selectedPage_ = range == HistoryRange.ALL_TIME ? |
| 14459 'infinite-list' : 'grouped-list'; | 14467 'infinite-list' : 'grouped-list'; |
| 14460 | 14468 |
| 14469 if (oldRange == undefined) |
| 14470 return; |
| 14471 |
| 14461 this.queryHistory(false); | 14472 this.queryHistory(false); |
| 14473 this.fire('history-view-changed'); |
| 14462 }, | 14474 }, |
| 14463 | 14475 |
| 14464 /** @private */ | 14476 /** @private */ |
| 14465 loadMoreHistory_: function() { this.queryHistory(true); }, | 14477 loadMoreHistory_: function() { this.queryHistory(true); }, |
| 14466 | 14478 |
| 14467 /** | 14479 /** |
| 14468 * @param {HistoryQuery} info | 14480 * @param {HistoryQuery} info |
| 14469 * @param {!Array<HistoryEntry>} results | 14481 * @param {!Array<HistoryEntry>} results |
| 14470 * @private | 14482 * @private |
| 14471 */ | 14483 */ |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14695 /** | 14707 /** |
| 14696 * An array of synced devices with synced tab data. | 14708 * An array of synced devices with synced tab data. |
| 14697 * @type {!Array<!ForeignDeviceInternal>} | 14709 * @type {!Array<!ForeignDeviceInternal>} |
| 14698 */ | 14710 */ |
| 14699 syncedDevices_: { | 14711 syncedDevices_: { |
| 14700 type: Array, | 14712 type: Array, |
| 14701 value: function() { return []; } | 14713 value: function() { return []; } |
| 14702 }, | 14714 }, |
| 14703 | 14715 |
| 14704 /** @private */ | 14716 /** @private */ |
| 14705 signInState_: { | 14717 signInState: { |
| 14706 type: Boolean, | 14718 type: Boolean, |
| 14707 value: loadTimeData.getBoolean('isUserSignedIn'), | 14719 observer: 'signInStateChanged_', |
| 14708 }, | 14720 }, |
| 14709 | 14721 |
| 14710 /** @private */ | 14722 /** @private */ |
| 14711 guestSession_: { | 14723 guestSession_: { |
| 14712 type: Boolean, | 14724 type: Boolean, |
| 14713 value: loadTimeData.getBoolean('isGuestSession'), | 14725 value: loadTimeData.getBoolean('isGuestSession'), |
| 14714 }, | 14726 }, |
| 14715 | 14727 |
| 14716 /** @private */ | 14728 /** @private */ |
| 14717 fetchingSyncedTabs_: { | 14729 fetchingSyncedTabs_: { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14883 */ | 14895 */ |
| 14884 tabSyncDisabled: function() { | 14896 tabSyncDisabled: function() { |
| 14885 this.fetchingSyncedTabs_ = false; | 14897 this.fetchingSyncedTabs_ = false; |
| 14886 this.clearDisplayedSyncedDevices_(); | 14898 this.clearDisplayedSyncedDevices_(); |
| 14887 }, | 14899 }, |
| 14888 | 14900 |
| 14889 /** | 14901 /** |
| 14890 * Get called when user's sign in state changes, this will affect UI of synced | 14902 * Get called when user's sign in state changes, this will affect UI of synced |
| 14891 * tabs page. Sign in promo gets displayed when user is signed out, and | 14903 * tabs page. Sign in promo gets displayed when user is signed out, and |
| 14892 * different messages are shown when there are no synced tabs. | 14904 * different messages are shown when there are no synced tabs. |
| 14893 * @param {boolean} isUserSignedIn | 14905 * @param {boolean} signInState |
| 14894 */ | 14906 */ |
| 14895 updateSignInState: function(isUserSignedIn) { | 14907 signInStateChanged_: function() { |
| 14896 // If user's sign in state didn't change, then don't change message or | 14908 this.fire('history-view-changed'); |
| 14897 // update UI. | |
| 14898 if (this.signInState_ == isUserSignedIn) | |
| 14899 return; | |
| 14900 | |
| 14901 this.signInState_ = isUserSignedIn; | |
| 14902 | 14909 |
| 14903 // User signed out, clear synced device list and show the sign in promo. | 14910 // User signed out, clear synced device list and show the sign in promo. |
| 14904 if (!isUserSignedIn) { | 14911 if (!this.signInState) { |
| 14905 this.clearDisplayedSyncedDevices_(); | 14912 this.clearDisplayedSyncedDevices_(); |
| 14906 return; | 14913 return; |
| 14907 } | 14914 } |
| 14908 // User signed in, show the loading message when querying for synced | 14915 // User signed in, show the loading message when querying for synced |
| 14909 // devices. | 14916 // devices. |
| 14910 this.fetchingSyncedTabs_ = true; | 14917 this.fetchingSyncedTabs_ = true; |
| 14911 }, | 14918 }, |
| 14912 | 14919 |
| 14913 searchTermChanged: function(searchTerm) { | 14920 searchTermChanged: function(searchTerm) { |
| 14914 this.clearDisplayedSyncedDevices_(); | 14921 this.clearDisplayedSyncedDevices_(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14986 | 14993 |
| 14987 }); | 14994 }); |
| 14988 // Copyright 2016 The Chromium Authors. All rights reserved. | 14995 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 14989 // Use of this source code is governed by a BSD-style license that can be | 14996 // Use of this source code is governed by a BSD-style license that can be |
| 14990 // found in the LICENSE file. | 14997 // found in the LICENSE file. |
| 14991 | 14998 |
| 14992 Polymer({ | 14999 Polymer({ |
| 14993 is: 'history-side-bar', | 15000 is: 'history-side-bar', |
| 14994 | 15001 |
| 14995 properties: { | 15002 properties: { |
| 14996 selectedPage: { | 15003 selectedPage: {type: String, notify: true}, |
| 14997 type: String, | |
| 14998 notify: true | |
| 14999 }, | |
| 15000 | 15004 |
| 15001 route: Object, | 15005 route: Object, |
| 15002 | 15006 |
| 15003 showFooter: Boolean, | 15007 showFooter: Boolean, |
| 15004 | 15008 |
| 15005 // If true, the sidebar is contained within an app-drawer. | 15009 // If true, the sidebar is contained within an app-drawer. |
| 15006 drawer: { | 15010 drawer: {type: Boolean, reflectToAttribute: true}, |
| 15007 type: Boolean, | |
| 15008 reflectToAttribute: true | |
| 15009 }, | |
| 15010 }, | |
| 15011 | |
| 15012 /** @private */ | |
| 15013 onSelectorActivate_: function() { | |
| 15014 this.fire('history-close-drawer'); | |
| 15015 }, | 15011 }, |
| 15016 | 15012 |
| 15017 /** | 15013 /** |
| 15014 * @private |
| 15015 */ |
| 15016 onSelectorActivate_: function() { this.fire('history-close-drawer'); }, |
| 15017 |
| 15018 /** |
| 15018 * Relocates the user to the clear browsing data section of the settings page. | 15019 * Relocates the user to the clear browsing data section of the settings page. |
| 15019 * @param {Event} e | 15020 * @param {Event} e |
| 15020 * @private | 15021 * @private |
| 15021 */ | 15022 */ |
| 15022 onClearBrowsingDataTap_: function(e) { | 15023 onClearBrowsingDataTap_: function(e) { |
| 15024 md_history.BrowserService.getInstance().recordAction( |
| 15025 'HistoryPage_InitClearBrowsingData'); |
| 15023 md_history.BrowserService.getInstance().openClearBrowsingData(); | 15026 md_history.BrowserService.getInstance().openClearBrowsingData(); |
| 15024 e.preventDefault(); | 15027 e.preventDefault(); |
| 15025 }, | 15028 }, |
| 15026 | 15029 |
| 15027 /** | 15030 /** |
| 15028 * @param {Object} route | 15031 * @param {Object} route |
| 15029 * @private | 15032 * @private |
| 15030 */ | 15033 */ |
| 15031 getQueryString_: function(route) { | 15034 getQueryString_: function(route) { return window.location.search; } |
| 15032 return window.location.search; | |
| 15033 } | |
| 15034 }); | 15035 }); |
| 15035 // Copyright 2016 The Chromium Authors. All rights reserved. | 15036 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 15036 // Use of this source code is governed by a BSD-style license that can be | 15037 // Use of this source code is governed by a BSD-style license that can be |
| 15037 // found in the LICENSE file. | 15038 // found in the LICENSE file. |
| 15038 | 15039 |
| 15039 Polymer({ | 15040 Polymer({ |
| 15040 is: 'history-app', | 15041 is: 'history-app', |
| 15041 | 15042 |
| 15042 properties: { | 15043 properties: { |
| 15043 showSidebarFooter: Boolean, | 15044 showSidebarFooter: Boolean, |
| 15044 | 15045 |
| 15045 // The id of the currently selected page. | 15046 // The id of the currently selected page. |
| 15046 selectedPage_: {type: String, value: 'history', observer: 'unselectAll'}, | 15047 selectedPage_: {type: String, observer: 'unselectAll'}, |
| 15047 | 15048 |
| 15048 // Whether domain-grouped history is enabled. | 15049 // Whether domain-grouped history is enabled. |
| 15049 grouped_: {type: Boolean, reflectToAttribute: true}, | 15050 grouped_: {type: Boolean, reflectToAttribute: true}, |
| 15050 | 15051 |
| 15051 /** @type {!QueryState} */ | 15052 /** @type {!QueryState} */ |
| 15052 queryState_: { | 15053 queryState_: { |
| 15053 type: Object, | 15054 type: Object, |
| 15054 value: function() { | 15055 value: function() { |
| 15055 return { | 15056 return { |
| 15056 // Whether the most recent query was incremental. | 15057 // Whether the most recent query was incremental. |
| 15057 incremental: false, | 15058 incremental: false, |
| 15058 // A query is initiated by page load. | 15059 // A query is initiated by page load. |
| 15059 querying: true, | 15060 querying: true, |
| 15060 queryingDisabled: false, | 15061 queryingDisabled: false, |
| 15061 _range: HistoryRange.ALL_TIME, | 15062 _range: HistoryRange.ALL_TIME, |
| 15062 searchTerm: '', | 15063 searchTerm: '', |
| 15063 // TODO(calamity): Make history toolbar buttons change the offset | 15064 // TODO(calamity): Make history toolbar buttons change the offset |
| 15064 groupedOffset: 0, | 15065 groupedOffset: 0, |
| 15065 | 15066 |
| 15066 set range(val) { this._range = Number(val); }, | 15067 set range(val) { this._range = Number(val); }, |
| 15067 get range() { return this._range; }, | 15068 get range() { return this._range; }, |
| 15068 }; | 15069 }; |
| 15069 } | 15070 } |
| 15070 }, | 15071 }, |
| 15071 | 15072 |
| 15072 /** @type {!QueryResult} */ | 15073 /** @type {!QueryResult} */ |
| 15073 queryResult_: { | 15074 queryResult_: { |
| 15074 type: Object, | 15075 type: Object, |
| 15075 value: function() { | 15076 value: function() { |
| 15076 return { | 15077 return { |
| 15077 info: null, | 15078 info: null, |
| 15078 results: null, | 15079 results: null, |
| 15079 sessionList: null, | 15080 sessionList: null, |
| 15080 }; | 15081 }; |
| 15081 } | 15082 } |
| 15082 }, | 15083 }, |
| 15083 | 15084 |
| 15084 // Route data for the current page. | 15085 // Route data for the current page. |
| 15085 routeData_: Object, | 15086 routeData_: Object, |
| 15086 | 15087 |
| 15087 // The query params for the page. | 15088 // The query params for the page. |
| 15088 queryParams_: Object, | 15089 queryParams_: Object, |
| 15089 | 15090 |
| 15090 // True if the window is narrow enough for the page to have a drawer. | 15091 // True if the window is narrow enough for the page to have a drawer. |
| 15091 hasDrawer: Boolean, | 15092 hasDrawer: Boolean, |
| 15093 |
| 15094 isUserSignedIn_: { |
| 15095 type: Boolean, |
| 15096 // Updated on synced-device-manager attach by chrome.sending |
| 15097 // 'otherDevicesInitialized'. |
| 15098 value: loadTimeData.getBoolean('isUserSignedIn'), |
| 15099 }, |
| 15092 }, | 15100 }, |
| 15093 | 15101 |
| 15094 observers: [ | 15102 observers: [ |
| 15095 // routeData_.page <=> selectedPage | 15103 // routeData_.page <=> selectedPage |
| 15096 'routeDataChanged_(routeData_.page)', | 15104 'routeDataChanged_(routeData_.page)', |
| 15097 'selectedPageChanged_(selectedPage_)', | 15105 'selectedPageChanged_(selectedPage_)', |
| 15098 | 15106 |
| 15099 // queryParams_.q <=> queryState.searchTerm | 15107 // queryParams_.q <=> queryState.searchTerm |
| 15100 'searchTermChanged_(queryState_.searchTerm)', | 15108 'searchTermChanged_(queryState_.searchTerm)', |
| 15101 'searchQueryParamChanged_(queryParams_.q)', | 15109 'searchQueryParamChanged_(queryParams_.q)', |
| 15102 | 15110 |
| 15103 ], | 15111 ], |
| 15104 | 15112 |
| 15105 // TODO(calamity): Replace these event listeners with data bound properties. | 15113 // TODO(calamity): Replace these event listeners with data bound properties. |
| 15106 listeners: { | 15114 listeners: { |
| 15107 'cr-menu-tap': 'onMenuTap_', | 15115 'cr-menu-tap': 'onMenuTap_', |
| 15108 'history-checkbox-select': 'checkboxSelected', | 15116 'history-checkbox-select': 'checkboxSelected', |
| 15109 'unselect-all': 'unselectAll', | 15117 'unselect-all': 'unselectAll', |
| 15110 'delete-selected': 'deleteSelected', | 15118 'delete-selected': 'deleteSelected', |
| 15111 'search-domain': 'searchDomain_', | 15119 'search-domain': 'searchDomain_', |
| 15112 'history-close-drawer': 'closeDrawer_', | 15120 'history-close-drawer': 'closeDrawer_', |
| 15121 'history-view-changed': 'recordHistoryView_', |
| 15113 }, | 15122 }, |
| 15114 | 15123 |
| 15115 /** @override */ | 15124 /** @override */ |
| 15116 ready: function() { | 15125 ready: function() { |
| 15117 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 15126 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
| 15118 | 15127 |
| 15119 cr.ui.decorate('command', cr.ui.Command); | 15128 cr.ui.decorate('command', cr.ui.Command); |
| 15120 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); | 15129 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); |
| 15121 document.addEventListener('command', this.onCommand_.bind(this)); | 15130 document.addEventListener('command', this.onCommand_.bind(this)); |
| 15122 | 15131 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 15151 * @private | 15160 * @private |
| 15152 */ | 15161 */ |
| 15153 unselectAll: function() { | 15162 unselectAll: function() { |
| 15154 var listContainer = | 15163 var listContainer = |
| 15155 /** @type {HistoryListContainerElement} */ (this.$.history); | 15164 /** @type {HistoryListContainerElement} */ (this.$.history); |
| 15156 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); | 15165 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); |
| 15157 listContainer.unselectAllItems(toolbar.count); | 15166 listContainer.unselectAllItems(toolbar.count); |
| 15158 toolbar.count = 0; | 15167 toolbar.count = 0; |
| 15159 }, | 15168 }, |
| 15160 | 15169 |
| 15161 deleteSelected: function() { | 15170 deleteSelected: function() { this.$.history.deleteSelectedWithPrompt(); }, |
| 15162 this.$.history.deleteSelectedWithPrompt(); | |
| 15163 }, | |
| 15164 | 15171 |
| 15165 /** | 15172 /** |
| 15166 * @param {HistoryQuery} info An object containing information about the | 15173 * @param {HistoryQuery} info An object containing information about the |
| 15167 * query. | 15174 * query. |
| 15168 * @param {!Array<HistoryEntry>} results A list of results. | 15175 * @param {!Array<HistoryEntry>} results A list of results. |
| 15169 */ | 15176 */ |
| 15170 historyResult: function(info, results) { | 15177 historyResult: function(info, results) { |
| 15171 this.set('queryState_.querying', false); | 15178 this.set('queryState_.querying', false); |
| 15172 this.set('queryResult_.info', info); | 15179 this.set('queryResult_.info', info); |
| 15173 this.set('queryResult_.results', results); | 15180 this.set('queryResult_.results', results); |
| 15174 var listContainer = | 15181 var listContainer = |
| 15175 /** @type {HistoryListContainerElement} */ (this.$['history']); | 15182 /** @type {HistoryListContainerElement} */ (this.$['history']); |
| 15176 listContainer.historyResult(info, results); | 15183 listContainer.historyResult(info, results); |
| 15177 }, | 15184 }, |
| 15178 | 15185 |
| 15179 /** | 15186 /** |
| 15180 * Focuses the search bar in the toolbar. | 15187 * Focuses the search bar in the toolbar. |
| 15181 */ | 15188 */ |
| 15182 focusToolbarSearchField: function() { | 15189 focusToolbarSearchField: function() { this.$.toolbar.showSearchField(); }, |
| 15183 this.$.toolbar.showSearchField(); | |
| 15184 }, | |
| 15185 | 15190 |
| 15186 /** | 15191 /** |
| 15187 * Fired when the user presses 'More from this site'. | 15192 * Fired when the user presses 'More from this site'. |
| 15188 * @param {{detail: {domain: string}}} e | 15193 * @param {{detail: {domain: string}}} e |
| 15189 */ | 15194 */ |
| 15190 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, | 15195 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, |
| 15191 | 15196 |
| 15192 /** | 15197 /** |
| 15193 * @param {Event} e | 15198 * @param {Event} e |
| 15194 * @private | 15199 * @private |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15252 } | 15257 } |
| 15253 | 15258 |
| 15254 this.set('queryResult_.sessionList', sessionList); | 15259 this.set('queryResult_.sessionList', sessionList); |
| 15255 }, | 15260 }, |
| 15256 | 15261 |
| 15257 /** | 15262 /** |
| 15258 * Update sign in state of synced device manager after user logs in or out. | 15263 * Update sign in state of synced device manager after user logs in or out. |
| 15259 * @param {boolean} isUserSignedIn | 15264 * @param {boolean} isUserSignedIn |
| 15260 */ | 15265 */ |
| 15261 updateSignInState: function(isUserSignedIn) { | 15266 updateSignInState: function(isUserSignedIn) { |
| 15262 var syncedDeviceManagerElem = | 15267 this.isUserSignedIn_ = isUserSignedIn; |
| 15263 /** @type {HistorySyncedDeviceManagerElement} */this | |
| 15264 .$$('history-synced-device-manager'); | |
| 15265 if (syncedDeviceManagerElem) | |
| 15266 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); | |
| 15267 }, | 15268 }, |
| 15268 | 15269 |
| 15269 /** | 15270 /** |
| 15270 * @param {string} selectedPage | 15271 * @param {string} selectedPage |
| 15271 * @return {boolean} | 15272 * @return {boolean} |
| 15272 * @private | 15273 * @private |
| 15273 */ | 15274 */ |
| 15274 syncedTabsSelected_: function(selectedPage) { | 15275 syncedTabsSelected_: function(selectedPage) { |
| 15275 return selectedPage == 'syncedTabs'; | 15276 return selectedPage == 'syncedTabs'; |
| 15276 }, | 15277 }, |
| 15277 | 15278 |
| 15278 /** | 15279 /** |
| 15279 * @param {boolean} querying | 15280 * @param {boolean} querying |
| 15280 * @param {boolean} incremental | 15281 * @param {boolean} incremental |
| 15281 * @param {string} searchTerm | 15282 * @param {string} searchTerm |
| 15282 * @return {boolean} Whether a loading spinner should be shown (implies the | 15283 * @return {boolean} Whether a loading spinner should be shown (implies the |
| 15283 * backend is querying a new search term). | 15284 * backend is querying a new search term). |
| 15284 * @private | 15285 * @private |
| 15285 */ | 15286 */ |
| 15286 shouldShowSpinner_: function(querying, incremental, searchTerm) { | 15287 shouldShowSpinner_: function(querying, incremental, searchTerm) { |
| 15287 return querying && !incremental && searchTerm != ''; | 15288 return querying && !incremental && searchTerm != ''; |
| 15288 }, | 15289 }, |
| 15289 | 15290 |
| 15290 /** | 15291 /** |
| 15291 * @param {string} page | 15292 * @param {string} page |
| 15292 * @private | 15293 * @private |
| 15293 */ | 15294 */ |
| 15294 routeDataChanged_: function(page) { | 15295 routeDataChanged_: function(page) { this.selectedPage_ = page; }, |
| 15295 this.selectedPage_ = page; | |
| 15296 }, | |
| 15297 | 15296 |
| 15298 /** | 15297 /** |
| 15299 * @param {string} selectedPage | 15298 * @param {string} selectedPage |
| 15300 * @private | 15299 * @private |
| 15301 */ | 15300 */ |
| 15302 selectedPageChanged_: function(selectedPage) { | 15301 selectedPageChanged_: function(selectedPage) { |
| 15303 this.set('routeData_.page', selectedPage); | 15302 this.set('routeData_.page', selectedPage); |
| 15303 this.recordHistoryView_(); |
| 15304 }, | 15304 }, |
| 15305 | 15305 |
| 15306 /** | 15306 /** |
| 15307 * This computed binding is needed to make the iron-pages selector update when | 15307 * This computed binding is needed to make the iron-pages selector update when |
| 15308 * the synced-device-manager is instantiated for the first time. Otherwise the | 15308 * the synced-device-manager is instantiated for the first time. Otherwise the |
| 15309 * fallback selection will continue to be used after the corresponding item is | 15309 * fallback selection will continue to be used after the corresponding item is |
| 15310 * added as a child of iron-pages. | 15310 * added as a child of iron-pages. |
| 15311 * @param {string} selectedPage | 15311 * @param {string} selectedPage |
| 15312 * @param {Array} items | 15312 * @param {Array} items |
| 15313 * @return {string} | 15313 * @return {string} |
| 15314 * @private | 15314 * @private |
| 15315 */ | 15315 */ |
| 15316 getSelectedPage_: function(selectedPage, items) { | 15316 getSelectedPage_: function(selectedPage, items) { return selectedPage; }, |
| 15317 return selectedPage; | |
| 15318 }, | |
| 15319 | 15317 |
| 15320 /** @private */ | 15318 /** @private */ |
| 15321 closeDrawer_: function() { | 15319 closeDrawer_: function() { |
| 15322 var drawer = this.$$('#drawer'); | 15320 var drawer = this.$$('#drawer'); |
| 15323 if (drawer) | 15321 if (drawer) |
| 15324 drawer.close(); | 15322 drawer.close(); |
| 15325 }, | 15323 }, |
| 15324 |
| 15325 /** @private */ |
| 15326 recordHistoryView_: function() { |
| 15327 var histogramValue = HistoryViewHistogram.END; |
| 15328 switch (this.selectedPage_) { |
| 15329 case 'syncedTabs': |
| 15330 histogramValue = this.isUserSignedIn_ ? |
| 15331 HistoryViewHistogram.SYNCED_TABS : |
| 15332 HistoryViewHistogram.SIGNIN_PROMO; |
| 15333 break; |
| 15334 default: |
| 15335 switch (this.queryState_.range) { |
| 15336 case HistoryRange.ALL_TIME: |
| 15337 histogramValue = HistoryViewHistogram.HISTORY; |
| 15338 break; |
| 15339 case HistoryRange.WEEK: |
| 15340 histogramValue = HistoryViewHistogram.GROUPED_WEEK; |
| 15341 break; |
| 15342 case HistoryRange.MONTH: |
| 15343 histogramValue = HistoryViewHistogram.GROUPED_MONTH; |
| 15344 break; |
| 15345 } |
| 15346 break; |
| 15347 } |
| 15348 |
| 15349 md_history.BrowserService.getInstance().recordHistogram( |
| 15350 'History.HistoryView', histogramValue, HistoryViewHistogram.END |
| 15351 ); |
| 15352 }, |
| 15326 }); | 15353 }); |
| OLD | NEW |