| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('ntp', function() { | 5 cr.define('ntp', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 var APP_LAUNCH = { | 8 var APP_LAUNCH = { |
| 9 // The histogram buckets (keep in sync with extension_constants.h). | 9 // The histogram buckets (keep in sync with extension_constants.h). |
| 10 NTP_APPS_MAXIMIZED: 0, | 10 NTP_APPS_MAXIMIZED: 0, |
| 11 NTP_APPS_COLLAPSED: 1, | 11 NTP_APPS_COLLAPSED: 1, |
| 12 NTP_APPS_MENU: 2, | 12 NTP_APPS_MENU: 2, |
| 13 NTP_MOST_VISITED: 3, | 13 NTP_MOST_VISITED: 3, |
| 14 NTP_APP_RE_ENABLE: 16, | 14 NTP_APP_RE_ENABLE: 16, |
| 15 NTP_WEBSTORE_FOOTER: 18, | 15 NTP_WEBSTORE_FOOTER: 18, |
| 16 NTP_WEBSTORE_PLUS_ICON: 19, | 16 NTP_WEBSTORE_PLUS_ICON: 19, |
| 17 }; | 17 }; |
| 18 | 18 |
| 19 // Histogram buckets for UMA tracking of where a DnD drop came from. | 19 // Histogram buckets for UMA tracking of where a DnD drop came from. |
| 20 var DRAG_SOURCE = { | 20 var DRAG_SOURCE = { |
| 21 SAME_APPS_PANE: 0, | 21 SAME_APPS_PANE: 0, |
| 22 OTHER_APPS_PANE: 1, | 22 OTHER_APPS_PANE: 1, |
| 23 MOST_VISITED_PANE: 2, | 23 MOST_VISITED_PANE: 2, // Deprecated. |
| 24 BOOKMARKS_PANE: 3, | 24 BOOKMARKS_PANE: 3, // Deprecated. |
| 25 OUTSIDE_NTP: 4 | 25 OUTSIDE_NTP: 4 |
| 26 }; | 26 }; |
| 27 var DRAG_SOURCE_LIMIT = DRAG_SOURCE.OUTSIDE_NTP + 1; | 27 var DRAG_SOURCE_LIMIT = DRAG_SOURCE.OUTSIDE_NTP + 1; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * App context menu. The class is designed to be used as a singleton with | 30 * App context menu. The class is designed to be used as a singleton with |
| 31 * the app that is currently showing a context menu stored in this.app_. | 31 * the app that is currently showing a context menu stored in this.app_. |
| 32 * @constructor | 32 * @constructor |
| 33 */ | 33 */ |
| 34 function AppContextMenu() { | 34 function AppContextMenu() { |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 var samePageDrag = originalPage == this; | 676 var samePageDrag = originalPage == this; |
| 677 sourceId = samePageDrag ? DRAG_SOURCE.SAME_APPS_PANE : | 677 sourceId = samePageDrag ? DRAG_SOURCE.SAME_APPS_PANE : |
| 678 DRAG_SOURCE.OTHER_APPS_PANE; | 678 DRAG_SOURCE.OTHER_APPS_PANE; |
| 679 this.tileGrid_.insertBefore(currentlyDraggingTile, | 679 this.tileGrid_.insertBefore(currentlyDraggingTile, |
| 680 this.tileElements_[index]); | 680 this.tileElements_[index]); |
| 681 this.tileMoved(currentlyDraggingTile); | 681 this.tileMoved(currentlyDraggingTile); |
| 682 if (!samePageDrag) { | 682 if (!samePageDrag) { |
| 683 originalPage.fireRemovedEvent(currentlyDraggingTile, index, true); | 683 originalPage.fireRemovedEvent(currentlyDraggingTile, index, true); |
| 684 this.fireAddedEvent(currentlyDraggingTile, index, true); | 684 this.fireAddedEvent(currentlyDraggingTile, index, true); |
| 685 } | 685 } |
| 686 } else if (currentlyDraggingTile.querySelector('.most-visited')) { | |
| 687 this.generateAppForLink(tileContents.data); | |
| 688 sourceId = DRAG_SOURCE.MOST_VISITED_PANE; | |
| 689 } | 686 } |
| 690 } else { | 687 } else { |
| 691 this.addOutsideData_(dataTransfer); | 688 this.addOutsideData_(dataTransfer); |
| 692 sourceId = DRAG_SOURCE.OUTSIDE_NTP; | 689 sourceId = DRAG_SOURCE.OUTSIDE_NTP; |
| 693 } | 690 } |
| 694 | 691 |
| 695 assert(sourceId != -1); | 692 assert(sourceId != -1); |
| 696 chrome.send('metricsHandler:recordInHistogram', | 693 chrome.send('metricsHandler:recordInHistogram', |
| 697 ['NewTabPage.AppsPageDragSource', sourceId, DRAG_SOURCE_LIMIT]); | 694 ['NewTabPage.AppsPageDragSource', sourceId, DRAG_SOURCE_LIMIT]); |
| 698 }, | 695 }, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 function launchAppAfterEnable(appId) { | 775 function launchAppAfterEnable(appId) { |
| 779 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); | 776 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); |
| 780 } | 777 } |
| 781 | 778 |
| 782 return { | 779 return { |
| 783 APP_LAUNCH: APP_LAUNCH, | 780 APP_LAUNCH: APP_LAUNCH, |
| 784 AppsPage: AppsPage, | 781 AppsPage: AppsPage, |
| 785 launchAppAfterEnable: launchAppAfterEnable, | 782 launchAppAfterEnable: launchAppAfterEnable, |
| 786 }; | 783 }; |
| 787 }); | 784 }); |
| OLD | NEW |