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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 1924473003: [Downloads] Use the initiating StoragePartition for resumption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in comment Created 4 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
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/api/downloads/downloads_api.h" 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "content/public/browser/download_item.h" 56 #include "content/public/browser/download_item.h"
57 #include "content/public/browser/download_save_info.h" 57 #include "content/public/browser/download_save_info.h"
58 #include "content/public/browser/download_url_parameters.h" 58 #include "content/public/browser/download_url_parameters.h"
59 #include "content/public/browser/notification_details.h" 59 #include "content/public/browser/notification_details.h"
60 #include "content/public/browser/notification_service.h" 60 #include "content/public/browser/notification_service.h"
61 #include "content/public/browser/notification_source.h" 61 #include "content/public/browser/notification_source.h"
62 #include "content/public/browser/render_frame_host.h" 62 #include "content/public/browser/render_frame_host.h"
63 #include "content/public/browser/render_process_host.h" 63 #include "content/public/browser/render_process_host.h"
64 #include "content/public/browser/render_view_host.h" 64 #include "content/public/browser/render_view_host.h"
65 #include "content/public/browser/render_widget_host_view.h" 65 #include "content/public/browser/render_widget_host_view.h"
66 #include "content/public/browser/resource_context.h" 66 #include "content/public/browser/storage_partition.h"
67 #include "content/public/browser/resource_dispatcher_host.h"
68 #include "content/public/browser/web_contents.h" 67 #include "content/public/browser/web_contents.h"
69 #include "extensions/browser/event_router.h" 68 #include "extensions/browser/event_router.h"
70 #include "extensions/browser/extension_function_dispatcher.h" 69 #include "extensions/browser/extension_function_dispatcher.h"
71 #include "extensions/browser/extension_prefs.h" 70 #include "extensions/browser/extension_prefs.h"
72 #include "extensions/browser/extension_registry.h" 71 #include "extensions/browser/extension_registry.h"
73 #include "extensions/browser/notification_types.h" 72 #include "extensions/browser/notification_types.h"
74 #include "extensions/browser/warning_service.h" 73 #include "extensions/browser/warning_service.h"
75 #include "extensions/common/permissions/permissions_data.h" 74 #include "extensions/common/permissions/permissions_data.h"
76 #include "net/base/filename_util.h" 75 #include "net/base/filename_util.h"
77 #include "net/base/load_flags.h" 76 #include "net/base/load_flags.h"
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 EXTENSION_FUNCTION_VALIDATE(params.get()); 949 EXTENSION_FUNCTION_VALIDATE(params.get());
951 const downloads::DownloadOptions& options = params->options; 950 const downloads::DownloadOptions& options = params->options;
952 GURL download_url(options.url); 951 GURL download_url(options.url);
953 if (Fault(!download_url.is_valid(), errors::kInvalidURL, &error_)) 952 if (Fault(!download_url.is_valid(), errors::kInvalidURL, &error_))
954 return false; 953 return false;
955 954
956 Profile* current_profile = GetProfile(); 955 Profile* current_profile = GetProfile();
957 if (include_incognito() && GetProfile()->HasOffTheRecordProfile()) 956 if (include_incognito() && GetProfile()->HasOffTheRecordProfile())
958 current_profile = GetProfile()->GetOffTheRecordProfile(); 957 current_profile = GetProfile()->GetOffTheRecordProfile();
959 958
959 content::StoragePartition* storage_partition =
960 BrowserContext::GetStoragePartition(
961 render_frame_host()->GetProcess()->GetBrowserContext(),
962 render_frame_host()->GetSiteInstance());
960 std::unique_ptr<content::DownloadUrlParameters> download_params( 963 std::unique_ptr<content::DownloadUrlParameters> download_params(
961 new content::DownloadUrlParameters( 964 new content::DownloadUrlParameters(
962 download_url, render_frame_host()->GetProcess()->GetID(), 965 download_url, render_frame_host()->GetProcess()->GetID(),
963 render_view_host_do_not_use()->GetRoutingID(), 966 render_view_host_do_not_use()->GetRoutingID(),
964 render_frame_host()->GetRoutingID(), 967 render_frame_host()->GetRoutingID(),
965 current_profile->GetResourceContext())); 968 storage_partition->GetURLRequestContext()));
966 969
967 base::FilePath creator_suggested_filename; 970 base::FilePath creator_suggested_filename;
968 if (options.filename.get()) { 971 if (options.filename.get()) {
969 #if defined(OS_WIN) 972 #if defined(OS_WIN)
970 // Can't get filename16 from options.ToValue() because that converts it from 973 // Can't get filename16 from options.ToValue() because that converts it from
971 // std::string. 974 // std::string.
972 base::DictionaryValue* options_value = NULL; 975 base::DictionaryValue* options_value = NULL;
973 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options_value)); 976 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options_value));
974 base::string16 filename16; 977 base::string16 filename16;
975 EXTENSION_FUNCTION_VALIDATE(options_value->GetString( 978 EXTENSION_FUNCTION_VALIDATE(options_value->GetString(
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 return; 1900 return;
1898 base::Time now(base::Time::Now()); 1901 base::Time now(base::Time::Now());
1899 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); 1902 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT();
1900 if (delta <= kFileExistenceRateLimitSeconds) 1903 if (delta <= kFileExistenceRateLimitSeconds)
1901 return; 1904 return;
1902 last_checked_removal_ = now; 1905 last_checked_removal_ = now;
1903 manager->CheckForHistoryFilesRemoval(); 1906 manager->CheckForHistoryFilesRemoval();
1904 } 1907 }
1905 1908
1906 } // namespace extensions 1909 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698