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

Unified Diff: chrome/browser/resources/extensions/extensions.js

Issue 10378026: Reland 135525 - Add a first-class off-store install UI to chrome://extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
Index: chrome/browser/resources/extensions/extensions.js
diff --git a/chrome/browser/resources/extensions/extensions.js b/chrome/browser/resources/extensions/extensions.js
index 51f7c80e6ec25f0561af9cc5da90dd9d92df4527..aedeb4aff2ca2a67ab18c68bb5e36fe4d5366740 100644
--- a/chrome/browser/resources/extensions/extensions.js
+++ b/chrome/browser/resources/extensions/extensions.js
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+<include src="../shared/js/cr/ui/drag_wrapper.js"></include>
<include src="../uber/uber_utils.js"></include>
<include src="extension_list.js"></include>
<include src="pack_extension_overlay.js"></include>
@@ -13,6 +14,45 @@ var webui_responded_ = false;
cr.define('extensions', function() {
var ExtensionsList = options.ExtensionsList;
+ // Implements the DragWrapper handler interface.
+ var dragWrapperHandler = {
+ // @inheritdoc
+ shouldAcceptDrag: function(e) {
+ // We can't access filenames during the 'dragenter' event, so we have to
+ // wait until 'drop' to decide whether to do something with the file or
+ // not.
+ // See: http://www.w3.org/TR/2011/WD-html5-20110113/dnd.html#concept-dnd-p
+ return e.dataTransfer.types.indexOf('Files') > -1;
+ },
+ // @inheritdoc
+ doDragEnter: function() {
+ chrome.send('startDrag');
+ ExtensionSettings.showOverlay(null);
+ ExtensionSettings.showOverlay($('dropTargetOverlay'));
+ },
+ // @inheritdoc
+ doDragLeave: function() {
+ ExtensionSettings.showOverlay(null);
+ chrome.send('stopDrag');
+ },
+ // @inheritdoc
+ doDragOver: function(e) {
+ },
+ // @inheritdoc
+ doDrop: function(e) {
+ // Only process files that look like extensions. Other files should
+ // navigate the browser normally.
+ if (!e.dataTransfer.files.length ||
+ !/\.crx$/.test(e.dataTransfer.files[0].name)) {
+ return;
+ }
+
+ chrome.send('installDroppedFile');
+ ExtensionSettings.showOverlay(null);
+ e.preventDefault();
+ }
+ };
+
/**
* ExtensionSettings class
* @class
@@ -53,8 +93,15 @@ cr.define('extensions', function() {
$('update-extensions-now').addEventListener('click',
this.handleUpdateExtensionNow_.bind(this));
+ if (!loadTimeData.getBoolean('offStoreInstallEnabled')) {
+ this.dragWrapper_ =
+ new cr.ui.DragWrapper(document.body, dragWrapperHandler);
+ }
+
var packExtensionOverlay = extensions.PackExtensionOverlay.getInstance();
packExtensionOverlay.initializePage();
+
+ cr.ui.overlay.setupOverlay($('dropTargetOverlay'));
},
/**
« no previous file with comments | « chrome/browser/resources/extensions/extensions.html ('k') | chrome/browser/ui/webui/extensions/extensions_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698