Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / download / download_completion_blocker.h
blobda3e0619bd163895683bb92dfccbe22200b20915
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_
8 #include "base/callback.h"
9 #include "base/supports_user_data.h"
10 #include "content/public/browser/download_item.h"
12 // A subsystem may use a DownloadCompletionBlocker in conjunction with
13 // DownloadManagerDelegate::ShouldCompleteDownload() in order to block the
14 // completion of a DownloadItem. CompleteDownload() will run the most recent
15 // callback set.
16 class DownloadCompletionBlocker : public base::SupportsUserData::Data {
17 public:
18 DownloadCompletionBlocker();
19 ~DownloadCompletionBlocker() override;
21 bool is_complete() const { return is_complete_; }
23 void set_callback(const base::Closure& callback) {
24 if (!is_complete())
25 callback_ = callback;
28 // Mark this download item as complete with respect to this blocker. (Other
29 // blockers may continue to block the item.) Run |callback_|. This method may
30 // only be called once, so |callback_| will only be called once. Subclasses
31 // must call the base implementation if they override this method.
32 virtual void CompleteDownload();
34 private:
35 bool is_complete_;
36 base::Closure callback_;
38 DISALLOW_COPY_AND_ASSIGN(DownloadCompletionBlocker);
41 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_