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 WRT_COMMON_RESOURCE_MANAGER_H_
18 #define WRT_COMMON_RESOURCE_MANAGER_H_
36 class ApplicationData;
40 class ResourceManager {
44 explicit Resource(const std::string& uri);
45 Resource(const std::string& uri, const std::string& mime);
46 Resource(const std::string& uri, const std::string& mime,
48 Resource(const Resource& res);
51 Resource& operator=(const Resource& res);
52 bool operator==(const Resource& res);
54 void set_uri(const std::string& uri) { uri_ = uri; }
55 void set_mime(const std::string& mime) { mime_ = mime; }
56 void set_should_reset(bool should_reset) { should_reset_ = should_reset; }
58 std::string uri() const { return uri_; }
59 std::string mime() const { return mime_; }
60 bool should_reset() const { return should_reset_; }
68 ResourceManager(ApplicationData* application_data,
69 LocaleManager* locale_manager);
72 // input : file:///..... , app://[appid]/....
73 // output : /[system path]/.../locales/.../
74 std::string GetLocalizedPath(const std::string& origin);
75 std::unique_ptr<Resource> GetStartResource(const AppControl* app_control);
77 void set_base_resource_path(const std::string& base_path);
80 std::string GetMatchedSrcOrUri(const wgt::parse::AppControlInfo&);
81 std::string GetDefaultOrEmpty();
83 bool Exists(const std::string& path);
85 std::string resource_base_path_;
87 std::map<const std::string, bool> file_existed_cache_;
88 std::map<const std::string, std::string> locale_cache_;
90 ApplicationData* application_data_;
91 LocaleManager* locale_manager_;
96 #endif // WRT_COMMON_RESOURCE_MANAGER_H_