[WRTjs] Refactor popup
[platform/framework/web/chromium-efl.git] / wrt / src / browser / tv / popup_tv.h
1 /*
2  * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16
17 #ifndef BROWSER_POPUP_TV_H_
18 #define BROWSER_POPUP_TV_H_
19
20 #include "base/timer/timer.h"
21 #include "electron/shell/browser/native_window_observer.h"
22 #include "wrt/src/browser/popup.h"
23
24 namespace wrt {
25
26 class PopupTV : public Popup, public electron::NativeWindowObserver {
27  public:
28   ~PopupTV() override;
29
30   static std::unique_ptr<PopupTV> CreatePopup(Evas_Object* window);
31   static void ShowVoiceRecognitionToast(const std::string& app_title);
32   static void HideVoiceRecognitionToast();
33
34   // Popup
35   void SetButtonType(ButtonType type) override;
36
37   void HandleEntryKeyDownEvent(const std::string& key);
38
39  private:
40   explicit PopupTV(Evas_Object* popup, Evas_Object* box, Evas_Object* window);
41
42   // Popup
43   Evas_Object* AddEntry(const char* id, Popup::EntryType type) override;
44   void SetCheckBox(const std::string& id) override;
45   void ShowInternal(std::unique_ptr<Popup> popup) override;
46
47   // electron::NativeWindowObserver
48   void OnWindowHide() override;
49   void OnWindowShow() override;
50
51   void Timeout();
52
53   base::OneShotTimer timeout_timer_;
54   Evas_Object* window_ = nullptr;
55 };
56
57 }  // namespace wrt
58
59 #endif  // BROWSER_POPUP_TV_H_