 Chromium Code Reviews
 Chromium Code Reviews Issue 1924473003:
  [Downloads] Use the initiating StoragePartition for resumption.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1924473003:
  [Downloads] Use the initiating StoragePartition for resumption.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 #include <limits> | 9 #include <limits> | 
| 10 #include <set> | 10 #include <set> | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "content/public/browser/download_save_info.h" | 45 #include "content/public/browser/download_save_info.h" | 
| 46 #include "content/public/browser/download_url_parameters.h" | 46 #include "content/public/browser/download_url_parameters.h" | 
| 47 #include "content/public/browser/navigation_controller.h" | 47 #include "content/public/browser/navigation_controller.h" | 
| 48 #include "content/public/browser/navigation_entry.h" | 48 #include "content/public/browser/navigation_entry.h" | 
| 49 #include "content/public/browser/notification_details.h" | 49 #include "content/public/browser/notification_details.h" | 
| 50 #include "content/public/browser/notification_service.h" | 50 #include "content/public/browser/notification_service.h" | 
| 51 #include "content/public/browser/notification_source.h" | 51 #include "content/public/browser/notification_source.h" | 
| 52 #include "content/public/browser/render_frame_host.h" | 52 #include "content/public/browser/render_frame_host.h" | 
| 53 #include "content/public/browser/render_process_host.h" | 53 #include "content/public/browser/render_process_host.h" | 
| 54 #include "content/public/browser/render_view_host.h" | 54 #include "content/public/browser/render_view_host.h" | 
| 55 #include "content/public/browser/storage_partition.h" | |
| 55 #include "content/public/browser/web_contents.h" | 56 #include "content/public/browser/web_contents.h" | 
| 56 #include "extensions/browser/extension_registry.h" | 57 #include "extensions/browser/extension_registry.h" | 
| 57 #include "extensions/browser/extension_system.h" | 58 #include "extensions/browser/extension_system.h" | 
| 58 #include "extensions/browser/install/crx_install_error.h" | 59 #include "extensions/browser/install/crx_install_error.h" | 
| 59 #include "extensions/common/extension.h" | 60 #include "extensions/common/extension.h" | 
| 60 #include "extensions/common/extension_urls.h" | 61 #include "extensions/common/extension_urls.h" | 
| 61 #include "extensions/common/manifest_constants.h" | 62 #include "extensions/common/manifest_constants.h" | 
| 62 #include "extensions/common/manifest_handlers/shared_module_info.h" | 63 #include "extensions/common/manifest_handlers/shared_module_info.h" | 
| 63 #include "net/base/escape.h" | 64 #include "net/base/escape.h" | 
| 64 #include "ui/base/l10n/l10n_util.h" | 65 #include "ui/base/l10n/l10n_util.h" | 
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 658 return; | 659 return; | 
| 659 } | 660 } | 
| 660 | 661 | 
| 661 // The download url for the given extension is contained in |download_url_|. | 662 // The download url for the given extension is contained in |download_url_|. | 
| 662 // We will navigate the current tab to this url to start the download. The | 663 // We will navigate the current tab to this url to start the download. The | 
| 663 // download system will then pass the crx to the CrxInstaller. | 664 // download system will then pass the crx to the CrxInstaller. | 
| 664 RecordDownloadSource(DOWNLOAD_INITIATED_BY_WEBSTORE_INSTALLER); | 665 RecordDownloadSource(DOWNLOAD_INITIATED_BY_WEBSTORE_INSTALLER); | 
| 665 int render_process_host_id = contents->GetRenderProcessHost()->GetID(); | 666 int render_process_host_id = contents->GetRenderProcessHost()->GetID(); | 
| 666 int render_view_host_routing_id = | 667 int render_view_host_routing_id = | 
| 667 contents->GetRenderViewHost()->GetRoutingID(); | 668 contents->GetRenderViewHost()->GetRoutingID(); | 
| 668 content::ResourceContext* resource_context = | 669 | 
| 669 controller.GetBrowserContext()->GetResourceContext(); | 670 content::RenderFrameHost* render_frame_host = contents->GetMainFrame(); | 
| 671 content::StoragePartition* storage_partition = | |
| 672 BrowserContext::GetStoragePartition(profile_, | |
| 673 render_frame_host->GetSiteInstance()); | |
| 670 std::unique_ptr<DownloadUrlParameters> params(new DownloadUrlParameters( | 674 std::unique_ptr<DownloadUrlParameters> params(new DownloadUrlParameters( | 
| 671 download_url_, render_process_host_id, render_view_host_routing_id, | 675 download_url_, render_process_host_id, render_view_host_routing_id, | 
| 672 contents->GetMainFrame()->GetRoutingID(), resource_context)); | 676 contents->GetMainFrame()->GetRoutingID(), | 
| 
Charlie Reis
2016/05/05 21:43:22
nit: Can use |render_frame_host| here.
 
asanka
2016/05/07 00:24:45
Done.
 | |
| 677 storage_partition->GetURLRequestContext())); | |
| 673 params->set_file_path(file); | 678 params->set_file_path(file); | 
| 674 if (controller.GetVisibleEntry()) | 679 if (controller.GetVisibleEntry()) | 
| 675 params->set_referrer(content::Referrer::SanitizeForRequest( | 680 params->set_referrer(content::Referrer::SanitizeForRequest( | 
| 676 download_url_, content::Referrer(controller.GetVisibleEntry()->GetURL(), | 681 download_url_, content::Referrer(controller.GetVisibleEntry()->GetURL(), | 
| 677 blink::WebReferrerPolicyDefault))); | 682 blink::WebReferrerPolicyDefault))); | 
| 678 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, | 683 params->set_callback(base::Bind(&WebstoreInstaller::OnDownloadStarted, | 
| 679 this, | 684 this, | 
| 680 extension_id)); | 685 extension_id)); | 
| 681 download_manager->DownloadUrl(std::move(params)); | 686 download_manager->DownloadUrl(std::move(params)); | 
| 682 } | 687 } | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 1, | 794 1, | 
| 790 kMaxSizeKb, | 795 kMaxSizeKb, | 
| 791 kNumBuckets); | 796 kNumBuckets); | 
| 792 } | 797 } | 
| 793 UMA_HISTOGRAM_BOOLEAN( | 798 UMA_HISTOGRAM_BOOLEAN( | 
| 794 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", | 799 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", | 
| 795 total_bytes <= 0); | 800 total_bytes <= 0); | 
| 796 } | 801 } | 
| 797 | 802 | 
| 798 } // namespace extensions | 803 } // namespace extensions | 
| OLD | NEW |