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

Side by Side Diff: chrome/browser/download/download_target_determiner.h

Issue 12662032: Merge SavePackageFilePicker{,ChromeOS} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r202870 Created 7 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // The only public entrypoint is the static Start() method which creates an 48 // The only public entrypoint is the static Start() method which creates an
49 // instance of DownloadTargetDeterminer. 49 // instance of DownloadTargetDeterminer.
50 class DownloadTargetDeterminer 50 class DownloadTargetDeterminer
51 : public content::DownloadItem::Observer { 51 : public content::DownloadItem::Observer {
52 public: 52 public:
53 // Start the process of determing the target of |download|. 53 // Start the process of determing the target of |download|.
54 // 54 //
55 // |download_prefs| is required and must outlive |download|. It is used for 55 // |download_prefs| is required and must outlive |download|. It is used for
56 // determining the user's preferences regarding the default downloads 56 // determining the user's preferences regarding the default downloads
57 // directory, prompting and auto-open behavior. 57 // directory, prompting and auto-open behavior.
58 // |last_selected_directory| is the most recent directory that was chosen by
59 // the user. If the user needs to be prompted, then this directory will be
60 // used as the directory for the download instead of the user's default
61 // downloads directory.
62 // |delegate| is required and must live until |callback| is invoked. 58 // |delegate| is required and must live until |callback| is invoked.
63 // |callback| will be scheduled asynchronously on the UI thread after download 59 // |callback| will be scheduled asynchronously on the UI thread after download
64 // determination is complete or after |download| is destroyed. 60 // determination is complete or after |download| is destroyed.
65 // 61 //
66 // Start() should be called on the UI thread. 62 // Start() should be called on the UI thread.
67 static void Start(content::DownloadItem* download, 63 static void Start(content::DownloadItem* download,
68 DownloadPrefs* download_prefs, 64 DownloadPrefs* download_prefs,
69 const base::FilePath& last_selected_directory,
70 DownloadTargetDeterminerDelegate* delegate, 65 DownloadTargetDeterminerDelegate* delegate,
71 const content::DownloadTargetCallback& callback); 66 const content::DownloadTargetCallback& callback);
72 67
73 // Returns a .crdownload intermediate path for the |suggested_path|. 68 // Returns a .crdownload intermediate path for the |suggested_path|.
74 static base::FilePath GetCrDownloadPath(const base::FilePath& suggested_path); 69 static base::FilePath GetCrDownloadPath(const base::FilePath& suggested_path);
75 70
76 private: 71 private:
77 // The main workflow is controlled via a set of state transitions. Each state 72 // The main workflow is controlled via a set of state transitions. Each state
78 // has an associated handler. The handler for STATE_FOO is DoFoo. Each handler 73 // has an associated handler. The handler for STATE_FOO is DoFoo. Each handler
79 // performs work, determines the next state to transition to and returns a 74 // performs work, determines the next state to transition to and returns a
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 enum PriorVisitsToReferrer { 108 enum PriorVisitsToReferrer {
114 NO_VISITS_TO_REFERRER, 109 NO_VISITS_TO_REFERRER,
115 VISITED_REFERRER, 110 VISITED_REFERRER,
116 }; 111 };
117 112
118 // Construct a DownloadTargetDeterminer object. Constraints on the arguments 113 // Construct a DownloadTargetDeterminer object. Constraints on the arguments
119 // are as per Start() above. 114 // are as per Start() above.
120 DownloadTargetDeterminer( 115 DownloadTargetDeterminer(
121 content::DownloadItem* download, 116 content::DownloadItem* download,
122 DownloadPrefs* download_prefs, 117 DownloadPrefs* download_prefs,
123 const base::FilePath& last_selected_directory,
124 DownloadTargetDeterminerDelegate* delegate, 118 DownloadTargetDeterminerDelegate* delegate,
125 const content::DownloadTargetCallback& callback); 119 const content::DownloadTargetCallback& callback);
126 120
127 virtual ~DownloadTargetDeterminer(); 121 virtual ~DownloadTargetDeterminer();
128 122
129 // Invoke each successive handler until a handler returns QUIT_DOLOOP or 123 // Invoke each successive handler until a handler returns QUIT_DOLOOP or
130 // COMPLETE. Note that as a result, this object might be deleted. So |this| 124 // COMPLETE. Note that as a result, this object might be deleted. So |this|
131 // should not be accessed after calling DoLoop(). 125 // should not be accessed after calling DoLoop().
132 void DoLoop(); 126 void DoLoop();
133 127
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 bool create_directory_; 231 bool create_directory_;
238 DownloadPathReservationTracker::FilenameConflictAction conflict_action_; 232 DownloadPathReservationTracker::FilenameConflictAction conflict_action_;
239 content::DownloadDangerType danger_type_; 233 content::DownloadDangerType danger_type_;
240 base::FilePath virtual_path_; 234 base::FilePath virtual_path_;
241 base::FilePath local_path_; 235 base::FilePath local_path_;
242 base::FilePath intermediate_path_; 236 base::FilePath intermediate_path_;
243 237
244 content::DownloadItem* download_; 238 content::DownloadItem* download_;
245 DownloadPrefs* download_prefs_; 239 DownloadPrefs* download_prefs_;
246 DownloadTargetDeterminerDelegate* delegate_; 240 DownloadTargetDeterminerDelegate* delegate_;
247 base::FilePath last_selected_directory_;
248 content::DownloadTargetCallback completion_callback_; 241 content::DownloadTargetCallback completion_callback_;
249 CancelableRequestConsumer history_consumer_; 242 CancelableRequestConsumer history_consumer_;
250 243
251 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_; 244 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_;
252 245
253 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer); 246 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer);
254 }; 247 };
255 248
256 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ 249 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_prefs.cc ('k') | chrome/browser/download/download_target_determiner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698