From ddc2e0df71204ae602fc28163e8f5788aaf7e4fe Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Sun, 22 Jan 2017 20:23:42 +0530 Subject: [PATCH] code cleanup --- atom/app/atom_content_client.cc | 3 ++- atom/browser/atom_resource_dispatcher_host_delegate.cc | 8 +++++--- atom/browser/atom_web_ui_controller_factory.cc | 2 +- atom/browser/stream_manager.h | 2 -- atom/browser/ui/webui/pdf_viewer_ui.cc | 4 +++- atom/browser/ui/webui/pdf_viewer_ui.h | 2 ++ chromium_src/components/pdf/common/pdf_messages.h | 7 ------- vendor/pdf_viewer | 2 +- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc index f1b7a9c..e346854 100644 --- a/atom/app/atom_content_client.cc +++ b/atom/app/atom_content_client.cc @@ -7,6 +7,7 @@ #include #include +#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" @@ -115,7 +116,7 @@ void ComputeBuiltInPlugins(std::vector* plugins) { 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); diff --git a/atom/browser/atom_resource_dispatcher_host_delegate.cc b/atom/browser/atom_resource_dispatcher_host_delegate.cc index 1bd7897..756943a 100644 --- a/atom/browser/atom_resource_dispatcher_host_delegate.cc +++ b/atom/browser/atom_resource_dispatcher_host_delegate.cc @@ -7,6 +7,7 @@ #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" @@ -78,8 +79,9 @@ void OnPdfStreamCreated( 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); } @@ -128,7 +130,7 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( GURL* origin, std::string* payload) { if (mime_type == "application/pdf") { - *origin = GURL("chrome://pdf-viewer/"); + *origin = GURL(PdfViewerUI::kOrigin); return true; } return false; diff --git a/atom/browser/atom_web_ui_controller_factory.cc b/atom/browser/atom_web_ui_controller_factory.cc index 705b203..1e8d90b 100644 --- a/atom/browser/atom_web_ui_controller_factory.cc +++ b/atom/browser/atom_web_ui_controller_factory.cc @@ -52,7 +52,7 @@ AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui, 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; } diff --git a/atom/browser/stream_manager.h b/atom/browser/stream_manager.h index 9f4101e..90b35fe 100644 --- a/atom/browser/stream_manager.h +++ b/atom/browser/stream_manager.h @@ -48,8 +48,6 @@ class StreamManager { StreamManager* stream_manager_; std::string view_id_; - int render_process_id_; - int render_frame_id_; DISALLOW_COPY_AND_ASSIGN(EmbedderObserver); }; diff --git a/atom/browser/ui/webui/pdf_viewer_ui.cc b/atom/browser/ui/webui/pdf_viewer_ui.cc index a2f30f3..dbe3d27 100644 --- a/atom/browser/ui/webui/pdf_viewer_ui.cc +++ b/atom/browser/ui/webui/pdf_viewer_ui.cc @@ -21,7 +21,7 @@ namespace atom { 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 { @@ -79,7 +79,9 @@ 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, diff --git a/atom/browser/ui/webui/pdf_viewer_ui.h b/atom/browser/ui/webui/pdf_viewer_ui.h index 50a6b50..78af615 100644 --- a/atom/browser/ui/webui/pdf_viewer_ui.h +++ b/atom/browser/ui/webui/pdf_viewer_ui.h @@ -21,7 +21,9 @@ namespace atom { 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, diff --git a/chromium_src/components/pdf/common/pdf_messages.h b/chromium_src/components/pdf/common/pdf_messages.h index 20420cd..c6325be 100644 --- a/chromium_src/components/pdf/common/pdf_messages.h +++ b/chromium_src/components/pdf/common/pdf_messages.h @@ -13,13 +13,6 @@ #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 */, diff --git a/vendor/pdf_viewer b/vendor/pdf_viewer index bdc199e..c2c521d 160000 --- a/vendor/pdf_viewer +++ b/vendor/pdf_viewer @@ -1 +1 @@ -Subproject commit bdc199ef4f310b710a1abaade293ee8763230438 +Subproject commit c2c521dc2769a6a6917d246fce2af353ec7e5ede -- 2.7.4