2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef XWALK_COMMON_RESOURCE_MANAGER_H_
18 #define XWALK_COMMON_RESOURCE_MANAGER_H_
32 class ApplicationData;
36 class ResourceManager {
40 explicit Resource(const std::string& uri);
41 Resource(const std::string& uri, bool should_reset);
42 Resource(const std::string& uri, const std::string& mime,
43 const std::string& encoding);
44 Resource(const Resource& res);
47 Resource& operator=(const Resource& res);
48 bool operator==(const Resource& res);
50 void set_uri(const std::string& uri) { uri_ = uri; }
51 void set_mime(const std::string& mime) { mime_ = mime; }
52 void set_should_reset(bool should_reset) { should_reset_ = should_reset; }
53 void set_encoding(const std::string& encoding) { encoding_ = encoding; }
55 std::string uri() const { return uri_; }
56 std::string mime() const { return mime_; }
57 bool should_reset() const { return should_reset_; }
58 std::string encoding() const { return encoding_; }
64 std::string encoding_;
67 ResourceManager(ApplicationData* application_data,
68 LocaleManager* locale_manager);
71 // input : file:///..... , app://[appid]/....
72 // output : /[system path]/.../locales/.../
73 std::string GetLocalizedPath(const std::string& origin);
74 std::unique_ptr<Resource> GetStartResource(const AppControl* app_control);
75 bool AllowNavigation(const std::string& url);
76 bool AllowedResource(const std::string& url);
78 bool IsEncrypted(const std::string& url);
79 std::string DecryptResource(const std::string& path);
81 void set_base_resource_path(const std::string& base_path);
84 std::unique_ptr<Resource> GetMatchedResource(
85 const wgt::parse::AppControlInfo&);
86 std::unique_ptr<Resource> GetDefaultResource();
89 bool Exists(const std::string& path);
90 bool CheckWARP(const std::string& url);
91 bool CheckAllowNavigation(const std::string& url);
92 std::string RemoveLocalePath(const std::string& path);
94 std::string resource_base_path_;
96 std::map<const std::string, bool> file_existed_cache_;
97 std::map<const std::string, std::string> locale_cache_;
98 std::map<const std::string, bool> warp_cache_;
100 ApplicationData* application_data_;
101 LocaleManager* locale_manager_;
102 int security_model_version_;
105 } // namespace common
107 #endif // XWALK_COMMON_RESOURCE_MANAGER_H_