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

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

Issue 324593004: Windows: Add an "Open in Adobe Reader" menu item for PDF files in the download shelf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix merge Created 6 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 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Start() should be called on the UI thread. 72 // Start() should be called on the UI thread.
73 static void Start(content::DownloadItem* download, 73 static void Start(content::DownloadItem* download,
74 const base::FilePath& initial_virtual_path, 74 const base::FilePath& initial_virtual_path,
75 DownloadPrefs* download_prefs, 75 DownloadPrefs* download_prefs,
76 DownloadTargetDeterminerDelegate* delegate, 76 DownloadTargetDeterminerDelegate* delegate,
77 const CompletionCallback& callback); 77 const CompletionCallback& callback);
78 78
79 // Returns a .crdownload intermediate path for the |suggested_path|. 79 // Returns a .crdownload intermediate path for the |suggested_path|.
80 static base::FilePath GetCrDownloadPath(const base::FilePath& suggested_path); 80 static base::FilePath GetCrDownloadPath(const base::FilePath& suggested_path);
81 81
82 #if defined(OS_WIN)
83 // Returns true if Adobe Reader is up to date. This information refreshed
84 // only when Start() gets called for a PDF and Adobe Reader is the default
85 // System PDF viewer.
86 static bool IsAdobeReaderUpToDate();
87 #endif
88
82 private: 89 private:
83 // 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
84 // 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
85 // 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
86 // 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
87 // handler returns COMPLETE. 94 // handler returns COMPLETE.
88 enum State { 95 enum State {
89 STATE_GENERATE_TARGET_PATH, 96 STATE_GENERATE_TARGET_PATH,
90 STATE_NOTIFY_EXTENSIONS, 97 STATE_NOTIFY_EXTENSIONS,
91 STATE_RESERVE_VIRTUAL_PATH, 98 STATE_RESERVE_VIRTUAL_PATH,
92 STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, 99 STATE_PROMPT_USER_FOR_DOWNLOAD_PATH,
93 STATE_DETERMINE_LOCAL_PATH, 100 STATE_DETERMINE_LOCAL_PATH,
94 STATE_DETERMINE_MIME_TYPE, 101 STATE_DETERMINE_MIME_TYPE,
95 STATE_DETERMINE_IF_HANDLED_SAFELY_BY_BROWSER, 102 STATE_DETERMINE_IF_HANDLED_SAFELY_BY_BROWSER,
103 STATE_DETERMINE_IF_ADOBE_READER_UP_TO_DATE,
96 STATE_CHECK_DOWNLOAD_URL, 104 STATE_CHECK_DOWNLOAD_URL,
97 STATE_CHECK_VISITED_REFERRER_BEFORE, 105 STATE_CHECK_VISITED_REFERRER_BEFORE,
98 STATE_DETERMINE_INTERMEDIATE_PATH, 106 STATE_DETERMINE_INTERMEDIATE_PATH,
99 STATE_NONE, 107 STATE_NONE,
100 }; 108 };
101 109
102 // Result code returned by each step of the workflow below. Controls execution 110 // Result code returned by each step of the workflow below. Controls execution
103 // of DoLoop(). 111 // of DoLoop().
104 enum Result { 112 enum Result {
105 // Continue processing. next_state_ is required to not be STATE_NONE. 113 // Continue processing. next_state_ is required to not be STATE_NONE.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // - STATE_DETERMINE_IF_HANDLED_SAFELY_BY_BROWSER. 206 // - STATE_DETERMINE_IF_HANDLED_SAFELY_BY_BROWSER.
199 Result DoDetermineMimeType(); 207 Result DoDetermineMimeType();
200 208
201 // Callback invoked when the MIME type is available. Since determination of 209 // Callback invoked when the MIME type is available. Since determination of
202 // the MIME type can involve disk access, it is done in the blocking pool. 210 // the MIME type can involve disk access, it is done in the blocking pool.
203 void DetermineMimeTypeDone(const std::string& mime_type); 211 void DetermineMimeTypeDone(const std::string& mime_type);
204 212
205 // Determine if the file type can be handled safely by the browser if it were 213 // Determine if the file type can be handled safely by the browser if it were
206 // to be opened via a file:// URL. 214 // to be opened via a file:// URL.
207 // Next state: 215 // Next state:
208 // - STATE_CHECK_DOWNLOAD_URL. 216 // - STATE_DETERMINE_IF_ADOBE_READER_UP_TO_DATE.
209 Result DoDetermineIfHandledSafely(); 217 Result DoDetermineIfHandledSafely();
210 218
219 #if defined(ENABLE_PLUGINS)
211 // Callback invoked when a decision is available about whether the file type 220 // Callback invoked when a decision is available about whether the file type
212 // can be handled safely by the browser. 221 // can be handled safely by the browser.
213 void DetermineIfHandledSafelyDone(bool is_handled_safely); 222 void DetermineIfHandledSafelyDone(bool is_handled_safely);
223 #endif
224
225 // Determine if Adobe Reader is up to date. Only do the check on Windows for
226 // .pdf file targets.
227 // Next state:
228 // - STATE_CHECK_DOWNLOAD_URL.
229 Result DoDetermineIfAdobeReaderUpToDate();
230
231 #if defined(OS_WIN)
232 // Callback invoked when a decision is available about whether Adobe Reader
233 // is up to date.
234 void DetermineIfAdobeReaderUpToDateDone(bool adobe_reader_up_to_date);
235 #endif
214 236
215 // Checks whether the downloaded URL is malicious. Invokes the 237 // Checks whether the downloaded URL is malicious. Invokes the
216 // DownloadProtectionService via the delegate. 238 // DownloadProtectionService via the delegate.
217 // Next state: 239 // Next state:
218 // - STATE_CHECK_VISITED_REFERRER_BEFORE. 240 // - STATE_CHECK_VISITED_REFERRER_BEFORE.
219 Result DoCheckDownloadUrl(); 241 Result DoCheckDownloadUrl();
220 242
221 // Callback invoked after the delegate has checked the download URL. Sets the 243 // Callback invoked after the delegate has checked the download URL. Sets the
222 // danger type of the download to |danger_type|. 244 // danger type of the download to |danger_type|.
223 void CheckDownloadUrlDone(content::DownloadDangerType danger_type); 245 void CheckDownloadUrlDone(content::DownloadDangerType danger_type);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 DownloadTargetDeterminerDelegate* delegate_; 316 DownloadTargetDeterminerDelegate* delegate_;
295 CompletionCallback completion_callback_; 317 CompletionCallback completion_callback_;
296 CancelableRequestConsumer history_consumer_; 318 CancelableRequestConsumer history_consumer_;
297 319
298 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_; 320 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_;
299 321
300 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer); 322 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer);
301 }; 323 };
302 324
303 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ 325 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_shelf_context_menu.cc ('k') | chrome/browser/download/download_target_determiner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698