1 // Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WRT_COMMON_RESOURCE_MANAGER_H_
6 #define WRT_COMMON_RESOURCE_MANAGER_H_
24 class ApplicationData;
28 class ResourceManager {
32 explicit Resource(const std::string& uri);
33 Resource(const std::string& uri, const std::string& mime);
34 Resource(const std::string& uri, const std::string& mime,
36 Resource(const Resource& res);
39 Resource& operator=(const Resource& res);
40 bool operator==(const Resource& res);
42 void set_uri(const std::string& uri) { uri_ = uri; }
43 void set_mime(const std::string& mime) { mime_ = mime; }
44 void set_should_reset(bool should_reset) { should_reset_ = should_reset; }
46 std::string uri() const { return uri_; }
47 std::string mime() const { return mime_; }
48 bool should_reset() const { return should_reset_; }
56 ResourceManager(ApplicationData* application_data,
57 LocaleManager* locale_manager);
60 // input : file:///..... , app://[appid]/....
61 // output : /[system path]/.../locales/.../
62 std::string GetLocalizedPath(const std::string& origin);
63 std::unique_ptr<Resource> GetStartResource(const AppControl* app_control);
65 void set_base_resource_path(const std::string& base_path);
68 std::string GetMatchedSrcOrUri(const wgt::parse::AppControlInfo&);
69 std::string GetDefaultOrEmpty();
71 bool Exists(const std::string& path);
73 std::string resource_base_path_;
75 std::map<const std::string, bool> file_existed_cache_;
76 std::map<const std::string, std::string> locale_cache_;
78 ApplicationData* application_data_;
79 LocaleManager* locale_manager_;
84 #endif // WRT_COMMON_RESOURCE_MANAGER_H_