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

Side by Side Diff: chrome/browser/extensions/webstore_installer.cc

Issue 10356052: Disable off-store extension installs by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 8 years, 7 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 | Annotate | Revision Log
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 #include "chrome/browser/extensions/webstore_installer.h" 5 #include "chrome/browser/extensions/webstore_installer.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 118 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
119 base::Bind(callback, file)); 119 base::Bind(callback, file));
120 } 120 }
121 121
122 } // namespace 122 } // namespace
123 123
124 WebstoreInstaller::Approval::Approval() 124 WebstoreInstaller::Approval::Approval()
125 : profile(NULL), 125 : profile(NULL),
126 use_app_installed_bubble(false), 126 use_app_installed_bubble(false),
127 skip_post_install_ui(false) { 127 skip_post_install_ui(false),
128 skip_install_dialog(false) {
128 } 129 }
129 130
130 WebstoreInstaller::Approval::~Approval() {} 131 WebstoreInstaller::Approval::~Approval() {}
131 132
132 const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval( 133 const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval(
133 const DownloadItem& download) { 134 const DownloadItem& download) {
134 return static_cast<const Approval*>(download.GetExternalData(kApprovalKey)); 135 return static_cast<const Approval*>(download.GetExternalData(kApprovalKey));
135 } 136 }
136 137
137 WebstoreInstaller::WebstoreInstaller(Profile* profile, 138 WebstoreInstaller::WebstoreInstaller(Profile* profile,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 279 }
279 280
280 void WebstoreInstaller::StartDownload(const FilePath& file) { 281 void WebstoreInstaller::StartDownload(const FilePath& file) {
281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
282 283
283 if (file.empty()) { 284 if (file.empty()) {
284 ReportFailure(kDownloadDirectoryError); 285 ReportFailure(kDownloadDirectoryError);
285 return; 286 return;
286 } 287 }
287 288
288 // TODO(mihaip): For inline installs, we pretend like the referrer is the
289 // gallery, even though this could be an inline install, in order to pass the
290 // checks in ExtensionService::IsDownloadFromGallery. We should instead pass
291 // the real referrer, track if this is an inline install in the whitelist
292 // entry and look that up when checking that this is a valid download.
293 GURL referrer = controller_->GetActiveEntry()->GetURL();
294 if (flags_ & FLAG_INLINE_INSTALL)
295 referrer = GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + id_);
296
297 content::DownloadSaveInfo save_info; 289 content::DownloadSaveInfo save_info;
298 save_info.file_path = file; 290 save_info.file_path = file;
299 291
300 // The download url for the given extension is contained in |download_url_|. 292 // The download url for the given extension is contained in |download_url_|.
301 // We will navigate the current tab to this url to start the download. The 293 // We will navigate the current tab to this url to start the download. The
302 // download system will then pass the crx to the CrxInstaller. 294 // download system will then pass the crx to the CrxInstaller.
303 download_util::RecordDownloadSource( 295 download_util::RecordDownloadSource(
304 download_util::INITIATED_BY_WEBSTORE_INSTALLER); 296 download_util::INITIATED_BY_WEBSTORE_INSTALLER);
305 scoped_ptr<DownloadUrlParameters> params( 297 scoped_ptr<DownloadUrlParameters> params(
306 DownloadUrlParameters::FromWebContents( 298 DownloadUrlParameters::FromWebContents(
307 controller_->GetWebContents(), download_url_, save_info)); 299 controller_->GetWebContents(), download_url_, save_info));
308 params->set_referrer(referrer); 300 params->set_referrer(controller_->GetActiveEntry()->GetURL());
309 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, this)); 301 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, this));
310 profile_->GetDownloadManager()->DownloadUrl(params.Pass()); 302 profile_->GetDownloadManager()->DownloadUrl(params.Pass());
311 } 303 }
312 304
313 void WebstoreInstaller::ReportFailure(const std::string& error) { 305 void WebstoreInstaller::ReportFailure(const std::string& error) {
314 if (delegate_) { 306 if (delegate_) {
315 delegate_->OnExtensionInstallFailure(id_, error); 307 delegate_->OnExtensionInstallFailure(id_, error);
316 delegate_ = NULL; 308 delegate_ = NULL;
317 } 309 }
318 310
319 Release(); // Balanced in Start(). 311 Release(); // Balanced in Start().
320 } 312 }
321 313
322 void WebstoreInstaller::ReportSuccess() { 314 void WebstoreInstaller::ReportSuccess() {
323 if (delegate_) { 315 if (delegate_) {
324 delegate_->OnExtensionInstallSuccess(id_); 316 delegate_->OnExtensionInstallSuccess(id_);
325 delegate_ = NULL; 317 delegate_ = NULL;
326 } 318 }
327 319
328 Release(); // Balanced in Start(). 320 Release(); // Balanced in Start().
329 } 321 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698