forked from adamlaska/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_page_handler.h
More file actions
57 lines (41 loc) · 1.52 KB
/
save_page_handler.h
File metadata and controls
57 lines (41 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_
#define SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_
#include <string>
#include "components/download/public/common/download_item.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/save_page_type.h"
#include "shell/common/promise_util.h"
#include "v8/include/v8.h"
namespace base {
class FilePath;
}
namespace content {
class WebContents;
}
namespace electron {
namespace api {
// A self-destroyed class for handling save page request.
class SavePageHandler : public content::DownloadManager::Observer,
public download::DownloadItem::Observer {
public:
SavePageHandler(content::WebContents* web_contents,
electron::util::Promise promise);
~SavePageHandler() override;
bool Handle(const base::FilePath& full_path,
const content::SavePageType& save_type);
private:
void Destroy(download::DownloadItem* item);
// content::DownloadManager::Observer:
void OnDownloadCreated(content::DownloadManager* manager,
download::DownloadItem* item) override;
// download::DownloadItem::Observer:
void OnDownloadUpdated(download::DownloadItem* item) override;
content::WebContents* web_contents_; // weak
electron::util::Promise promise_;
};
} // namespace api
} // namespace electron
#endif // SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_