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

Unified Diff: chrome/browser/download/download_manager.cc

Issue 55046: Installing extensions (drag/drop, download crx file) will now be... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | « chrome/browser/download/download_manager.h ('k') | chrome/browser/download/download_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_manager.cc
===================================================================
--- chrome/browser/download/download_manager.cc (revision 12708)
+++ chrome/browser/download/download_manager.cc (working copy)
@@ -18,6 +18,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_file.h"
#include "chrome/browser/extensions/extension.h"
+#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
@@ -690,7 +691,8 @@
NewRunnableMethod(file_manager_,
&DownloadFileManager::OnFinalDownloadName,
download->id(),
- target_path));
+ target_path,
+ this));
// If the download already completed by the time we reached this point, then
// notify observers that it did.
@@ -817,6 +819,18 @@
ContinueDownloadFinished(download);
}
+void DownloadManager::DownloadRenamedToFinalName(int download_id,
+ const FilePath& full_path) {
+ FilePath::StringType extension = full_path.Extension();
+ // Drop the leading period.
+ if (extension.size() > 0)
+ extension = extension.substr(1);
+
+ if (extension == chrome::kExtensionFileExtension) {
+ OpenChromeExtension(full_path);
+ }
+}
+
void DownloadManager::ContinueDownloadFinished(DownloadItem* download) {
// If this was a dangerous download, it has now been approved and must be
// removed from dangerous_finished_ so it does not get deleted on shutdown.
@@ -833,6 +847,14 @@
// Drop the leading period.
if (extension.size() > 0)
extension = extension.substr(1);
+
+ // Handle chrome extensions explicitly and skip the shell execute.
+ if (extension == chrome::kExtensionFileExtension) {
+ // Skip the shell execute. This will be handled in
+ // DownloadRenamedToFinalName
+ return;
+ }
+
if (download->open_when_complete() || ShouldOpenFileExtension(extension))
OpenDownloadInShell(download, NULL);
}
@@ -1192,6 +1214,27 @@
FilePath(download->full_path())));
}
+void DownloadManager::OpenDownload(const DownloadItem* download,
+ gfx::NativeView parent_window) {
+ FilePath::StringType extension = download->full_path().Extension();
+ // Drop the leading period.
+ if (extension.size() > 0)
+ extension = extension.substr(1);
+
+ // Open Chrome extensions with ExtenstionsService. For everthing else do shell
+ // execute.
+ if (extension == chrome::kExtensionFileExtension) {
+ OpenChromeExtension(download->full_path());
+ } else {
+ OpenDownloadInShell(download, parent_window);
+ }
+}
+
+void DownloadManager::OpenChromeExtension(const FilePath& full_path) {
+ ExtensionsService* extensions_service = profile_->GetExtensionsService();
+ extensions_service->InstallExtension(full_path);
+}
+
void DownloadManager::OpenDownloadInShell(const DownloadItem* download,
gfx::NativeView parent_window) {
DCHECK(file_manager_);
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | chrome/browser/download/download_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698