#include "content/public/browser/web_contents.h"
#include "content/public/browser/render_process_host.h"
+#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
#include "xwalk/runtime/browser/ui/native_app_window.h"
+#include "xwalk/runtime/browser/ui/native_app_window_tizen.h"
#include "xwalk/runtime/common/xwalk_common_messages.h"
#if defined(USE_OZONE)
-#include "base/message_loop/message_pump_ozone.h"
#include "content/public/browser/render_view_host.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_codes_posix.h"
+#include "ui/events/platform/platform_event_source.h"
#include "xwalk/application/common/manifest_handlers/tizen_setting_handler.h"
#endif
#include "xwalk/application/common/application_manifest_constants.h"
-#include "xwalk/application/common/manifest_handlers/navigation_handler.h"
namespace xwalk {
namespace application {
-namespace {
-const char kAsterisk[] = "*";
-} // namespace
-
-
ApplicationTizen::ApplicationTizen(
scoped_refptr<ApplicationData> data,
RuntimeContext* runtime_context,
Application::Observer* observer)
: Application(data, runtime_context, observer) {
#if defined(USE_OZONE)
- base::MessagePumpOzone::Current()->AddObserver(this);
+ ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
#endif
}
ApplicationTizen::~ApplicationTizen() {
#if defined(USE_OZONE)
- base::MessagePumpOzone::Current()->RemoveObserver(this);
+ ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
#endif
}
void ApplicationTizen::Hide() {
- DCHECK(runtimes_.size());
+ DCHECK(!runtimes_.empty());
std::set<Runtime*>::iterator it = runtimes_.begin();
for (; it != runtimes_.end(); ++it) {
if ((*it)->window())
}
}
-void ApplicationTizen::InitSecurityPolicy() {
- // On Tizen, CSP mode has higher priority, and WARP will be disabled
- // if the application is under CSP mode.
- if (!data_->HasCSPDefined()) {
- Application::InitSecurityPolicy();
- return;
+bool ApplicationTizen::Launch(const LaunchParams& launch_params) {
+ if (Application::Launch(launch_params)) {
+ DCHECK(render_process_host_);
+ render_process_host_->GetScreenOrientationDispatcherHost()->
+ SetProviderForTests(this);
+ return true;
}
-
- if (data_->GetPackageType() != Package::WGT)
- return;
-
- // Always enable security mode when under CSP mode.
- security_mode_enabled_ = true;
- NavigationInfo* info = static_cast<NavigationInfo*>(
- data_->GetManifestData(widget_keys::kAllowNavigationKey));
- if (info) {
- 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 the policy is "*", it represents that any external link is allowed
- // to navigate to.
- if ((*it) == kAsterisk) {
- security_mode_enabled_ = false;
- return;
- }
-
- // If the policy start with "*.", like this: *.domain,
- // means that can access to all subdomains for 'domain',
- // otherwise, the host of request url should exactly the same
- // as policy.
- bool subdomains = ((*it).find("*.") == 0);
- std::string host = subdomains ? (*it).substr(2) : (*it);
- AddSecurityPolicy(GURL("http://" + host), subdomains);
- AddSecurityPolicy(GURL("https://" + host), subdomains);
- }
- }
- DCHECK(render_process_host_);
- render_process_host_->Send(
- new ViewMsg_EnableSecurityMode(
- ApplicationData::GetBaseURLFromApplicationId(id()),
- SecurityPolicy::CSP));
+ return false;
}
#if defined(USE_OZONE)
-base::EventStatus ApplicationTizen::WillProcessEvent(
- const base::NativeEvent& event) {
- return base::EVENT_CONTINUE;
-}
+void ApplicationTizen::WillProcessEvent(const ui::PlatformEvent& event) {}
void ApplicationTizen::DidProcessEvent(
- const base::NativeEvent& event) {
+ const ui::PlatformEvent& event) {
ui::Event* ui_event = static_cast<ui::Event*>(event);
if (!ui_event->IsKeyEvent() || ui_event->type() != ui::ET_KEY_PRESSED)
return;
}
#endif
+void ApplicationTizen::LockOrientation(
+ blink::WebScreenOrientationLockType lock) {
+ DCHECK(!runtimes_.empty());
+ // FIXME: Probably need better alignment with
+ // https://w3c.github.io/screen-orientation/#screen-orientation-lock-lifetime
+ std::set<Runtime*>::iterator it = runtimes_.begin();
+ for (; it != runtimes_.end(); ++it) {
+ NativeAppWindow* window = (*it)->window();
+ if (window && window->IsActive()) {
+ ToNativeAppWindowTizen(window)->LockOrientation(lock);
+ break;
+ }
+ }
+}
+
+void ApplicationTizen::UnlockOrientation() {
+ LockOrientation(blink::WebScreenOrientationLockDefault);
+}
+
} // namespace application
} // namespace xwalk