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

Side by Side Diff: chrome/browser/ui/download/download_tab_helper.cc

Issue 7324031: Revert 91861 - When the download folder does not exist, change the download folder to a user's "D... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/download/download_tab_helper.h" 5 #include "chrome/browser/ui/download/download_tab_helper.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/download/download_manager.h" 8 #include "chrome/browser/download/download_manager.h"
9 #include "chrome/browser/download/download_request_limiter.h" 9 #include "chrome/browser/download/download_request_limiter.h"
10 #include "chrome/browser/download/download_util.h" 10 #include "chrome/browser/download/download_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // another thread. 47 // another thread.
48 save_package_ = new SavePackage(tab_contents_wrapper_); 48 save_package_ = new SavePackage(tab_contents_wrapper_);
49 save_package_->GetSaveInfo(); 49 save_package_->GetSaveInfo();
50 } 50 }
51 51
52 void DownloadTabHelper::OnSaveURL(const GURL& url) { 52 void DownloadTabHelper::OnSaveURL(const GURL& url) {
53 DownloadManager* dlm = tab_contents()->profile()->GetDownloadManager(); 53 DownloadManager* dlm = tab_contents()->profile()->GetDownloadManager();
54 dlm->DownloadUrl(url, tab_contents()->GetURL(), "", tab_contents()); 54 dlm->DownloadUrl(url, tab_contents()->GetURL(), "", tab_contents());
55 } 55 }
56 56
57 // Used in automated testing to bypass prompting the user for file names.
58 // Instead, the names and paths are hard coded rather than running them through
59 // file name sanitation and extension / mime checking.
57 bool DownloadTabHelper::SavePage(const FilePath& main_file, 60 bool DownloadTabHelper::SavePage(const FilePath& main_file,
58 const FilePath& dir_path, 61 const FilePath& dir_path,
59 SavePackage::SavePackageType save_type) { 62 SavePackage::SavePackageType save_type) {
60 // Stop the page from navigating. 63 // Stop the page from navigating.
61 tab_contents()->Stop(); 64 tab_contents()->Stop();
62 65
63 save_package_ = 66 save_package_ =
64 new SavePackage(tab_contents_wrapper_, save_type, main_file, dir_path); 67 new SavePackage(tab_contents_wrapper_, save_type, main_file, dir_path);
65 // Skips GetSaveInfo() and directly calls Init().
66 // We do not have to explicitly disable the select file dialog
67 // since we skip the process that can show the dialog.
68 return save_package_->Init(); 68 return save_package_->Init();
69 } 69 }
70 70
71 string16 DownloadTabHelper::SavePageBasedOnDefaultPrefs() {
72 tab_contents()->Stop();
73
74 save_package_ = new SavePackage(tab_contents_wrapper_);
75 // Disables the select file dialog.
76 save_package_->SetShouldPromptUser(false);
77 // This GetSaveInfo() calls save_package_->Init() in the background.
78 save_package_->GetSaveInfo();
79 return tab_contents()->GetTitle();
80 }
81
82 bool DownloadTabHelper::CanDownload(int request_id) { 71 bool DownloadTabHelper::CanDownload(int request_id) {
83 if (delegate_) 72 if (delegate_)
84 return delegate_->CanDownload(request_id); 73 return delegate_->CanDownload(request_id);
85 return true; 74 return true;
86 } 75 }
87 76
88 void DownloadTabHelper::OnStartDownload(DownloadItem* download) { 77 void DownloadTabHelper::OnStartDownload(DownloadItem* download) {
89 DCHECK(download); 78 DCHECK(download);
90 79
91 BlockedContentTabHelperDelegate* blocked_content_delegate = 80 BlockedContentTabHelperDelegate* blocked_content_delegate =
(...skipping 21 matching lines...) Expand all
113 102
114 return handled; 103 return handled;
115 } 104 }
116 105
117 void DownloadTabHelper::DidGetUserGesture() { 106 void DownloadTabHelper::DidGetUserGesture() {
118 DownloadRequestLimiter* limiter = 107 DownloadRequestLimiter* limiter =
119 g_browser_process->download_request_limiter(); 108 g_browser_process->download_request_limiter();
120 if (limiter) 109 if (limiter)
121 limiter->OnUserGesture(tab_contents()); 110 limiter->OnUserGesture(tab_contents());
122 } 111 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/download/download_tab_helper.h ('k') | chrome/browser/ui/webui/options/advanced_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698