| Index: chrome/browser/resources/md_history/app.crisper.js
|
| diff --git a/chrome/browser/resources/md_history/app.crisper.js b/chrome/browser/resources/md_history/app.crisper.js
|
| index 39c72ed5189bb4fa38fe12fc5742018e5a5586d8..e6c08baa1f5371681f39411a52f209fb17b4ecca 100644
|
| --- a/chrome/browser/resources/md_history/app.crisper.js
|
| +++ b/chrome/browser/resources/md_history/app.crisper.js
|
| @@ -507,612 +507,49 @@ cr.define('cr.ui', function() {
|
| };
|
| });
|
|
|
| -(function() {
|
| - 'use strict';
|
| - Polymer({
|
| - is: 'iron-location',
|
| - properties: {
|
| - path: {
|
| - type: String,
|
| - notify: true,
|
| - value: function() {
|
| - return window.decodeURIComponent(window.location.pathname);
|
| - }
|
| - },
|
| - query: {
|
| - type: String,
|
| - notify: true,
|
| - value: function() {
|
| - return window.decodeURIComponent(window.location.search.slice(1));
|
| - }
|
| - },
|
| - hash: {
|
| - type: String,
|
| - notify: true,
|
| - value: function() {
|
| - return window.decodeURIComponent(window.location.hash.slice(1));
|
| - }
|
| - },
|
| - dwellTime: {
|
| - type: Number,
|
| - value: 2e3
|
| - },
|
| - urlSpaceRegex: {
|
| - type: String,
|
| - value: ''
|
| - },
|
| - _urlSpaceRegExp: {
|
| - computed: '_makeRegExp(urlSpaceRegex)'
|
| - },
|
| - _lastChangedAt: {
|
| - type: Number
|
| - },
|
| - _initialized: {
|
| - type: Boolean,
|
| - value: false
|
| - }
|
| - },
|
| - hostAttributes: {
|
| - hidden: true
|
| - },
|
| - observers: [ '_updateUrl(path, query, hash)' ],
|
| - attached: function() {
|
| - this.listen(window, 'hashchange', '_hashChanged');
|
| - this.listen(window, 'location-changed', '_urlChanged');
|
| - this.listen(window, 'popstate', '_urlChanged');
|
| - this.listen(document.body, 'click', '_globalOnClick');
|
| - this._lastChangedAt = window.performance.now() - (this.dwellTime - 200);
|
| - this._initialized = true;
|
| - this._urlChanged();
|
| - },
|
| - detached: function() {
|
| - this.unlisten(window, 'hashchange', '_hashChanged');
|
| - this.unlisten(window, 'location-changed', '_urlChanged');
|
| - this.unlisten(window, 'popstate', '_urlChanged');
|
| - this.unlisten(document.body, 'click', '_globalOnClick');
|
| - this._initialized = false;
|
| - },
|
| - _hashChanged: function() {
|
| - this.hash = window.decodeURIComponent(window.location.hash.substring(1));
|
| - },
|
| - _urlChanged: function() {
|
| - this._dontUpdateUrl = true;
|
| - this._hashChanged();
|
| - this.path = window.decodeURIComponent(window.location.pathname);
|
| - this.query = window.decodeURIComponent(window.location.search.substring(1));
|
| - this._dontUpdateUrl = false;
|
| - this._updateUrl();
|
| - },
|
| - _getUrl: function() {
|
| - var partiallyEncodedPath = window.encodeURI(this.path).replace(/\#/g, '%23').replace(/\?/g, '%3F');
|
| - var partiallyEncodedQuery = '';
|
| - if (this.query) {
|
| - partiallyEncodedQuery = '?' + window.encodeURI(this.query).replace(/\#/g, '%23');
|
| - }
|
| - var partiallyEncodedHash = '';
|
| - if (this.hash) {
|
| - partiallyEncodedHash = '#' + window.encodeURI(this.hash);
|
| - }
|
| - return partiallyEncodedPath + partiallyEncodedQuery + partiallyEncodedHash;
|
| - },
|
| - _updateUrl: function() {
|
| - if (this._dontUpdateUrl || !this._initialized) {
|
| - return;
|
| - }
|
| - if (this.path === window.decodeURIComponent(window.location.pathname) && this.query === window.decodeURIComponent(window.location.search.substring(1)) && this.hash === window.decodeURIComponent(window.location.hash.substring(1))) {
|
| - return;
|
| - }
|
| - var newUrl = this._getUrl();
|
| - var fullNewUrl = new URL(newUrl, window.location.protocol + '//' + window.location.host).href;
|
| - var now = window.performance.now();
|
| - var shouldReplace = this._lastChangedAt + this.dwellTime > now;
|
| - this._lastChangedAt = now;
|
| - if (shouldReplace) {
|
| - window.history.replaceState({}, '', fullNewUrl);
|
| - } else {
|
| - window.history.pushState({}, '', fullNewUrl);
|
| - }
|
| - this.fire('location-changed', {}, {
|
| - node: window
|
| - });
|
| - },
|
| - _globalOnClick: function(event) {
|
| - if (event.defaultPrevented) {
|
| - return;
|
| - }
|
| - var href = this._getSameOriginLinkHref(event);
|
| - if (!href) {
|
| - return;
|
| - }
|
| - event.preventDefault();
|
| - if (href === window.location.href) {
|
| - return;
|
| - }
|
| - window.history.pushState({}, '', href);
|
| - this.fire('location-changed', {}, {
|
| - node: window
|
| - });
|
| - },
|
| - _getSameOriginLinkHref: function(event) {
|
| - if (event.button !== 0) {
|
| - return null;
|
| - }
|
| - if (event.metaKey || event.ctrlKey) {
|
| - return null;
|
| - }
|
| - var eventPath = Polymer.dom(event).path;
|
| - var anchor = null;
|
| - for (var i = 0; i < eventPath.length; i++) {
|
| - var element = eventPath[i];
|
| - if (element.tagName === 'A' && element.href) {
|
| - anchor = element;
|
| - break;
|
| - }
|
| - }
|
| - if (!anchor) {
|
| - return null;
|
| - }
|
| - if (anchor.target === '_blank') {
|
| - return null;
|
| - }
|
| - if ((anchor.target === '_top' || anchor.target === '_parent') && window.top !== window) {
|
| - return null;
|
| - }
|
| - var href = anchor.href;
|
| - var url;
|
| - if (document.baseURI != null) {
|
| - url = new URL(href, document.baseURI);
|
| - } else {
|
| - url = new URL(href);
|
| - }
|
| - var origin;
|
| - if (window.location.origin) {
|
| - origin = window.location.origin;
|
| - } else {
|
| - origin = window.location.protocol + '//' + window.location.hostname;
|
| - if (window.location.port) {
|
| - origin += ':' + window.location.port;
|
| - }
|
| - }
|
| - if (url.origin !== origin) {
|
| - return null;
|
| - }
|
| - var normalizedHref = url.pathname + url.search + url.hash;
|
| - if (this._urlSpaceRegExp && !this._urlSpaceRegExp.test(normalizedHref)) {
|
| - return null;
|
| - }
|
| - var fullNormalizedHref = new URL(normalizedHref, window.location.href).href;
|
| - return fullNormalizedHref;
|
| - },
|
| - _makeRegExp: function(urlSpaceRegex) {
|
| - return RegExp(urlSpaceRegex);
|
| - }
|
| - });
|
| -})();
|
| -
|
| -'use strict';
|
| -
|
| Polymer({
|
| - is: 'iron-query-params',
|
| + is: 'iron-media-query',
|
| properties: {
|
| - paramsString: {
|
| + queryMatches: {
|
| + type: Boolean,
|
| + value: false,
|
| + readOnly: true,
|
| + notify: true
|
| + },
|
| + query: {
|
| type: String,
|
| - notify: true,
|
| - observer: 'paramsStringChanged'
|
| + observer: 'queryChanged'
|
| },
|
| - paramsObject: {
|
| - type: Object,
|
| - notify: true,
|
| + full: {
|
| + type: Boolean,
|
| + value: false
|
| + },
|
| + _boundMQHandler: {
|
| value: function() {
|
| - return {};
|
| + return this.queryHandler.bind(this);
|
| }
|
| },
|
| - _dontReact: {
|
| - type: Boolean,
|
| - value: false
|
| + _mq: {
|
| + value: null
|
| }
|
| },
|
| - hostAttributes: {
|
| - hidden: true
|
| + attached: function() {
|
| + this.style.display = 'none';
|
| + this.queryChanged();
|
| },
|
| - observers: [ 'paramsObjectChanged(paramsObject.*)' ],
|
| - paramsStringChanged: function() {
|
| - this._dontReact = true;
|
| - this.paramsObject = this._decodeParams(this.paramsString);
|
| - this._dontReact = false;
|
| + detached: function() {
|
| + this._remove();
|
| },
|
| - paramsObjectChanged: function() {
|
| - if (this._dontReact) {
|
| - return;
|
| + _add: function() {
|
| + if (this._mq) {
|
| + this._mq.addListener(this._boundMQHandler);
|
| }
|
| - this.paramsString = this._encodeParams(this.paramsObject);
|
| },
|
| - _encodeParams: function(params) {
|
| - var encodedParams = [];
|
| - for (var key in params) {
|
| - var value = params[key];
|
| - if (value === '') {
|
| - encodedParams.push(encodeURIComponent(key));
|
| - } else if (value) {
|
| - encodedParams.push(encodeURIComponent(key) + '=' + encodeURIComponent(value.toString()));
|
| - }
|
| + _remove: function() {
|
| + if (this._mq) {
|
| + this._mq.removeListener(this._boundMQHandler);
|
| }
|
| - return encodedParams.join('&');
|
| - },
|
| - _decodeParams: function(paramString) {
|
| - var params = {};
|
| - paramString = (paramString || '').replace(/\+/g, '%20');
|
| - var paramList = paramString.split('&');
|
| - for (var i = 0; i < paramList.length; i++) {
|
| - var param = paramList[i].split('=');
|
| - if (param[0]) {
|
| - params[decodeURIComponent(param[0])] = decodeURIComponent(param[1] || '');
|
| - }
|
| - }
|
| - return params;
|
| - }
|
| -});
|
| -
|
| -'use strict';
|
| -
|
| -Polymer.AppRouteConverterBehavior = {
|
| - properties: {
|
| - route: {
|
| - type: Object,
|
| - notify: true
|
| - },
|
| - queryParams: {
|
| - type: Object,
|
| - notify: true
|
| - },
|
| - path: {
|
| - type: String,
|
| - notify: true
|
| - }
|
| - },
|
| - observers: [ '_locationChanged(path, queryParams)', '_routeChanged(route.prefix, route.path)', '_routeQueryParamsChanged(route.__queryParams)' ],
|
| - created: function() {
|
| - this.linkPaths('route.__queryParams', 'queryParams');
|
| - this.linkPaths('queryParams', 'route.__queryParams');
|
| - },
|
| - _locationChanged: function() {
|
| - if (this.route && this.route.path === this.path && this.queryParams === this.route.__queryParams) {
|
| - return;
|
| - }
|
| - this.route = {
|
| - prefix: '',
|
| - path: this.path,
|
| - __queryParams: this.queryParams
|
| - };
|
| - },
|
| - _routeChanged: function() {
|
| - if (!this.route) {
|
| - return;
|
| - }
|
| - this.path = this.route.prefix + this.route.path;
|
| - },
|
| - _routeQueryParamsChanged: function(queryParams) {
|
| - if (!this.route) {
|
| - return;
|
| - }
|
| - this.queryParams = queryParams;
|
| - }
|
| -};
|
| -
|
| -'use strict';
|
| -
|
| -Polymer({
|
| - is: 'app-location',
|
| - properties: {
|
| - route: {
|
| - type: Object,
|
| - notify: true
|
| - },
|
| - useHashAsPath: {
|
| - type: Boolean,
|
| - value: false
|
| - },
|
| - urlSpaceRegex: {
|
| - type: String,
|
| - notify: true
|
| - },
|
| - __queryParams: {
|
| - type: Object
|
| - },
|
| - __path: {
|
| - type: String
|
| - },
|
| - __query: {
|
| - type: String
|
| - },
|
| - __hash: {
|
| - type: String
|
| - },
|
| - path: {
|
| - type: String,
|
| - observer: '__onPathChanged'
|
| - }
|
| - },
|
| - behaviors: [ Polymer.AppRouteConverterBehavior ],
|
| - observers: [ '__computeRoutePath(useHashAsPath, __hash, __path)' ],
|
| - __computeRoutePath: function() {
|
| - this.path = this.useHashAsPath ? this.__hash : this.__path;
|
| - },
|
| - __onPathChanged: function() {
|
| - if (!this._readied) {
|
| - return;
|
| - }
|
| - if (this.useHashAsPath) {
|
| - this.__hash = this.path;
|
| - } else {
|
| - this.__path = this.path;
|
| - }
|
| - }
|
| -});
|
| -
|
| -'use strict';
|
| -
|
| -Polymer({
|
| - is: 'app-route',
|
| - properties: {
|
| - route: {
|
| - type: Object,
|
| - notify: true
|
| - },
|
| - pattern: {
|
| - type: String
|
| - },
|
| - data: {
|
| - type: Object,
|
| - value: function() {
|
| - return {};
|
| - },
|
| - notify: true
|
| - },
|
| - queryParams: {
|
| - type: Object,
|
| - value: function() {
|
| - return {};
|
| - },
|
| - notify: true
|
| - },
|
| - tail: {
|
| - type: Object,
|
| - value: function() {
|
| - return {
|
| - path: null,
|
| - prefix: null,
|
| - __queryParams: null
|
| - };
|
| - },
|
| - notify: true
|
| - },
|
| - active: {
|
| - type: Boolean,
|
| - notify: true,
|
| - readOnly: true
|
| - },
|
| - _queryParamsUpdating: {
|
| - type: Boolean,
|
| - value: false
|
| - },
|
| - _matched: {
|
| - type: String,
|
| - value: ''
|
| - }
|
| - },
|
| - observers: [ '__tryToMatch(route.path, pattern)', '__updatePathOnDataChange(data.*)', '__tailPathChanged(tail.path)', '__routeQueryParamsChanged(route.__queryParams)', '__tailQueryParamsChanged(tail.__queryParams)', '__queryParamsChanged(queryParams.*)' ],
|
| - created: function() {
|
| - this.linkPaths('route.__queryParams', 'tail.__queryParams');
|
| - this.linkPaths('tail.__queryParams', 'route.__queryParams');
|
| - },
|
| - __routeQueryParamsChanged: function(queryParams) {
|
| - if (queryParams && this.tail) {
|
| - this.set('tail.__queryParams', queryParams);
|
| - if (!this.active || this._queryParamsUpdating) {
|
| - return;
|
| - }
|
| - var copyOfQueryParams = {};
|
| - var anythingChanged = false;
|
| - for (var key in queryParams) {
|
| - copyOfQueryParams[key] = queryParams[key];
|
| - if (anythingChanged || !this.queryParams || queryParams[key] !== this.queryParams[key]) {
|
| - anythingChanged = true;
|
| - }
|
| - }
|
| - for (var key in this.queryParams) {
|
| - if (anythingChanged || !(key in queryParams)) {
|
| - anythingChanged = true;
|
| - break;
|
| - }
|
| - }
|
| - if (!anythingChanged) {
|
| - return;
|
| - }
|
| - this._queryParamsUpdating = true;
|
| - this.set('queryParams', copyOfQueryParams);
|
| - this._queryParamsUpdating = false;
|
| - }
|
| - },
|
| - __tailQueryParamsChanged: function(queryParams) {
|
| - if (queryParams && this.route) {
|
| - this.set('route.__queryParams', queryParams);
|
| - }
|
| - },
|
| - __queryParamsChanged: function(changes) {
|
| - if (!this.active || this._queryParamsUpdating) {
|
| - return;
|
| - }
|
| - this.set('route.__' + changes.path, changes.value);
|
| - },
|
| - __resetProperties: function() {
|
| - this._setActive(false);
|
| - this._matched = null;
|
| - },
|
| - __tryToMatch: function() {
|
| - if (!this.route) {
|
| - return;
|
| - }
|
| - var path = this.route.path;
|
| - var pattern = this.pattern;
|
| - if (!pattern) {
|
| - return;
|
| - }
|
| - if (!path) {
|
| - this.__resetProperties();
|
| - return;
|
| - }
|
| - var remainingPieces = path.split('/');
|
| - var patternPieces = pattern.split('/');
|
| - var matched = [];
|
| - var namedMatches = {};
|
| - for (var i = 0; i < patternPieces.length; i++) {
|
| - var patternPiece = patternPieces[i];
|
| - if (!patternPiece && patternPiece !== '') {
|
| - break;
|
| - }
|
| - var pathPiece = remainingPieces.shift();
|
| - if (!pathPiece && pathPiece !== '') {
|
| - this.__resetProperties();
|
| - return;
|
| - }
|
| - matched.push(pathPiece);
|
| - if (patternPiece.charAt(0) == ':') {
|
| - namedMatches[patternPiece.slice(1)] = pathPiece;
|
| - } else if (patternPiece !== pathPiece) {
|
| - this.__resetProperties();
|
| - return;
|
| - }
|
| - }
|
| - this._matched = matched.join('/');
|
| - var propertyUpdates = {};
|
| - if (!this.active) {
|
| - propertyUpdates.active = true;
|
| - }
|
| - var tailPrefix = this.route.prefix + this._matched;
|
| - var tailPath = remainingPieces.join('/');
|
| - if (remainingPieces.length > 0) {
|
| - tailPath = '/' + tailPath;
|
| - }
|
| - if (!this.tail || this.tail.prefix !== tailPrefix || this.tail.path !== tailPath) {
|
| - propertyUpdates.tail = {
|
| - prefix: tailPrefix,
|
| - path: tailPath,
|
| - __queryParams: this.route.__queryParams
|
| - };
|
| - }
|
| - propertyUpdates.data = namedMatches;
|
| - this._dataInUrl = {};
|
| - for (var key in namedMatches) {
|
| - this._dataInUrl[key] = namedMatches[key];
|
| - }
|
| - this.__setMulti(propertyUpdates);
|
| - },
|
| - __tailPathChanged: function() {
|
| - if (!this.active) {
|
| - return;
|
| - }
|
| - var tailPath = this.tail.path;
|
| - var newPath = this._matched;
|
| - if (tailPath) {
|
| - if (tailPath.charAt(0) !== '/') {
|
| - tailPath = '/' + tailPath;
|
| - }
|
| - newPath += tailPath;
|
| - }
|
| - this.set('route.path', newPath);
|
| - },
|
| - __updatePathOnDataChange: function() {
|
| - if (!this.route || !this.active) {
|
| - return;
|
| - }
|
| - var newPath = this.__getLink({});
|
| - var oldPath = this.__getLink(this._dataInUrl);
|
| - if (newPath === oldPath) {
|
| - return;
|
| - }
|
| - this.set('route.path', newPath);
|
| - },
|
| - __getLink: function(overrideValues) {
|
| - var values = {
|
| - tail: null
|
| - };
|
| - for (var key in this.data) {
|
| - values[key] = this.data[key];
|
| - }
|
| - for (var key in overrideValues) {
|
| - values[key] = overrideValues[key];
|
| - }
|
| - var patternPieces = this.pattern.split('/');
|
| - var interp = patternPieces.map(function(value) {
|
| - if (value[0] == ':') {
|
| - value = values[value.slice(1)];
|
| - }
|
| - return value;
|
| - }, this);
|
| - if (values.tail && values.tail.path) {
|
| - if (interp.length > 0 && values.tail.path.charAt(0) === '/') {
|
| - interp.push(values.tail.path.slice(1));
|
| - } else {
|
| - interp.push(values.tail.path);
|
| - }
|
| - }
|
| - return interp.join('/');
|
| - },
|
| - __setMulti: function(setObj) {
|
| - for (var property in setObj) {
|
| - this._propertySetter(property, setObj[property]);
|
| - }
|
| - for (var property in setObj) {
|
| - this._pathEffector(property, this[property]);
|
| - this._notifyPathUp(property, this[property]);
|
| - }
|
| - }
|
| -});
|
| -
|
| -Polymer({
|
| - is: 'iron-media-query',
|
| - properties: {
|
| - queryMatches: {
|
| - type: Boolean,
|
| - value: false,
|
| - readOnly: true,
|
| - notify: true
|
| - },
|
| - query: {
|
| - type: String,
|
| - observer: 'queryChanged'
|
| - },
|
| - full: {
|
| - type: Boolean,
|
| - value: false
|
| - },
|
| - _boundMQHandler: {
|
| - value: function() {
|
| - return this.queryHandler.bind(this);
|
| - }
|
| - },
|
| - _mq: {
|
| - value: null
|
| - }
|
| - },
|
| - attached: function() {
|
| - this.style.display = 'none';
|
| - this.queryChanged();
|
| - },
|
| - detached: function() {
|
| - this._remove();
|
| - },
|
| - _add: function() {
|
| - if (this._mq) {
|
| - this._mq.addListener(this._boundMQHandler);
|
| - }
|
| - },
|
| - _remove: function() {
|
| - if (this._mq) {
|
| - this._mq.removeListener(this._boundMQHandler);
|
| - }
|
| - this._mq = null;
|
| + this._mq = null;
|
| },
|
| queryChanged: function() {
|
| this._remove();
|
| @@ -3660,6 +3097,7 @@ Polymer({
|
| },
|
| searchTerm: {
|
| type: String,
|
| + observer: 'searchTermChanged_',
|
| notify: true
|
| },
|
| spinnerActive: {
|
| @@ -3691,15 +3129,20 @@ Polymer({
|
| }
|
| }
|
| },
|
| + get searchField() {
|
| + return this.$['main-toolbar'].getSearchField();
|
| + },
|
| + showSearchField: function() {
|
| + this.searchField.showAndFocus();
|
| + },
|
| changeToolbarView_: function() {
|
| this.itemsSelected_ = this.count > 0;
|
| },
|
| - setSearchTerm: function(search) {
|
| - if (this.searchTerm == search) return;
|
| - this.searchTerm = search;
|
| - var searchField = this.$['main-toolbar'].getSearchField();
|
| - searchField.showAndFocus();
|
| - searchField.setValue(search);
|
| + searchTermChanged_: function() {
|
| + if (this.searchField.getValue() != this.searchTerm) {
|
| + this.searchField.showAndFocus();
|
| + this.searchField.setValue(this.searchTerm);
|
| + }
|
| },
|
| onMenuPromoShown_: function() {
|
| md_history.BrowserService.getInstance().menuPromoShown();
|
| @@ -3718,12 +3161,6 @@ Polymer({
|
| onDeleteTap_: function() {
|
| this.fire('delete-selected');
|
| },
|
| - get searchBar() {
|
| - return this.$['main-toolbar'].getSearchField();
|
| - },
|
| - showSearchField: function() {
|
| - this.$['main-toolbar'].getSearchField().showAndFocus();
|
| - },
|
| deletingAllowed_: function() {
|
| return loadTimeData.getBoolean('allowDeletingHistory');
|
| },
|
| @@ -5225,79 +4662,469 @@ var HistoryListBehavior = {
|
| }
|
| };
|
|
|
| -// Copyright 2015 The Chromium Authors. All rights reserved.
|
| -// Use of this source code is governed by a BSD-style license that can be
|
| -// found in the LICENSE file.
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +Polymer({
|
| + is: 'history-list',
|
| + behaviors: [ HistoryListBehavior ],
|
| + properties: {
|
| + searchedTerm: {
|
| + type: String,
|
| + value: ''
|
| + },
|
| + querying: Boolean,
|
| + historyData_: Array,
|
| + resultLoadingDisabled_: {
|
| + type: Boolean,
|
| + value: false
|
| + },
|
| + lastFocused_: Object
|
| + },
|
| + listeners: {
|
| + scroll: 'notifyListScroll_',
|
| + 'remove-bookmark-stars': 'removeBookmarkStars_'
|
| + },
|
| + attached: function() {
|
| + this.$['infinite-list'].notifyResize();
|
| + this.$['infinite-list'].scrollTarget = this;
|
| + this.$['scroll-threshold'].scrollTarget = this;
|
| + },
|
| + removeBookmarkStars_: function(e) {
|
| + var url = e.detail;
|
| + if (this.historyData_ === undefined) return;
|
| + for (var i = 0; i < this.historyData_.length; i++) {
|
| + if (this.historyData_[i].url == url) this.set('historyData_.' + i + '.starred', false);
|
| + }
|
| + },
|
| + disableResultLoading: function() {
|
| + this.resultLoadingDisabled_ = true;
|
| + },
|
| + addNewResults: function(historyResults, incremental) {
|
| + var results = historyResults.slice();
|
| + this.$['scroll-threshold'].clearTriggers();
|
| + if (!incremental) {
|
| + this.resultLoadingDisabled_ = false;
|
| + if (this.historyData_) this.splice('historyData_', 0, this.historyData_.length);
|
| + this.fire('unselect-all');
|
| + }
|
| + if (this.historyData_) {
|
| + results.unshift('historyData_');
|
| + this.push.apply(this, results);
|
| + } else {
|
| + this.set('historyData_', results);
|
| + }
|
| + },
|
| + loadMoreData_: function() {
|
| + if (this.resultLoadingDisabled_ || this.querying) return;
|
| + this.fire('load-more-history');
|
| + },
|
| + needsTimeGap_: function(item, index, length) {
|
| + return md_history.HistoryItem.needsTimeGap(this.historyData_, index, this.searchedTerm);
|
| + },
|
| + isCardStart_: function(item, i, length) {
|
| + if (length == 0 || i > length - 1) return false;
|
| + return i == 0 || this.historyData_[i].dateRelativeDay != this.historyData_[i - 1].dateRelativeDay;
|
| + },
|
| + isCardEnd_: function(item, i, length) {
|
| + if (length == 0 || i > length - 1) return false;
|
| + return i == length - 1 || this.historyData_[i].dateRelativeDay != this.historyData_[i + 1].dateRelativeDay;
|
| + },
|
| + notifyListScroll_: function() {
|
| + this.fire('history-list-scrolled');
|
| + },
|
| + pathForItem_: function(index) {
|
| + return 'historyData_.' + index;
|
| + }
|
| +});
|
| +
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +Polymer({
|
| + is: 'history-list-container',
|
| + properties: {
|
| + selectedPage_: String,
|
| + grouped: Boolean,
|
| + groupedRange: {
|
| + type: Number,
|
| + observer: 'groupedRangeChanged_'
|
| + },
|
| + queryState: Object,
|
| + queryResult: Object
|
| + },
|
| + observers: [ 'searchTermChanged_(queryState.searchTerm)' ],
|
| + listeners: {
|
| + 'history-list-scrolled': 'closeMenu_',
|
| + 'load-more-history': 'loadMoreHistory_',
|
| + 'toggle-menu': 'toggleMenu_'
|
| + },
|
| + historyResult: function(info, results) {
|
| + this.initializeResults_(info, results);
|
| + this.closeMenu_();
|
| + if (this.selectedPage_ == 'grouped-list') {
|
| + this.$$('#grouped-list').historyData = results;
|
| + return;
|
| + }
|
| + var list = this.$['infinite-list'];
|
| + list.addNewResults(results, this.queryState.incremental);
|
| + if (info.finished) list.disableResultLoading();
|
| + },
|
| + queryHistory: function(incremental) {
|
| + var queryState = this.queryState;
|
| + var noResults = !this.queryResult || this.queryResult.results == null;
|
| + if (queryState.queryingDisabled || !this.queryState.searchTerm && noResults) {
|
| + return;
|
| + }
|
| + var dialog = this.$.dialog.getIfExists();
|
| + if (!incremental && dialog && dialog.open) dialog.close();
|
| + this.set('queryState.querying', true);
|
| + this.set('queryState.incremental', incremental);
|
| + var lastVisitTime = 0;
|
| + if (incremental) {
|
| + var lastVisit = this.queryResult.results.slice(-1)[0];
|
| + lastVisitTime = lastVisit ? lastVisit.time : 0;
|
| + }
|
| + var maxResults = this.groupedRange == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
|
| + chrome.send('queryHistory', [ queryState.searchTerm, queryState.groupedOffset, queryState.range, lastVisitTime, maxResults ]);
|
| + },
|
| + historyDeleted: function() {
|
| + if (this.getSelectedItemCount() > 0) return;
|
| + this.queryHistory(false);
|
| + },
|
| + getContentScrollTarget: function() {
|
| + return this.getSelectedList_();
|
| + },
|
| + getSelectedItemCount: function() {
|
| + return this.getSelectedList_().selectedPaths.size;
|
| + },
|
| + unselectAllItems: function(count) {
|
| + var selectedList = this.getSelectedList_();
|
| + if (selectedList) selectedList.unselectAllItems(count);
|
| + },
|
| + deleteSelectedWithPrompt: function() {
|
| + if (!loadTimeData.getBoolean('allowDeletingHistory')) return;
|
| + var browserService = md_history.BrowserService.getInstance();
|
| + browserService.recordAction('RemoveSelected');
|
| + if (this.queryState.searchTerm != '') browserService.recordAction('SearchResultRemove');
|
| + this.$.dialog.get().showModal();
|
| + },
|
| + groupedRangeChanged_: function(range, oldRange) {
|
| + this.selectedPage_ = range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list';
|
| + if (oldRange == undefined) return;
|
| + this.queryHistory(false);
|
| + this.fire('history-view-changed');
|
| + },
|
| + searchTermChanged_: function() {
|
| + this.queryHistory(false);
|
| + if (this.queryState.searchTerm) md_history.BrowserService.getInstance().recordAction('Search');
|
| + },
|
| + loadMoreHistory_: function() {
|
| + this.queryHistory(true);
|
| + },
|
| + initializeResults_: function(info, results) {
|
| + if (results.length == 0) return;
|
| + var currentDate = results[0].dateRelativeDay;
|
| + for (var i = 0; i < results.length; i++) {
|
| + results[i].selected = false;
|
| + results[i].readableTimestamp = info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort;
|
| + if (results[i].dateRelativeDay != currentDate) {
|
| + currentDate = results[i].dateRelativeDay;
|
| + }
|
| + }
|
| + },
|
| + onDialogConfirmTap_: function() {
|
| + md_history.BrowserService.getInstance().recordAction('ConfirmRemoveSelected');
|
| + this.getSelectedList_().deleteSelected();
|
| + var dialog = assert(this.$.dialog.getIfExists());
|
| + dialog.close();
|
| + },
|
| + onDialogCancelTap_: function() {
|
| + md_history.BrowserService.getInstance().recordAction('CancelRemoveSelected');
|
| + var dialog = assert(this.$.dialog.getIfExists());
|
| + dialog.close();
|
| + },
|
| + closeMenu_: function() {
|
| + var menu = this.$.sharedMenu.getIfExists();
|
| + if (menu) menu.closeMenu();
|
| + },
|
| + toggleMenu_: function(e) {
|
| + var target = e.detail.target;
|
| + var menu = this.$.sharedMenu.get();
|
| + menu.toggleMenu(target, e.detail);
|
| + },
|
| + onMoreFromSiteTap_: function() {
|
| + md_history.BrowserService.getInstance().recordAction('EntryMenuShowMoreFromSite');
|
| + var menu = assert(this.$.sharedMenu.getIfExists());
|
| + this.set('queryState.searchTerm', menu.itemData.item.domain);
|
| + menu.closeMenu();
|
| + },
|
| + onRemoveFromHistoryTap_: function() {
|
| + var browserService = md_history.BrowserService.getInstance();
|
| + browserService.recordAction('EntryMenuRemoveFromHistory');
|
| + var menu = assert(this.$.sharedMenu.getIfExists());
|
| + var itemData = menu.itemData;
|
| + browserService.deleteItems([ itemData.item ]).then(function(items) {
|
| + this.getSelectedList_().removeItemsByPath([ itemData.path ]);
|
| + this.fire('unselect-all');
|
| + var index = itemData.index;
|
| + if (index == undefined) return;
|
| + var browserService = md_history.BrowserService.getInstance();
|
| + browserService.recordHistogram('HistoryPage.RemoveEntryPosition', index, UMA_MAX_BUCKET_VALUE);
|
| + if (index <= UMA_MAX_SUBSET_BUCKET_VALUE) {
|
| + browserService.recordHistogram('HistoryPage.RemoveEntryPositionSubset', index, UMA_MAX_SUBSET_BUCKET_VALUE);
|
| + }
|
| + }.bind(this));
|
| + menu.closeMenu();
|
| + },
|
| + getSelectedList_: function() {
|
| + return this.$.content.selectedItem;
|
| + }
|
| +});
|
| +
|
| +(function() {
|
| + 'use strict';
|
| + Polymer({
|
| + is: 'iron-location',
|
| + properties: {
|
| + path: {
|
| + type: String,
|
| + notify: true,
|
| + value: function() {
|
| + return window.decodeURIComponent(window.location.pathname);
|
| + }
|
| + },
|
| + query: {
|
| + type: String,
|
| + notify: true,
|
| + value: function() {
|
| + return window.decodeURIComponent(window.location.search.slice(1));
|
| + }
|
| + },
|
| + hash: {
|
| + type: String,
|
| + notify: true,
|
| + value: function() {
|
| + return window.decodeURIComponent(window.location.hash.slice(1));
|
| + }
|
| + },
|
| + dwellTime: {
|
| + type: Number,
|
| + value: 2e3
|
| + },
|
| + urlSpaceRegex: {
|
| + type: String,
|
| + value: ''
|
| + },
|
| + _urlSpaceRegExp: {
|
| + computed: '_makeRegExp(urlSpaceRegex)'
|
| + },
|
| + _lastChangedAt: {
|
| + type: Number
|
| + },
|
| + _initialized: {
|
| + type: Boolean,
|
| + value: false
|
| + }
|
| + },
|
| + hostAttributes: {
|
| + hidden: true
|
| + },
|
| + observers: [ '_updateUrl(path, query, hash)' ],
|
| + attached: function() {
|
| + this.listen(window, 'hashchange', '_hashChanged');
|
| + this.listen(window, 'location-changed', '_urlChanged');
|
| + this.listen(window, 'popstate', '_urlChanged');
|
| + this.listen(document.body, 'click', '_globalOnClick');
|
| + this._lastChangedAt = window.performance.now() - (this.dwellTime - 200);
|
| + this._initialized = true;
|
| + this._urlChanged();
|
| + },
|
| + detached: function() {
|
| + this.unlisten(window, 'hashchange', '_hashChanged');
|
| + this.unlisten(window, 'location-changed', '_urlChanged');
|
| + this.unlisten(window, 'popstate', '_urlChanged');
|
| + this.unlisten(document.body, 'click', '_globalOnClick');
|
| + this._initialized = false;
|
| + },
|
| + _hashChanged: function() {
|
| + this.hash = window.decodeURIComponent(window.location.hash.substring(1));
|
| + },
|
| + _urlChanged: function() {
|
| + this._dontUpdateUrl = true;
|
| + this._hashChanged();
|
| + this.path = window.decodeURIComponent(window.location.pathname);
|
| + this.query = window.decodeURIComponent(window.location.search.substring(1));
|
| + this._dontUpdateUrl = false;
|
| + this._updateUrl();
|
| + },
|
| + _getUrl: function() {
|
| + var partiallyEncodedPath = window.encodeURI(this.path).replace(/\#/g, '%23').replace(/\?/g, '%3F');
|
| + var partiallyEncodedQuery = '';
|
| + if (this.query) {
|
| + partiallyEncodedQuery = '?' + window.encodeURI(this.query).replace(/\#/g, '%23');
|
| + }
|
| + var partiallyEncodedHash = '';
|
| + if (this.hash) {
|
| + partiallyEncodedHash = '#' + window.encodeURI(this.hash);
|
| + }
|
| + return partiallyEncodedPath + partiallyEncodedQuery + partiallyEncodedHash;
|
| + },
|
| + _updateUrl: function() {
|
| + if (this._dontUpdateUrl || !this._initialized) {
|
| + return;
|
| + }
|
| + if (this.path === window.decodeURIComponent(window.location.pathname) && this.query === window.decodeURIComponent(window.location.search.substring(1)) && this.hash === window.decodeURIComponent(window.location.hash.substring(1))) {
|
| + return;
|
| + }
|
| + var newUrl = this._getUrl();
|
| + var fullNewUrl = new URL(newUrl, window.location.protocol + '//' + window.location.host).href;
|
| + var now = window.performance.now();
|
| + var shouldReplace = this._lastChangedAt + this.dwellTime > now;
|
| + this._lastChangedAt = now;
|
| + if (shouldReplace) {
|
| + window.history.replaceState({}, '', fullNewUrl);
|
| + } else {
|
| + window.history.pushState({}, '', fullNewUrl);
|
| + }
|
| + this.fire('location-changed', {}, {
|
| + node: window
|
| + });
|
| + },
|
| + _globalOnClick: function(event) {
|
| + if (event.defaultPrevented) {
|
| + return;
|
| + }
|
| + var href = this._getSameOriginLinkHref(event);
|
| + if (!href) {
|
| + return;
|
| + }
|
| + event.preventDefault();
|
| + if (href === window.location.href) {
|
| + return;
|
| + }
|
| + window.history.pushState({}, '', href);
|
| + this.fire('location-changed', {}, {
|
| + node: window
|
| + });
|
| + },
|
| + _getSameOriginLinkHref: function(event) {
|
| + if (event.button !== 0) {
|
| + return null;
|
| + }
|
| + if (event.metaKey || event.ctrlKey) {
|
| + return null;
|
| + }
|
| + var eventPath = Polymer.dom(event).path;
|
| + var anchor = null;
|
| + for (var i = 0; i < eventPath.length; i++) {
|
| + var element = eventPath[i];
|
| + if (element.tagName === 'A' && element.href) {
|
| + anchor = element;
|
| + break;
|
| + }
|
| + }
|
| + if (!anchor) {
|
| + return null;
|
| + }
|
| + if (anchor.target === '_blank') {
|
| + return null;
|
| + }
|
| + if ((anchor.target === '_top' || anchor.target === '_parent') && window.top !== window) {
|
| + return null;
|
| + }
|
| + var href = anchor.href;
|
| + var url;
|
| + if (document.baseURI != null) {
|
| + url = new URL(href, document.baseURI);
|
| + } else {
|
| + url = new URL(href);
|
| + }
|
| + var origin;
|
| + if (window.location.origin) {
|
| + origin = window.location.origin;
|
| + } else {
|
| + origin = window.location.protocol + '//' + window.location.hostname;
|
| + if (window.location.port) {
|
| + origin += ':' + window.location.port;
|
| + }
|
| + }
|
| + if (url.origin !== origin) {
|
| + return null;
|
| + }
|
| + var normalizedHref = url.pathname + url.search + url.hash;
|
| + if (this._urlSpaceRegExp && !this._urlSpaceRegExp.test(normalizedHref)) {
|
| + return null;
|
| + }
|
| + var fullNormalizedHref = new URL(normalizedHref, window.location.href).href;
|
| + return fullNormalizedHref;
|
| + },
|
| + _makeRegExp: function(urlSpaceRegex) {
|
| + return RegExp(urlSpaceRegex);
|
| + }
|
| + });
|
| +})();
|
| +
|
| +'use strict';
|
| +
|
| Polymer({
|
| - is: 'history-list',
|
| - behaviors: [ HistoryListBehavior ],
|
| + is: 'iron-query-params',
|
| properties: {
|
| - searchedTerm: {
|
| + paramsString: {
|
| type: String,
|
| - value: ''
|
| + notify: true,
|
| + observer: 'paramsStringChanged'
|
| },
|
| - querying: Boolean,
|
| - historyData_: Array,
|
| - resultLoadingDisabled_: {
|
| + paramsObject: {
|
| + type: Object,
|
| + notify: true,
|
| + value: function() {
|
| + return {};
|
| + }
|
| + },
|
| + _dontReact: {
|
| type: Boolean,
|
| value: false
|
| - },
|
| - lastFocused_: Object
|
| + }
|
| },
|
| - listeners: {
|
| - scroll: 'notifyListScroll_',
|
| - 'remove-bookmark-stars': 'removeBookmarkStars_'
|
| + hostAttributes: {
|
| + hidden: true
|
| },
|
| - attached: function() {
|
| - this.$['infinite-list'].notifyResize();
|
| - this.$['infinite-list'].scrollTarget = this;
|
| - this.$['scroll-threshold'].scrollTarget = this;
|
| + observers: [ 'paramsObjectChanged(paramsObject.*)' ],
|
| + paramsStringChanged: function() {
|
| + this._dontReact = true;
|
| + this.paramsObject = this._decodeParams(this.paramsString);
|
| + this._dontReact = false;
|
| },
|
| - removeBookmarkStars_: function(e) {
|
| - var url = e.detail;
|
| - if (this.historyData_ === undefined) return;
|
| - for (var i = 0; i < this.historyData_.length; i++) {
|
| - if (this.historyData_[i].url == url) this.set('historyData_.' + i + '.starred', false);
|
| + paramsObjectChanged: function() {
|
| + if (this._dontReact) {
|
| + return;
|
| }
|
| + this.paramsString = this._encodeParams(this.paramsObject);
|
| },
|
| - disableResultLoading: function() {
|
| - this.resultLoadingDisabled_ = true;
|
| - },
|
| - addNewResults: function(historyResults, incremental) {
|
| - var results = historyResults.slice();
|
| - this.$['scroll-threshold'].clearTriggers();
|
| - if (!incremental) {
|
| - this.resultLoadingDisabled_ = false;
|
| - if (this.historyData_) this.splice('historyData_', 0, this.historyData_.length);
|
| - this.fire('unselect-all');
|
| - }
|
| - if (this.historyData_) {
|
| - results.unshift('historyData_');
|
| - this.push.apply(this, results);
|
| - } else {
|
| - this.set('historyData_', results);
|
| + _encodeParams: function(params) {
|
| + var encodedParams = [];
|
| + for (var key in params) {
|
| + var value = params[key];
|
| + if (value === '') {
|
| + encodedParams.push(encodeURIComponent(key));
|
| + } else if (value) {
|
| + encodedParams.push(encodeURIComponent(key) + '=' + encodeURIComponent(value.toString()));
|
| + }
|
| }
|
| + return encodedParams.join('&');
|
| },
|
| - loadMoreData_: function() {
|
| - if (this.resultLoadingDisabled_ || this.querying) return;
|
| - this.fire('load-more-history');
|
| - },
|
| - needsTimeGap_: function(item, index, length) {
|
| - return md_history.HistoryItem.needsTimeGap(this.historyData_, index, this.searchedTerm);
|
| - },
|
| - isCardStart_: function(item, i, length) {
|
| - if (length == 0 || i > length - 1) return false;
|
| - return i == 0 || this.historyData_[i].dateRelativeDay != this.historyData_[i - 1].dateRelativeDay;
|
| - },
|
| - isCardEnd_: function(item, i, length) {
|
| - if (length == 0 || i > length - 1) return false;
|
| - return i == length - 1 || this.historyData_[i].dateRelativeDay != this.historyData_[i + 1].dateRelativeDay;
|
| - },
|
| - notifyListScroll_: function() {
|
| - this.fire('history-list-scrolled');
|
| - },
|
| - pathForItem_: function(index) {
|
| - return 'historyData_.' + index;
|
| + _decodeParams: function(paramString) {
|
| + var params = {};
|
| + paramString = (paramString || '').replace(/\+/g, '%20');
|
| + var paramList = paramString.split('&');
|
| + for (var i = 0; i < paramList.length; i++) {
|
| + var param = paramList[i].split('=');
|
| + if (param[0]) {
|
| + params[decodeURIComponent(param[0])] = decodeURIComponent(param[1] || '');
|
| + }
|
| + }
|
| + return params;
|
| }
|
| });
|
|
|
| @@ -5305,140 +5132,42 @@ Polymer({
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
| Polymer({
|
| - is: 'history-list-container',
|
| + is: 'history-router',
|
| properties: {
|
| - selectedPage_: String,
|
| - grouped: Boolean,
|
| - groupedRange: {
|
| - type: Number,
|
| - observer: 'groupedRangeChanged_'
|
| + selectedPage: {
|
| + type: String,
|
| + observer: 'serializePath_',
|
| + notify: true
|
| },
|
| - queryState: Object,
|
| - queryResult: Object
|
| - },
|
| - listeners: {
|
| - 'history-list-scrolled': 'closeMenu_',
|
| - 'load-more-history': 'loadMoreHistory_',
|
| - 'toggle-menu': 'toggleMenu_'
|
| - },
|
| - historyResult: function(info, results) {
|
| - this.initializeResults_(info, results);
|
| - this.closeMenu_();
|
| - if (this.selectedPage_ == 'grouped-list') {
|
| - this.$$('#grouped-list').historyData = results;
|
| - return;
|
| - }
|
| - var list = this.$['infinite-list'];
|
| - list.addNewResults(results, this.queryState.incremental);
|
| - if (info.finished) list.disableResultLoading();
|
| - },
|
| - queryHistory: function(incremental) {
|
| - var queryState = this.queryState;
|
| - var noResults = !this.queryResult || this.queryResult.results == null;
|
| - if (queryState.queryingDisabled || !this.queryState.searchTerm && noResults) {
|
| - return;
|
| - }
|
| - var dialog = this.$.dialog.getIfExists();
|
| - if (!incremental && dialog && dialog.open) dialog.close();
|
| - this.set('queryState.querying', true);
|
| - this.set('queryState.incremental', incremental);
|
| - var lastVisitTime = 0;
|
| - if (incremental) {
|
| - var lastVisit = this.queryResult.results.slice(-1)[0];
|
| - lastVisitTime = lastVisit ? lastVisit.time : 0;
|
| - }
|
| - var maxResults = this.groupedRange == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
|
| - chrome.send('queryHistory', [ queryState.searchTerm, queryState.groupedOffset, queryState.range, lastVisitTime, maxResults ]);
|
| - },
|
| - historyDeleted: function() {
|
| - if (this.getSelectedItemCount() > 0) return;
|
| - this.queryHistory(false);
|
| - },
|
| - getContentScrollTarget: function() {
|
| - return this.getSelectedList_();
|
| - },
|
| - getSelectedItemCount: function() {
|
| - return this.getSelectedList_().selectedPaths.size;
|
| - },
|
| - unselectAllItems: function(count) {
|
| - var selectedList = this.getSelectedList_();
|
| - if (selectedList) selectedList.unselectAllItems(count);
|
| - },
|
| - deleteSelectedWithPrompt: function() {
|
| - if (!loadTimeData.getBoolean('allowDeletingHistory')) return;
|
| - var browserService = md_history.BrowserService.getInstance();
|
| - browserService.recordAction('RemoveSelected');
|
| - if (this.queryState.searchTerm != '') browserService.recordAction('SearchResultRemove');
|
| - this.$.dialog.get().showModal();
|
| - },
|
| - groupedRangeChanged_: function(range, oldRange) {
|
| - this.selectedPage_ = range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list';
|
| - if (oldRange == undefined) return;
|
| - this.queryHistory(false);
|
| - this.fire('history-view-changed');
|
| - },
|
| - loadMoreHistory_: function() {
|
| - this.queryHistory(true);
|
| + queryState: {
|
| + type: Object,
|
| + notify: true
|
| + },
|
| + path_: {
|
| + type: String,
|
| + observer: 'pathChanged_'
|
| + },
|
| + queryParams_: Object
|
| },
|
| - initializeResults_: function(info, results) {
|
| - if (results.length == 0) return;
|
| - var currentDate = results[0].dateRelativeDay;
|
| - for (var i = 0; i < results.length; i++) {
|
| - results[i].selected = false;
|
| - results[i].readableTimestamp = info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort;
|
| - if (results[i].dateRelativeDay != currentDate) {
|
| - currentDate = results[i].dateRelativeDay;
|
| - }
|
| + observers: [ 'queryParamsChanged_(queryParams_.*)', 'searchTermChanged_(queryState.searchTerm)' ],
|
| + attached: function() {
|
| + if (window.location.hash) {
|
| + window.location.href = window.location.href.split('#')[0] + '?' + window.location.hash.substr(1);
|
| }
|
| },
|
| - onDialogConfirmTap_: function() {
|
| - md_history.BrowserService.getInstance().recordAction('ConfirmRemoveSelected');
|
| - this.getSelectedList_().deleteSelected();
|
| - var dialog = assert(this.$.dialog.getIfExists());
|
| - dialog.close();
|
| - },
|
| - onDialogCancelTap_: function() {
|
| - md_history.BrowserService.getInstance().recordAction('CancelRemoveSelected');
|
| - var dialog = assert(this.$.dialog.getIfExists());
|
| - dialog.close();
|
| - },
|
| - closeMenu_: function() {
|
| - var menu = this.$.sharedMenu.getIfExists();
|
| - if (menu) menu.closeMenu();
|
| - },
|
| - toggleMenu_: function(e) {
|
| - var target = e.detail.target;
|
| - var menu = this.$.sharedMenu.get();
|
| - menu.toggleMenu(target, e.detail);
|
| + serializePath_: function() {
|
| + var page = this.selectedPage == 'history' ? '' : this.selectedPage;
|
| + this.path_ = '/' + page;
|
| },
|
| - onMoreFromSiteTap_: function() {
|
| - md_history.BrowserService.getInstance().recordAction('EntryMenuShowMoreFromSite');
|
| - var menu = assert(this.$.sharedMenu.getIfExists());
|
| - this.fire('search-domain', {
|
| - domain: menu.itemData.item.domain
|
| - });
|
| - menu.closeMenu();
|
| + pathChanged_: function() {
|
| + var sections = this.path_.substr(1).split('/');
|
| + this.selectedPage = sections[0] || 'history';
|
| },
|
| - onRemoveFromHistoryTap_: function() {
|
| - var browserService = md_history.BrowserService.getInstance();
|
| - browserService.recordAction('EntryMenuRemoveFromHistory');
|
| - var menu = assert(this.$.sharedMenu.getIfExists());
|
| - var itemData = menu.itemData;
|
| - browserService.deleteItems([ itemData.item ]).then(function(items) {
|
| - this.getSelectedList_().removeItemsByPath([ itemData.path ]);
|
| - this.fire('unselect-all');
|
| - var index = itemData.index;
|
| - if (index == undefined) return;
|
| - var browserService = md_history.BrowserService.getInstance();
|
| - browserService.recordHistogram('HistoryPage.RemoveEntryPosition', index, UMA_MAX_BUCKET_VALUE);
|
| - if (index <= UMA_MAX_SUBSET_BUCKET_VALUE) {
|
| - browserService.recordHistogram('HistoryPage.RemoveEntryPositionSubset', index, UMA_MAX_SUBSET_BUCKET_VALUE);
|
| - }
|
| - }.bind(this));
|
| - menu.closeMenu();
|
| + queryParamsChanged_: function() {
|
| + this.set('queryState.searchTerm', this.queryParams_.q || '');
|
| },
|
| - getSelectedList_: function() {
|
| - return this.$.content.selectedItem;
|
| + searchTermChanged_: function() {
|
| + this.set('queryParams_.q', this.queryState.searchTerm || null);
|
| }
|
| });
|
|
|
| @@ -5555,7 +5284,6 @@ Polymer({
|
| type: String,
|
| notify: true
|
| },
|
| - route: Object,
|
| showFooter: Boolean,
|
| drawer: {
|
| type: Boolean,
|
| @@ -5578,8 +5306,8 @@ Polymer({
|
| this.$['cbd-ripple'].upAction();
|
| e.preventDefault();
|
| },
|
| - getQueryString_: function(route) {
|
| - return window.location.search;
|
| + onItemClick_: function(e) {
|
| + e.preventDefault();
|
| }
|
| });
|
|
|
| @@ -5609,7 +5337,7 @@ Polymer({
|
| hasSyncedResults: Boolean,
|
| selectedPage_: {
|
| type: String,
|
| - observer: 'unselectAll'
|
| + observer: 'selectedPageChanged_'
|
| },
|
| grouped_: {
|
| type: Boolean,
|
| @@ -5644,8 +5372,6 @@ Polymer({
|
| };
|
| }
|
| },
|
| - routeData_: Object,
|
| - queryParams_: Object,
|
| hasDrawer_: Boolean,
|
| isUserSignedIn_: {
|
| type: Boolean,
|
| @@ -5657,13 +5383,11 @@ Polymer({
|
| notify: true
|
| }
|
| },
|
| - observers: [ 'routeDataChanged_(routeData_.page)', 'selectedPageChanged_(selectedPage_)', 'searchTermChanged_(queryState_.searchTerm)', 'searchQueryParamChanged_(queryParams_.q)' ],
|
| 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_'
|
| },
|
| @@ -5672,9 +5396,6 @@ Polymer({
|
| cr.ui.decorate('command', cr.ui.Command);
|
| document.addEventListener('canExecute', this.onCanExecute_.bind(this));
|
| document.addEventListener('command', this.onCommand_.bind(this));
|
| - if (window.location.hash) {
|
| - window.location.href = window.location.href.split('#')[0] + '?' + window.location.hash.substr(1);
|
| - }
|
| },
|
| onFirstRender: function() {
|
| setTimeout(function() {
|
| @@ -5686,7 +5407,7 @@ Polymer({
|
| md_history.ensureLazyLoaded();
|
| },
|
| _scrollHandler: function() {
|
| - this.toolbarShadow_ = this.scrollTarget.scrollTop != 0;
|
| + if (this.scrollTarget) this.toolbarShadow_ = this.scrollTarget.scrollTop != 0;
|
| },
|
| onMenuTap_: function() {
|
| var drawer = this.$$('#drawer');
|
| @@ -5715,9 +5436,6 @@ Polymer({
|
| focusToolbarSearchField: function() {
|
| this.$.toolbar.showSearchField();
|
| },
|
| - searchDomain_: function(e) {
|
| - this.$.toolbar.setSearchTerm(e.detail.domain);
|
| - },
|
| onCanExecute_: function(e) {
|
| e = e;
|
| switch (e.command.id) {
|
| @@ -5726,7 +5444,7 @@ Polymer({
|
| break;
|
|
|
| case 'slash-command':
|
| - e.canExecute = !this.$.toolbar.searchBar.isSearchFocused();
|
| + e.canExecute = !this.$.toolbar.searchField.isSearchFocused();
|
| break;
|
|
|
| case 'delete-command':
|
| @@ -5734,14 +5452,6 @@ Polymer({
|
| break;
|
| }
|
| },
|
| - searchTermChanged_: function(searchTerm) {
|
| - this.set('queryParams_.q', searchTerm || null);
|
| - this.$['history'].queryHistory(false);
|
| - if (this.queryState_.searchTerm) md_history.BrowserService.getInstance().recordAction('Search');
|
| - },
|
| - searchQueryParamChanged_: function(searchQuery) {
|
| - this.$.toolbar.setSearchTerm(searchQuery || '');
|
| - },
|
| onCommand_: function(e) {
|
| if (e.command.id == 'find-command' || e.command.id == 'slash-command') this.focusToolbarSearchField();
|
| if (e.command.id == 'delete-command') this.deleteSelected();
|
| @@ -5769,15 +5479,13 @@ Polymer({
|
| showSyncNotice_: function(hasSyncedResults, selectedPage) {
|
| return hasSyncedResults && selectedPage != 'syncedTabs';
|
| },
|
| - routeDataChanged_: function(page) {
|
| - this.selectedPage_ = page;
|
| - },
|
| - selectedPageChanged_: function(selectedPage) {
|
| - this.set('routeData_.page', selectedPage);
|
| + selectedPageChanged_: function() {
|
| + this.unselectAll();
|
| this.historyViewChanged_();
|
| },
|
| historyViewChanged_: function() {
|
| requestAnimationFrame(function() {
|
| + if (!this.$.content.selectedItem) return;
|
| this.scrollTarget = this.$.content.selectedItem.getContentScrollTarget();
|
| this._scrollHandler();
|
| }.bind(this));
|
|
|