#include "tizen_src/chromium_impl/tizen/vconf_handle.h"
#include "wrt/src/browser/tv/video_splash_screen.h"
-#include "wrt/src/common/application_data.h"
+#include "wrt/src/common/tv/application_data_tv.h"
namespace wrt {
}
bool SplashScreenDelegateTV::IsVideoPlaying() {
- auto& app_data = ApplicationData::GetInstance();
+ auto& app_data = ApplicationDataTV::GetInstance();
return app_data.video_splash_screen_info().HasVideoSplashScreenData() &&
VideoSplashScreen::IsVSSPlaying();
}
#include "wrt/src/browser/native_web_runtime.h"
#include "wrt/src/browser/tv/widget_state.h"
#include "wrt/src/browser/tv/wrt_native_window_tv.h"
+#include "wrt/src/common/tv/application_data_tv.h"
namespace wrt {
}
bool ReleaseVSSCom() {
- auto& app_data = ApplicationData::GetInstance();
+ auto& app_data = ApplicationDataTV::GetInstance();
return (app_data.video_splash_screen_info().HasVideoSplashScreenData() &&
!!aul_app_com_connection_ &&
// static
void VideoSplashScreen::InitializeVSS() {
- auto& app_data = ApplicationData::GetInstance();
+ auto& app_data = ApplicationDataTV::GetInstance();
if (!app_data.video_splash_screen_info().HasVideoSplashScreenData())
return;
}
wgt::parse::ReadyWhen VideoSplashScreen::GetReadyWhen() {
- auto& app_data = ApplicationData::GetInstance();
+ auto& app_data = ApplicationDataTV::GetInstance();
return app_data.video_splash_screen_info().ready_when();
}
#include <tzplatform_config.h>
#include <vector>
#include <wgt_manifest_handlers/application_manifest_constants.h>
-#include <wgt_manifest_handlers/widget_config_parser.h>
#include "base/command_line.h"
#include "base/files/file_util.h"
#if BUILDFLAG(IS_TIZEN_TV)
#include "wrt/src/browser/tv/native_web_runtime_delegate_tv.h"
#include "wrt/src/common/tv/application_data_tv.h"
+
+using ApplicationDataType = wrt::ApplicationDataTV;
+#else
+using ApplicationDataType = wrt::ApplicationData;
#endif
namespace wrt {
if (!instance) {
base::AutoLock lock(instance_lock_);
if (!instance) // double check to avoid create instance again
-#if BUILDFLAG(IS_TIZEN_TV)
- instance = new ApplicationDataTV;
-#else
- instance = new ApplicationData;
-#endif
+ instance = new ApplicationDataType;
}
return *instance;
}
// static
ApplicationData* ApplicationData::Create(const std::string& service_id,
const std::string& pkg_path) {
-#if BUILDFLAG(IS_TIZEN_TV)
- return new ApplicationDataTV(service_id, pkg_path);
-#else
- return new ApplicationData(service_id, pkg_path);
-#endif
+ return new ApplicationDataType(service_id, pkg_path);
}
-bool ApplicationData::Initialize() {
- if (initialized_)
- return true;
-
- SCOPE_PROFILE();
- base::AutoLock lock(data_lock_);
+void ApplicationData::ParseAndSetManifestData() {
base::FilePath config_xml_path;
if (!backup_config_xml_.empty()) {
config_xml_path = backup_config_xml_;
if (!base::PathExists(config_xml_path)) {
LOG(ERROR) << "Failed to load manifest data : No such file '"
<< config_xml_path << "'.";
- return false;
+ return;
}
}
if (!widget_config_parser->ParseManifest(config_xml_path.value())) {
LOG(ERROR) << "Failed to load widget config parser data: "
<< widget_config_parser->GetErrorMessage();
- return false;
+ return;
}
tizen_application_info_.SetImpl(
widget_config_parser->GetManifestData(
wgt::parse::LaunchScreenInfo::Key())));
-#if BUILDFLAG(IS_TIZEN_TV)
- video_splash_screen_info_.SetImpl(
- std::static_pointer_cast<const wgt::parse::VideoSplashScreenInfo>(
- widget_config_parser->GetManifestData(
- wgt::parse::VideoSplashScreenInfo::Key())));
-#endif
-
meta_data_info_.SetImpl(
std::static_pointer_cast<const wgt::parse::MetaDataInfo>(
widget_config_parser->GetManifestData(
widget_info_.SetImpl(std::static_pointer_cast<const wgt::parse::WidgetInfo>(
widget_config_parser->GetManifestData(wgt::parse::WidgetInfo::Key())));
+ if (delegate_)
+ delegate_->ParseAndSetManifestData(widget_config_parser.get());
+}
+
+bool ApplicationData::Initialize() {
+ if (initialized_)
+ return true;
+
+ SCOPE_PROFILE();
+ base::AutoLock lock(data_lock_);
+ ParseAndSetManifestData();
app_type_ = GetAppType();
std::string src = content_info_.src();
}
// static
+const std::string ApplicationData::GetUpgradableWrtjsPath() {
+ std::string wrt_upgraded_tpk_res_path =
+ std::string(tzplatform_getenv(TZ_SYS_RW_APP)) + kWrtUpgradedTpkResPath;
+ if (utils::Exists(wrt_upgraded_tpk_res_path.c_str()))
+ return wrt_upgraded_tpk_res_path;
+ else
+ return std::string();
+}
+
+// static
const std::string ApplicationData::GetWrtResPath() {
-#if BUILDFLAG(IS_TIZEN_TV)
- wrt_res_path_ = ApplicationDataTV::GetWrtResPath();
-#endif
if (wrt_res_path_.empty()) {
- std::string wrt_upgraded_tpk_res_path =
- std::string(tzplatform_getenv(TZ_SYS_RW_APP)) + kWrtUpgradedTpkResPath;
- if (utils::Exists(wrt_upgraded_tpk_res_path.c_str())) {
- return wrt_res_path_ = wrt_upgraded_tpk_res_path;
- }
- wrt_res_path_ = kWrtPreloadedResPath;
+ auto upgradable_wrtjs_path = ApplicationDataType::GetUpgradableWrtjsPath();
+ if (upgradable_wrtjs_path.empty())
+ wrt_res_path_ = kWrtPreloadedResPath;
+ else
+ wrt_res_path_ = upgradable_wrtjs_path;
}
return wrt_res_path_;
}
#include <unordered_map>
+#include <wgt_manifest_handlers/widget_config_parser.h>
+
#include "base/files/file_path.h"
#include "wrt/src/common/application_data_wrapper.h"
class NativeAppControl;
+class ApplicationDataDelegate {
+ public:
+ ApplicationDataDelegate() = default;
+ ~ApplicationDataDelegate() = default;
+
+ virtual void ParseAndSetManifestData(wgt::parse::WidgetConfigParser* parser) {}
+};
+
class ApplicationData {
public:
enum AppType { UI = 0, IME, WATCH, SERVICE };
static ApplicationData* Create(const std::string& service_id,
const std::string& pkg_path);
bool Initialize();
+ void ParseAndSetManifestData();
+ void SetDelegate(ApplicationDataDelegate* delegate) {
+ delegate_ = delegate;
+ }
const AllowedNavigationInfo& allowed_navigation_info() const {
return allowed_navigation_info_;
const LaunchScreenInfo& launch_screen_info() const {
return launch_screen_info_;
}
-#if BUILDFLAG(IS_TIZEN_TV)
- const VideoSplashScreenInfo& video_splash_screen_info() const {
- return video_splash_screen_info_;
- }
-#endif
const MetaDataInfo& meta_data_info() const {
return meta_data_info_;
}
static const std::string GetPackagePath(const std::string& app_id);
static const std::string GetServiceID(const std::string& internal_id);
+ static const std::string GetUpgradableWrtjsPath();
static const std::string GetWrtResPath();
static bool IsServiceApp();
static void SetServiceApp();
mutable std::string pkg_id_;
ApplicationData::AppType app_type_;
std::unordered_map<std::string, std::string> metadata_;
-#if BUILDFLAG(IS_TIZEN_TV)
- VideoSplashScreenInfo video_splash_screen_info_;
-#endif
base::FilePath backup_config_xml_;
+ ApplicationDataDelegate* delegate_ = nullptr;
};
} // namespace wrt
LOG(INFO) << "user_data_path_ : " << user_data_path_;
LOG(INFO) << "backup_config_xml_ : " << backup_config_xml_;
+ SetDelegate(this);
Initialize();
+ SetDelegate(nullptr);
}
ApplicationDataTV::ApplicationDataTV(const std::string& app_id,
backup_config_xml_ = GetBackupConfigXml(application_path_);
}
+void ApplicationDataTV::ParseAndSetManifestData(
+ wgt::parse::WidgetConfigParser* parser) {
+ video_splash_screen_info_.SetImpl(
+ std::static_pointer_cast<const wgt::parse::VideoSplashScreenInfo>(
+ parser->GetManifestData(wgt::parse::VideoSplashScreenInfo::Key())));
+}
+
// static
-std::string ApplicationDataTV::GetWrtResPath() {
+const std::string ApplicationDataTV::GetUpgradableWrtjsPath() {
std::string wrt_upgraded_tpk_res_path =
std::string(CHROMIUM_RO_ROOT_DIR) + kWrtUpgradedTpkResPath;
base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
bool ApplicationDataTV::HasWidgetLicense() {
if (widget_license_exist_.has_value())
return widget_license_exist_.value();
- auto application_path = ApplicationData::GetInstance().application_path();
auto path =
- base::FilePath(application_path).DirName().Append(kWidgetLicense);
+ base::FilePath(application_path()).DirName().Append(kWidgetLicense);
widget_license_exist_ = base::PathExists(path);
return widget_license_exist_.value();
}
std::string ApplicationDataTV::PointDeviceOption() {
- auto& setting_info = ApplicationData::GetInstance().setting_info();
- return setting_info.pointing_device_option();
+ return setting_info().pointing_device_option();
}
// static
namespace wrt {
-class ApplicationDataTV : public ApplicationData {
+class ApplicationDataTV : public ApplicationData,
+ public ApplicationDataDelegate {
public:
static ApplicationDataTV& GetInstance();
- static std::string GetWrtResPath();
+ static const std::string GetUpgradableWrtjsPath();
ApplicationDataTV();
explicit ApplicationDataTV(const std::string& app_id,
bool HasWidgetLicense();
std::string PointDeviceOption();
+ const VideoSplashScreenInfo& video_splash_screen_info() const {
+ return video_splash_screen_info_;
+ }
+
private:
+ // ApplicationDataDelegate
+ void ParseAndSetManifestData(wgt::parse::WidgetConfigParser* parser) override;
+
absl::optional<bool> widget_license_exist_;
+ VideoSplashScreenInfo video_splash_screen_info_;
};
} // namespace wrt