Upload upstream chromium 76.0.3809.146
[platform/framework/web/chromium-efl.git] / pdf / out_of_process_instance.h
index 654623f..899c132 100644 (file)
 #include "pdf/paint_manager.h"
 #include "pdf/pdf_engine.h"
 #include "pdf/preview_mode_client.h"
-#include "ppapi/c/private/ppb_pdf.h"
 #include "ppapi/c/private/ppp_pdf.h"
 #include "ppapi/cpp/dev/printing_dev.h"
-#include "ppapi/cpp/dev/scriptable_object_deprecated.h"
-#include "ppapi/cpp/graphics_2d.h"
 #include "ppapi/cpp/image_data.h"
-#include "ppapi/cpp/input_event.h"
 #include "ppapi/cpp/instance.h"
 #include "ppapi/cpp/private/find_private.h"
 #include "ppapi/cpp/private/uma_private.h"
@@ -82,16 +78,19 @@ class OutOfProcessInstance : public pp::Instance,
   void SetSelectionBounds(const pp::FloatPoint& base,
                           const pp::FloatPoint& extent);
   bool CanEditText();
+  bool HasEditableText();
   void ReplaceSelection(const std::string& text);
+  bool CanUndo();
+  bool CanRedo();
+  void Undo();
+  void Redo();
+  int32_t PdfPrintBegin(const PP_PrintSettings_Dev* print_settings,
+                        const PP_PdfPrintSettings_Dev* pdf_print_settings);
 
   void FlushCallback(int32_t result);
   void DidOpen(int32_t result);
   void DidOpenPreview(int32_t result);
 
-  // Called when the timer is fired.
-  void OnClientTimerFired(int32_t id);
-  void OnClientTouchTimerFired(int32_t id);
-
   // Called to print without re-entrancy issues.
   void OnPrint(int32_t);
 
@@ -113,6 +112,7 @@ class OutOfProcessInstance : public pp::Instance,
       const PDFEngine::PageFeatures* page_features) override;
   void GetDocumentPassword(
       pp::CompletionCallbackWithOutput<pp::Var> callback) override;
+  void Beep() override;
   void Alert(const std::string& message) override;
   bool Confirm(const std::string& message) override;
   std::string Prompt(const std::string& question,
@@ -128,12 +128,9 @@ class OutOfProcessInstance : public pp::Instance,
                   const void* data,
                   int length) override;
   pp::URLLoader CreateURLLoader() override;
-  void ScheduleCallback(int id, base::TimeDelta delay) override;
-  void ScheduleTouchTimerCallback(int id, base::TimeDelta delay) override;
   std::vector<SearchStringResult> SearchString(const base::char16* string,
                                                const base::char16* term,
                                                bool case_sensitive) override;
-  void DocumentPaintOccurred() override;
   void DocumentLoadComplete(
       const PDFEngine::DocumentFeatures& document_features,
       uint32_t file_size) override;
@@ -159,6 +156,10 @@ class OutOfProcessInstance : public pp::Instance,
   void RotateClockwise();
   void RotateCounterclockwise();
 
+  // Creates a file name for saving a PDF file, given the source URL. Exposed
+  // for testing.
+  static std::string GetFileNameFromUrl(const std::string& url);
+
  private:
   void ResetRecentlySentFindUpdate(int32_t);
 
@@ -184,6 +185,11 @@ class OutOfProcessInstance : public pp::Instance,
   // frame's origin.
   pp::URLLoader CreateURLLoaderInternal();
 
+  bool ShouldSaveEdits() const;
+  void SaveToFile(const std::string& token);
+  void SaveToBuffer(const std::string& token);
+  void ConsumeSaveToken(const std::string& token);
+
   void FormDidOpen(int32_t result);
 
   void UserMetricsRecordAction(const std::string& action);
@@ -304,18 +310,22 @@ class OutOfProcessInstance : public pp::Instance,
 
   struct PrintSettings {
     PrintSettings() { Clear(); }
-    void Clear() {
-      is_printing = false;
-      print_pages_called_ = false;
-      memset(&pepper_print_settings, 0, sizeof(pepper_print_settings));
-    }
-    // This is set to true when PrintBegin is called and false when PrintEnd is
-    // called.
+
+    void Clear();
+
+    // This is set to true when PdfPrintBegin() is called and false when
+    // PrintEnd() is called.
     bool is_printing;
+
     // To know whether this was an actual print operation, so we don't double
     // count UMA logging.
-    bool print_pages_called_;
+    bool print_pages_called;
+
+    // Generic print settings.
     PP_PrintSettings_Dev pepper_print_settings;
+
+    // PDF-specific print settings.
+    PP_PdfPrintSettings_Dev pdf_print_settings;
   };
 
   PrintSettings print_settings_;
@@ -421,6 +431,8 @@ class OutOfProcessInstance : public pp::Instance,
   // Annotation types that were already counted for this document.
   std::set<int> annotation_types_counted_;
 
+  bool edit_mode_ = false;
+
   // The current state of accessibility: either off, enabled but waiting
   // for the document to load, or fully loaded.
   enum AccessibilityState {