| 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/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 browser_displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( | 458 browser_displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( |
| 459 profile_, chrome::GetActiveDesktop())); | 459 profile_, chrome::GetActiveDesktop())); |
| 460 browser = browser_displayer->browser(); | 460 browser = browser_displayer->browser(); |
| 461 } | 461 } |
| 462 content::OpenURLParams params( | 462 content::OpenURLParams params( |
| 463 net::FilePathToFileURL(download->GetTargetFilePath()), | 463 net::FilePathToFileURL(download->GetTargetFilePath()), |
| 464 content::Referrer(), | 464 content::Referrer(), |
| 465 NEW_FOREGROUND_TAB, | 465 NEW_FOREGROUND_TAB, |
| 466 ui::PAGE_TRANSITION_LINK, | 466 ui::PAGE_TRANSITION_LINK, |
| 467 false); | 467 false); |
| 468 |
| 469 if (download->GetOriginalMimeType() == "application/x-x509-user-cert") { |
| 470 params = content::OpenURLParams(GURL("chrome://settings/certificates"), |
| 471 content::Referrer(), NEW_FOREGROUND_TAB, |
| 472 ui::PAGE_TRANSITION_LINK, false); |
| 473 } |
| 474 |
| 468 browser->OpenURL(params); | 475 browser->OpenURL(params); |
| 469 RecordDownloadOpenMethod(DOWNLOAD_OPEN_METHOD_DEFAULT_BROWSER); | 476 RecordDownloadOpenMethod(DOWNLOAD_OPEN_METHOD_DEFAULT_BROWSER); |
| 470 #else | 477 #else |
| 471 // ShouldPreferOpeningInBrowser() should never be true on Android. | 478 // ShouldPreferOpeningInBrowser() should never be true on Android. |
| 472 NOTREACHED(); | 479 NOTREACHED(); |
| 473 #endif | 480 #endif |
| 474 } | 481 } |
| 475 | 482 |
| 476 void ChromeDownloadManagerDelegate::ShowDownloadInShell( | 483 void ChromeDownloadManagerDelegate::ShowDownloadInShell( |
| 477 DownloadItem* download) { | 484 DownloadItem* download) { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 const content::DownloadTargetCallback& callback, | 720 const content::DownloadTargetCallback& callback, |
| 714 scoped_ptr<DownloadTargetInfo> target_info) { | 721 scoped_ptr<DownloadTargetInfo> target_info) { |
| 715 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 722 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 716 DownloadItem* item = download_manager_->GetDownload(download_id); | 723 DownloadItem* item = download_manager_->GetDownload(download_id); |
| 717 if (item) { | 724 if (item) { |
| 718 if (!target_info->target_path.empty() && | 725 if (!target_info->target_path.empty() && |
| 719 IsOpenInBrowserPreferreredForFile(target_info->target_path) && | 726 IsOpenInBrowserPreferreredForFile(target_info->target_path) && |
| 720 target_info->is_filetype_handled_safely) | 727 target_info->is_filetype_handled_safely) |
| 721 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); | 728 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); |
| 722 | 729 |
| 730 #if defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 731 if (item->GetOriginalMimeType() == "application/x-x509-user-cert") |
| 732 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); |
| 733 #endif |
| 734 |
| 723 if (target_info->is_dangerous_file) | 735 if (target_info->is_dangerous_file) |
| 724 DownloadItemModel(item).SetIsDangerousFileBasedOnType(true); | 736 DownloadItemModel(item).SetIsDangerousFileBasedOnType(true); |
| 725 } | 737 } |
| 726 callback.Run(target_info->target_path, | 738 callback.Run(target_info->target_path, |
| 727 target_info->target_disposition, | 739 target_info->target_disposition, |
| 728 target_info->danger_type, | 740 target_info->danger_type, |
| 729 target_info->intermediate_path); | 741 target_info->intermediate_path); |
| 730 } | 742 } |
| 731 | 743 |
| 732 bool ChromeDownloadManagerDelegate::IsOpenInBrowserPreferreredForFile( | 744 bool ChromeDownloadManagerDelegate::IsOpenInBrowserPreferreredForFile( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 752 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || | 764 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || |
| 753 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || | 765 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || |
| 754 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || | 766 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || |
| 755 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || | 767 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || |
| 756 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { | 768 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { |
| 757 return true; | 769 return true; |
| 758 } | 770 } |
| 759 #endif | 771 #endif |
| 760 return false; | 772 return false; |
| 761 } | 773 } |
| OLD | NEW |