Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/extensions/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
| 12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_thread.h" | 15 #include "chrome/browser/chrome_thread.h" |
| 16 #include "chrome/browser/extensions/convert_user_script.h" | 16 #include "chrome/browser/extensions/convert_user_script.h" |
| 17 #include "chrome/browser/extensions/extension_error_reporter.h" | 17 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 18 #include "chrome/browser/profile.h" | 18 #include "chrome/browser/profile.h" |
| 19 #include "chrome/browser/shell_integration.h" | 19 #include "chrome/browser/shell_integration.h" |
| 20 #include "chrome/browser/web_applications/web_app.h" | 20 #include "chrome/browser/web_applications/web_app.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/extensions/extension_file_util.h" | 22 #include "chrome/common/extensions/extension_file_util.h" |
| 23 #include "chrome/common/extensions/extension_constants.h" | |
| 23 #include "chrome/common/notification_service.h" | 24 #include "chrome/common/notification_service.h" |
| 24 #include "chrome/common/notification_type.h" | 25 #include "chrome/common/notification_type.h" |
| 25 #include "grit/browser_resources.h" | 26 #include "grit/browser_resources.h" |
| 26 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
| 27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 28 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 // Helper function to delete files. This is used to avoid ugly casts which | 32 // Helper function to delete files. This is used to avoid ugly casts which |
| 32 // would be necessary with PostMessage since file_util::Delete is overloaded. | 33 // would be necessary with PostMessage since file_util::Delete is overloaded. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); | 129 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); |
| 129 | 130 |
| 130 // Note: We take ownership of |extension| and |temp_dir|. | 131 // Note: We take ownership of |extension| and |temp_dir|. |
| 131 extension_.reset(extension); | 132 extension_.reset(extension); |
| 132 temp_dir_ = temp_dir; | 133 temp_dir_ = temp_dir; |
| 133 | 134 |
| 134 // The unpack dir we don't have to delete explicity since it is a child of | 135 // The unpack dir we don't have to delete explicity since it is a child of |
| 135 // the temp dir. | 136 // the temp dir. |
| 136 unpacked_extension_root_ = extension_dir; | 137 unpacked_extension_root_ = extension_dir; |
| 137 | 138 |
| 139 // Only allow extensions with a gallery update url to be installed after | |
| 140 // having been directly downloaded from the gallery. | |
| 141 if (extension->update_url() == GURL(extension_urls::kGalleryUpdateURL) && | |
| 142 !StartsWithASCII(original_url_.spec(), | |
| 143 extension_urls::kGalleryDownloadPrefix, false)) { | |
| 144 ReportFailureFromUIThread(l10n_util::GetStringFUTF8( | |
|
akalin
2010/06/24 01:09:58
This should be ReportFailureFromFileThread()
rafaelw
2010/06/24 02:27:51
Thanks for the catch. Done here: http://codereview
| |
| 145 IDS_EXTENSION_DISALLOW_NON_DOWNLOADED_GALLERY_INSTALLS, | |
| 146 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE))); | |
| 147 return; | |
| 148 } | |
| 149 | |
| 138 // Determine whether to allow installation. We always allow themes and | 150 // Determine whether to allow installation. We always allow themes and |
| 139 // external installs. | 151 // external installs. |
| 140 if (!extensions_enabled_ && !extension->IsTheme() && | 152 if (!extensions_enabled_ && !extension->IsTheme() && |
| 141 !Extension::IsExternalLocation(install_source_)) { | 153 !Extension::IsExternalLocation(install_source_)) { |
| 142 ReportFailureFromFileThread("Extensions are not enabled."); | 154 ReportFailureFromFileThread("Extensions are not enabled."); |
| 143 return; | 155 return; |
| 144 } | 156 } |
| 145 | 157 |
| 146 // Make sure the expected id matches. | 158 // Make sure the expected id matches. |
| 147 // TODO(aa): Also support expected version? | 159 // TODO(aa): Also support expected version? |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 client_->OnInstallSuccess(extension_.get()); | 333 client_->OnInstallSuccess(extension_.get()); |
| 322 | 334 |
| 323 // Tell the frontend about the installation and hand off ownership of | 335 // Tell the frontend about the installation and hand off ownership of |
| 324 // extension_ to it. | 336 // extension_ to it. |
| 325 frontend_->OnExtensionInstalled(extension_.release(), | 337 frontend_->OnExtensionInstalled(extension_.release(), |
| 326 allow_privilege_increase_); | 338 allow_privilege_increase_); |
| 327 | 339 |
| 328 // We're done. We don't post any more tasks to ourselves so we are deleted | 340 // We're done. We don't post any more tasks to ourselves so we are deleted |
| 329 // soon. | 341 // soon. |
| 330 } | 342 } |
| OLD | NEW |