} // namespace
+ResourceManager::Resource::Resource(const std::string& uri)
+ : uri_(uri), should_reset_(true) {}
+
+ResourceManager::Resource::Resource(const std::string& uri,
+ const std::string& mime)
+ : uri_(uri), mime_(mime), should_reset_(true) {}
+
+ResourceManager::Resource::Resource(const std::string& uri,
+ const std::string& mime, bool should_reset)
+ : uri_(uri), mime_(mime), should_reset_(should_reset) {}
+
+ResourceManager::Resource::Resource(const ResourceManager::Resource& res) {
+ *this = res;
+}
+
+ResourceManager::Resource& ResourceManager::Resource::operator=(
+ const ResourceManager::Resource& res) {
+ this->uri_ = res.uri();
+ this->mime_ = res.mime();
+ this->should_reset_ = res.should_reset();
+ return *this;
+}
+
+bool ResourceManager::Resource::operator==(const Resource& res) {
+ if (this->uri_ == res.uri() && this->mime_ == res.mime()
+ && this->should_reset_ == res.should_reset()) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
ResourceManager::ResourceManager(ApplicationData* application_data,
LocaleManager* locale_manager)
: application_data_(application_data), locale_manager_(locale_manager) {
return GetDefaultOrEmpty();
}
-std::string ResourceManager::GetStartURL() {
- std::string operation = app_control_->operation();
+std::unique_ptr<ResourceManager::Resource> ResourceManager::GetStartResource(
+ const AppControl* app_control) {
+ std::string operation = app_control->operation();
if (operation.empty()) {
LoggerE("operation(mandatory) is NULL");
- return GetDefaultOrEmpty();
+ return std::unique_ptr<Resource>(new Resource(GetDefaultOrEmpty()));
}
- std::string mime = app_control_->mime();
- std::string uri = app_control_->uri();
+ std::string mime = app_control->mime();
+ std::string uri = app_control->uri();
if (mime.empty() && !uri.empty()) {
mime = GetMimeFromUri(uri);
}
if (application_data_ == NULL ||
application_data_->app_control_info_list() == NULL) {
- return GetDefaultOrEmpty();
+ return std::unique_ptr<Resource>(new Resource(GetDefaultOrEmpty()));
}
AppControlList app_control_list =
AppControlList::const_iterator iter =
CompareMimeAndUri(app_control_list, mime, uri);
if (iter != app_control_list.end()) {
- return GetMatchedSrcOrUri(*iter);
+ // TODO(jh5.cho) : following comment will be added after SRPOL implement
+ return std::unique_ptr<Resource>(
+ new Resource(GetMatchedSrcOrUri(*iter), iter->mime()
+ /*, iter->should_reset()*/));
} else {
- return GetDefaultOrEmpty();
+ return std::unique_ptr<Resource>(new Resource(GetDefaultOrEmpty()));
}
} else {
- return GetDefaultOrEmpty();
+ return std::unique_ptr<Resource>(new Resource(GetDefaultOrEmpty()));
}
}
#include <string>
#include <map>
+#include <memory>
namespace wgt {
class ResourceManager {
public:
+ class Resource {
+ public:
+ explicit Resource(const std::string& uri);
+ Resource(const std::string& uri, const std::string& mime);
+ Resource(const std::string& uri, const std::string& mime,
+ bool should_reset);
+ Resource(const Resource& res);
+ ~Resource() {}
+
+ Resource& operator=(const Resource& res);
+ bool operator==(const Resource& res);
+
+ void set_uri(const std::string& uri) { uri_ = uri; }
+ void set_mime(const std::string& mime) { mime_ = mime; }
+ void set_should_reset(bool should_reset) { should_reset_ = should_reset; }
+
+ std::string uri() const { return uri_; }
+ std::string mime() const { return mime_; }
+ bool should_reset() const { return should_reset_; }
+
+ private:
+ std::string uri_;
+ std::string mime_;
+ bool should_reset_;
+ };
+
ResourceManager(ApplicationData* application_data,
LocaleManager* locale_manager);
~ResourceManager() {}
// input : file:///..... , app://[appid]/....
// output : /[system path]/.../locales/.../
std::string GetLocalizedPath(const std::string& origin);
- std::string GetStartURL();
+ std::unique_ptr<Resource> GetStartResource(const AppControl* app_control);
void set_base_resource_path(const std::string& base_path);
- void set_app_control(AppControl* app_control) {
- app_control_ = app_control;
- }
-
- const AppControl* app_control() const { return app_control_; }
private:
std::string GetMatchedSrcOrUri(const wgt::parse::AppControlInfo&);
ApplicationData* application_data_;
LocaleManager* locale_manager_;
- AppControl* app_control_;
};
} // namespace wrt
}
void WebApplication::Launch(std::unique_ptr<wrt::AppControl> appcontrol) {
- resource_manager_->set_app_control(appcontrol.get());
WebView* view = new WebView(window_, ewk_context_);
SetupWebView(view);
// view->LoadUrl("file:///home/owner/apps_rw/33CFo0eFJe/"
// "33CFo0eFJe.annex/index.html");
- view->LoadUrl(resource_manager_->GetStartURL());
-
+ std::unique_ptr<ResourceManager::Resource> res =
+ resource_manager_->GetStartResource(appcontrol.get());
+ view->LoadUrl(res->uri());
view_stack_.push_front(view);
window_->SetContent(view->evas_object());
void WebApplication::AppControl(std::unique_ptr<wrt::AppControl> appcontrol) {
// TODO(sngn.lee): Set the injected bundle into extension process
- resource_manager_->set_app_control(appcontrol.get());
- if (true) {
+ std::unique_ptr<ResourceManager::Resource> res =
+ resource_manager_->GetStartResource(appcontrol.get());
+ if (res->should_reset()) {
// Reset to context
ClearViewStack();
WebView* view = new WebView(window_, ewk_context_);
SetupWebView(view);
- view->LoadUrl(resource_manager_->GetStartURL());
+ view->LoadUrl(res->uri());
view_stack_.push_front(view);
window_->SetContent(view->evas_object());
} else {