Index: chrome/browser/extensions/webstore_installer.cc |
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc |
index d1193418342dcecba43261a8614072aaeda2a081..9f6535523a85eeb4f4a564d060eec384a3a9b086 100644 |
--- a/chrome/browser/extensions/webstore_installer.cc |
+++ b/chrome/browser/extensions/webstore_installer.cc |
@@ -195,9 +195,7 @@ void WebstoreInstaller::Start() { |
BrowserThread::PostTask( |
BrowserThread::FILE, FROM_HERE, |
base::Bind(&GetDownloadFilePath, download_path, id_, |
- base::Bind(&WebstoreInstaller::StartDownload, |
- base::Unretained(this)))); |
- |
+ base::Bind(&WebstoreInstaller::StartDownload, this))); |
} |
void WebstoreInstaller::Observe(int type, |
@@ -303,7 +301,7 @@ void WebstoreInstaller::OnDownloadOpened(DownloadItem* download) { |
void WebstoreInstaller::StartDownload(const FilePath& file) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- if (file.empty()) { |
+ if (file.empty() || !controller_ || !controller_->GetWebContents()) { |
Aaron Boodman
2012/06/11 21:53:42
How can controller_ be NULL?
benjhayden
2012/06/12 17:51:53
Changed the c-tor to validate it. PTAL.
|
ReportFailure(kDownloadDirectoryError); |
return; |
} |
@@ -319,9 +317,10 @@ void WebstoreInstaller::StartDownload(const FilePath& file) { |
scoped_ptr<DownloadUrlParameters> params( |
DownloadUrlParameters::FromWebContents( |
controller_->GetWebContents(), download_url_, save_info)); |
- params->set_referrer( |
- content::Referrer(controller_->GetActiveEntry()->GetURL(), |
- WebKit::WebReferrerPolicyDefault)); |
+ if (controller_->GetActiveEntry()) |
+ params->set_referrer( |
+ content::Referrer(controller_->GetActiveEntry()->GetURL(), |
+ WebKit::WebReferrerPolicyDefault)); |
params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, this)); |
profile_->GetDownloadManager()->DownloadUrl(params.Pass()); |
} |