2017-01-18 13:58:20 +00:00
|
|
|
// Copyright (c) 2017 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
|
|
|
#define ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
|
|
|
|
2018-03-15 13:56:25 +00:00
|
|
|
#ifndef ENABLE_PDF_VIEWER
|
|
|
|
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled") // NOLINT
|
|
|
|
#endif // defined(ENABLE_PDF_VIEWER)
|
|
|
|
|
2017-01-18 13:58:20 +00:00
|
|
|
#include <string>
|
|
|
|
|
2017-06-08 00:13:49 +00:00
|
|
|
#include "atom/browser/web_contents_zoom_controller.h"
|
2017-01-18 13:58:20 +00:00
|
|
|
#include "base/macros.h"
|
2017-01-18 16:25:36 +00:00
|
|
|
#include "content/public/browser/host_zoom_map.h"
|
2017-01-18 13:58:20 +00:00
|
|
|
#include "content/public/browser/web_ui_message_handler.h"
|
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class ListValue;
|
|
|
|
}
|
|
|
|
|
2017-01-20 19:16:38 +00:00
|
|
|
namespace content {
|
2017-01-23 22:49:18 +00:00
|
|
|
struct StreamInfo;
|
2017-01-20 19:16:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-18 13:58:20 +00:00
|
|
|
namespace atom {
|
|
|
|
|
2017-06-08 00:13:49 +00:00
|
|
|
class PdfViewerHandler : public content::WebUIMessageHandler,
|
|
|
|
public WebContentsZoomController::Observer {
|
2017-01-18 13:58:20 +00:00
|
|
|
public:
|
2017-02-27 06:10:49 +00:00
|
|
|
explicit PdfViewerHandler(const std::string& original_url);
|
2017-01-18 13:58:20 +00:00
|
|
|
~PdfViewerHandler() override;
|
|
|
|
|
2017-02-27 06:10:49 +00:00
|
|
|
void SetPdfResourceStream(content::StreamInfo* stream);
|
|
|
|
|
|
|
|
protected:
|
2017-01-18 13:58:20 +00:00
|
|
|
// WebUIMessageHandler implementation.
|
|
|
|
void RegisterMessages() override;
|
2017-01-18 16:25:36 +00:00
|
|
|
void OnJavascriptAllowed() override;
|
|
|
|
void OnJavascriptDisallowed() override;
|
2017-01-18 13:58:20 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Initialize(const base::ListValue* args);
|
2017-01-18 16:25:36 +00:00
|
|
|
void GetDefaultZoom(const base::ListValue* args);
|
|
|
|
void GetInitialZoom(const base::ListValue* args);
|
2017-03-01 17:11:51 +00:00
|
|
|
void SetZoom(const base::ListValue* args);
|
2017-01-22 14:50:38 +00:00
|
|
|
void GetStrings(const base::ListValue* args);
|
2017-02-14 01:25:52 +00:00
|
|
|
void Reload(const base::ListValue* args);
|
2017-06-08 07:57:24 +00:00
|
|
|
void OnZoomLevelChanged(content::WebContents* web_contents, double level,
|
2017-06-08 00:13:49 +00:00
|
|
|
bool is_temporary);
|
2017-10-19 14:27:08 +00:00
|
|
|
void AddObserver();
|
|
|
|
void RemoveObserver();
|
2017-02-27 06:10:49 +00:00
|
|
|
std::unique_ptr<base::Value> initialize_callback_id_;
|
|
|
|
content::StreamInfo* stream_;
|
2017-01-23 11:12:39 +00:00
|
|
|
std::string original_url_;
|
2017-01-18 13:58:20 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(PdfViewerHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|