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

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

Issue 1217223006: Prompt user for file access permission before download starts (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,
96 STATE_GENERATE_TARGET_PATH, 97 STATE_GENERATE_TARGET_PATH,
97 STATE_NOTIFY_EXTENSIONS, 98 STATE_NOTIFY_EXTENSIONS,
98 STATE_RESERVE_VIRTUAL_PATH, 99 STATE_RESERVE_VIRTUAL_PATH,
99 STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, 100 STATE_PROMPT_USER_FOR_DOWNLOAD_PATH,
100 STATE_DETERMINE_LOCAL_PATH, 101 STATE_DETERMINE_LOCAL_PATH,
101 STATE_DETERMINE_MIME_TYPE, 102 STATE_DETERMINE_MIME_TYPE,
102 STATE_DETERMINE_IF_HANDLED_SAFELY_BY_BROWSER, 103 STATE_DETERMINE_IF_HANDLED_SAFELY_BY_BROWSER,
103 STATE_DETERMINE_IF_ADOBE_READER_UP_TO_DATE, 104 STATE_DETERMINE_IF_ADOBE_READER_UP_TO_DATE,
104 STATE_CHECK_DOWNLOAD_URL, 105 STATE_CHECK_DOWNLOAD_URL,
105 STATE_CHECK_VISITED_REFERRER_BEFORE, 106 STATE_CHECK_VISITED_REFERRER_BEFORE,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 142
142 ~DownloadTargetDeterminer() override; 143 ~DownloadTargetDeterminer() override;
143 144
144 // Invoke each successive handler until a handler returns QUIT_DOLOOP or 145 // Invoke each successive handler until a handler returns QUIT_DOLOOP or
145 // COMPLETE. Note that as a result, this object might be deleted. So |this| 146 // COMPLETE. Note that as a result, this object might be deleted. So |this|
146 // should not be accessed after calling DoLoop(). 147 // should not be accessed after calling DoLoop().
147 void DoLoop(); 148 void DoLoop();
148 149
149 // === Main workflow === 150 // === Main workflow ===
150 151
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
151 // Generates an initial target path. This target is based only on the state of 163 // Generates an initial target path. This target is based only on the state of
152 // the download item. 164 // the download item.
153 // Next state: 165 // Next state:
154 // - STATE_NONE : If the download is not in progress, returns COMPLETE. 166 // - STATE_NONE : If the download is not in progress, returns COMPLETE.
155 // - STATE_NOTIFY_EXTENSIONS : All other downloads. 167 // - STATE_NOTIFY_EXTENSIONS : All other downloads.
156 Result DoGenerateTargetPath(); 168 Result DoGenerateTargetPath();
157 169
158 // Notifies downloads extensions. If any extension wishes to override the 170 // Notifies downloads extensions. If any extension wishes to override the
159 // download filename, it will respond to the OnDeterminingFilename() 171 // download filename, it will respond to the OnDeterminingFilename()
160 // notification. 172 // notification.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 DownloadTargetDeterminerDelegate* delegate_; 329 DownloadTargetDeterminerDelegate* delegate_;
318 CompletionCallback completion_callback_; 330 CompletionCallback completion_callback_;
319 base::CancelableTaskTracker history_tracker_; 331 base::CancelableTaskTracker history_tracker_;
320 332
321 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_; 333 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_;
322 334
323 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer); 335 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer);
324 }; 336 };
325 337
326 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ 338 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698