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

Side by Side Diff: chrome/browser/resources/ntp/most_visited.js

Issue 8052028: NTP: Clean up of MetricsHandler class and namespacing chrome.send messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed whitespace and rebased Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Dependencies that we should remove/formalize: 5 // Dependencies that we should remove/formalize:
6 // util.js 6 // util.js
7 // 7 //
8 // afterTransition 8 // afterTransition
9 // chrome.send 9 // chrome.send
10 // hideNotification 10 // hideNotification
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 updatePinnedDom(source, true); 96 updatePinnedDom(source, true);
97 97
98 var destinationData = this.data[destinationIndex]; 98 var destinationData = this.data[destinationIndex];
99 // Only update the destination if it was pinned before. 99 // Only update the destination if it was pinned before.
100 if (destinationData.pinned) { 100 if (destinationData.pinned) {
101 addPinnedUrl(destinationData, sourceIndex); 101 addPinnedUrl(destinationData, sourceIndex);
102 } 102 }
103 this.data[destinationIndex] = sourceData; 103 this.data[destinationIndex] = sourceData;
104 this.data[sourceIndex] = destinationData; 104 this.data[sourceIndex] = destinationData;
105 105
106 chrome.send('recordAction', ['MostVisitedReordered']); 106 chrome.send('metricsHandler:recordAction', ['MostVisitedReordered']);
107 }, 107 },
108 108
109 updateSettingsLink: function(hasBlacklistedUrls) { 109 updateSettingsLink: function(hasBlacklistedUrls) {
110 if (hasBlacklistedUrls) 110 if (hasBlacklistedUrls)
111 $('most-visited-settings').classList.add('has-blacklist'); 111 $('most-visited-settings').classList.add('has-blacklist');
112 else 112 else
113 $('most-visited-settings').classList.remove('has-blacklist'); 113 $('most-visited-settings').classList.remove('has-blacklist');
114 }, 114 },
115 115
116 blacklist: function(el) { 116 blacklist: function(el) {
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 * Record the time the mouse has been hovering over a thumbnail. 533 * Record the time the mouse has been hovering over a thumbnail.
534 * |clicked| must be true if the thumbnail was clicked, or false if 534 * |clicked| must be true if the thumbnail was clicked, or false if
535 * the cursor was moved off of the thumbnail. 535 * the cursor was moved off of the thumbnail.
536 */ 536 */
537 RecordHoverTime_: function(clicked) { 537 RecordHoverTime_: function(clicked) {
538 if (!this.hoverStartTime_) 538 if (!this.hoverStartTime_)
539 return; 539 return;
540 var hoverDuration = (new Date()).getTime() - this.hoverStartTime_; 540 var hoverDuration = (new Date()).getTime() - this.hoverStartTime_;
541 if (hoverDuration > 500) 541 if (hoverDuration > 500)
542 hoverDuration = 500; 542 hoverDuration = 500;
543 chrome.send('recordInHistogram', 543 chrome.send('metricsHandler:recordInHistogram',
544 [clicked ? 'NewTabPage.HoverTimeClicked' 544 [clicked ? 'NewTabPage.HoverTimeClicked'
545 : 'NewTabPage.HoverTimeNotClicked', 545 : 'NewTabPage.HoverTimeNotClicked',
546 hoverDuration, 546 hoverDuration,
547 500]); 547 500]);
548 this.hoverStartTime_ = null; 548 this.hoverStartTime_ = null;
549 }, 549 },
550 550
551 /** 551 /**
552 * Record the time the cursor started hovering over a thumbnail. 552 * Record the time the cursor started hovering over a thumbnail.
553 * Do nothing if currently dragging the thumbnail. 553 * Do nothing if currently dragging the thumbnail.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 } else if (target.classList.contains('remove')) { 685 } else if (target.classList.contains('remove')) {
686 this.blacklist(getItem(target)); 686 this.blacklist(getItem(target));
687 e.preventDefault(); 687 e.preventDefault();
688 } else { 688 } else {
689 var item = getItem(target); 689 var item = getItem(target);
690 if (item) { 690 if (item) {
691 var index = Array.prototype.indexOf.call(item.parentNode.children, 691 var index = Array.prototype.indexOf.call(item.parentNode.children,
692 item); 692 item);
693 this.RecordHoverTime_(true); 693 this.RecordHoverTime_(true);
694 if (index != -1) 694 if (index != -1)
695 chrome.send('recordInHistogram', 695 chrome.send('metricsHandler:recordInHistogram',
696 ['NewTabPage.MostVisited', index, 8]); 696 ['NewTabPage.MostVisited', index, 8]);
697 } 697 }
698 } 698 }
699 }, 699 },
700 700
701 /** 701 /**
702 * Allow blacklisting most visited site using the keyboard. 702 * Allow blacklisting most visited site using the keyboard.
703 */ 703 */
704 handleKeyDown_: function(e) { 704 handleKeyDown_: function(e) {
705 if (!cr.isMac && e.keyCode == 46 || // Del 705 if (!cr.isMac && e.keyCode == 46 || // Del
706 cr.isMac && e.metaKey && e.keyCode == 8) { // Cmd + Backspace 706 cr.isMac && e.metaKey && e.keyCode == 8) { // Cmd + Backspace
707 this.blacklist(e.target); 707 this.blacklist(e.target);
708 } 708 }
709 } 709 }
710 }; 710 };
711 711
712 return MostVisited; 712 return MostVisited;
713 })(); 713 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698