electron/shell/browser/api/save_page_handler.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 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 "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;
}
namespace electron {
namespace api {
// A self-destroyed class for handling save page request.
class SavePageHandler : public content::DownloadManager::Observer,
public 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
content::WebContents* web_contents_; // weak
gin_helper::Promise<void> promise_;
2015-10-14 04:41:31 +00:00
};
} // namespace api
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_