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

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

Issue 6905049: Detect removed files and reflect the state in chrome://downloads and the download shelf (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: is_path_exists_ => file_exists_, aggregate scattered AddObserver()s into one AddObserver() Created 9 years, 7 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 // Each download is represented by a DownloadItem, and all DownloadItems 5 // Each download is represented by a DownloadItem, and all DownloadItems
6 // are owned by the DownloadManager which maintains a global list of all 6 // are owned by the DownloadManager which maintains a global list of all
7 // downloads. DownloadItems are created when a user initiates a download, 7 // downloads. DownloadItems are created when a user initiates a download,
8 // and exist for the duration of the browser life time. 8 // and exist for the duration of the browser life time.
9 // 9 //
10 // Download observers: 10 // Download observers:
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 // Constructing for the "Save Page As..." feature: 110 // Constructing for the "Save Page As..." feature:
111 DownloadItem(DownloadManager* download_manager, 111 DownloadItem(DownloadManager* download_manager,
112 const FilePath& path, 112 const FilePath& path,
113 const GURL& url, 113 const GURL& url,
114 bool is_otr); 114 bool is_otr);
115 115
116 ~DownloadItem(); 116 ~DownloadItem();
117 117
118 void AddObserver(Observer* observer); 118 void AddObserver(Observer* observer);
119 bool HasObserver(Observer* observer);
119 void RemoveObserver(Observer* observer); 120 void RemoveObserver(Observer* observer);
120 121
121 // Notifies our observers periodically. 122 // Notifies our observers periodically.
122 void UpdateObservers(); 123 void UpdateObservers();
123 124
124 // Whether it is OK to open this download. 125 // Whether it is OK to open this download.
125 bool CanOpenDownload(); 126 bool CanOpenDownload();
126 127
127 // Tests if a file type should be opened automatically. 128 // Tests if a file type should be opened automatically.
128 bool ShouldOpenFileBasedOnExtension(); 129 bool ShouldOpenFileBasedOnExtension();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 int64 received_bytes() const { return received_bytes_; } 253 int64 received_bytes() const { return received_bytes_; }
253 int32 id() const { return id_; } 254 int32 id() const { return id_; }
254 base::Time start_time() const { return start_time_; } 255 base::Time start_time() const { return start_time_; }
255 void set_db_handle(int64 handle) { db_handle_ = handle; } 256 void set_db_handle(int64 handle) { db_handle_ = handle; }
256 int64 db_handle() const { return db_handle_; } 257 int64 db_handle() const { return db_handle_; }
257 bool is_paused() const { return is_paused_; } 258 bool is_paused() const { return is_paused_; }
258 bool open_when_complete() const { return open_when_complete_; } 259 bool open_when_complete() const { return open_when_complete_; }
259 void set_open_when_complete(bool open) { open_when_complete_ = open; } 260 void set_open_when_complete(bool open) { open_when_complete_ = open; }
260 int render_process_id() const { return render_process_id_; } 261 int render_process_id() const { return render_process_id_; }
261 int request_id() const { return request_id_; } 262 int request_id() const { return request_id_; }
263 bool file_exists() const { return file_exists_; }
264 void set_file_exists(bool file_exists) {
265 file_exists_ = file_exists;
266 }
262 SafetyState safety_state() const { return safety_state_; } 267 SafetyState safety_state() const { return safety_state_; }
263 void set_safety_state(SafetyState safety_state) { 268 void set_safety_state(SafetyState safety_state) {
264 safety_state_ = safety_state; 269 safety_state_ = safety_state;
265 } 270 }
266 DangerType danger_type() { return danger_type_;} 271 DangerType danger_type() { return danger_type_;}
267 bool auto_opened() { return auto_opened_; } 272 bool auto_opened() { return auto_opened_; }
268 FilePath target_name() const { return target_name_; } 273 FilePath target_name() const { return target_name_; }
269 bool save_as() const { return save_as_; } 274 bool save_as() const { return save_as_; }
270 bool is_otr() const { return is_otr_; } 275 bool is_otr() const { return is_otr_; }
271 bool is_extension_install() const { return is_extension_install_; } 276 bool is_extension_install() const { return is_extension_install_; }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 363
359 // Our owning object 364 // Our owning object
360 DownloadManager* download_manager_; 365 DownloadManager* download_manager_;
361 366
362 // In progress downloads may be paused by the user, we note it here 367 // In progress downloads may be paused by the user, we note it here
363 bool is_paused_; 368 bool is_paused_;
364 369
365 // A flag for indicating if the download should be opened at completion. 370 // A flag for indicating if the download should be opened at completion.
366 bool open_when_complete_; 371 bool open_when_complete_;
367 372
373 // A flag for indicating if the downloaded path exists or not.
Paweł Hajdan Jr. 2011/05/10 11:37:51 nit: Please remove "or not", and replace "path" wi
374 bool file_exists_;
375
368 // Whether the download is considered potentially safe or dangerous 376 // Whether the download is considered potentially safe or dangerous
369 // (executable files are typically considered dangerous). 377 // (executable files are typically considered dangerous).
370 SafetyState safety_state_; 378 SafetyState safety_state_;
371 379
372 // Why |safety_state_| is not SAFE. 380 // Why |safety_state_| is not SAFE.
373 DangerType danger_type_; 381 DangerType danger_type_;
374 382
375 // Whether the download was auto-opened. We set this rather than using 383 // Whether the download was auto-opened. We set this rather than using
376 // an observer as it's frequently possible for the download to be auto opened 384 // an observer as it's frequently possible for the download to be auto opened
377 // before the observer is added. 385 // before the observer is added.
(...skipping 26 matching lines...) Expand all
404 // Did the user open the item either directly or indirectly (such as by 412 // Did the user open the item either directly or indirectly (such as by
405 // setting always open files of this type)? The shelf also sets this field 413 // setting always open files of this type)? The shelf also sets this field
406 // when the user closes the shelf before the item has been opened but should 414 // when the user closes the shelf before the item has been opened but should
407 // be treated as though the user opened it. 415 // be treated as though the user opened it.
408 bool opened_; 416 bool opened_;
409 417
410 DISALLOW_COPY_AND_ASSIGN(DownloadItem); 418 DISALLOW_COPY_AND_ASSIGN(DownloadItem);
411 }; 419 };
412 420
413 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 421 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698