| Index: chrome/browser/resources/md_history/app.js
|
| diff --git a/chrome/browser/resources/md_history/app.js b/chrome/browser/resources/md_history/app.js
|
| index 266e4dfc290750811c8651044c13f8e09ea070de..887fa1cd76ce001e5fe653e783f3b211eaeff057 100644
|
| --- a/chrome/browser/resources/md_history/app.js
|
| +++ b/chrome/browser/resources/md_history/app.js
|
| @@ -2,77 +2,46 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -/**
|
| - * @typedef {{querying: boolean,
|
| - * searchTerm: string,
|
| - * results: ?Array<!HistoryEntry>,
|
| - * info: ?HistoryQuery,
|
| - * incremental: boolean,
|
| - * range: HistoryRange,
|
| - * groupedOffset: number,
|
| - * sessionList: ?Array<!ForeignSession>}}
|
| - */
|
| -var QueryState;
|
| -
|
| Polymer({
|
| is: 'history-app',
|
|
|
| properties: {
|
| // The id of the currently selected page.
|
| - selectedPage_: {
|
| - type: String,
|
| - value: 'history-list',
|
| - observer: 'unselectAll'
|
| - },
|
| + selectedPage_: {type: String, value: 'history', observer: 'unselectAll'},
|
|
|
| // Whether domain-grouped history is enabled.
|
| - grouped_: {
|
| - type: Boolean,
|
| - reflectToAttribute: true
|
| - },
|
| -
|
| - // Whether the first set of results have returned.
|
| - firstLoad_: { type: Boolean, value: true },
|
| -
|
| - // True if the history queries are disabled.
|
| - queryingDisabled_: Boolean,
|
| + grouped_: {type: Boolean, reflectToAttribute: true},
|
|
|
| /** @type {!QueryState} */
|
| - // TODO(calamity): Split out readOnly data into a separate property which is
|
| - // only set on result return.
|
| queryState_: {
|
| type: Object,
|
| value: function() {
|
| return {
|
| + // Whether the most recent query was incremental.
|
| + incremental: false,
|
| // A query is initiated by page load.
|
| querying: true,
|
| + queryingDisabled: Boolean,
|
| + _range: HistoryRange.ALL_TIME,
|
| searchTerm: '',
|
| - results: null,
|
| - // Whether the most recent query was incremental.
|
| - incremental: false,
|
| - info: null,
|
| - range: HistoryRange.ALL_TIME,
|
| - // TODO(calamity): Make history toolbar buttons change the offset.
|
| + // TODO(calamity): Make history toolbar buttons change the offset
|
| groupedOffset: 0,
|
| - sessionList: null,
|
| +
|
| + set range(val) { this._range = Number(val); },
|
| + get range() { return this._range; },
|
| };
|
| }
|
| },
|
| - },
|
|
|
| - observers: [
|
| - 'searchTermChanged_(queryState_.searchTerm)',
|
| - 'groupedRangeChanged_(queryState_.range)',
|
| - ],
|
| + sessionList: Array,
|
| + },
|
|
|
| - // TODO(calamity): Replace these event listeners with data bound properties.
|
| listeners: {
|
| 'cr-menu-tap': 'onMenuTap_',
|
| 'history-checkbox-select': 'checkboxSelected',
|
| 'unselect-all': 'unselectAll',
|
| 'delete-selected': 'deleteSelected',
|
| 'search-domain': 'searchDomain_',
|
| - 'load-more-history': 'loadMoreHistory_',
|
| },
|
|
|
| /** @override */
|
| @@ -81,9 +50,7 @@ Polymer({
|
| },
|
|
|
| /** @private */
|
| - onMenuTap_: function() {
|
| - this.$['side-bar'].toggle();
|
| - },
|
| + onMenuTap_: function() { this.$['side-bar'].toggle(); },
|
|
|
| /**
|
| * Listens for history-item being selected or deselected (through checkbox)
|
| @@ -91,7 +58,7 @@ Polymer({
|
| * @param {{detail: {countAddition: number}}} e
|
| */
|
| checkboxSelected: function(e) {
|
| - var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar);
|
| + var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar);
|
| toolbar.count += e.detail.countAddition;
|
| },
|
|
|
| @@ -101,10 +68,10 @@ Polymer({
|
| * @private
|
| */
|
| unselectAll: function() {
|
| - var historyList =
|
| - /** @type {HistoryListElement} */(this.$['history-list']);
|
| - var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar);
|
| - historyList.unselectAllItems(toolbar.count);
|
| + var listContainer =
|
| + /** @type {HistoryListContainerElement} */ (this.$['history']);
|
| + var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar);
|
| + listContainer.unselectAllItems(toolbar.count);
|
| toolbar.count = 0;
|
| },
|
|
|
| @@ -118,25 +85,8 @@ Polymer({
|
|
|
| // TODO(hsampson): add a popup to check whether the user definitely
|
| // wants to delete the selected items.
|
| - /** @type {HistoryListElement} */(this.$['history-list']).deleteSelected();
|
| - },
|
| -
|
| - initializeResults_: function(info, results) {
|
| - if (results.length == 0)
|
| - return;
|
| -
|
| - var currentDate = results[0].dateRelativeDay;
|
| -
|
| - for (var i = 0; i < results.length; i++) {
|
| - // Sets the default values for these fields to prevent undefined types.
|
| - results[i].selected = false;
|
| - results[i].readableTimestamp =
|
| - info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort;
|
| -
|
| - if (results[i].dateRelativeDay != currentDate) {
|
| - currentDate = results[i].dateRelativeDay;
|
| - }
|
| - }
|
| + /** @type {HistoryListContainerElement} */ (this.$['history'])
|
| + .deleteSelected();
|
| },
|
|
|
| /**
|
| @@ -145,71 +95,17 @@ Polymer({
|
| * @param {!Array<HistoryEntry>} results A list of results.
|
| */
|
| historyResult: function(info, results) {
|
| - this.firstLoad_ = false;
|
| - this.set('queryState_.info', info);
|
| - this.set('queryState_.results', results);
|
| this.set('queryState_.querying', false);
|
| -
|
| - this.initializeResults_(info, results);
|
| -
|
| - if (this.grouped_ && this.queryState_.range != HistoryRange.ALL_TIME) {
|
| - this.$$('history-grouped-list').historyData = results;
|
| - return;
|
| - }
|
| -
|
| - var list = /** @type {HistoryListElement} */(this.$['history-list']);
|
| - list.addNewResults(results);
|
| - if (info.finished)
|
| - list.disableResultLoading();
|
| + var listContainer =
|
| + /** @type {HistoryListContainerElement} */ (this.$['history']);
|
| + listContainer.historyResult(info, results);
|
| },
|
|
|
| /**
|
| * Fired when the user presses 'More from this site'.
|
| * @param {{detail: {domain: string}}} e
|
| */
|
| - searchDomain_: function(e) {
|
| - this.$.toolbar.setSearchTerm(e.detail.domain);
|
| - },
|
| -
|
| - searchTermChanged_: function(searchTerm) {
|
| - this.queryHistory(false);
|
| - },
|
| -
|
| - groupedRangeChanged_: function(range) {
|
| - this.queryHistory(false);
|
| - },
|
| -
|
| - loadMoreHistory_: function() {
|
| - this.queryHistory(true);
|
| - },
|
| -
|
| - /**
|
| - * Queries the history backend for results based on queryState_.
|
| - * @param {boolean} incremental Whether the new query should continue where
|
| - * the previous query stopped.
|
| - */
|
| - queryHistory: function(incremental) {
|
| - if (this.queryingDisabled_ || this.firstLoad_)
|
| - return;
|
| -
|
| - this.set('queryState_.querying', true);
|
| - this.set('queryState_.incremental', incremental);
|
| -
|
| - var queryState = this.queryState_;
|
| -
|
| - var lastVisitTime = 0;
|
| - if (incremental) {
|
| - var lastVisit = queryState.results.slice(-1)[0];
|
| - lastVisitTime = lastVisit ? lastVisit.time : 0;
|
| - }
|
| -
|
| - var maxResults =
|
| - queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
|
| - chrome.send('queryHistory', [
|
| - queryState.searchTerm, queryState.groupedOffset, Number(queryState.range),
|
| - lastVisitTime, maxResults
|
| - ]);
|
| - },
|
| + searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); },
|
|
|
| /**
|
| * @param {!Array<!ForeignSession>} sessionList Array of objects describing
|
| @@ -220,19 +116,7 @@ Polymer({
|
| if (!isTabSyncEnabled)
|
| return;
|
|
|
| - this.set('queryState_.sessionList', sessionList);
|
| - },
|
| -
|
| - /**
|
| - * @param {string} selectedPage
|
| - * @param {HistoryRange} range
|
| - * @return {string}
|
| - */
|
| - getSelectedPage: function(selectedPage, range) {
|
| - if (selectedPage == 'history-list' && range != HistoryRange.ALL_TIME)
|
| - return 'history-grouped-list';
|
| -
|
| - return selectedPage;
|
| + this.sessionList = sessionList;
|
| },
|
|
|
| /**
|
| @@ -252,7 +136,7 @@ Polymer({
|
| * @private
|
| */
|
| syncedTabsSelected_: function(selectedPage) {
|
| - return selectedPage == 'history-synced-device-manager';
|
| + return selectedPage == 'synced-devices';
|
| },
|
|
|
| /**
|
| @@ -265,5 +149,5 @@ Polymer({
|
| */
|
| shouldShowSpinner_: function(querying, incremental, searchTerm) {
|
| return querying && !incremental && searchTerm != '';
|
| - }
|
| + },
|
| });
|
|
|