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

Unified Diff: chrome/browser/resources/ntp4/apps_page.js

Issue 7592001: ntp4: most visited dragging onto apps page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/ntp4/most_visited_page.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/apps_page.js
diff --git a/chrome/browser/resources/ntp4/apps_page.js b/chrome/browser/resources/ntp4/apps_page.js
index d7374c48f783c3635c9b30f1d2ff85df41a3adbb..f69e9b5bedb05a15caa8f9795a468d7c146c51ed 100644
--- a/chrome/browser/resources/ntp4/apps_page.js
+++ b/chrome/browser/resources/ntp4/apps_page.js
@@ -327,6 +327,26 @@ cr.define('ntp4', function() {
menu.setupForApp(this);
return menu.menu;
},
+
+ /**
+ * Returns whether this element can be 'removed' from chrome (i.e. whether
+ * the user can drag it onto the trash and expect something to happen).
+ * @return {boolean} True if the app can be uninstalled.
+ */
+ canBeRemoved: function() {
+ return this.appData_.can_uninstall;
+ },
+
+ /**
+ * Uninstalls the app after it's been dropped on the trash.
+ */
+ removeFromChrome: function() {
+ chrome.send('uninstallApp', [this.appData_.id, true]);
+
+ var tile = this.parentNode;
+ tile.tilePage.cleanupDrag();
+ tile.parentNode.removeChild(tile);
+ },
};
var TilePage = ntp4.TilePage;
@@ -384,7 +404,31 @@ cr.define('ntp4', function() {
},
/** @inheritDoc */
- addOutsideData: function(dataTransfer, index) {
+ addDragData: function(dataTransfer, index) {
+ var currentlyDraggingTile = ntp4.getCurrentlyDraggingTile();
+ if (currentlyDraggingTile) {
+ var tileContents = currentlyDraggingTile.firstChild;
+ if (tileContents.classList.contains('app')) {
+ this.tileGrid_.insertBefore(
+ currentlyDraggingTile,
+ this.tileElements_[index]);
+ this.tileMoved(currentlyDraggingTile);
+ } else if (tileContents.classList.contains('most-visited')) {
+ this.generateAppForLink(tileContents.data);
+ }
+ } else {
+ this.addOutsideData_(e.dataTransfer, index);
+ }
+ },
+
+ /**
+ * Adds drag data that has been dropped from a source that is not a tile.
+ * @param {Object} dataTransfer The data transfer object that holds drop
+ * data.
+ * @param {number} index The index for the new data.
+ * @private
+ */
+ addOutsideData_: function(dataTransfer, index) {
var url = dataTransfer.getData('url');
assert(url);
if (!url)
@@ -417,9 +461,12 @@ cr.define('ntp4', function() {
/**
* Creates a new crx-less app manifest and installs it.
* @param {Object} data The data object describing the link. Must have |url|
- * and |title| members.
+ * and |title| members.
+ * TODO(estade): pass along an index.
*/
generateAppForLink: function(data) {
+ assert(data.url != undefined);
+ assert(data.title != undefined);
chrome.send('generateAppForLink', [data.url, data.title]);
},
« no previous file with comments | « no previous file | chrome/browser/resources/ntp4/most_visited_page.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698