d17c641e12a311d2c52302a1550de2b33b57d073
[platform/framework/web/web-provider.git] / src / Core / BoxSchemeHandler.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Flora License, Version 1.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://floralicense.org/license/
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  * @file    BoxSchemeHandler.h
18  * @author  Yunchan Cho (yunchan.cho@samsung.com)
19  */
20 #ifndef BOX_SCHEME_HANDLER_H
21 #define BOX_SCHEME_HANDLER_H
22
23 #include <string>
24 #include <map>
25
26 class Box;
27
28 namespace Service {
29 class PeriodChanger;
30 }
31
32 #define EXPORT_CLASS __attribute__ ((visibility("default"))
33
34 class EXPORT_CLASS BoxSchemeHandler {
35     public:
36         static BoxSchemeHandler* Instance();
37         void registerBox(std::string& instanceId, Box* box);
38         void unregisterBox(std::string& instanceId);
39         bool process(std::string& instanceId, std::string& uri);
40         bool isBoxScheme(std::string& uri);
41
42     private:
43         Box* getBox(std::string& instanceId);
44         bool handleReload(std::string& instanceId);
45         bool handleChangePeriod(std::string& instanceId, float requestedPeriod = -1.0f);
46         bool handleLaunchBrowser(std::string& instanceId, std::string& url);
47         bool handleScroll(std::string& instanceId, bool start);
48         std::string parse(std::string& uri, std::string& key);
49
50         BoxSchemeHandler();
51         ~BoxSchemeHandler();
52
53         // members
54         typedef std::map<std::string, Box*> BoxMap;
55         typedef std::pair<std::string, Box*> BoxMapPair;
56         BoxMap m_boxMap;
57         // members for service
58         std::shared_ptr<Service::PeriodChanger> m_periodChanger;
59         static BoxSchemeHandler* s_instance;
60 };
61
62 #endif // BOX_SCHEME_HANDLER_H
63