Remove IS_TIZEN_TV on TV profile's file handlers.
Change-Id: I56843c1e5aeab42426f782a9156abacae9b86993
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
runtime_delegate_->Initialize();
app_data.Initialize();
- InitializeWRTFileURLLoader();
LocaleManager::GetInstance();
resource_manager_.reset(new ResourceManager);
request, std::move(loader), std::move(client)));
}
+void SetEncryptedFileUrlCallbacks() {
+ WRTProxyingURLLoaderFactory::SetUrlParser(
+ base::BindRepeating(&ParseEncryptedURL));
+ WRTProxyingURLLoaderFactory::SetEncryptedFileLoader(
+ base::BindRepeating(&CreateEncryptedFileURLLoader));
+}
+
} // namespace wrt
const network::ResourceRequest& request,
mojo::PendingReceiver<network::mojom::URLLoader> loader,
mojo::PendingRemote<network::mojom::URLLoaderClient> client);
+void SetEncryptedFileUrlCallbacks();
} // namespace wrt
#include "wrt/src/common/application_data.h"
#include "wrt/src/common/constants.h"
-#if BUILDFLAG(IS_TIZEN_TV)
-#include <tzplatform_config.h>
-#endif
-
namespace wrt {
namespace {
constexpr size_t kDefaultFileUrlPipeSize = 65536;
+FileRequestIntercepter file_request_intercepter;
+
bool ShouldOverrideMimeType(const GURL& url,
std::string& new_mime_type,
std::string& new_charset_type) {
} // namespace
-#if BUILDFLAG(IS_TIZEN_TV)
-std::vector<std::string> allowed_path_list;
-std::vector<std::string> allowed_sub_path_list;
-
-void SetAllowedPath() {
- auto pkg_id = ApplicationData::GetInstance().GetPackageID();
- auto rw_base_path = std::string(tzplatform_getenv(TZ_SYS_RW_APP));
-
- // this path should be first for early return
- allowed_path_list.push_back(rw_base_path + "/" + pkg_id);
-
- allowed_path_list.push_back("/opt/media/");
- allowed_path_list.push_back("/media/");
-
- allowed_path_list.push_back("/opt/usr/home/owner/share/");
- allowed_path_list.push_back("/home/owner/share/");
-
- allowed_path_list.push_back("/opt/usr/home/owner/content/");
- allowed_path_list.push_back("/home/owner/content/");
- allowed_path_list.push_back("/usr/share/feedback/");
-
- allowed_path_list.push_back("/opt/usr/home/owner/apps_rw/" + pkg_id);
- allowed_path_list.push_back("/home/owner/apps_rw/" + pkg_id);
-
- allowed_path_list.push_back("/usr/bin/emps/empPepperPlugins/");
- allowed_path_list.push_back("/bin/emps/empPepperPlugins/");
- allowed_path_list.push_back(rw_base_path + "/appbinarymanager/");
-
- allowed_path_list.push_back("/tmp/");
- allowed_path_list.push_back("/opt/share/");
- allowed_path_list.push_back(rw_base_path + "/pepper/");
-
- // this path is for allowed sub path
- allowed_sub_path_list.push_back("/shared/res");
- allowed_sub_path_list.push_back("/shared/data");
-}
-#endif
-
class WRTFileURLLoader : public network::mojom::URLLoader {
public:
static void CreateAndStart(
WRTFileURLLoader() = default;
~WRTFileURLLoader() override = default;
-#if BUILDFLAG(IS_TIZEN_TV)
- bool IsAllowedPath(const base::FilePath& path) {
- for (auto allowed_path : allowed_path_list) {
- if (base::StartsWith(path.value(), allowed_path,
- base::CompareCase::SENSITIVE)) {
- return true;
- }
- }
-
- for (auto allowed_path : allowed_sub_path_list) {
- if (path.value().find(allowed_path) != std::string::npos) {
- return true;
- }
- }
-
- LOG(ERROR) << "Invalid access : " << path;
- return false;
- }
-#endif
-
void Start(
const network::ResourceRequest& request,
mojo::PendingReceiver<network::mojom::URLLoader> loader,
return;
}
-#if BUILDFLAG(IS_TIZEN_TV)
- if (!IsAllowedPath(path)) {
- OnClientComplete(net::ERR_ACCESS_DENIED);
- return;
+ if (!file_request_intercepter.is_null()) {
+ if (!file_request_intercepter.Run(path)) {
+ OnClientComplete(net::ERR_ACCESS_DENIED);
+ return;
+ }
}
-#endif
+
std::string new_mime_type;
std::string new_charset_type;
if (ShouldOverrideMimeType(request.url, new_mime_type, new_charset_type)) {
uint64_t total_bytes_written_ = 0;
};
-void InitializeWRTFileURLLoader() {
-#if BUILDFLAG(IS_TIZEN_TV)
- SetAllowedPath();
-#endif
+void SetFileRequestIntercepter(const FileRequestIntercepter intercepter) {
+ file_request_intercepter = intercepter;
}
void CreateWRTFileURLLoader(
namespace wrt {
-void InitializeWRTFileURLLoader();
-
void CreateWRTFileURLLoader(
const network::ResourceRequest& request,
mojo::PendingReceiver<network::mojom::URLLoader> loader,
mojo::PendingRemote<network::mojom::URLLoaderClient> client);
+using FileRequestIntercepter =
+ base::RepeatingCallback<bool(const base::FilePath&)>;
+void SetFileRequestIntercepter(const FileRequestIntercepter intercepter);
+
} // namespace wrt
#endif // BROWSER_NET_WRT_FILE_URL_LOADER_H_
#include "base/no_destructor.h"
#include "content/browser/data_url_loader_factory.h"
-#include "wrt/src/browser/net/wrt_file_url_loader.h"
-
-#if BUILDFLAG(IS_TIZEN_TV)
#include "electron/shell/browser/browser.h"
-#include "wrt/src/browser/net/tv/encrypted_file_url_loader.h"
-#endif
+#include "wrt/src/browser/net/wrt_file_url_loader.h"
namespace wrt {
namespace {
-#if !BUILDFLAG(IS_TIZEN_TV)
WRTProxyingURL ParseURLInternal(const GURL& url) {
std::string url_str = url.possibly_invalid_spec();
std::string orignal_str = url_str;
else
return WRTProxyingURL(GURL());
}
-#endif
+
+WRTProxyingURLLoaderFactory::UrlParser url_parser =
+ base::BindRepeating(&ParseURLInternal);
+WRTProxyingURLLoaderFactory::EncryptedFileLoader encrypted_file_loader;
} // namespace
}
// static
+void WRTProxyingURLLoaderFactory::SetUrlParser(const UrlParser& paraser) {
+ url_parser = paraser;
+}
+
+// static
+void WRTProxyingURLLoaderFactory::SetEncryptedFileLoader(
+ const EncryptedFileLoader& loader) {
+ encrypted_file_loader = loader;
+}
+
+// static
WRTProxyingURL WRTProxyingURLLoaderFactory::ParseURL(const GURL& url) {
auto& resource_manager = WRTProxyingURLLoaderFactory::GetResourceManager();
if (!resource_manager.AllowedResource(url.possibly_invalid_spec())) {
<< "] was blocked by WARP";
return GURL("about:blank");
}
-#if BUILDFLAG(IS_TIZEN_TV)
- return ParseEncryptedURL(url);
-#else
- return ParseURLInternal(url);
-#endif
+ return url_parser.Run(url);
}
WRTProxyingURLLoaderFactory::WRTProxyingURLLoaderFactory(
if (parsed_url.is_valid())
request.url = parsed_url;
-#if BUILDFLAG(IS_TIZEN_TV)
if (electron::Browser::Get()->is_quitting()) {
LOG(INFO) << "ignore request : " << request.url.possibly_invalid_spec();
return;
}
- if (proxying_url.encrypted()) {
- CreateEncryptedFileURLLoader(
- request, std::move(loader), std::move(client));
+ if (proxying_url.encrypted() && !encrypted_file_loader.is_null()) {
+ encrypted_file_loader.Run(request, std::move(loader), std::move(client));
return;
}
-#else
LOG(INFO) << "url : " << request.url.possibly_invalid_spec();
-#endif
// Check if user has intercepted this scheme.
auto it = intercepted_handlers_.find(request.url.scheme());
class WRTProxyingURLLoaderFactory
: public network::mojom::URLLoaderFactory {
public:
+ using UrlParser = base::RepeatingCallback<WRTProxyingURL(const GURL&)>;
+ using EncryptedFileLoader = base::RepeatingCallback<void(
+ const network::ResourceRequest&,
+ mojo::PendingReceiver<network::mojom::URLLoader>,
+ mojo::PendingRemote<network::mojom::URLLoaderClient>)>;
static ResourceManager& GetResourceManager();
static WRTProxyingURL ParseURL(const GURL& url);
+ static void SetUrlParser(const UrlParser& parser);
+ static void SetEncryptedFileLoader(const EncryptedFileLoader& loader);
WRTProxyingURLLoaderFactory(
const electron::HandlersMap& intercepted_handlers,
#include "wrt/src/app/tv/wrt_main_delegate_tv.h"
#include "wrt/src/base/platform_info.h"
#include "wrt/src/browser/native_web_runtime.h"
+#include "wrt/src/browser/net/tv/encrypted_file_url_loader.h"
+#include "wrt/src/browser/net/wrt_file_url_loader.h"
#include "wrt/src/browser/tv/ambient_mode.h"
#include "wrt/src/browser/tv/decorator_window.h"
#include "wrt/src/browser/tv/mounter.h"
app_id_ = app_data.app_id();
auto extension_manager = XWalkExtensionManager::GetInstance();
extension_manager->RegisterUpgradableExtensions();
+
+ SetAllowedPath();
+ SetFileRequestIntercepter(base::BindRepeating(
+ &NativeWebRuntimeDelegateTV::IsAllowedPath, base::Unretained(this)));
+ SetEncryptedFileUrlCallbacks();
+
initialized_ = true;
}
return true;
}
+void NativeWebRuntimeDelegateTV::SetAllowedPath() {
+ auto pkg_id = ApplicationData::GetInstance().GetPackageID();
+ auto rw_base_path = std::string(tzplatform_getenv(TZ_SYS_RW_APP));
+
+ // this path should be first for early return
+ allowed_path_list_.push_back(rw_base_path + "/" + pkg_id);
+
+ allowed_path_list_.push_back("/opt/media/");
+ allowed_path_list_.push_back("/media/");
+
+ allowed_path_list_.push_back("/opt/usr/home/owner/share/");
+ allowed_path_list_.push_back("/home/owner/share/");
+
+ allowed_path_list_.push_back("/opt/usr/home/owner/content/");
+ allowed_path_list_.push_back("/home/owner/content/");
+ allowed_path_list_.push_back("/usr/share/feedback/");
+
+ allowed_path_list_.push_back("/opt/usr/home/owner/apps_rw/" + pkg_id);
+ allowed_path_list_.push_back("/home/owner/apps_rw/" + pkg_id);
+
+ allowed_path_list_.push_back("/usr/bin/emps/empPepperPlugins/");
+ allowed_path_list_.push_back("/bin/emps/empPepperPlugins/");
+ allowed_path_list_.push_back(rw_base_path + "/appbinarymanager/");
+
+ allowed_path_list_.push_back("/tmp/");
+ allowed_path_list_.push_back("/opt/share/");
+ allowed_path_list_.push_back(rw_base_path + "/pepper/");
+
+ // this path is for allowed sub path
+ allowed_sub_path_list_.push_back("/shared/res");
+ allowed_sub_path_list_.push_back("/shared/data");
+}
+
+bool NativeWebRuntimeDelegateTV::IsAllowedPath(const base::FilePath& path) {
+ for (const auto& allowed_path : allowed_path_list_) {
+ if (base::StartsWith(path.value(), allowed_path,
+ base::CompareCase::SENSITIVE)) {
+ return true;
+ }
+ }
+ for (const auto& allowed_path : allowed_sub_path_list_) {
+ if (path.value().find(allowed_path) != std::string::npos) {
+ return true;
+ }
+ }
+ LOG(ERROR) << "Invalid access : " << path;
+ return false;
+}
+
} // namespace wrt
void ApplyHalfWindow(std::string half_window_option);
void ClearTmpFolder();
void EarlyLoadUrlIfHostedApp();
+ bool IsAllowedPath(const base::FilePath& path);
+ void SetAllowedPath();
void SetD2dServiceMessageListener();
void SetDiskCache(bool enable);
std::string CheckPrivilege(const std::string& privilege);
bool power_callback_registered_ = false;
bool has_payload_data_ = false;
std::set<std::string> privileges_cache_;
+ std::vector<std::string> allowed_path_list_;
+ std::vector<std::string> allowed_sub_path_list_;
};
} // namespace wrt