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

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

Issue 10399069: Reland 137540 - Disable off-store extension installs by default. Also get rid of ExtensionService::… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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) {
129 }
130
131 scoped_ptr<WebstoreInstaller::Approval>
132 WebstoreInstaller::Approval::CreateWithInstallPrompt(Profile* profile) {
133 scoped_ptr<Approval> result(new Approval());
134 result->profile = profile;
135 return result.Pass();
136 }
137
138 scoped_ptr<WebstoreInstaller::Approval>
139 WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
140 Profile* profile,
141 const std::string& extension_id,
142 scoped_ptr<base::DictionaryValue> parsed_manifest) {
143 scoped_ptr<Approval> result(new Approval());
144 result->extension_id = extension_id;
145 result->profile = profile;
146 result->parsed_manifest = parsed_manifest.Pass();
147 result->skip_install_dialog = true;
148 return result.Pass();
128 } 149 }
129 150
130 WebstoreInstaller::Approval::~Approval() {} 151 WebstoreInstaller::Approval::~Approval() {}
131 152
132 const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval( 153 const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval(
133 const DownloadItem& download) { 154 const DownloadItem& download) {
134 return static_cast<const Approval*>(download.GetExternalData(kApprovalKey)); 155 return static_cast<const Approval*>(download.GetExternalData(kApprovalKey));
135 } 156 }
136 157
137 WebstoreInstaller::WebstoreInstaller(Profile* profile, 158 WebstoreInstaller::WebstoreInstaller(Profile* profile,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 299 }
279 300
280 void WebstoreInstaller::StartDownload(const FilePath& file) { 301 void WebstoreInstaller::StartDownload(const FilePath& file) {
281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
282 303
283 if (file.empty()) { 304 if (file.empty()) {
284 ReportFailure(kDownloadDirectoryError); 305 ReportFailure(kDownloadDirectoryError);
285 return; 306 return;
286 } 307 }
287 308
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; 309 content::DownloadSaveInfo save_info;
298 save_info.file_path = file; 310 save_info.file_path = file;
299 311
300 // The download url for the given extension is contained in |download_url_|. 312 // 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 313 // 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. 314 // download system will then pass the crx to the CrxInstaller.
303 download_util::RecordDownloadSource( 315 download_util::RecordDownloadSource(
304 download_util::INITIATED_BY_WEBSTORE_INSTALLER); 316 download_util::INITIATED_BY_WEBSTORE_INSTALLER);
305 scoped_ptr<DownloadUrlParameters> params( 317 scoped_ptr<DownloadUrlParameters> params(
306 DownloadUrlParameters::FromWebContents( 318 DownloadUrlParameters::FromWebContents(
307 controller_->GetWebContents(), download_url_, save_info)); 319 controller_->GetWebContents(), download_url_, save_info));
308 params->set_referrer(referrer); 320 params->set_referrer(controller_->GetActiveEntry()->GetURL());
309 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, this)); 321 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, this));
310 profile_->GetDownloadManager()->DownloadUrl(params.Pass()); 322 profile_->GetDownloadManager()->DownloadUrl(params.Pass());
311 } 323 }
312 324
313 void WebstoreInstaller::ReportFailure(const std::string& error) { 325 void WebstoreInstaller::ReportFailure(const std::string& error) {
314 if (delegate_) { 326 if (delegate_) {
315 delegate_->OnExtensionInstallFailure(id_, error); 327 delegate_->OnExtensionInstallFailure(id_, error);
316 delegate_ = NULL; 328 delegate_ = NULL;
317 } 329 }
318 330
319 Release(); // Balanced in Start(). 331 Release(); // Balanced in Start().
320 } 332 }
321 333
322 void WebstoreInstaller::ReportSuccess() { 334 void WebstoreInstaller::ReportSuccess() {
323 if (delegate_) { 335 if (delegate_) {
324 delegate_->OnExtensionInstallSuccess(id_); 336 delegate_->OnExtensionInstallSuccess(id_);
325 delegate_ = NULL; 337 delegate_ = NULL;
326 } 338 }
327 339
328 Release(); // Balanced in Start(). 340 Release(); // Balanced in Start().
329 } 341 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_installer.h ('k') | chrome/browser/ui/intents/web_intent_picker_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698