2017-01-18 19:28:20 +05:30
|
|
|
// 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 13:56:58 -07:00
|
|
|
#ifndef SHELL_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
|
|
|
#define SHELL_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
2017-01-18 19:28:20 +05:30
|
|
|
|
2018-09-12 19:25:56 -05:00
|
|
|
#include <memory>
|
2017-01-18 19:28:20 +05:30
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "base/macros.h"
|
2017-01-18 21:55:36 +05:30
|
|
|
#include "content/public/browser/host_zoom_map.h"
|
2017-01-18 19:28:20 +05:30
|
|
|
#include "content/public/browser/web_ui_message_handler.h"
|
2019-06-19 13:46:59 -07:00
|
|
|
#include "shell/browser/web_contents_zoom_controller.h"
|
2017-01-18 19:28:20 +05:30
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class ListValue;
|
|
|
|
}
|
|
|
|
|
2017-01-21 00:46:38 +05:30
|
|
|
namespace content {
|
2017-01-23 14:49:18 -08:00
|
|
|
struct StreamInfo;
|
2017-01-21 00:46:38 +05:30
|
|
|
}
|
|
|
|
|
2019-06-19 14:23:04 -07:00
|
|
|
namespace electron {
|
2017-01-18 19:28:20 +05:30
|
|
|
|
2017-06-08 02:13:49 +02:00
|
|
|
class PdfViewerHandler : public content::WebUIMessageHandler,
|
|
|
|
public WebContentsZoomController::Observer {
|
2017-01-18 19:28:20 +05:30
|
|
|
public:
|
2017-02-27 11:40:49 +05:30
|
|
|
explicit PdfViewerHandler(const std::string& original_url);
|
2017-01-18 19:28:20 +05:30
|
|
|
~PdfViewerHandler() override;
|
|
|
|
|
2017-02-27 11:40:49 +05:30
|
|
|
void SetPdfResourceStream(content::StreamInfo* stream);
|
|
|
|
|
|
|
|
protected:
|
2017-01-18 19:28:20 +05:30
|
|
|
// WebUIMessageHandler implementation.
|
|
|
|
void RegisterMessages() override;
|
2017-01-18 21:55:36 +05:30
|
|
|
void OnJavascriptAllowed() override;
|
|
|
|
void OnJavascriptDisallowed() override;
|
2017-01-18 19:28:20 +05:30
|
|
|
|
|
|
|
private:
|
|
|
|
void Initialize(const base::ListValue* args);
|
2017-01-18 21:55:36 +05:30
|
|
|
void GetDefaultZoom(const base::ListValue* args);
|
|
|
|
void GetInitialZoom(const base::ListValue* args);
|
2017-03-01 22:41:51 +05:30
|
|
|
void SetZoom(const base::ListValue* args);
|
2017-01-22 20:20:38 +05:30
|
|
|
void GetStrings(const base::ListValue* args);
|
2017-02-14 06:55:52 +05:30
|
|
|
void Reload(const base::ListValue* args);
|
2018-04-17 21:44:10 -04:00
|
|
|
void OnZoomLevelChanged(content::WebContents* web_contents,
|
|
|
|
double level,
|
|
|
|
bool is_temporary);
|
2017-10-19 16:27:08 +02:00
|
|
|
void AddObserver();
|
|
|
|
void RemoveObserver();
|
2017-02-27 11:40:49 +05:30
|
|
|
std::unique_ptr<base::Value> initialize_callback_id_;
|
2018-05-22 00:18:38 +02:00
|
|
|
content::StreamInfo* stream_ = nullptr;
|
2017-01-23 16:42:39 +05:30
|
|
|
std::string original_url_;
|
2017-01-18 19:28:20 +05:30
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(PdfViewerHandler);
|
|
|
|
};
|
|
|
|
|
2019-06-19 14:23:04 -07:00
|
|
|
} // namespace electron
|
2017-01-18 19:28:20 +05:30
|
|
|
|
2019-06-19 13:56:58 -07:00
|
|
|
#endif // SHELL_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|