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/webstore_installer.h" | 5 #include "chrome/browser/extensions/webstore_installer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | |
10 #include <limits> | 9 #include <limits> |
11 #include <set> | 10 #include <set> |
| 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
17 #include "base/metrics/field_trial.h" | 17 #include "base/metrics/field_trial.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/metrics/sparse_histogram.h" | 19 #include "base/metrics/sparse_histogram.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/rand_util.h" | 21 #include "base/rand_util.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 skip_post_install_ui(false), | 245 skip_post_install_ui(false), |
246 skip_install_dialog(false), | 246 skip_install_dialog(false), |
247 enable_launcher(false), | 247 enable_launcher(false), |
248 manifest_check_level(MANIFEST_CHECK_LEVEL_STRICT) { | 248 manifest_check_level(MANIFEST_CHECK_LEVEL_STRICT) { |
249 } | 249 } |
250 | 250 |
251 scoped_ptr<WebstoreInstaller::Approval> | 251 scoped_ptr<WebstoreInstaller::Approval> |
252 WebstoreInstaller::Approval::CreateWithInstallPrompt(Profile* profile) { | 252 WebstoreInstaller::Approval::CreateWithInstallPrompt(Profile* profile) { |
253 scoped_ptr<Approval> result(new Approval()); | 253 scoped_ptr<Approval> result(new Approval()); |
254 result->profile = profile; | 254 result->profile = profile; |
255 return result.Pass(); | 255 return result; |
256 } | 256 } |
257 | 257 |
258 scoped_ptr<WebstoreInstaller::Approval> | 258 scoped_ptr<WebstoreInstaller::Approval> |
259 WebstoreInstaller::Approval::CreateForSharedModule(Profile* profile) { | 259 WebstoreInstaller::Approval::CreateForSharedModule(Profile* profile) { |
260 scoped_ptr<Approval> result(new Approval()); | 260 scoped_ptr<Approval> result(new Approval()); |
261 result->profile = profile; | 261 result->profile = profile; |
262 result->skip_install_dialog = true; | 262 result->skip_install_dialog = true; |
263 result->skip_post_install_ui = true; | 263 result->skip_post_install_ui = true; |
264 result->manifest_check_level = MANIFEST_CHECK_LEVEL_NONE; | 264 result->manifest_check_level = MANIFEST_CHECK_LEVEL_NONE; |
265 return result.Pass(); | 265 return result; |
266 } | 266 } |
267 | 267 |
268 scoped_ptr<WebstoreInstaller::Approval> | 268 scoped_ptr<WebstoreInstaller::Approval> |
269 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( | 269 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
270 Profile* profile, | 270 Profile* profile, |
271 const std::string& extension_id, | 271 const std::string& extension_id, |
272 scoped_ptr<base::DictionaryValue> parsed_manifest, | 272 scoped_ptr<base::DictionaryValue> parsed_manifest, |
273 bool strict_manifest_check) { | 273 bool strict_manifest_check) { |
274 scoped_ptr<Approval> result(new Approval()); | 274 scoped_ptr<Approval> result(new Approval()); |
275 result->extension_id = extension_id; | 275 result->extension_id = extension_id; |
276 result->profile = profile; | 276 result->profile = profile; |
277 result->manifest = scoped_ptr<Manifest>( | 277 result->manifest = scoped_ptr<Manifest>( |
278 new Manifest(Manifest::INVALID_LOCATION, | 278 new Manifest(Manifest::INVALID_LOCATION, |
279 scoped_ptr<base::DictionaryValue>( | 279 scoped_ptr<base::DictionaryValue>( |
280 parsed_manifest->DeepCopy()))); | 280 parsed_manifest->DeepCopy()))); |
281 result->skip_install_dialog = true; | 281 result->skip_install_dialog = true; |
282 result->manifest_check_level = strict_manifest_check ? | 282 result->manifest_check_level = strict_manifest_check ? |
283 MANIFEST_CHECK_LEVEL_STRICT : MANIFEST_CHECK_LEVEL_LOOSE; | 283 MANIFEST_CHECK_LEVEL_STRICT : MANIFEST_CHECK_LEVEL_LOOSE; |
284 return result.Pass(); | 284 return result; |
285 } | 285 } |
286 | 286 |
287 WebstoreInstaller::Approval::~Approval() {} | 287 WebstoreInstaller::Approval::~Approval() {} |
288 | 288 |
289 const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval( | 289 const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval( |
290 const DownloadItem& download) { | 290 const DownloadItem& download) { |
291 return static_cast<const Approval*>(download.GetUserData(kApprovalKey)); | 291 return static_cast<const Approval*>(download.GetUserData(kApprovalKey)); |
292 } | 292 } |
293 | 293 |
294 WebstoreInstaller::WebstoreInstaller(Profile* profile, | 294 WebstoreInstaller::WebstoreInstaller(Profile* profile, |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 contents->GetMainFrame()->GetRoutingID(), | 673 contents->GetMainFrame()->GetRoutingID(), |
674 resource_context)); | 674 resource_context)); |
675 params->set_file_path(file); | 675 params->set_file_path(file); |
676 if (controller.GetVisibleEntry()) | 676 if (controller.GetVisibleEntry()) |
677 params->set_referrer(content::Referrer::SanitizeForRequest( | 677 params->set_referrer(content::Referrer::SanitizeForRequest( |
678 download_url_, content::Referrer(controller.GetVisibleEntry()->GetURL(), | 678 download_url_, content::Referrer(controller.GetVisibleEntry()->GetURL(), |
679 blink::WebReferrerPolicyDefault))); | 679 blink::WebReferrerPolicyDefault))); |
680 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, | 680 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, |
681 this, | 681 this, |
682 extension_id)); | 682 extension_id)); |
683 download_manager->DownloadUrl(params.Pass()); | 683 download_manager->DownloadUrl(std::move(params)); |
684 } | 684 } |
685 | 685 |
686 void WebstoreInstaller::UpdateDownloadProgress() { | 686 void WebstoreInstaller::UpdateDownloadProgress() { |
687 // If the download has gone away, or isn't in progress (in which case we can't | 687 // If the download has gone away, or isn't in progress (in which case we can't |
688 // give a good progress estimate), stop any running timers and return. | 688 // give a good progress estimate), stop any running timers and return. |
689 if (!download_item_ || | 689 if (!download_item_ || |
690 download_item_->GetState() != DownloadItem::IN_PROGRESS) { | 690 download_item_->GetState() != DownloadItem::IN_PROGRESS) { |
691 download_progress_timer_.Stop(); | 691 download_progress_timer_.Stop(); |
692 return; | 692 return; |
693 } | 693 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 1, | 791 1, |
792 kMaxSizeKb, | 792 kMaxSizeKb, |
793 kNumBuckets); | 793 kNumBuckets); |
794 } | 794 } |
795 UMA_HISTOGRAM_BOOLEAN( | 795 UMA_HISTOGRAM_BOOLEAN( |
796 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", | 796 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", |
797 total_bytes <= 0); | 797 total_bytes <= 0); |
798 } | 798 } |
799 | 799 |
800 } // namespace extensions | 800 } // namespace extensions |
OLD | NEW |