summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 02:15:20 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 02:15:20 +0000
commit6657afa65426f10f5dc51c0ac12d573c4826cb54 (patch)
tree3b24f83dd2f834bde93b7b7e27327701814379ac /chrome/browser/download
parent6c856ae733bf8d1f187ec5b93e07216ace0c4693 (diff)
downloadchromium_src-6657afa65426f10f5dc51c0ac12d573c4826cb54.zip
chromium_src-6657afa65426f10f5dc51c0ac12d573c4826cb54.tar.gz
chromium_src-6657afa65426f10f5dc51c0ac12d573c4826cb54.tar.bz2
Add first class support for user scripts.
Original review: http://codereview.chromium.org/340057 TBR=mpcomplete@chromium.org BUG=22103 TEST=Install a user script (such as from userscripts.org). You should get the extension install UI and the script should show up in the extension management UI. It should also work, though some scripts use Firefox-specific APIs and those won't work in Chromium. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30925 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r--chrome/browser/download/download_manager.cc44
1 files changed, 34 insertions, 10 deletions
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index eef8b04..bb0a280 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -34,6 +34,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/user_script.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/platform_util.h"
@@ -1243,14 +1244,25 @@ void DownloadManager::OpenChromeExtension(const FilePath& full_path,
nservice->Notify(NotificationType::EXTENSION_READY_FOR_INSTALL,
Source<DownloadManager>(this),
NotificationService::NoDetails());
- CrxInstaller::Start(full_path,
- service->install_directory(),
- Extension::INTERNAL,
- "", // no expected id
- true, // please delete crx on completion
- true, // privilege increase allowed
- service,
- new ExtensionInstallUI(profile_));
+ if (UserScript::HasUserScriptFileExtension(full_path)) {
+ CrxInstaller::InstallUserScript(
+ full_path,
+ download_url,
+ service->install_directory(),
+ true, // please delete crx on completion
+ service,
+ new ExtensionInstallUI(profile_));
+ } else {
+ CrxInstaller::Start(
+ full_path,
+ service->install_directory(),
+ Extension::INTERNAL,
+ "", // no expected id
+ true, // please delete crx on completion
+ true, // privilege increase allowed
+ service,
+ new ExtensionInstallUI(profile_));
+ }
}
}
@@ -1453,11 +1465,23 @@ void DownloadManager::GenerateSafeFilename(const std::string& mime_type,
}
bool DownloadManager::IsExtensionInstall(const DownloadItem* item) {
- return item->mime_type() == Extension::kMimeType && !item->save_as();
+ if (item->save_as())
+ return false;
+
+ if (UserScript::HasUserScriptFileExtension(item->original_name()))
+ return true;
+
+ return item->mime_type() == Extension::kMimeType;
}
bool DownloadManager::IsExtensionInstall(const DownloadCreateInfo* info) {
- return info->mime_type == Extension::kMimeType && !info->save_as;
+ if (info->save_as)
+ return false;
+
+ if (UserScript::HasUserScriptFileExtension(info->path))
+ return true;
+
+ return info->mime_type == Extension::kMimeType;
}
// Operations posted to us from the history service ----------------------------