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/file_select_helper.h" | 5 #include "chrome/browser/file_select_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/threading/worker_pool.h" | 19 #include "base/threading/worker_pool.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/platform_util.h" | 22 #include "chrome/browser/platform_util.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_list.h" | 26 #include "chrome/browser/ui/browser_list.h" |
27 #include "chrome/browser/ui/chrome_select_file_policy.h" | 27 #include "chrome/browser/ui/chrome_select_file_policy.h" |
28 #include "chrome/common/pref_names.h" | |
28 #include "chrome/grit/generated_resources.h" | 29 #include "chrome/grit/generated_resources.h" |
30 #include "components/prefs/pref_service.h" | |
29 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/notification_details.h" | 32 #include "content/public/browser/notification_details.h" |
31 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
32 #include "content/public/browser/notification_types.h" | 34 #include "content/public/browser/notification_types.h" |
33 #include "content/public/browser/render_frame_host.h" | 35 #include "content/public/browser/render_frame_host.h" |
34 #include "content/public/browser/render_process_host.h" | 36 #include "content/public/browser/render_process_host.h" |
35 #include "content/public/browser/render_view_host.h" | 37 #include "content/public/browser/render_view_host.h" |
36 #include "content/public/browser/render_widget_host.h" | 38 #include "content/public/browser/render_widget_host.h" |
37 #include "content/public/browser/render_widget_host_view.h" | 39 #include "content/public/browser/render_widget_host_view.h" |
38 #include "content/public/browser/storage_partition.h" | 40 #include "content/public/browser/storage_partition.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 for (const auto& extension_in_list : extensions_list) { | 524 for (const auto& extension_in_list : extensions_list) { |
523 base::FilePath::StringType extension = | 525 base::FilePath::StringType extension = |
524 default_file_path.ReplaceExtension(extension_in_list) | 526 default_file_path.ReplaceExtension(extension_in_list) |
525 .FinalExtension(); | 527 .FinalExtension(); |
526 alternate_extensions.push_back(extension); | 528 alternate_extensions.push_back(extension); |
527 } | 529 } |
528 } | 530 } |
529 } | 531 } |
530 | 532 |
531 GURL requestor_url = params->requestor; | 533 GURL requestor_url = params->requestor; |
534 content::BrowserContext* browser_context = web_contents_->GetBrowserContext(); | |
535 bool is_incognito = browser_context && browser_context->IsOffTheRecord(); | |
536 Profile* profile = Profile::FromBrowserContext(browser_context); | |
537 bool is_extended_reporting = | |
538 profile && | |
539 profile->GetPrefs()->GetBoolean( | |
540 prefs::kSafeBrowsingExtendedReportingEnabled); | |
532 sb_service->download_protection_service()->CheckPPAPIDownloadRequest( | 541 sb_service->download_protection_service()->CheckPPAPIDownloadRequest( |
533 requestor_url, default_file_path, alternate_extensions, | 542 requestor_url, default_file_path, alternate_extensions, |
543 is_extended_reporting, is_incognito, | |
asanka
2016/07/14 16:48:15
Since CheckPPAPIDownloadRequest's behavior changes
Jialiu Lin
2016/07/14 20:28:35
Yep, passing the profile is much better. Done.
| |
534 base::Bind(&InterpretSafeBrowsingVerdict, | 544 base::Bind(&InterpretSafeBrowsingVerdict, |
535 base::Bind(&FileSelectHelper::ProceedWithSafeBrowsingVerdict, | 545 base::Bind(&FileSelectHelper::ProceedWithSafeBrowsingVerdict, |
536 this, default_file_path, base::Passed(¶ms)))); | 546 this, default_file_path, base::Passed(¶ms)))); |
537 } | 547 } |
538 | 548 |
539 void FileSelectHelper::ProceedWithSafeBrowsingVerdict( | 549 void FileSelectHelper::ProceedWithSafeBrowsingVerdict( |
540 const base::FilePath& default_file_path, | 550 const base::FilePath& default_file_path, |
541 std::unique_ptr<content::FileChooserParams> params, | 551 std::unique_ptr<content::FileChooserParams> params, |
542 bool allowed_by_safe_browsing) { | 552 bool allowed_by_safe_browsing) { |
543 if (!allowed_by_safe_browsing) { | 553 if (!allowed_by_safe_browsing) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
680 | 690 |
681 // static | 691 // static |
682 base::FilePath FileSelectHelper::GetSanitizedFileName( | 692 base::FilePath FileSelectHelper::GetSanitizedFileName( |
683 const base::FilePath& suggested_filename) { | 693 const base::FilePath& suggested_filename) { |
684 if (suggested_filename.empty()) | 694 if (suggested_filename.empty()) |
685 return base::FilePath(); | 695 return base::FilePath(); |
686 return net::GenerateFileName( | 696 return net::GenerateFileName( |
687 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), | 697 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), |
688 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); | 698 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); |
689 } | 699 } |
OLD | NEW |