| 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/download/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/download/download_service.h" | 32 #include "chrome/browser/download/download_service.h" |
| 33 #include "chrome/browser/download/download_service_factory.h" | 33 #include "chrome/browser/download/download_service_factory.h" |
| 34 #include "chrome/browser/download/download_stats.h" | 34 #include "chrome/browser/download/download_stats.h" |
| 35 #include "chrome/browser/download/download_target_determiner.h" | 35 #include "chrome/browser/download/download_target_determiner.h" |
| 36 #include "chrome/browser/download/save_package_file_picker.h" | 36 #include "chrome/browser/download/save_package_file_picker.h" |
| 37 #include "chrome/browser/platform_util.h" | 37 #include "chrome/browser/platform_util.h" |
| 38 #include "chrome/browser/profiles/profile.h" | 38 #include "chrome/browser/profiles/profile.h" |
| 39 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 39 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 40 #include "chrome/browser/ui/browser.h" | 40 #include "chrome/browser/ui/browser.h" |
| 41 #include "chrome/browser/ui/browser_finder.h" | 41 #include "chrome/browser/ui/browser_finder.h" |
| 42 #include "chrome/browser/ui/chrome_pages.h" |
| 42 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 43 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 43 #include "chrome/common/chrome_constants.h" | 44 #include "chrome/common/chrome_constants.h" |
| 44 #include "chrome/common/features.h" | 45 #include "chrome/common/features.h" |
| 45 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 46 #include "components/pref_registry/pref_registry_syncable.h" | 47 #include "components/pref_registry/pref_registry_syncable.h" |
| 47 #include "content/public/browser/download_item.h" | 48 #include "content/public/browser/download_item.h" |
| 48 #include "content/public/browser/download_manager.h" | 49 #include "content/public/browser/download_manager.h" |
| 49 #include "content/public/browser/notification_source.h" | 50 #include "content/public/browser/notification_source.h" |
| 50 #include "content/public/browser/page_navigator.h" | 51 #include "content/public/browser/page_navigator.h" |
| 51 #include "net/base/filename_util.h" | 52 #include "net/base/filename_util.h" |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 browser_displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( | 461 browser_displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( |
| 461 profile_, chrome::GetActiveDesktop())); | 462 profile_, chrome::GetActiveDesktop())); |
| 462 browser = browser_displayer->browser(); | 463 browser = browser_displayer->browser(); |
| 463 } | 464 } |
| 464 content::OpenURLParams params( | 465 content::OpenURLParams params( |
| 465 net::FilePathToFileURL(download->GetTargetFilePath()), | 466 net::FilePathToFileURL(download->GetTargetFilePath()), |
| 466 content::Referrer(), | 467 content::Referrer(), |
| 467 NEW_FOREGROUND_TAB, | 468 NEW_FOREGROUND_TAB, |
| 468 ui::PAGE_TRANSITION_LINK, | 469 ui::PAGE_TRANSITION_LINK, |
| 469 false); | 470 false); |
| 470 browser->OpenURL(params); | 471 |
| 472 if (download->GetMimeType() == "application/x-x509-user-cert") |
| 473 chrome::ShowSettingsSubPage(browser, "certificates"); |
| 474 else |
| 475 browser->OpenURL(params); |
| 476 |
| 471 RecordDownloadOpenMethod(DOWNLOAD_OPEN_METHOD_DEFAULT_BROWSER); | 477 RecordDownloadOpenMethod(DOWNLOAD_OPEN_METHOD_DEFAULT_BROWSER); |
| 472 #else | 478 #else |
| 473 // ShouldPreferOpeningInBrowser() should never be true on Android. | 479 // ShouldPreferOpeningInBrowser() should never be true on Android. |
| 474 NOTREACHED(); | 480 NOTREACHED(); |
| 475 #endif | 481 #endif |
| 476 } | 482 } |
| 477 | 483 |
| 478 void ChromeDownloadManagerDelegate::ShowDownloadInShell( | 484 void ChromeDownloadManagerDelegate::ShowDownloadInShell( |
| 479 DownloadItem* download) { | 485 DownloadItem* download) { |
| 480 if (!download->CanShowInFolder()) | 486 if (!download->CanShowInFolder()) |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 const content::DownloadTargetCallback& callback, | 721 const content::DownloadTargetCallback& callback, |
| 716 scoped_ptr<DownloadTargetInfo> target_info) { | 722 scoped_ptr<DownloadTargetInfo> target_info) { |
| 717 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 723 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 718 DownloadItem* item = download_manager_->GetDownload(download_id); | 724 DownloadItem* item = download_manager_->GetDownload(download_id); |
| 719 if (item) { | 725 if (item) { |
| 720 if (!target_info->target_path.empty() && | 726 if (!target_info->target_path.empty() && |
| 721 IsOpenInBrowserPreferreredForFile(target_info->target_path) && | 727 IsOpenInBrowserPreferreredForFile(target_info->target_path) && |
| 722 target_info->is_filetype_handled_safely) | 728 target_info->is_filetype_handled_safely) |
| 723 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); | 729 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); |
| 724 | 730 |
| 731 #if defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 732 if (item->GetOriginalMimeType() == "application/x-x509-user-cert") |
| 733 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); |
| 734 #endif |
| 735 |
| 725 if (target_info->is_dangerous_file) | 736 if (target_info->is_dangerous_file) |
| 726 DownloadItemModel(item).SetIsDangerousFileBasedOnType(true); | 737 DownloadItemModel(item).SetIsDangerousFileBasedOnType(true); |
| 727 } | 738 } |
| 728 callback.Run(target_info->target_path, | 739 callback.Run(target_info->target_path, |
| 729 target_info->target_disposition, | 740 target_info->target_disposition, |
| 730 target_info->danger_type, | 741 target_info->danger_type, |
| 731 target_info->intermediate_path); | 742 target_info->intermediate_path); |
| 732 } | 743 } |
| 733 | 744 |
| 734 bool ChromeDownloadManagerDelegate::IsOpenInBrowserPreferreredForFile( | 745 bool ChromeDownloadManagerDelegate::IsOpenInBrowserPreferreredForFile( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 754 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || | 765 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || |
| 755 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || | 766 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || |
| 756 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || | 767 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || |
| 757 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || | 768 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || |
| 758 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { | 769 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { |
| 759 return true; | 770 return true; |
| 760 } | 771 } |
| 761 #endif | 772 #endif |
| 762 return false; | 773 return false; |
| 763 } | 774 } |
| OLD | NEW |