electron/shell/browser/ui/webui/pdf_viewer_ui.h

62 lines
1.7 KiB
C
Raw Normal View History

// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
2019-06-19 20:56:58 +00:00
#ifndef SHELL_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
#define SHELL_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui_controller.h"
#include "ipc/ipc_message.h"
namespace content {
class BrowserContext;
2017-01-23 22:49:18 +00:00
struct StreamInfo;
2018-04-18 01:44:10 +00:00
} // namespace content
namespace electron {
class PdfViewerHandler;
class PdfViewerUI : public content::WebUIController,
2017-02-27 15:01:54 +00:00
public content::WebContentsObserver {
public:
PdfViewerUI(content::BrowserContext* browser_context,
content::WebUI* web_ui,
2017-01-23 11:12:39 +00:00
const std::string& src);
~PdfViewerUI() override;
// content::WebContentsObserver:
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
void RenderFrameCreated(content::RenderFrameHost* rfh) override;
private:
2017-02-27 15:01:54 +00:00
using StreamResponseCallback =
base::OnceCallback<void(std::unique_ptr<content::StreamInfo>)>;
class ResourceRequester;
void OnPdfStreamCreated(std::unique_ptr<content::StreamInfo> stream_info);
void OnSaveURLAs(const GURL& url, const content::Referrer& referrer);
// Source URL from where the PDF originates.
2017-01-23 11:12:39 +00:00
std::string src_;
PdfViewerHandler* pdf_handler_;
2017-02-27 15:01:54 +00:00
scoped_refptr<ResourceRequester> resource_requester_;
// Pdf Resource stream.
2017-01-23 11:12:39 +00:00
std::unique_ptr<content::StreamInfo> stream_;
DISALLOW_COPY_AND_ASSIGN(PdfViewerUI);
};
} // namespace electron
2019-06-19 20:56:58 +00:00
#endif // SHELL_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_