diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-10 16:12:52 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-10 16:12:52 +0000 |
commit | 51b95502776e23711259722219e3afde9318ee4a (patch) | |
tree | da95ed315592990457fd4ef2bb4f52ff1ce6a489 /chrome/browser/download | |
parent | 994eeb0d32e289c0929bb2d52cd8defcb78f7b95 (diff) | |
download | chromium_src-51b95502776e23711259722219e3afde9318ee4a.zip chromium_src-51b95502776e23711259722219e3afde9318ee4a.tar.gz chromium_src-51b95502776e23711259722219e3afde9318ee4a.tar.bz2 |
First round of audits to make sure 'app' is displayed instead of 'extension' where appropriate. This includes some cleanup and deletion of stale/unused code surrounding apps and extensions.
BUG=61259
TEST=Make sure proper wording is used when dealing with apps instead of extensions.
Review URL: http://codereview.chromium.org/4753001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65663 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r-- | chrome/browser/download/download_util.cc | 112 |
1 files changed, 48 insertions, 64 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 193ccaa..a0d774a 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -230,52 +230,35 @@ void OpenChromeExtension(Profile* profile, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(download_item.is_extension_install()); - // We don't support extensions in OTR mode. ExtensionsService* service = profile->GetExtensionsService(); - if (service) { - NotificationService* nservice = NotificationService::current(); - GURL nonconst_download_url = download_item.url(); - nservice->Notify(NotificationType::EXTENSION_READY_FOR_INSTALL, - Source<DownloadManager>(download_manager), - Details<GURL>(&nonconst_download_url)); - - scoped_refptr<CrxInstaller> installer( - new CrxInstaller(service->install_directory(), - service, - new ExtensionInstallUI(profile))); - installer->set_delete_source(true); - - if (UserScript::HasUserScriptFileExtension(download_item.url())) { - installer->InstallUserScript(download_item.full_path(), - download_item.url()); - } else { - bool is_gallery_download = service->IsDownloadFromGallery( - download_item.url(), download_item.referrer_url()); - installer->set_original_mime_type(download_item.original_mime_type()); - installer->set_apps_require_extension_mime_type(true); - installer->set_allow_privilege_increase(true); - installer->set_original_url(download_item.url()); - installer->set_is_gallery_install(is_gallery_download); - installer->InstallCrx(download_item.full_path()); - installer->set_allow_silent_install(is_gallery_download); - } - } else { - TabContents* contents = NULL; - // Get last active normal browser of profile. - Browser* last_active = - BrowserList::FindBrowserWithType(profile, Browser::TYPE_NORMAL, true); - if (last_active) - contents = last_active->GetSelectedTabContents(); - if (contents) { - contents->AddInfoBar( - new SimpleAlertInfoBarDelegate(contents, - l10n_util::GetStringUTF16( - IDS_EXTENSION_INCOGNITO_INSTALL_INFOBAR_LABEL), - ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_INFOBAR_PLUGIN_INSTALL), - true)); - } + CHECK(service); + NotificationService* nservice = NotificationService::current(); + GURL nonconst_download_url = download_item.url(); + nservice->Notify(NotificationType::EXTENSION_READY_FOR_INSTALL, + Source<DownloadManager>(download_manager), + Details<GURL>(&nonconst_download_url)); + + scoped_refptr<CrxInstaller> installer( + new CrxInstaller(service->install_directory(), + service, + new ExtensionInstallUI(profile))); + installer->set_delete_source(true); + + if (UserScript::HasUserScriptFileExtension(download_item.url())) { + installer->InstallUserScript(download_item.full_path(), + download_item.url()); + return; } + + bool is_gallery_download = service->IsDownloadFromGallery( + download_item.url(), download_item.referrer_url()); + installer->set_original_mime_type(download_item.original_mime_type()); + installer->set_apps_require_extension_mime_type(true); + installer->set_allow_privilege_increase(true); + installer->set_original_url(download_item.url()); + installer->set_is_gallery_install(is_gallery_download); + installer->InstallCrx(download_item.full_path()); + installer->set_allow_silent_install(is_gallery_download); } // Download progress painting -------------------------------------------------- @@ -724,26 +707,26 @@ int GetUniquePathNumberWithCrDownload(const FilePath& path) { } namespace { -
-// NOTE: If index is 0, deletes files that do not have the " (nnn)" appended.
-void DeleteUniqueDownloadFile(const FilePath& path, int index) {
- FilePath new_path(path);
- if (index > 0)
- AppendNumberToPath(&new_path, index);
- file_util::Delete(new_path, false);
-}
-
-}
-
-void EraseUniqueDownloadFiles(const FilePath& path) {
- FilePath cr_path = GetCrDownloadPath(path);
-
- for (int index = 0; index <= kMaxUniqueFiles; ++index) {
- DeleteUniqueDownloadFile(path, index);
- DeleteUniqueDownloadFile(cr_path, index);
- }
-}
-
+ +// NOTE: If index is 0, deletes files that do not have the " (nnn)" appended. +void DeleteUniqueDownloadFile(const FilePath& path, int index) { + FilePath new_path(path); + if (index > 0) + AppendNumberToPath(&new_path, index); + file_util::Delete(new_path, false); +} + +} + +void EraseUniqueDownloadFiles(const FilePath& path) { + FilePath cr_path = GetCrDownloadPath(path); + + for (int index = 0; index <= kMaxUniqueFiles; ++index) { + DeleteUniqueDownloadFile(path, index); + DeleteUniqueDownloadFile(cr_path, index); + } +} + FilePath GetCrDownloadPath(const FilePath& suggested_path) { FilePath::StringType file_name; base::SStringPrintf( @@ -771,3 +754,4 @@ bool IsDangerous(DownloadCreateInfo* info, Profile* profile) { } } // namespace download_util + |