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/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 <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #include "extensions/browser/event_router.h" | 72 #include "extensions/browser/event_router.h" |
73 #include "extensions/browser/extension_function_dispatcher.h" | 73 #include "extensions/browser/extension_function_dispatcher.h" |
74 #include "extensions/browser/extension_prefs.h" | 74 #include "extensions/browser/extension_prefs.h" |
75 #include "extensions/browser/extension_registry.h" | 75 #include "extensions/browser/extension_registry.h" |
76 #include "extensions/browser/notification_types.h" | 76 #include "extensions/browser/notification_types.h" |
77 #include "extensions/browser/warning_service.h" | 77 #include "extensions/browser/warning_service.h" |
78 #include "extensions/common/permissions/permissions_data.h" | 78 #include "extensions/common/permissions/permissions_data.h" |
79 #include "net/base/filename_util.h" | 79 #include "net/base/filename_util.h" |
80 #include "net/base/load_flags.h" | 80 #include "net/base/load_flags.h" |
81 #include "net/http/http_util.h" | 81 #include "net/http/http_util.h" |
| 82 #include "net/traffic_annotation/network_traffic_annotation.h" |
82 #include "third_party/skia/include/core/SkBitmap.h" | 83 #include "third_party/skia/include/core/SkBitmap.h" |
83 #include "ui/base/webui/web_ui_util.h" | 84 #include "ui/base/webui/web_ui_util.h" |
84 #include "ui/gfx/image/image_skia.h" | 85 #include "ui/gfx/image/image_skia.h" |
85 | 86 |
86 using content::BrowserContext; | 87 using content::BrowserContext; |
87 using content::BrowserThread; | 88 using content::BrowserThread; |
88 using content::DownloadItem; | 89 using content::DownloadItem; |
89 using content::DownloadManager; | 90 using content::DownloadManager; |
90 | 91 |
91 namespace download_extension_errors { | 92 namespace download_extension_errors { |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 if (options.body.get()) | 1035 if (options.body.get()) |
1035 download_params->set_post_body(*options.body); | 1036 download_params->set_post_body(*options.body); |
1036 download_params->set_callback(base::Bind( | 1037 download_params->set_callback(base::Bind( |
1037 &DownloadsDownloadFunction::OnStarted, this, | 1038 &DownloadsDownloadFunction::OnStarted, this, |
1038 creator_suggested_filename, options.conflict_action)); | 1039 creator_suggested_filename, options.conflict_action)); |
1039 // Prevent login prompts for 401/407 responses. | 1040 // Prevent login prompts for 401/407 responses. |
1040 download_params->set_do_not_prompt_for_login(true); | 1041 download_params->set_do_not_prompt_for_login(true); |
1041 | 1042 |
1042 DownloadManager* manager = BrowserContext::GetDownloadManager( | 1043 DownloadManager* manager = BrowserContext::GetDownloadManager( |
1043 current_profile); | 1044 current_profile); |
1044 manager->DownloadUrl(std::move(download_params)); | 1045 manager->DownloadUrl(std::move(download_params), NO_TRAFFIC_ANNOTATION_YET); |
1045 RecordDownloadSource(DOWNLOAD_INITIATED_BY_EXTENSION); | 1046 RecordDownloadSource(DOWNLOAD_INITIATED_BY_EXTENSION); |
1046 RecordApiFunctions(DOWNLOADS_FUNCTION_DOWNLOAD); | 1047 RecordApiFunctions(DOWNLOADS_FUNCTION_DOWNLOAD); |
1047 return true; | 1048 return true; |
1048 } | 1049 } |
1049 | 1050 |
1050 void DownloadsDownloadFunction::OnStarted( | 1051 void DownloadsDownloadFunction::OnStarted( |
1051 const base::FilePath& creator_suggested_filename, | 1052 const base::FilePath& creator_suggested_filename, |
1052 downloads::FilenameConflictAction creator_conflict_action, | 1053 downloads::FilenameConflictAction creator_conflict_action, |
1053 DownloadItem* item, | 1054 DownloadItem* item, |
1054 content::DownloadInterruptReason interrupt_reason) { | 1055 content::DownloadInterruptReason interrupt_reason) { |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 return; | 1932 return; |
1932 base::Time now(base::Time::Now()); | 1933 base::Time now(base::Time::Now()); |
1933 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); | 1934 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); |
1934 if (delta <= kFileExistenceRateLimitSeconds) | 1935 if (delta <= kFileExistenceRateLimitSeconds) |
1935 return; | 1936 return; |
1936 last_checked_removal_ = now; | 1937 last_checked_removal_ = now; |
1937 manager->CheckForHistoryFilesRemoval(); | 1938 manager->CheckForHistoryFilesRemoval(); |
1938 } | 1939 } |
1939 | 1940 |
1940 } // namespace extensions | 1941 } // namespace extensions |
OLD | NEW |