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 e3ce661c53ff300564fe432bff9707cf650ba461..33e2c62d79a61eec7d0d97c1c32fad400fe67ff8 100644 |
--- a/chrome/browser/resources/md_history/app.js |
+++ b/chrome/browser/resources/md_history/app.js |
@@ -31,7 +31,7 @@ Polymer({ |
hasSyncedResults: Boolean, |
// The id of the currently selected page. |
- selectedPage_: {type: String, observer: 'unselectAll'}, |
+ selectedPage_: {type: String, observer: 'selectedPageChanged_'}, |
// Whether domain-grouped history is enabled. |
grouped_: {type: Boolean, reflectToAttribute: true}, |
@@ -69,12 +69,6 @@ Polymer({ |
} |
}, |
- // Route data for the current page. |
- routeData_: Object, |
- |
- // The query params for the page. |
- queryParams_: Object, |
- |
// True if the window is narrow enough for the page to have a drawer. |
hasDrawer_: Boolean, |
@@ -92,24 +86,12 @@ Polymer({ |
} |
}, |
- observers: [ |
- // routeData_.page <=> selectedPage |
- 'routeDataChanged_(routeData_.page)', |
- 'selectedPageChanged_(selectedPage_)', |
- |
- // queryParams_.q <=> queryState.searchTerm |
- 'searchTermChanged_(queryState_.searchTerm)', |
- 'searchQueryParamChanged_(queryParams_.q)', |
- |
- ], |
- |
// 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_', |
'history-close-drawer': 'closeDrawer_', |
'history-view-changed': 'historyViewChanged_', |
}, |
@@ -121,12 +103,6 @@ Polymer({ |
cr.ui.decorate('command', cr.ui.Command); |
document.addEventListener('canExecute', this.onCanExecute_.bind(this)); |
document.addEventListener('command', this.onCommand_.bind(this)); |
- |
- // Redirect legacy search URLs to URLs compatible with material history. |
- if (window.location.hash) { |
- window.location.href = window.location.href.split('#')[0] + '?' + |
- window.location.hash.substr(1); |
- } |
}, |
onFirstRender: function() { |
@@ -148,7 +124,8 @@ Polymer({ |
/** Overridden from IronScrollTargetBehavior */ |
_scrollHandler: function() { |
- this.toolbarShadow_ = this.scrollTarget.scrollTop != 0; |
+ if (this.scrollTarget) |
+ this.toolbarShadow_ = this.scrollTarget.scrollTop != 0; |
}, |
/** @private */ |
@@ -204,12 +181,6 @@ Polymer({ |
focusToolbarSearchField: function() { this.$.toolbar.showSearchField(); }, |
/** |
- * Fired when the user presses 'More from this site'. |
- * @param {{detail: {domain: string}}} e |
- */ |
- searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, |
- |
- /** |
* @param {Event} e |
* @private |
*/ |
@@ -220,7 +191,7 @@ Polymer({ |
e.canExecute = true; |
break; |
case 'slash-command': |
- e.canExecute = !this.$.toolbar.searchBar.isSearchFocused(); |
+ e.canExecute = !this.$.toolbar.searchField.isSearchFocused(); |
break; |
case 'delete-command': |
e.canExecute = this.$.toolbar.count > 0; |
@@ -229,26 +200,6 @@ Polymer({ |
}, |
/** |
- * @param {string} searchTerm |
- * @private |
- */ |
- searchTermChanged_: function(searchTerm) { |
- this.set('queryParams_.q', searchTerm || null); |
- this.$['history'].queryHistory(false); |
- // TODO(tsergeant): Ignore incremental searches in this metric. |
- if (this.queryState_.searchTerm) |
- md_history.BrowserService.getInstance().recordAction('Search'); |
- }, |
- |
- /** |
- * @param {string} searchQuery |
- * @private |
- */ |
- searchQueryParamChanged_: function(searchQuery) { |
- this.$.toolbar.setSearchTerm(searchQuery || ''); |
- }, |
- |
- /** |
* @param {Event} e |
* @private |
*/ |
@@ -324,17 +275,10 @@ Polymer({ |
}, |
/** |
- * @param {string} page |
- * @private |
- */ |
- routeDataChanged_: function(page) { this.selectedPage_ = page; }, |
- |
- /** |
- * @param {string} selectedPage |
* @private |
*/ |
- selectedPageChanged_: function(selectedPage) { |
- this.set('routeData_.page', selectedPage); |
+ selectedPageChanged_: function() { |
+ this.unselectAll(); |
this.historyViewChanged_(); |
}, |
@@ -343,7 +287,12 @@ Polymer({ |
// This allows the synced-device-manager to render so that it can be set as |
// the scroll target. |
requestAnimationFrame(function() { |
- this.scrollTarget = this.$.content.selectedItem.getContentScrollTarget(); |
+ // <iron-pages> can occasionally end up with no item selected during |
+ // tests. |
+ if (!this.$.content.selectedItem) |
+ return; |
+ this.scrollTarget = |
+ this.$.content.selectedItem.getContentScrollTarget(); |
this._scrollHandler(); |
}.bind(this)); |
this.recordHistoryPageView_(); |