#include <string>
#include <vector>
+#include "atom/browser/ui/webui/pdf_viewer_ui.h"
#include "atom/common/atom_version.h"
#include "atom/common/chrome_version.h"
#include "atom/common/options_switches.h"
pdf_info.is_out_of_process = true;
pdf_info.name = "Chromium PDF Viewer";
pdf_info.description = "Portable Document Format";
- pdf_info.path = base::FilePath::FromUTF8Unsafe("internal-pdf-viewer");
+ pdf_info.path = base::FilePath::FromUTF8Unsafe(PdfViewerUI::kOrigin);
content::WebPluginMimeType pdf_mime_type("application/x-google-chrome-pdf",
"pdf", "Portable Document Format");
pdf_info.mime_types.push_back(pdf_mime_type);
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/login_handler.h"
#include "atom/browser/stream_manager.h"
+#include "atom/browser/ui/webui/pdf_viewer_ui.h"
#include "atom/browser/web_contents_permission_helper.h"
#include "atom/common/platform_util.h"
#include "base/guid.h"
std::string view_id = base::GenerateGUID();
stream_manager->AddStream(std::move(stream), view_id, render_process_id,
render_frame_id);
- content::NavigationController::LoadURLParams params(GURL(base::StringPrintf(
- "chrome://pdf-viewer/index.html?viewId=%s", view_id.c_str())));
+ content::NavigationController::LoadURLParams params(
+ GURL(base::StringPrintf("%sindex.html?%s=%s", PdfViewerUI::kOrigin,
+ PdfViewerUI::kId, view_id.c_str())));
web_contents->GetController().LoadURLWithParams(params);
}
GURL* origin,
std::string* payload) {
if (mime_type == "application/pdf") {
- *origin = GURL("chrome://pdf-viewer/");
+ *origin = GURL(PdfViewerUI::kOrigin);
return true;
}
return false;
base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &toplevel_params);
std::string view_id;
for (const auto& param : toplevel_params) {
- if (param.first == "viewId") {
+ if (param.first == PdfViewerUI::kId) {
view_id = param.second;
break;
}
StreamManager* stream_manager_;
std::string view_id_;
- int render_process_id_;
- int render_frame_id_;
DISALLOW_COPY_AND_ASSIGN(EmbedderObserver);
};
namespace {
std::string PathWithoutParams(const std::string& path) {
- return GURL(std::string("chrome://pdf-viewer/") + path).path().substr(1);
+ return GURL(PdfViewerUI::kOrigin + path).path().substr(1);
}
class BundledDataSource : public content::URLDataSource {
} // namespace
+const char PdfViewerUI::kOrigin[] = "chrome://pdf-viewer/";
const char PdfViewerUI::kHost[] = "pdf-viewer";
+const char PdfViewerUI::kId[] = "viewId";
PdfViewerUI::PdfViewerUI(content::BrowserContext* browser_context,
content::WebUI* web_ui,
class PdfViewerUI : public content::WebUIController,
public content::WebContentsObserver {
public:
+ static const char kOrigin[];
static const char kHost[];
+ static const char kId[];
PdfViewerUI(content::BrowserContext* browser_context,
content::WebUI* web_ui,
#define IPC_MESSAGE_START PDFMsgStart
-// Updates the content restrictions, i.e. to disable print/copy.
-IPC_MESSAGE_ROUTED1(PDFHostMsg_PDFUpdateContentRestrictions,
- int /* restrictions */)
-
-// The currently displayed PDF has an unsupported feature.
-IPC_MESSAGE_ROUTED0(PDFHostMsg_PDFHasUnsupportedFeature)
-
// Brings up SaveAs... dialog to save specified URL.
IPC_MESSAGE_ROUTED2(PDFHostMsg_PDFSaveURLAs,
GURL /* url */,
-Subproject commit bdc199ef4f310b710a1abaade293ee8763230438
+Subproject commit c2c521dc2769a6a6917d246fce2af353ec7e5ede