#include "content/public/browser/web_contents.h"
#include "content/public/common/main_function_params.h"
#include "content/public/common/show_desktop_notification_params.h"
+#include "net/ssl/ssl_info.h"
#include "net/url_request/url_request_context_getter.h"
#include "xwalk/extensions/common/xwalk_extension_switches.h"
#include "xwalk/runtime/browser/xwalk_browser_main_parts.h"
#endif
#if defined(OS_TIZEN)
+#include "xwalk/application/browser/application_system.h"
+#include "xwalk/application/browser/application_service.h"
+#include "xwalk/application/browser/application.h"
+#include "xwalk/application/common/application_manifest_constants.h"
+#include "xwalk/application/common/manifest_handlers/navigation_handler.h"
+#include "xwalk/application/common/constants.h"
+#include "xwalk/runtime/browser/runtime_platform_util.h"
#include "xwalk/runtime/browser/xwalk_browser_main_parts_tizen.h"
#endif
const net::CookieList& cookie_list,
content::ResourceContext* context,
int render_process_id,
- int render_view_id) {
+ int render_frame_id) {
#if defined(OS_ANDROID)
return XWalkCookieAccessPolicy::GetInstance()->AllowGetCookie(
url,
cookie_list,
context,
render_process_id,
- render_view_id);
+ render_frame_id);
#else
return true;
#endif
const std::string& cookie_line,
content::ResourceContext* context,
int render_process_id,
- int render_view_id,
+ int render_frame_id,
net::CookieOptions* options) {
#if defined(OS_ANDROID)
return XWalkCookieAccessPolicy::GetInstance()->AllowSetCookie(
cookie_line,
context,
render_process_id,
- render_view_id,
+ render_frame_id,
options);
#else
return true;
#endif
}
+void XWalkContentBrowserClient::AllowCertificateError(
+ int render_process_id,
+ int render_frame_id,
+ int cert_error,
+ const net::SSLInfo& ssl_info,
+ const GURL& request_url,
+ ResourceType::Type resource_type,
+ bool overridable,
+ bool strict_enforcement,
+ const base::Callback<void(bool)>& callback,
+ content::CertificateRequestResultType* result) {
+ // Currently only Android handles it.
+ // TODO(yongsheng): applies it for other platforms?
+#if defined(OS_ANDROID)
+ XWalkContentsClientBridgeBase* client =
+ XWalkContentsClientBridgeBase::FromRenderFrameID(render_process_id,
+ render_frame_id);
+ bool cancel_request = true;
+ if (client)
+ client->AllowCertificateError(cert_error,
+ ssl_info.cert.get(),
+ request_url,
+ callback,
+ &cancel_request);
+ if (cancel_request)
+ *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY;
+#endif
+}
+
void XWalkContentBrowserClient::RequestDesktopNotificationPermission(
const GURL& source_origin,
int callback_context,
bool worker) {
#if defined(OS_ANDROID)
XWalkContentsClientBridgeBase* bridge =
- XWalkContentsClientBridgeBase::FromID(render_process_id, render_view_id);
+ XWalkContentsClientBridgeBase::FromRenderViewID(render_process_id,
+ render_view_id);
bridge->ShowNotification(params, worker, render_process_id, render_view_id);
#endif
}
int notification_id) {
#if defined(OS_ANDROID)
XWalkContentsClientBridgeBase* bridge =
- XWalkContentsClientBridgeBase::FromID(render_process_id, render_view_id);
+ XWalkContentsClientBridgeBase::FromRenderViewID(render_process_id,
+ render_view_id);
bridge->CancelNotification(
notification_id, render_process_id, render_view_id);
#endif
}
#if defined(OS_ANDROID)
-void XWalkContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
- const CommandLine& command_line,
- int child_process_id,
- std::vector<content::FileDescriptorInfo>* mappings) {
- int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
- base::FilePath pak_file;
- bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file);
- CHECK(r);
- pak_file = pak_file.Append(FILE_PATH_LITERAL("paks"));
- pak_file = pak_file.Append(FILE_PATH_LITERAL(kXWalkPakFilePath));
-
- base::PlatformFile f =
- base::CreatePlatformFile(pak_file, flags, NULL, NULL);
- if (f == base::kInvalidPlatformFileValue) {
- NOTREACHED() << "Failed to open file when creating renderer process: "
- << "xwalk.pak";
- }
- mappings->push_back(
- content::FileDescriptorInfo(kXWalkPakDescriptor,
- base::FileDescriptor(f, true)));
-}
-
void XWalkContentBrowserClient::ResourceDispatcherHostCreated() {
RuntimeResourceDispatcherHostDelegateAndroid::
ResourceDispatcherHostCreated();
return new xwalk::XWalkSpeechRecognitionManagerDelegate();
}
+#if defined(OS_TIZEN)
+bool XWalkContentBrowserClient::CanCommitURL(
+ content::RenderProcessHost* process_host, const GURL& url) {
+ application::Application* app = xwalk_runner_->app_system()->
+ application_service()->GetApplicationByRenderHostID(
+ process_host->GetID());
+ DCHECK(app);
+ const application::ApplicationData* app_data =app->data();
+ if (!app_data->HasCSPDefined() ||
+ (url.SchemeIs(application::kApplicationScheme) &&
+ url.host() == app_data->ID()))
+ return true;
+
+ application::NavigationInfo* info = static_cast<application::NavigationInfo*>(
+ app_data->GetManifestData(application_widget_keys::kAllowNavigationKey));
+ if (!info || !url.SchemeIsHTTPOrHTTPS()) {
+ LOG(INFO) << "[Block] Navigation link: " << url.spec();
+ // FIXME: Blocked navigation link should be opened in system web browser,
+ // add corresponding code like this:
+ // platform_util::OpenExternal(url);
+ return false;
+ }
+
+ // Check whether the navigation url domain is listed in WGT <allow-navigation>
+ // element, if yes, display it in web application, otherwise block the
+ // request.
+ const std::vector<std::string>& allowed_list = info->GetAllowedDomains();
+ for (std::vector<std::string>::const_iterator it = allowed_list.begin();
+ it != allowed_list.end(); ++it) {
+ if ((*it).find("*.") == 0 &&
+ url.DomainIs((*it).substr(2).c_str())) {
+ LOG(INFO) << "[Allow] Navigation link: " << url.spec();
+ return true;
+ }
+
+ if (url.host() == *it) {
+ LOG(INFO) << "[Allow] Navigation link: " << url.spec();
+ return true;
+ }
+ }
+ LOG(INFO) << "[Block] navigation link: " << url.spec();
+ // FIXME: Should open blocked link in system web browser, need to add:
+ // platform_util::OpenExternal(url);
+ return false;
+}
+#endif
+
} // namespace xwalk