| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 void CrxInstaller::InstallCrx(const FilePath& source_file) { | 152 void CrxInstaller::InstallCrx(const FilePath& source_file) { |
| 153 source_file_ = source_file; | 153 source_file_ = source_file; |
| 154 | 154 |
| 155 scoped_refptr<SandboxedUnpacker> unpacker( | 155 scoped_refptr<SandboxedUnpacker> unpacker( |
| 156 new SandboxedUnpacker( | 156 new SandboxedUnpacker( |
| 157 source_file, | 157 source_file, |
| 158 content::ResourceDispatcherHost::Get() != NULL, | 158 content::ResourceDispatcherHost::Get() != NULL, |
| 159 install_source_, | 159 install_source_, |
| 160 creation_flags_, | 160 creation_flags_, |
| 161 install_directory_, |
| 161 this)); | 162 this)); |
| 162 | 163 |
| 163 if (!BrowserThread::PostTask( | 164 if (!BrowserThread::PostTask( |
| 164 BrowserThread::FILE, FROM_HERE, | 165 BrowserThread::FILE, FROM_HERE, |
| 165 base::Bind(&SandboxedUnpacker::Start, unpacker.get()))) | 166 base::Bind(&SandboxedUnpacker::Start, unpacker.get()))) |
| 166 NOTREACHED(); | 167 NOTREACHED(); |
| 167 } | 168 } |
| 168 | 169 |
| 169 void CrxInstaller::InstallUserScript(const FilePath& source_file, | 170 void CrxInstaller::InstallUserScript(const FilePath& source_file, |
| 170 const GURL& download_url) { | 171 const GURL& download_url) { |
| 171 DCHECK(!download_url.is_empty()); | 172 DCHECK(!download_url.is_empty()); |
| 172 | 173 |
| 173 source_file_ = source_file; | 174 source_file_ = source_file; |
| 174 download_url_ = download_url; | 175 download_url_ = download_url; |
| 175 | 176 |
| 176 if (!BrowserThread::PostTask( | 177 if (!BrowserThread::PostTask( |
| 177 BrowserThread::FILE, FROM_HERE, | 178 BrowserThread::FILE, FROM_HERE, |
| 178 base::Bind(&CrxInstaller::ConvertUserScriptOnFileThread, this))) | 179 base::Bind(&CrxInstaller::ConvertUserScriptOnFileThread, this))) |
| 179 NOTREACHED(); | 180 NOTREACHED(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 void CrxInstaller::ConvertUserScriptOnFileThread() { | 183 void CrxInstaller::ConvertUserScriptOnFileThread() { |
| 183 string16 error; | 184 string16 error; |
| 184 scoped_refptr<Extension> extension = ConvertUserScriptToExtension( | 185 scoped_refptr<Extension> extension = ConvertUserScriptToExtension( |
| 185 source_file_, download_url_, &error); | 186 source_file_, download_url_, install_directory_, &error); |
| 186 if (!extension) { | 187 if (!extension) { |
| 187 ReportFailureFromFileThread(CrxInstallerError(error)); | 188 ReportFailureFromFileThread(CrxInstallerError(error)); |
| 188 return; | 189 return; |
| 189 } | 190 } |
| 190 | 191 |
| 191 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension); | 192 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension); |
| 192 } | 193 } |
| 193 | 194 |
| 194 void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { | 195 void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { |
| 195 if (!BrowserThread::PostTask( | 196 if (!BrowserThread::PostTask( |
| 196 BrowserThread::FILE, FROM_HERE, | 197 BrowserThread::FILE, FROM_HERE, |
| 197 base::Bind(&CrxInstaller::ConvertWebAppOnFileThread, this, web_app))) | 198 base::Bind(&CrxInstaller::ConvertWebAppOnFileThread, |
| 199 this, |
| 200 web_app, |
| 201 install_directory_))) |
| 198 NOTREACHED(); | 202 NOTREACHED(); |
| 199 } | 203 } |
| 200 | 204 |
| 201 void CrxInstaller::ConvertWebAppOnFileThread( | 205 void CrxInstaller::ConvertWebAppOnFileThread( |
| 202 const WebApplicationInfo& web_app) { | 206 const WebApplicationInfo& web_app, const FilePath& install_directory) { |
| 203 string16 error; | 207 string16 error; |
| 204 scoped_refptr<Extension> extension( | 208 scoped_refptr<Extension> extension( |
| 205 ConvertWebAppToExtension(web_app, base::Time::Now())); | 209 ConvertWebAppToExtension(web_app, base::Time::Now(), install_directory)); |
| 206 if (!extension) { | 210 if (!extension) { |
| 207 // Validation should have stopped any potential errors before getting here. | 211 // Validation should have stopped any potential errors before getting here. |
| 208 NOTREACHED() << "Could not convert web app to extension."; | 212 NOTREACHED() << "Could not convert web app to extension."; |
| 209 return; | 213 return; |
| 210 } | 214 } |
| 211 | 215 |
| 212 // TODO(aa): conversion data gets lost here :( | 216 // TODO(aa): conversion data gets lost here :( |
| 213 | 217 |
| 214 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension); | 218 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension); |
| 215 } | 219 } |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 // is problematic because they don't know anything about the | 656 // is problematic because they don't know anything about the |
| 653 // extension before it is unpacked, so they cannot filter based | 657 // extension before it is unpacked, so they cannot filter based |
| 654 // on the extension. | 658 // on the extension. |
| 655 content::NotificationService::current()->Notify( | 659 content::NotificationService::current()->Notify( |
| 656 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 660 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 657 content::Source<CrxInstaller>(this), | 661 content::Source<CrxInstaller>(this), |
| 658 content::Details<const Extension>(extension)); | 662 content::Details<const Extension>(extension)); |
| 659 } | 663 } |
| 660 | 664 |
| 661 } // namespace extensions | 665 } // namespace extensions |
| OLD | NEW |