Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: chrome/browser/resources/md_history/app.crisper.js

Issue 2280513002: MD History: promote menu button to show clear browsing data in narrow mode (Closed)
Patch Set: !showingSearch_ Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 function PromiseResolver() { 4 function PromiseResolver() {
5 this.resolve_; 5 this.resolve_;
6 this.reject_; 6 this.reject_;
7 this.promise_ = new Promise(function(resolve, reject) { 7 this.promise_ = new Promise(function(resolve, reject) {
8 this.resolve_ = resolve; 8 this.resolve_ = resolve;
9 this.reject_ = reject; 9 this.reject_ = reject;
10 }.bind(this)); 10 }.bind(this));
(...skipping 3851 matching lines...) Expand 10 before | Expand all | Expand 10 after
3862 if (cl.contains('expand')) { 3862 if (cl.contains('expand')) {
3863 cl.remove('expand'); 3863 cl.remove('expand');
3864 cl.add('contract'); 3864 cl.add('contract');
3865 this._positionBar(this._pos.width, this._pos.left); 3865 this._positionBar(this._pos.width, this._pos.left);
3866 } else if (cl.contains('contract')) { 3866 } else if (cl.contains('contract')) {
3867 cl.remove('contract'); 3867 cl.remove('contract');
3868 } 3868 }
3869 } 3869 }
3870 }); 3870 });
3871 3871
3872 Polymer.NeonAnimatableBehavior = {
3873 properties: {
3874 animationConfig: {
3875 type: Object
3876 },
3877 entryAnimation: {
3878 observer: '_entryAnimationChanged',
3879 type: String
3880 },
3881 exitAnimation: {
3882 observer: '_exitAnimationChanged',
3883 type: String
3884 }
3885 },
3886 _entryAnimationChanged: function() {
3887 this.animationConfig = this.animationConfig || {};
3888 this.animationConfig['entry'] = [ {
3889 name: this.entryAnimation,
3890 node: this
3891 } ];
3892 },
3893 _exitAnimationChanged: function() {
3894 this.animationConfig = this.animationConfig || {};
3895 this.animationConfig['exit'] = [ {
3896 name: this.exitAnimation,
3897 node: this
3898 } ];
3899 },
3900 _copyProperties: function(config1, config2) {
3901 for (var property in config2) {
3902 config1[property] = config2[property];
3903 }
3904 },
3905 _cloneConfig: function(config) {
3906 var clone = {
3907 isClone: true
3908 };
3909 this._copyProperties(clone, config);
3910 return clone;
3911 },
3912 _getAnimationConfigRecursive: function(type, map, allConfigs) {
3913 if (!this.animationConfig) {
3914 return;
3915 }
3916 if (this.animationConfig.value && typeof this.animationConfig.value === 'fun ction') {
3917 this._warn(this._logf('playAnimation', "Please put 'animationConfig' insid e of your components 'properties' object instead of outside of it."));
3918 return;
3919 }
3920 var thisConfig;
3921 if (type) {
3922 thisConfig = this.animationConfig[type];
3923 } else {
3924 thisConfig = this.animationConfig;
3925 }
3926 if (!Array.isArray(thisConfig)) {
3927 thisConfig = [ thisConfig ];
3928 }
3929 if (thisConfig) {
3930 for (var config, index = 0; config = thisConfig[index]; index++) {
3931 if (config.animatable) {
3932 config.animatable._getAnimationConfigRecursive(config.type || type, ma p, allConfigs);
3933 } else {
3934 if (config.id) {
3935 var cachedConfig = map[config.id];
3936 if (cachedConfig) {
3937 if (!cachedConfig.isClone) {
3938 map[config.id] = this._cloneConfig(cachedConfig);
3939 cachedConfig = map[config.id];
3940 }
3941 this._copyProperties(cachedConfig, config);
3942 } else {
3943 map[config.id] = config;
3944 }
3945 } else {
3946 allConfigs.push(config);
3947 }
3948 }
3949 }
3950 }
3951 },
3952 getAnimationConfig: function(type) {
3953 var map = {};
3954 var allConfigs = [];
3955 this._getAnimationConfigRecursive(type, map, allConfigs);
3956 for (var key in map) {
3957 allConfigs.push(map[key]);
3958 }
3959 return allConfigs;
3960 }
3961 };
3962
3963 Polymer.NeonAnimationRunnerBehaviorImpl = {
3964 _configureAnimations: function(configs) {
3965 var results = [];
3966 if (configs.length > 0) {
3967 for (var config, index = 0; config = configs[index]; index++) {
3968 var neonAnimation = document.createElement(config.name);
3969 if (neonAnimation.isNeonAnimation) {
3970 var result = null;
3971 try {
3972 result = neonAnimation.configure(config);
3973 if (typeof result.cancel != 'function') {
3974 result = document.timeline.play(result);
3975 }
3976 } catch (e) {
3977 result = null;
3978 console.warn('Couldnt play', '(', config.name, ').', e);
3979 }
3980 if (result) {
3981 results.push({
3982 neonAnimation: neonAnimation,
3983 config: config,
3984 animation: result
3985 });
3986 }
3987 } else {
3988 console.warn(this.is + ':', config.name, 'not found!');
3989 }
3990 }
3991 }
3992 return results;
3993 },
3994 _shouldComplete: function(activeEntries) {
3995 var finished = true;
3996 for (var i = 0; i < activeEntries.length; i++) {
3997 if (activeEntries[i].animation.playState != 'finished') {
3998 finished = false;
3999 break;
4000 }
4001 }
4002 return finished;
4003 },
4004 _complete: function(activeEntries) {
4005 for (var i = 0; i < activeEntries.length; i++) {
4006 activeEntries[i].neonAnimation.complete(activeEntries[i].config);
4007 }
4008 for (var i = 0; i < activeEntries.length; i++) {
4009 activeEntries[i].animation.cancel();
4010 }
4011 },
4012 playAnimation: function(type, cookie) {
4013 var configs = this.getAnimationConfig(type);
4014 if (!configs) {
4015 return;
4016 }
4017 this._active = this._active || {};
4018 if (this._active[type]) {
4019 this._complete(this._active[type]);
4020 delete this._active[type];
4021 }
4022 var activeEntries = this._configureAnimations(configs);
4023 if (activeEntries.length == 0) {
4024 this.fire('neon-animation-finish', cookie, {
4025 bubbles: false
4026 });
4027 return;
4028 }
4029 this._active[type] = activeEntries;
4030 for (var i = 0; i < activeEntries.length; i++) {
4031 activeEntries[i].animation.onfinish = function() {
4032 if (this._shouldComplete(activeEntries)) {
4033 this._complete(activeEntries);
4034 delete this._active[type];
4035 this.fire('neon-animation-finish', cookie, {
4036 bubbles: false
4037 });
4038 }
4039 }.bind(this);
4040 }
4041 },
4042 cancelAnimation: function() {
4043 for (var k in this._animations) {
4044 this._animations[k].cancel();
4045 }
4046 this._animations = {};
4047 }
4048 };
4049
4050 Polymer.NeonAnimationRunnerBehavior = [ Polymer.NeonAnimatableBehavior, Polymer. NeonAnimationRunnerBehaviorImpl ];
4051
4052 Polymer.NeonAnimationBehavior = {
4053 properties: {
4054 animationTiming: {
4055 type: Object,
4056 value: function() {
4057 return {
4058 duration: 500,
4059 easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
4060 fill: 'both'
4061 };
4062 }
4063 }
4064 },
4065 isNeonAnimation: true,
4066 timingFromConfig: function(config) {
4067 if (config.timing) {
4068 for (var property in config.timing) {
4069 this.animationTiming[property] = config.timing[property];
4070 }
4071 }
4072 return this.animationTiming;
4073 },
4074 setPrefixedProperty: function(node, property, value) {
4075 var map = {
4076 transform: [ 'webkitTransform' ],
4077 transformOrigin: [ 'mozTransformOrigin', 'webkitTransformOrigin' ]
4078 };
4079 var prefixes = map[property];
4080 for (var prefix, index = 0; prefix = prefixes[index]; index++) {
4081 node.style[prefix] = value;
4082 }
4083 node.style[property] = value;
4084 },
4085 complete: function() {}
4086 };
4087
4088 Polymer({
4089 is: 'fade-in-animation',
4090 behaviors: [ Polymer.NeonAnimationBehavior ],
4091 configure: function(config) {
4092 var node = config.node;
4093 this._effect = new KeyframeEffect(node, [ {
4094 opacity: '0'
4095 }, {
4096 opacity: '1'
4097 } ], this.timingFromConfig(config));
4098 return this._effect;
4099 }
4100 });
4101
4102 Polymer({
4103 is: 'fade-out-animation',
4104 behaviors: [ Polymer.NeonAnimationBehavior ],
4105 configure: function(config) {
4106 var node = config.node;
4107 this._effect = new KeyframeEffect(node, [ {
4108 opacity: '1'
4109 }, {
4110 opacity: '0'
4111 } ], this.timingFromConfig(config));
4112 return this._effect;
4113 }
4114 });
4115
4116 Polymer({
4117 is: 'paper-tooltip',
4118 hostAttributes: {
4119 role: 'tooltip',
4120 tabindex: -1
4121 },
4122 behaviors: [ Polymer.NeonAnimationRunnerBehavior ],
4123 properties: {
4124 "for": {
4125 type: String,
4126 observer: '_findTarget'
4127 },
4128 manualMode: {
4129 type: Boolean,
4130 value: false,
4131 observer: '_manualModeChanged'
4132 },
4133 position: {
4134 type: String,
4135 value: 'bottom'
4136 },
4137 fitToVisibleBounds: {
4138 type: Boolean,
4139 value: false
4140 },
4141 offset: {
4142 type: Number,
4143 value: 14
4144 },
4145 marginTop: {
4146 type: Number,
4147 value: 14
4148 },
4149 animationDelay: {
4150 type: Number,
4151 value: 500
4152 },
4153 animationConfig: {
4154 type: Object,
4155 value: function() {
4156 return {
4157 entry: [ {
4158 name: 'fade-in-animation',
4159 node: this,
4160 timing: {
4161 delay: 0
4162 }
4163 } ],
4164 exit: [ {
4165 name: 'fade-out-animation',
4166 node: this
4167 } ]
4168 };
4169 }
4170 },
4171 _showing: {
4172 type: Boolean,
4173 value: false
4174 }
4175 },
4176 listeners: {
4177 'neon-animation-finish': '_onAnimationFinish'
4178 },
4179 get target() {
4180 var parentNode = Polymer.dom(this).parentNode;
4181 var ownerRoot = Polymer.dom(this).getOwnerRoot();
4182 var target;
4183 if (this.for) {
4184 target = Polymer.dom(ownerRoot).querySelector('#' + this.for);
4185 } else {
4186 target = parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE ? ownerRoot.ho st : parentNode;
4187 }
4188 return target;
4189 },
4190 attached: function() {
4191 this._findTarget();
4192 },
4193 detached: function() {
4194 if (!this.manualMode) this._removeListeners();
4195 },
4196 show: function() {
4197 if (this._showing) return;
4198 if (Polymer.dom(this).textContent.trim() === '') return;
4199 this.cancelAnimation();
4200 this._showing = true;
4201 this.toggleClass('hidden', false, this.$.tooltip);
4202 this.updatePosition();
4203 this.animationConfig.entry[0].timing = this.animationConfig.entry[0].timing || {};
4204 this.animationConfig.entry[0].timing.delay = this.animationDelay;
4205 this._animationPlaying = true;
4206 this.playAnimation('entry');
4207 },
4208 hide: function() {
4209 if (!this._showing) {
4210 return;
4211 }
4212 if (this._animationPlaying) {
4213 this.cancelAnimation();
4214 this._showing = false;
4215 this._onAnimationFinish();
4216 return;
4217 }
4218 this._showing = false;
4219 this._animationPlaying = true;
4220 this.playAnimation('exit');
4221 },
4222 updatePosition: function() {
4223 if (!this._target || !this.offsetParent) return;
4224 var offset = this.offset;
4225 if (this.marginTop != 14 && this.offset == 14) offset = this.marginTop;
4226 var parentRect = this.offsetParent.getBoundingClientRect();
4227 var targetRect = this._target.getBoundingClientRect();
4228 var thisRect = this.getBoundingClientRect();
4229 var horizontalCenterOffset = (targetRect.width - thisRect.width) / 2;
4230 var verticalCenterOffset = (targetRect.height - thisRect.height) / 2;
4231 var targetLeft = targetRect.left - parentRect.left;
4232 var targetTop = targetRect.top - parentRect.top;
4233 var tooltipLeft, tooltipTop;
4234 switch (this.position) {
4235 case 'top':
4236 tooltipLeft = targetLeft + horizontalCenterOffset;
4237 tooltipTop = targetTop - thisRect.height - offset;
4238 break;
4239
4240 case 'bottom':
4241 tooltipLeft = targetLeft + horizontalCenterOffset;
4242 tooltipTop = targetTop + targetRect.height + offset;
4243 break;
4244
4245 case 'left':
4246 tooltipLeft = targetLeft - thisRect.width - offset;
4247 tooltipTop = targetTop + verticalCenterOffset;
4248 break;
4249
4250 case 'right':
4251 tooltipLeft = targetLeft + targetRect.width + offset;
4252 tooltipTop = targetTop + verticalCenterOffset;
4253 break;
4254 }
4255 if (this.fitToVisibleBounds) {
4256 if (tooltipLeft + thisRect.width > window.innerWidth) {
4257 this.style.right = '0px';
4258 this.style.left = 'auto';
4259 } else {
4260 this.style.left = Math.max(0, tooltipLeft) + 'px';
4261 this.style.right = 'auto';
4262 }
4263 if (tooltipTop + thisRect.height > window.innerHeight) {
4264 this.style.bottom = '0px';
4265 this.style.top = 'auto';
4266 } else {
4267 this.style.top = Math.max(0, tooltipTop) + 'px';
4268 this.style.bottom = 'auto';
4269 }
4270 } else {
4271 this.style.left = tooltipLeft + 'px';
4272 this.style.top = tooltipTop + 'px';
4273 }
4274 },
4275 _addListeners: function() {
4276 if (this._target) {
4277 this.listen(this._target, 'mouseenter', 'show');
4278 this.listen(this._target, 'focus', 'show');
4279 this.listen(this._target, 'mouseleave', 'hide');
4280 this.listen(this._target, 'blur', 'hide');
4281 this.listen(this._target, 'tap', 'hide');
4282 }
4283 this.listen(this, 'mouseenter', 'hide');
4284 },
4285 _findTarget: function() {
4286 if (!this.manualMode) this._removeListeners();
4287 this._target = this.target;
4288 if (!this.manualMode) this._addListeners();
4289 },
4290 _manualModeChanged: function() {
4291 if (this.manualMode) this._removeListeners(); else this._addListeners();
4292 },
4293 _onAnimationFinish: function() {
4294 this._animationPlaying = false;
4295 if (!this._showing) {
4296 this.toggleClass('hidden', true, this.$.tooltip);
4297 }
4298 },
4299 _removeListeners: function() {
4300 if (this._target) {
4301 this.unlisten(this._target, 'mouseenter', 'show');
4302 this.unlisten(this._target, 'focus', 'show');
4303 this.unlisten(this._target, 'mouseleave', 'hide');
4304 this.unlisten(this._target, 'blur', 'hide');
4305 this.unlisten(this._target, 'tap', 'hide');
4306 }
4307 this.unlisten(this, 'mouseenter', 'hide');
4308 }
4309 });
4310
3872 (function() { 4311 (function() {
3873 'use strict'; 4312 'use strict';
3874 Polymer.IronA11yAnnouncer = Polymer({ 4313 Polymer.IronA11yAnnouncer = Polymer({
3875 is: 'iron-a11y-announcer', 4314 is: 'iron-a11y-announcer',
3876 properties: { 4315 properties: {
3877 mode: { 4316 mode: {
3878 type: String, 4317 type: String,
3879 value: 'polite' 4318 value: 'polite'
3880 }, 4319 },
3881 _text: { 4320 _text: {
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
4500 // Copyright 2016 The Chromium Authors. All rights reserved. 4939 // Copyright 2016 The Chromium Authors. All rights reserved.
4501 // Use of this source code is governed by a BSD-style license that can be 4940 // Use of this source code is governed by a BSD-style license that can be
4502 // found in the LICENSE file. 4941 // found in the LICENSE file.
4503 Polymer({ 4942 Polymer({
4504 is: 'cr-toolbar', 4943 is: 'cr-toolbar',
4505 properties: { 4944 properties: {
4506 pageName: String, 4945 pageName: String,
4507 searchPrompt: String, 4946 searchPrompt: String,
4508 clearLabel: String, 4947 clearLabel: String,
4509 menuLabel: String, 4948 menuLabel: String,
4949 menuPromo: String,
4510 spinnerActive: Boolean, 4950 spinnerActive: Boolean,
4511 showMenu: { 4951 showMenu: {
4512 type: Boolean, 4952 type: Boolean,
4513 value: false 4953 value: false
4514 }, 4954 },
4955 showMenuPromo: {
4956 type: Boolean,
4957 value: false
4958 },
4515 narrow_: { 4959 narrow_: {
4516 type: Boolean, 4960 type: Boolean,
4517 reflectToAttribute: true 4961 reflectToAttribute: true
4518 }, 4962 },
4519 showingSearch_: { 4963 showingSearch_: {
4520 type: Boolean, 4964 type: Boolean,
4521 reflectToAttribute: true 4965 reflectToAttribute: true
4522 } 4966 }
4523 }, 4967 },
4968 observers: [ 'possiblyShowMenuPromo_(showMenu, showMenuPromo, showingSearch_)' ],
4524 getSearchField: function() { 4969 getSearchField: function() {
4525 return this.$.search; 4970 return this.$.search;
4526 }, 4971 },
4527 onMenuTap_: function(e) { 4972 onMenuTap_: function() {
4528 this.fire('cr-menu-tap'); 4973 this.fire('cr-menu-tap');
4974 this.onMenuPromoCloseTap_();
4975 },
4976 onMenuPromoCloseTap_: function() {
4977 this.showMenuPromo = false;
4978 },
4979 possiblyShowMenuPromo_: function() {
4980 Polymer.RenderStatus.afterNextRender(this, function() {
4981 if (this.showMenu && this.showMenuPromo && !this.showingSearch_) {
4982 this.$$('paper-tooltip').show();
4983 this.fire('cr-menu-promo-shown');
4984 }
4985 }.bind(this));
4986 },
4987 titleIfNotShowMenuPromo_: function(title, showMenuPromo) {
4988 return showMenuPromo ? '' : title;
4529 } 4989 }
4530 }); 4990 });
4531 4991
4992 // Copyright 2016 The Chromium Authors. All rights reserved.
4993 // Use of this source code is governed by a BSD-style license that can be
4994 // found in the LICENSE file.
4995 cr.define('md_history', function() {
4996 function BrowserService() {
4997 this.pendingDeleteItems_ = null;
4998 this.pendingDeletePromise_ = null;
4999 }
5000 BrowserService.prototype = {
5001 deleteItems: function(items) {
5002 if (this.pendingDeleteItems_ != null) {
5003 return new Promise(function(resolve, reject) {
5004 reject(items);
5005 });
5006 }
5007 var removalList = items.map(function(item) {
5008 return {
5009 url: item.url,
5010 timestamps: item.allTimestamps
5011 };
5012 });
5013 this.pendingDeleteItems_ = items;
5014 this.pendingDeletePromise_ = new PromiseResolver();
5015 chrome.send('removeVisits', removalList);
5016 return this.pendingDeletePromise_.promise;
5017 },
5018 removeBookmark: function(url) {
5019 chrome.send('removeBookmark', [ url ]);
5020 },
5021 openForeignSessionAllTabs: function(sessionTag) {
5022 chrome.send('openForeignSession', [ sessionTag ]);
5023 },
5024 openForeignSessionTab: function(sessionTag, windowId, tabId, e) {
5025 chrome.send('openForeignSession', [ sessionTag, String(windowId), String(t abId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]);
5026 },
5027 deleteForeignSession: function(sessionTag) {
5028 chrome.send('deleteForeignSession', [ sessionTag ]);
5029 },
5030 openClearBrowsingData: function() {
5031 chrome.send('clearBrowsingData');
5032 },
5033 recordHistogram: function(histogram, value, max) {
5034 chrome.send('metricsHandler:recordInHistogram', [ histogram, value, max ]) ;
5035 },
5036 recordAction: function(action) {
5037 if (action.indexOf('_') == -1) action = 'HistoryPage_' + action;
5038 chrome.send('metricsHandler:recordAction', [ action ]);
5039 },
5040 resolveDelete_: function(successful) {
5041 if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null ) {
5042 return;
5043 }
5044 if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems _); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_);
5045 this.pendingDeleteItems_ = null;
5046 this.pendingDeletePromise_ = null;
5047 },
5048 menuPromoShown: function() {
5049 chrome.send('menuPromoShown');
5050 }
5051 };
5052 cr.addSingletonGetter(BrowserService);
5053 return {
5054 BrowserService: BrowserService
5055 };
5056 });
5057
5058 function deleteComplete() {
5059 md_history.BrowserService.getInstance().resolveDelete_(true);
5060 }
5061
5062 function deleteFailed() {
5063 md_history.BrowserService.getInstance().resolveDelete_(false);
5064 }
5065
4532 // Copyright 2015 The Chromium Authors. All rights reserved. 5066 // Copyright 2015 The Chromium Authors. All rights reserved.
4533 // Use of this source code is governed by a BSD-style license that can be 5067 // Use of this source code is governed by a BSD-style license that can be
4534 // found in the LICENSE file. 5068 // found in the LICENSE file.
4535 Polymer({ 5069 Polymer({
4536 is: 'history-toolbar', 5070 is: 'history-toolbar',
4537 properties: { 5071 properties: {
4538 count: { 5072 count: {
4539 type: Number, 5073 type: Number,
4540 value: 0, 5074 value: 0,
4541 observer: 'changeToolbarView_' 5075 observer: 'changeToolbarView_'
(...skipping 20 matching lines...) Expand all
4562 type: Boolean, 5096 type: Boolean,
4563 reflectToAttribute: true 5097 reflectToAttribute: true
4564 }, 5098 },
4565 groupedRange: { 5099 groupedRange: {
4566 type: Number, 5100 type: Number,
4567 value: 0, 5101 value: 0,
4568 reflectToAttribute: true, 5102 reflectToAttribute: true,
4569 notify: true 5103 notify: true
4570 }, 5104 },
4571 queryStartTime: String, 5105 queryStartTime: String,
4572 queryEndTime: String 5106 queryEndTime: String,
5107 showMenuPromo_: {
5108 type: Boolean,
5109 value: function() {
5110 return loadTimeData.getBoolean('showMenuPromo');
5111 }
5112 }
4573 }, 5113 },
4574 changeToolbarView_: function() { 5114 changeToolbarView_: function() {
4575 this.itemsSelected_ = this.count > 0; 5115 this.itemsSelected_ = this.count > 0;
4576 }, 5116 },
4577 setSearchTerm: function(search) { 5117 setSearchTerm: function(search) {
4578 if (this.searchTerm == search) return; 5118 if (this.searchTerm == search) return;
4579 this.searchTerm = search; 5119 this.searchTerm = search;
4580 var searchField = this.$['main-toolbar'].getSearchField(); 5120 var searchField = this.$['main-toolbar'].getSearchField();
4581 searchField.showAndFocus(); 5121 searchField.showAndFocus();
4582 searchField.setValue(search); 5122 searchField.setValue(search);
4583 }, 5123 },
5124 onMenuPromoShown_: function() {
5125 md_history.BrowserService.getInstance().menuPromoShown();
5126 },
4584 onSearchChanged_: function(event) { 5127 onSearchChanged_: function(event) {
4585 this.searchTerm = event.detail; 5128 this.searchTerm = event.detail;
4586 }, 5129 },
4587 onClearSelectionTap_: function() { 5130 onClearSelectionTap_: function() {
4588 this.fire('unselect-all'); 5131 this.fire('unselect-all');
4589 }, 5132 },
4590 onDeleteTap_: function() { 5133 onDeleteTap_: function() {
4591 this.fire('delete-selected'); 5134 this.fire('delete-selected');
4592 }, 5135 },
4593 get searchBar() { 5136 get searchBar() {
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
5539 var self = this; 6082 var self = this;
5540 this.__raf = window.requestAnimationFrame(function nextAnimationFrame() { 6083 this.__raf = window.requestAnimationFrame(function nextAnimationFrame() {
5541 self.__raf = null; 6084 self.__raf = null;
5542 callback.call(self); 6085 callback.call(self);
5543 }); 6086 });
5544 } 6087 }
5545 }; 6088 };
5546 Polymer.IronOverlayBehavior = [ Polymer.IronFitBehavior, Polymer.IronResizable Behavior, Polymer.IronOverlayBehaviorImpl ]; 6089 Polymer.IronOverlayBehavior = [ Polymer.IronFitBehavior, Polymer.IronResizable Behavior, Polymer.IronOverlayBehaviorImpl ];
5547 })(); 6090 })();
5548 6091
5549 Polymer.NeonAnimatableBehavior = {
5550 properties: {
5551 animationConfig: {
5552 type: Object
5553 },
5554 entryAnimation: {
5555 observer: '_entryAnimationChanged',
5556 type: String
5557 },
5558 exitAnimation: {
5559 observer: '_exitAnimationChanged',
5560 type: String
5561 }
5562 },
5563 _entryAnimationChanged: function() {
5564 this.animationConfig = this.animationConfig || {};
5565 this.animationConfig['entry'] = [ {
5566 name: this.entryAnimation,
5567 node: this
5568 } ];
5569 },
5570 _exitAnimationChanged: function() {
5571 this.animationConfig = this.animationConfig || {};
5572 this.animationConfig['exit'] = [ {
5573 name: this.exitAnimation,
5574 node: this
5575 } ];
5576 },
5577 _copyProperties: function(config1, config2) {
5578 for (var property in config2) {
5579 config1[property] = config2[property];
5580 }
5581 },
5582 _cloneConfig: function(config) {
5583 var clone = {
5584 isClone: true
5585 };
5586 this._copyProperties(clone, config);
5587 return clone;
5588 },
5589 _getAnimationConfigRecursive: function(type, map, allConfigs) {
5590 if (!this.animationConfig) {
5591 return;
5592 }
5593 if (this.animationConfig.value && typeof this.animationConfig.value === 'fun ction') {
5594 this._warn(this._logf('playAnimation', "Please put 'animationConfig' insid e of your components 'properties' object instead of outside of it."));
5595 return;
5596 }
5597 var thisConfig;
5598 if (type) {
5599 thisConfig = this.animationConfig[type];
5600 } else {
5601 thisConfig = this.animationConfig;
5602 }
5603 if (!Array.isArray(thisConfig)) {
5604 thisConfig = [ thisConfig ];
5605 }
5606 if (thisConfig) {
5607 for (var config, index = 0; config = thisConfig[index]; index++) {
5608 if (config.animatable) {
5609 config.animatable._getAnimationConfigRecursive(config.type || type, ma p, allConfigs);
5610 } else {
5611 if (config.id) {
5612 var cachedConfig = map[config.id];
5613 if (cachedConfig) {
5614 if (!cachedConfig.isClone) {
5615 map[config.id] = this._cloneConfig(cachedConfig);
5616 cachedConfig = map[config.id];
5617 }
5618 this._copyProperties(cachedConfig, config);
5619 } else {
5620 map[config.id] = config;
5621 }
5622 } else {
5623 allConfigs.push(config);
5624 }
5625 }
5626 }
5627 }
5628 },
5629 getAnimationConfig: function(type) {
5630 var map = {};
5631 var allConfigs = [];
5632 this._getAnimationConfigRecursive(type, map, allConfigs);
5633 for (var key in map) {
5634 allConfigs.push(map[key]);
5635 }
5636 return allConfigs;
5637 }
5638 };
5639
5640 Polymer.NeonAnimationRunnerBehaviorImpl = {
5641 _configureAnimations: function(configs) {
5642 var results = [];
5643 if (configs.length > 0) {
5644 for (var config, index = 0; config = configs[index]; index++) {
5645 var neonAnimation = document.createElement(config.name);
5646 if (neonAnimation.isNeonAnimation) {
5647 var result = null;
5648 try {
5649 result = neonAnimation.configure(config);
5650 if (typeof result.cancel != 'function') {
5651 result = document.timeline.play(result);
5652 }
5653 } catch (e) {
5654 result = null;
5655 console.warn('Couldnt play', '(', config.name, ').', e);
5656 }
5657 if (result) {
5658 results.push({
5659 neonAnimation: neonAnimation,
5660 config: config,
5661 animation: result
5662 });
5663 }
5664 } else {
5665 console.warn(this.is + ':', config.name, 'not found!');
5666 }
5667 }
5668 }
5669 return results;
5670 },
5671 _shouldComplete: function(activeEntries) {
5672 var finished = true;
5673 for (var i = 0; i < activeEntries.length; i++) {
5674 if (activeEntries[i].animation.playState != 'finished') {
5675 finished = false;
5676 break;
5677 }
5678 }
5679 return finished;
5680 },
5681 _complete: function(activeEntries) {
5682 for (var i = 0; i < activeEntries.length; i++) {
5683 activeEntries[i].neonAnimation.complete(activeEntries[i].config);
5684 }
5685 for (var i = 0; i < activeEntries.length; i++) {
5686 activeEntries[i].animation.cancel();
5687 }
5688 },
5689 playAnimation: function(type, cookie) {
5690 var configs = this.getAnimationConfig(type);
5691 if (!configs) {
5692 return;
5693 }
5694 this._active = this._active || {};
5695 if (this._active[type]) {
5696 this._complete(this._active[type]);
5697 delete this._active[type];
5698 }
5699 var activeEntries = this._configureAnimations(configs);
5700 if (activeEntries.length == 0) {
5701 this.fire('neon-animation-finish', cookie, {
5702 bubbles: false
5703 });
5704 return;
5705 }
5706 this._active[type] = activeEntries;
5707 for (var i = 0; i < activeEntries.length; i++) {
5708 activeEntries[i].animation.onfinish = function() {
5709 if (this._shouldComplete(activeEntries)) {
5710 this._complete(activeEntries);
5711 delete this._active[type];
5712 this.fire('neon-animation-finish', cookie, {
5713 bubbles: false
5714 });
5715 }
5716 }.bind(this);
5717 }
5718 },
5719 cancelAnimation: function() {
5720 for (var k in this._animations) {
5721 this._animations[k].cancel();
5722 }
5723 this._animations = {};
5724 }
5725 };
5726
5727 Polymer.NeonAnimationRunnerBehavior = [ Polymer.NeonAnimatableBehavior, Polymer. NeonAnimationRunnerBehaviorImpl ];
5728
5729 Polymer.NeonAnimationBehavior = {
5730 properties: {
5731 animationTiming: {
5732 type: Object,
5733 value: function() {
5734 return {
5735 duration: 500,
5736 easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
5737 fill: 'both'
5738 };
5739 }
5740 }
5741 },
5742 isNeonAnimation: true,
5743 timingFromConfig: function(config) {
5744 if (config.timing) {
5745 for (var property in config.timing) {
5746 this.animationTiming[property] = config.timing[property];
5747 }
5748 }
5749 return this.animationTiming;
5750 },
5751 setPrefixedProperty: function(node, property, value) {
5752 var map = {
5753 transform: [ 'webkitTransform' ],
5754 transformOrigin: [ 'mozTransformOrigin', 'webkitTransformOrigin' ]
5755 };
5756 var prefixes = map[property];
5757 for (var prefix, index = 0; prefix = prefixes[index]; index++) {
5758 node.style[prefix] = value;
5759 }
5760 node.style[property] = value;
5761 },
5762 complete: function() {}
5763 };
5764
5765 Polymer({ 6092 Polymer({
5766 is: 'opaque-animation', 6093 is: 'opaque-animation',
5767 behaviors: [ Polymer.NeonAnimationBehavior ], 6094 behaviors: [ Polymer.NeonAnimationBehavior ],
5768 configure: function(config) { 6095 configure: function(config) {
5769 var node = config.node; 6096 var node = config.node;
5770 this._effect = new KeyframeEffect(node, [ { 6097 this._effect = new KeyframeEffect(node, [ {
5771 opacity: '1' 6098 opacity: '1'
5772 }, { 6099 }, {
5773 opacity: '1' 6100 opacity: '1'
5774 } ], this.timingFromConfig(config)); 6101 } ], this.timingFromConfig(config));
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
6112 if (focusTarget && this.opened && !this.noAutoFocus) { 6439 if (focusTarget && this.opened && !this.noAutoFocus) {
6113 focusTarget.focus(); 6440 focusTarget.focus();
6114 } else { 6441 } else {
6115 Polymer.IronOverlayBehaviorImpl._applyFocus.apply(this, arguments); 6442 Polymer.IronOverlayBehaviorImpl._applyFocus.apply(this, arguments);
6116 } 6443 }
6117 } 6444 }
6118 }); 6445 });
6119 })(); 6446 })();
6120 6447
6121 Polymer({ 6448 Polymer({
6122 is: 'fade-in-animation',
6123 behaviors: [ Polymer.NeonAnimationBehavior ],
6124 configure: function(config) {
6125 var node = config.node;
6126 this._effect = new KeyframeEffect(node, [ {
6127 opacity: '0'
6128 }, {
6129 opacity: '1'
6130 } ], this.timingFromConfig(config));
6131 return this._effect;
6132 }
6133 });
6134
6135 Polymer({
6136 is: 'fade-out-animation',
6137 behaviors: [ Polymer.NeonAnimationBehavior ],
6138 configure: function(config) {
6139 var node = config.node;
6140 this._effect = new KeyframeEffect(node, [ {
6141 opacity: '1'
6142 }, {
6143 opacity: '0'
6144 } ], this.timingFromConfig(config));
6145 return this._effect;
6146 }
6147 });
6148
6149 Polymer({
6150 is: 'paper-menu-grow-height-animation', 6449 is: 'paper-menu-grow-height-animation',
6151 behaviors: [ Polymer.NeonAnimationBehavior ], 6450 behaviors: [ Polymer.NeonAnimationBehavior ],
6152 configure: function(config) { 6451 configure: function(config) {
6153 var node = config.node; 6452 var node = config.node;
6154 var rect = node.getBoundingClientRect(); 6453 var rect = node.getBoundingClientRect();
6155 var height = rect.height; 6454 var height = rect.height;
6156 this._effect = new KeyframeEffect(node, [ { 6455 this._effect = new KeyframeEffect(node, [ {
6157 height: height / 2 + 'px' 6456 height: height / 2 + 'px'
6158 }, { 6457 }, {
6159 height: height + 'px' 6458 height: height + 'px'
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
6340 } 6639 }
6341 }; 6640 };
6342 6641
6343 Polymer.PaperItemBehavior = [ Polymer.IronButtonState, Polymer.IronControlState, Polymer.PaperItemBehaviorImpl ]; 6642 Polymer.PaperItemBehavior = [ Polymer.IronButtonState, Polymer.IronControlState, Polymer.PaperItemBehaviorImpl ];
6344 6643
6345 Polymer({ 6644 Polymer({
6346 is: 'paper-item', 6645 is: 'paper-item',
6347 behaviors: [ Polymer.PaperItemBehavior ] 6646 behaviors: [ Polymer.PaperItemBehavior ]
6348 }); 6647 });
6349 6648
6350 // Copyright 2016 The Chromium Authors. All rights reserved.
6351 // Use of this source code is governed by a BSD-style license that can be
6352 // found in the LICENSE file.
6353 cr.define('md_history', function() {
6354 function BrowserService() {
6355 this.pendingDeleteItems_ = null;
6356 this.pendingDeletePromise_ = null;
6357 }
6358 BrowserService.prototype = {
6359 deleteItems: function(items) {
6360 if (this.pendingDeleteItems_ != null) {
6361 return new Promise(function(resolve, reject) {
6362 reject(items);
6363 });
6364 }
6365 var removalList = items.map(function(item) {
6366 return {
6367 url: item.url,
6368 timestamps: item.allTimestamps
6369 };
6370 });
6371 this.pendingDeleteItems_ = items;
6372 this.pendingDeletePromise_ = new PromiseResolver();
6373 chrome.send('removeVisits', removalList);
6374 return this.pendingDeletePromise_.promise;
6375 },
6376 removeBookmark: function(url) {
6377 chrome.send('removeBookmark', [ url ]);
6378 },
6379 openForeignSessionAllTabs: function(sessionTag) {
6380 chrome.send('openForeignSession', [ sessionTag ]);
6381 },
6382 openForeignSessionTab: function(sessionTag, windowId, tabId, e) {
6383 chrome.send('openForeignSession', [ sessionTag, String(windowId), String(t abId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]);
6384 },
6385 deleteForeignSession: function(sessionTag) {
6386 chrome.send('deleteForeignSession', [ sessionTag ]);
6387 },
6388 openClearBrowsingData: function() {
6389 chrome.send('clearBrowsingData');
6390 },
6391 recordHistogram: function(histogram, value, max) {
6392 chrome.send('metricsHandler:recordInHistogram', [ histogram, value, max ]) ;
6393 },
6394 recordAction: function(action) {
6395 if (action.indexOf('_') == -1) action = 'HistoryPage_' + action;
6396 chrome.send('metricsHandler:recordAction', [ action ]);
6397 },
6398 resolveDelete_: function(successful) {
6399 if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null ) {
6400 return;
6401 }
6402 if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems _); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_);
6403 this.pendingDeleteItems_ = null;
6404 this.pendingDeletePromise_ = null;
6405 }
6406 };
6407 cr.addSingletonGetter(BrowserService);
6408 return {
6409 BrowserService: BrowserService
6410 };
6411 });
6412
6413 function deleteComplete() {
6414 md_history.BrowserService.getInstance().resolveDelete_(true);
6415 }
6416
6417 function deleteFailed() {
6418 md_history.BrowserService.getInstance().resolveDelete_(false);
6419 }
6420
6421 Polymer({ 6649 Polymer({
6422 is: 'iron-collapse', 6650 is: 'iron-collapse',
6423 behaviors: [ Polymer.IronResizableBehavior ], 6651 behaviors: [ Polymer.IronResizableBehavior ],
6424 properties: { 6652 properties: {
6425 horizontal: { 6653 horizontal: {
6426 type: Boolean, 6654 type: Boolean,
6427 value: false, 6655 value: false,
6428 observer: '_horizontalChanged' 6656 observer: '_horizontalChanged'
6429 }, 6657 },
6430 opened: { 6658 opened: {
(...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after
8817 9045
8818 case HistoryRange.MONTH: 9046 case HistoryRange.MONTH:
8819 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; 9047 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH;
8820 break; 9048 break;
8821 } 9049 }
8822 break; 9050 break;
8823 } 9051 }
8824 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END); 9052 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END);
8825 } 9053 }
8826 }); 9054 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698