electron/shell/browser/api/save_page_handler.h
Charles Kerr 752efddf89
refactor: prefer to inherit observer classes privately (#41360)
* refactor: use private inheritance in CookieChangeNotifier

* refactor: use private inheritance in WebViewGuestDelegate

* refactor: use private inheritance in UsbChooserController

* refactor: use private inheritance in DesktopCapturer

* refactor: use private inheritance in Browser

* refactor: use private inheritance in WebContentsZoomController

* refactor: use private inheritance in FrameSubscriber

* refactor: use private inheritance in AutofillAgent

* refactor: use private inheritance in HidChooserController

* refactor: use private inheritance in PepperHelper

* refactor: use private inheritance in AutofillPopup

* refactor: use private inheritance in SerialChooserController

* refactor: use private inheritance in MediaCaptureDevicesDispatcher

* refactor: use private inheritance in electron::api::View

* refactor: use private inheritance in AutofillDriverFactory

* refactor: use private inheritance in GPUInfoManager

* refactor: use private inheritance in SavePageHandler

* refactor: use private inheritance in GlobalShortcut

* refactor: use private inheritance in ElectronRenderFrameObserver
2024-05-21 14:21:31 -05:00

52 lines
1.5 KiB
C++

// 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_
#include "base/memory/raw_ptr.h"
#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/gin_helper/promise.h"
#include "v8/include/v8.h"
namespace base {
class FilePath;
}
namespace content {
class WebContents;
}
namespace electron::api {
// A self-destroyed class for handling save page request.
class SavePageHandler : private content::DownloadManager::Observer,
private download::DownloadItem::Observer {
public:
SavePageHandler(content::WebContents* web_contents,
gin_helper::Promise<void> 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;
raw_ptr<content::WebContents> web_contents_; // weak
gin_helper::Promise<void> promise_;
};
} // namespace electron::api
#endif // ELECTRON_SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_