[WRTjs] Refactor popup
[platform/framework/web/chromium-efl.git] / wrt / src / browser / native_app_control.h
1 /*
2  * Copyright (c) 2015 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_APP_CONTROL_H_
18 #define BROWSER_APP_CONTROL_H_
19
20 #include <app_control.h>
21 #include <bundle.h>
22 #include <map>
23 #include <memory>
24 #include <string>
25 #include <vector>
26
27 namespace wrt {
28
29 class NativeAppControl {
30  public:
31   static std::unique_ptr<NativeAppControl> MakeAppcontrolFromURL(
32       const std::string& url);
33
34   explicit NativeAppControl(app_control_h app_control);
35   explicit NativeAppControl();
36   ~NativeAppControl();
37
38   // disable copy
39   NativeAppControl(const NativeAppControl& src) = delete;
40   NativeAppControl& operator=(const NativeAppControl&) = delete;
41
42   std::string GetOperation() const;
43   void SetOperation(const std::string& operation);
44
45   std::string GetMime() const;
46   void SetMime(const std::string& mime);
47
48   std::string GetUri() const;
49   void SetUri(const std::string& uri);
50
51   std::string GetCategory() const;
52   void SetCategory(const std::string& category);
53
54   bool IsDataArray(const std::string& key);
55   std::string GetData(const std::string& key) const;
56   std::vector<std::string> GetDataArray(const std::string& key) const;
57   bool AddData(const std::string& key, const std::string& value);
58   bool AddDataArray(const std::string& key,
59                     const std::vector<std::string>& value_array);
60
61   bool SendLaunchRequest();
62   bool Reply(const std::map<std::string, std::vector<std::string>>& data);
63
64   std::string GetEncodedBundle();
65
66  private:
67   app_control_h app_control_ = nullptr;
68   bundle* app_control_bundle_ = nullptr;
69 };
70
71 }  // namespace wrt
72
73 #endif  // BROWSER_APP_CONTROL_H_