electron/shell/browser/api/save_page_handler.h

53 lines
1.5 KiB
C
Raw Normal View History

2015-10-14 04:41:31 +00:00
// 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 ELECTRON_SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_
#define ELECTRON_SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_
2015-10-14 04:41:31 +00:00
#include "base/memory/raw_ptr.h"
#include "components/download/public/common/download_item.h"
2015-10-14 04:41:31 +00:00
#include "content/public/browser/download_manager.h"
#include "content/public/browser/save_page_type.h"
#include "shell/common/gin_helper/promise.h"
2015-10-14 04:41:31 +00:00
#include "v8/include/v8.h"
namespace base {
class FilePath;
}
namespace content {
class WebContents;
}
2022-06-29 19:55:47 +00:00
namespace electron::api {
2015-10-14 04:41:31 +00:00
// A self-destroyed class for handling save page request.
class SavePageHandler : private content::DownloadManager::Observer,
private download::DownloadItem::Observer {
2015-10-14 04:41:31 +00:00
public:
SavePageHandler(content::WebContents* web_contents,
gin_helper::Promise<void> promise);
~SavePageHandler() override;
2015-10-14 04:41:31 +00:00
bool Handle(const base::FilePath& full_path,
const content::SavePageType& save_type);
private:
void Destroy(download::DownloadItem* item);
2015-10-14 04:41:31 +00:00
// content::DownloadManager::Observer:
void OnDownloadCreated(content::DownloadManager* manager,
download::DownloadItem* item) override;
2015-10-14 04:41:31 +00:00
// download::DownloadItem::Observer:
void OnDownloadUpdated(download::DownloadItem* item) override;
2015-10-14 04:41:31 +00:00
raw_ptr<content::WebContents> web_contents_; // weak
gin_helper::Promise<void> promise_;
2015-10-14 04:41:31 +00:00
};
2022-06-29 19:55:47 +00:00
} // namespace electron::api
2015-10-14 04:41:31 +00:00
#endif // ELECTRON_SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_