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

Side by Side Diff: chrome/browser/download/download_crx_util.cc

Issue 10696176: Move UserScript and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Download code which handles CRX files (extensions, themes, apps, ...). 5 // Download code which handles CRX files (extensions, themes, apps, ...).
6 6
7 #include "chrome/browser/download/download_util.h" 7 #include "chrome/browser/download/download_util.h"
8 #include "chrome/browser/extensions/crx_installer.h" 8 #include "chrome/browser/extensions/crx_installer.h"
9 #include "chrome/browser/extensions/extension_install_prompt.h" 9 #include "chrome/browser/extensions/extension_install_prompt.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 WebstoreInstaller::GetAssociatedApproval(download_item))); 84 WebstoreInstaller::GetAssociatedApproval(download_item)));
85 85
86 installer->set_delete_source(true); 86 installer->set_delete_source(true);
87 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); 87 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD);
88 88
89 if (OffStoreInstallAllowedByPrefs(profile, download_item)) { 89 if (OffStoreInstallAllowedByPrefs(profile, download_item)) {
90 installer->set_off_store_install_allow_reason( 90 installer->set_off_store_install_allow_reason(
91 CrxInstaller::OffStoreInstallAllowedBecausePref); 91 CrxInstaller::OffStoreInstallAllowedBecausePref);
92 } 92 }
93 93
94 if (UserScript::IsURLUserScript(download_item.GetURL(), 94 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(),
95 download_item.GetMimeType())) { 95 download_item.GetMimeType())) {
96 installer->InstallUserScript(download_item.GetFullPath(), 96 installer->InstallUserScript(download_item.GetFullPath(),
97 download_item.GetURL()); 97 download_item.GetURL());
98 } else { 98 } else {
99 bool is_gallery_download = 99 bool is_gallery_download =
100 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL; 100 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL;
101 installer->set_original_mime_type(download_item.GetOriginalMimeType()); 101 installer->set_original_mime_type(download_item.GetOriginalMimeType());
102 installer->set_apps_require_extension_mime_type(true); 102 installer->set_apps_require_extension_mime_type(true);
103 installer->set_download_url(download_item.GetURL()); 103 installer->set_download_url(download_item.GetURL());
104 installer->set_is_gallery_install(is_gallery_download); 104 installer->set_is_gallery_install(is_gallery_download);
105 if (is_gallery_download) 105 if (is_gallery_download)
106 installer->set_original_download_url(download_item.GetOriginalUrl()); 106 installer->set_original_download_url(download_item.GetOriginalUrl());
107 installer->set_allow_silent_install(is_gallery_download); 107 installer->set_allow_silent_install(is_gallery_download);
108 installer->InstallCrx(download_item.GetFullPath()); 108 installer->InstallCrx(download_item.GetFullPath());
109 } 109 }
110 110
111 return installer; 111 return installer;
112 } 112 }
113 113
114 bool IsExtensionDownload(const DownloadItem& download_item) { 114 bool IsExtensionDownload(const DownloadItem& download_item) {
115 if (download_item.GetTargetDisposition() == 115 if (download_item.GetTargetDisposition() ==
116 DownloadItem::TARGET_DISPOSITION_PROMPT) 116 DownloadItem::TARGET_DISPOSITION_PROMPT)
117 return false; 117 return false;
118 118
119 if (download_item.GetMimeType() == extensions::Extension::kMimeType || 119 if (download_item.GetMimeType() == extensions::Extension::kMimeType ||
120 UserScript::IsURLUserScript(download_item.GetURL(), 120 extensions::UserScript::IsURLUserScript(download_item.GetURL(),
121 download_item.GetMimeType())) { 121 download_item.GetMimeType())) {
122 return true; 122 return true;
123 } else { 123 } else {
124 return false; 124 return false;
125 } 125 }
126 } 126 }
127 127
128 } // namespace download_crx_util 128 } // namespace download_crx_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698