[WRTjs] Refactor popup
[platform/framework/web/chromium-efl.git] / wrt / src / browser / popup.h
old mode 100755 (executable)
new mode 100644 (file)
index f700de0..a49b883
 #define BROWSER_POPUP_H_
 
 #include <Elementary.h>
-#include <Evas.h>
 
 #include <string>
 
 #include "base/functional/callback.h"
-#include "electron/shell/browser/native_window_observer.h"
-
-#if BUILDFLAG(IS_TIZEN_TV)
-#include "base/timer/timer.h"
-#endif
 
 namespace wrt {
 
-class Popup : electron::NativeWindowObserver {
+class Popup {
  public:
   enum class ButtonType {
     OkButton,
@@ -49,12 +43,13 @@ class Popup : electron::NativeWindowObserver {
   static void Show(std::unique_ptr<Popup> popup);
   static void ForceCloseAllPopup();
 
-  ~Popup();
+  virtual ~Popup();
+
+  virtual void SetButtonType(ButtonType type);
+  virtual void SetCheckBox(const std::string& id);
 
-  void SetButtonType(ButtonType type);
   void SetFirstEntry(const std::string& id, EntryType type);
   void SetSecondEntry(const std::string& id, EntryType type);
-  void SetCheckBox(const std::string& id);
   void SetTitle(const std::string& id);
   void SetBody(const std::string& id);
 
@@ -65,42 +60,33 @@ class Popup : electron::NativeWindowObserver {
 
   void SetResultHandler(ResultHandler handler);
 
-#if BUILDFLAG(IS_TIZEN_TV)
-  static void ShowVoiceRecognitionToast(const std::string& app_title);
-  static void HideVoiceRecognitionToast();
+ protected:
+  Popup(Evas_Object* popup, Evas_Object* box);
 
-  void HandleEntryKeyDownEvent(const std::string& key);
-#endif
+  virtual Evas_Object* AddEntry(const char* id, Popup::EntryType type);
+  virtual void ShowInternal(std::unique_ptr<Popup> popup);
 
- private:
-  Popup(Evas_Object* popup, Evas_Object* box, Evas_Object* window);
+  Evas_Object* popup_;
+  Evas_Object* button2_ = nullptr;
+  Evas_Object* button1_ = nullptr;
+
+  std::string edjeFilePath_ = std::string();
+  std::string checkStyle_ = std::string();
+
+  static std::vector<std::unique_ptr<Popup>> opened_popups_;
 
+ private:
   Evas_Object* AddButton(const char* id, const char* content,
                          const char* button_style);
-  Evas_Object* AddEntry(const char* id, Popup::EntryType type);
 
   void HandleButtonClickEvent(Evas_Object* button);
 
   void Hide();
 
-  // electron::NativeWindowObserver
-  void OnWindowHide() override;
-  void OnWindowShow() override;
-
-#if BUILDFLAG(IS_TIZEN_TV)
-  void Timeout();
-
-  base::OneShotTimer timeout_timer_;
-#endif
-
-  Evas_Object* popup_;
   Evas_Object* box_;
-  Evas_Object* button1_ = nullptr;
-  Evas_Object* button2_ = nullptr;
   Evas_Object* entry1_ = nullptr;
   Evas_Object* entry2_ = nullptr;
   Evas_Object* check_box_ = nullptr;
-  Evas_Object* window_ = nullptr;
 
   ResultHandler handler_;
 };