f9c387ac3b7005d4472487bf01a1caa19c47f3ac
[profile/tv/apps/web/browser.git] / services / WebPageUI / WebPageUI.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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 WEBPAGEUI_H
18 #define WEBPAGEUI_H
19
20 #include <Evas.h>
21 #include <boost/signals2/signal.hpp>
22 #include "AbstractService.h"
23 #include "AbstractUIComponent.h"
24 #include "ServiceFactory.h"
25 #include "service_macros.h"
26 #include "ButtonBar.h"
27 #include "URIEntry.h"
28
29 namespace tizen_browser {
30 namespace base_ui {
31
32 class BROWSER_EXPORT WebPageUI : public tizen_browser::core::AbstractService, public tizen_browser::interfaces::AbstractUIComponent {
33 public:
34     WebPageUI();
35     virtual ~WebPageUI();
36     virtual std::string getName();
37     virtual void init(Evas_Object* parent);
38     virtual Evas_Object* getContent();
39     virtual void showUI();
40     virtual void hideUI();
41     void loadStopped();
42     void loadStarted();
43     void progressChanged(double progress);
44     void loadFinished();
45     bool isErrorPageActive();
46     bool isIncognitoPageActive();
47     bool isHomePageActive() { return m_homePageActive; }
48     void toIncognito(bool);
49     void switchViewToErrorPage();
50     void switchViewToWebPage(Evas_Object* content, const std::string uri, const std::string title);
51     void switchViewToIncognitoPage();
52     void switchViewToQuickAccess(Evas_Object* content);
53     URIEntry& getURIEntry() const { return *m_URIEntry.get(); }
54     void setPageTitle(const std::string& title);
55     void setTabsNumber(int tabs);
56     void setBackButtonEnabled(bool enabled) { m_back->setEnabled(enabled); }
57     void setForwardButtonEnabled(bool enabled) { m_forward->setEnabled(enabled); }
58     void setReloadButtonEnabled(bool enabled) { m_reload->setEnabled(enabled); }
59     void setStopButtonEnabled(bool enabled) { m_stopLoading->setEnabled(enabled); }
60     void setMoreMenuButtonEnabled(bool enabled) { m_showMoreMenu->setEnabled(enabled); }
61
62     boost::signals2::signal<void ()> backPage;
63     boost::signals2::signal<void ()> forwardPage;
64     boost::signals2::signal<void ()> stopLoadingPage;
65     boost::signals2::signal<void ()> reloadPage;
66     boost::signals2::signal<void ()> showTabUI;
67     boost::signals2::signal<void ()> showMoreMenu;
68     boost::signals2::signal<void ()> hideQuickAccess;
69     boost::signals2::signal<void ()> showQuickAccess;
70     boost::signals2::signal<void ()> bookmarkManagerClicked;
71     boost::signals2::signal<void ()> showZoomNavigation;
72
73     static void faviconClicked(void* data, Evas_Object* obj, const char* emission, const char* source);
74
75 private:
76     void createLayout();
77     void createErrorLayout();
78     void createPrivateLayout();
79     void createActions();
80     void connectActions();
81     void showProgressBar();
82     void hideProgressBar();
83     void hideWebView();
84     void setErrorButtons();
85     void setPrivateButtons();
86     void setMainContent(Evas_Object* content);
87     void updateURIBar(const std::string& uri);
88     std::string edjePath(const std::string& file);
89     void refreshFocusChain();
90
91     static void _bookmark_manager_clicked(void * data, Evas_Object *, void *);
92
93     // wrappers to call singal as a reaction to other signal
94     void backPageConnect() { backPage(); }
95     void forwardPageConnect() { forwardPage(); }
96     void stopLoadingPageConnect() { stopLoadingPage(); }
97     void reloadPageConnect() { reloadPage(); }
98     void showTabUIConnect();
99     void showMoreMenuConnect();
100
101     Evas_Object* m_parent;
102     Evas_Object* m_mainLayout;
103     Evas_Object* m_errorLayout;
104     Evas_Object* m_privateLayout;
105     Evas_Object* m_progressBar;
106     Evas_Object* m_bookmarkManagerButton;
107     std::unique_ptr<ButtonBar> m_leftButtonBar;
108     std::unique_ptr<ButtonBar> m_rightButtonBar;
109     std::unique_ptr<URIEntry> m_URIEntry;
110     bool m_homePageActive;
111
112     sharedAction m_back;
113     sharedAction m_forward;
114     sharedAction m_stopLoading;
115     sharedAction m_reload;
116     sharedAction m_tab;
117     sharedAction m_showMoreMenu;
118 };
119
120
121 }   // namespace tizen_browser
122 }   // namespace base_ui
123
124 #endif // WEBPAGEUI_H