| OLD | NEW |
| 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 #include "chrome/browser/extensions/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 download_url_ = download_url; | 165 download_url_ = download_url; |
| 166 | 166 |
| 167 if (!BrowserThread::PostTask( | 167 if (!BrowserThread::PostTask( |
| 168 BrowserThread::FILE, FROM_HERE, | 168 BrowserThread::FILE, FROM_HERE, |
| 169 base::Bind(&CrxInstaller::ConvertUserScriptOnFileThread, this))) | 169 base::Bind(&CrxInstaller::ConvertUserScriptOnFileThread, this))) |
| 170 NOTREACHED(); | 170 NOTREACHED(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void CrxInstaller::ConvertUserScriptOnFileThread() { | 173 void CrxInstaller::ConvertUserScriptOnFileThread() { |
| 174 string16 error; | 174 string16 error; |
| 175 scoped_refptr<Extension> extension = | 175 scoped_refptr<Extension> extension = extensions::ConvertUserScriptToExtension( |
| 176 ConvertUserScriptToExtension(source_file_, download_url_, &error); | 176 source_file_, download_url_, &error); |
| 177 if (!extension) { | 177 if (!extension) { |
| 178 ReportFailureFromFileThread(CrxInstallerError(error)); | 178 ReportFailureFromFileThread(CrxInstallerError(error)); |
| 179 return; | 179 return; |
| 180 } | 180 } |
| 181 | 181 |
| 182 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension); | 182 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { | 185 void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { |
| 186 if (!BrowserThread::PostTask( | 186 if (!BrowserThread::PostTask( |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 if (extension->UpdatesFromGallery()) { | 308 if (extension->UpdatesFromGallery()) { |
| 309 return CrxInstallerError( | 309 return CrxInstallerError( |
| 310 l10n_util::GetStringFUTF16( | 310 l10n_util::GetStringFUTF16( |
| 311 IDS_EXTENSION_DISALLOW_NON_DOWNLOADED_GALLERY_INSTALLS, | 311 IDS_EXTENSION_DISALLOW_NON_DOWNLOADED_GALLERY_INSTALLS, |
| 312 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE))); | 312 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE))); |
| 313 } | 313 } |
| 314 | 314 |
| 315 // For self-hosted apps, verify that the entire extent is on the same | 315 // For self-hosted apps, verify that the entire extent is on the same |
| 316 // host (or a subdomain of the host) the download happened from. There's | 316 // host (or a subdomain of the host) the download happened from. There's |
| 317 // no way for us to verify that the app controls any other hosts. | 317 // no way for us to verify that the app controls any other hosts. |
| 318 URLPattern pattern(UserScript::kValidUserScriptSchemes); | 318 URLPattern pattern(extensions::UserScript::kValidUserScriptSchemes); |
| 319 pattern.SetHost(download_url_.host()); | 319 pattern.SetHost(download_url_.host()); |
| 320 pattern.SetMatchSubdomains(true); | 320 pattern.SetMatchSubdomains(true); |
| 321 | 321 |
| 322 URLPatternSet patterns = extension_->web_extent(); | 322 URLPatternSet patterns = extension_->web_extent(); |
| 323 for (URLPatternSet::const_iterator i = patterns.begin(); | 323 for (URLPatternSet::const_iterator i = patterns.begin(); |
| 324 i != patterns.end(); ++i) { | 324 i != patterns.end(); ++i) { |
| 325 if (!pattern.MatchesHost(i->host())) { | 325 if (!pattern.MatchesHost(i->host())) { |
| 326 return CrxInstallerError( | 326 return CrxInstallerError( |
| 327 l10n_util::GetStringUTF16( | 327 l10n_util::GetStringUTF16( |
| 328 IDS_EXTENSION_INSTALL_INCORRECT_INSTALL_HOST)); | 328 IDS_EXTENSION_INSTALL_INCORRECT_INSTALL_HOST)); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 // Some users (such as the download shelf) need to know when a | 617 // Some users (such as the download shelf) need to know when a |
| 618 // CRXInstaller is done. Listening for the EXTENSION_* events | 618 // CRXInstaller is done. Listening for the EXTENSION_* events |
| 619 // is problematic because they don't know anything about the | 619 // is problematic because they don't know anything about the |
| 620 // extension before it is unpacked, so they cannot filter based | 620 // extension before it is unpacked, so they cannot filter based |
| 621 // on the extension. | 621 // on the extension. |
| 622 content::NotificationService::current()->Notify( | 622 content::NotificationService::current()->Notify( |
| 623 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 623 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 624 content::Source<CrxInstaller>(this), | 624 content::Source<CrxInstaller>(this), |
| 625 content::Details<const Extension>(extension)); | 625 content::Details<const Extension>(extension)); |
| 626 } | 626 } |
| OLD | NEW |