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

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

Issue 1229933010: move file access permission logic to DownloadResourceThrottle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 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
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 static bool IsAdobeReaderUpToDate(); 86 static bool IsAdobeReaderUpToDate();
87 #endif 87 #endif
88 88
89 private: 89 private:
90 // The main workflow is controlled via a set of state transitions. Each state 90 // The main workflow is controlled via a set of state transitions. Each state
91 // has an associated handler. The handler for STATE_FOO is DoFoo. Each handler 91 // has an associated handler. The handler for STATE_FOO is DoFoo. Each handler
92 // performs work, determines the next state to transition to and returns a 92 // performs work, determines the next state to transition to and returns a
93 // Result indicating how the workflow should proceed. The loop ends when a 93 // Result indicating how the workflow should proceed. The loop ends when a
94 // handler returns COMPLETE. 94 // handler returns COMPLETE.
95 enum State { 95 enum State {
96 STATE_PROMPT_USER_FOR_PERMISSION,
97 STATE_GENERATE_TARGET_PATH, 96 STATE_GENERATE_TARGET_PATH,
98 STATE_NOTIFY_EXTENSIONS, 97 STATE_NOTIFY_EXTENSIONS,
99 STATE_RESERVE_VIRTUAL_PATH, 98 STATE_RESERVE_VIRTUAL_PATH,
100 STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, 99 STATE_PROMPT_USER_FOR_DOWNLOAD_PATH,
101 STATE_DETERMINE_LOCAL_PATH, 100 STATE_DETERMINE_LOCAL_PATH,
102 STATE_DETERMINE_MIME_TYPE, 101 STATE_DETERMINE_MIME_TYPE,
103 STATE_DETERMINE_IF_HANDLED_SAFELY_BY_BROWSER, 102 STATE_DETERMINE_IF_HANDLED_SAFELY_BY_BROWSER,
104 STATE_DETERMINE_IF_ADOBE_READER_UP_TO_DATE, 103 STATE_DETERMINE_IF_ADOBE_READER_UP_TO_DATE,
105 STATE_CHECK_DOWNLOAD_URL, 104 STATE_CHECK_DOWNLOAD_URL,
106 STATE_CHECK_VISITED_REFERRER_BEFORE, 105 STATE_CHECK_VISITED_REFERRER_BEFORE,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 141
143 ~DownloadTargetDeterminer() override; 142 ~DownloadTargetDeterminer() override;
144 143
145 // Invoke each successive handler until a handler returns QUIT_DOLOOP or 144 // Invoke each successive handler until a handler returns QUIT_DOLOOP or
146 // COMPLETE. Note that as a result, this object might be deleted. So |this| 145 // COMPLETE. Note that as a result, this object might be deleted. So |this|
147 // should not be accessed after calling DoLoop(). 146 // should not be accessed after calling DoLoop().
148 void DoLoop(); 147 void DoLoop();
149 148
150 // === Main workflow === 149 // === Main workflow ===
151 150
152 // Prompts user for file access if necessary.
153 // Next state:
154 // - STATE_GENERATE_TARGET_PATH.
155 Result DoPromptUserForPermission();
156
157 #if defined(OS_ANDROID)
158 // Callback invoked after the file access prompt completes. Cancels the
159 // download if the user doesn't grant file access.
160 void PromptUserForPermissionDone(bool granted);
161 #endif
162
163 // Generates an initial target path. This target is based only on the state of 151 // Generates an initial target path. This target is based only on the state of
164 // the download item. 152 // the download item.
165 // Next state: 153 // Next state:
166 // - STATE_NONE : If the download is not in progress, returns COMPLETE. 154 // - STATE_NONE : If the download is not in progress, returns COMPLETE.
167 // - STATE_NOTIFY_EXTENSIONS : All other downloads. 155 // - STATE_NOTIFY_EXTENSIONS : All other downloads.
168 Result DoGenerateTargetPath(); 156 Result DoGenerateTargetPath();
169 157
170 // Notifies downloads extensions. If any extension wishes to override the 158 // Notifies downloads extensions. If any extension wishes to override the
171 // download filename, it will respond to the OnDeterminingFilename() 159 // download filename, it will respond to the OnDeterminingFilename()
172 // notification. 160 // notification.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 DownloadTargetDeterminerDelegate* delegate_; 317 DownloadTargetDeterminerDelegate* delegate_;
330 CompletionCallback completion_callback_; 318 CompletionCallback completion_callback_;
331 base::CancelableTaskTracker history_tracker_; 319 base::CancelableTaskTracker history_tracker_;
332 320
333 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_; 321 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_;
334 322
335 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer); 323 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer);
336 }; 324 };
337 325
338 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ 326 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_resource_throttle_unittest.cc ('k') | chrome/browser/download/download_target_determiner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698