code cleanup
authordeepak1556 <hop2deep@gmail.com>
Sun, 22 Jan 2017 14:53:42 +0000 (20:23 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Mon, 13 Mar 2017 18:55:59 +0000 (00:25 +0530)
atom/app/atom_content_client.cc
atom/browser/atom_resource_dispatcher_host_delegate.cc
atom/browser/atom_web_ui_controller_factory.cc
atom/browser/stream_manager.h
atom/browser/ui/webui/pdf_viewer_ui.cc
atom/browser/ui/webui/pdf_viewer_ui.h
chromium_src/components/pdf/common/pdf_messages.h
vendor/pdf_viewer

index f1b7a9c..e346854 100644 (file)
@@ -7,6 +7,7 @@
 #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"
@@ -115,7 +116,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* 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);
index 1bd7897..756943a 100644 (file)
@@ -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;
index 705b203..1e8d90b 100644 (file)
@@ -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;
       }
index 9f4101e..90b35fe 100644 (file)
@@ -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);
   };
index a2f30f3..dbe3d27 100644 (file)
@@ -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,
index 50a6b50..78af615 100644 (file)
@@ -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,
index 20420cd..c6325be 100644 (file)
 
 #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 */,
index bdc199e..c2c521d 160000 (submodule)
@@ -1 +1 @@
-Subproject commit bdc199ef4f310b710a1abaade293ee8763230438
+Subproject commit c2c521dc2769a6a6917d246fce2af353ec7e5ede