2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "runtime/browser/web_application.h"
21 #include <cynara-client.h>
31 #include "common/application_data.h"
32 #include "common/app_db.h"
33 #include "common/app_control.h"
34 #include "common/command_line.h"
35 #include "common/locale_manager.h"
36 #include "common/logger.h"
37 #include "common/profiler.h"
38 #include "common/resource_manager.h"
39 #include "common/string_utils.h"
40 #include "extensions/renderer/xwalk_extension_renderer_controller.h"
41 #include "runtime/browser/native_window.h"
42 #include "runtime/browser/notification_manager.h"
43 #include "runtime/browser/popup.h"
44 #include "runtime/browser/popup_string.h"
45 #include "runtime/browser/vibration_manager.h"
46 #include "runtime/browser/web_view.h"
47 #include "runtime/browser/splash_screen.h"
48 #include "runtime/browser/ui_runtime.h"
49 #include "extensions/common/xwalk_extension_server.h"
51 #ifndef INJECTED_BUNDLE_PATH
52 #error INJECTED_BUNDLE_PATH is not set.
55 #define TIMER_INTERVAL 0.1
57 using namespace extensions;
62 const char* kKeyNameBack = "back";
63 const char* kKeyNameMenu = "menu";
65 const char* kConsoleLogEnableKey = "WRT_CONSOLE_LOG_ENABLE";
66 const char* kConsoleMessageLogTag = "ConsoleMessage";
68 const char* kVerboseKey = "verbose";
69 const char* kPortKey = "port";
71 const char* kAppControlEventScript =
73 "var __event = document.createEvent(\"CustomEvent\");\n"
74 "__event.initCustomEvent(\"appcontrol\", true, true, null);\n"
75 "document.dispatchEvent(__event);\n"
77 "for (var i=0; i < window.frames.length; i++)\n"
78 "{ window.frames[i].document.dispatchEvent(__event); }"
80 const char* kBackKeyEventScript =
82 "var __event = document.createEvent(\"CustomEvent\");\n"
83 "__event.initCustomEvent(\"tizenhwkey\", true, true, null);\n"
84 "__event.keyName = \"back\";\n"
85 "document.dispatchEvent(__event);\n"
87 "for (var i=0; i < window.frames.length; i++)\n"
88 "{ window.frames[i].document.dispatchEvent(__event); }"
90 const char* kMenuKeyEventScript =
92 "var __event = document.createEvent(\"CustomEvent\");\n"
93 "__event.initCustomEvent(\"tizenhwkey\", true, true, null);\n"
94 "__event.keyName = \"menu\";\n"
95 "document.dispatchEvent(__event);\n"
97 "for (var i=0; i < window.frames.length; i++)\n"
98 "{ window.frames[i].document.dispatchEvent(__event); }"
100 const char* kAmbientTickEventScript =
102 "var __event = document.createEvent(\"CustomEvent\");\n"
103 "__event.initCustomEvent(\"timetick\", true, true);\n"
104 "document.dispatchEvent(__event);\n"
106 "for (var i=0; i < window.frames.length; i++)\n"
107 "{ window.frames[i].document.dispatchEvent(__event); }"
109 const char* kCameraPrivilege = "http://tizen.org/privilege/camera";
110 const char* kFullscreenPrivilege = "http://tizen.org/privilege/fullscreen";
111 const char* kFullscreenFeature = "fullscreen";
112 const char* kNotificationPrivilege = "http://tizen.org/privilege/notification";
113 const char* kLocationPrivilege = "http://tizen.org/privilege/location";
114 const char* kRecordPrivilege = "http://tizen.org/privilege/recorder";
115 const char* kStoragePrivilege = "http://tizen.org/privilege/unlimitedstorage";
116 const char* kUsermediaPrivilege = "http://tizen.org/privilege/mediacapture";
117 const char* kNotiIconFile = "noti_icon.png";
118 const char* kFileScheme = "file://";
120 const char* kVisibilitySuspendFeature = "visibility,suspend";
121 const char* kMediastreamRecordFeature = "mediastream,record";
122 const char* kEncryptedDatabaseFeature = "encrypted,database";
123 const char* kRotationLockFeature = "rotation,lock";
124 const char* kBackgroundMusicFeature = "background,music";
125 const char* kSoundModeFeature = "sound,mode";
126 const char* kBackgroundVibrationFeature = "background,vibration";
127 const char* kCSPFeature = "csp";
129 const char* kGeolocationPermissionPrefix = "__WRT_GEOPERM_";
130 const char* kNotificationPermissionPrefix = "__WRT_NOTIPERM_";
131 const char* kQuotaPermissionPrefix = "__WRT_QUOTAPERM_";
132 const char* kCertificateAllowPrefix = "__WRT_CERTIPERM_";
133 const char* kUsermediaPermissionPrefix = "__WRT_USERMEDIAPERM_";
134 const char* kDBPrivateSection = "private";
136 const char* kDefaultCSPRule =
137 "default-src *; script-src 'self'; style-src 'self'; object-src 'none';";
138 const char* kResWgtPath = "res/wgt/";
139 const char* kAppControlMain = "http://tizen.org/appcontrol/operation/main";
141 // Looking for added privilege by Application developer in config.xml.
142 bool FindPrivilegeFromConfig(common::ApplicationData* app_data,
143 const std::string& privilege) {
144 if (app_data->permissions_info().get() == NULL) return false;
145 LOGGER(INFO) << "Finding privilege from config.xml";
146 auto it = app_data->permissions_info()->GetAPIPermissions().begin();
147 auto end = app_data->permissions_info()->GetAPIPermissions().end();
148 for (; it != end; ++it) {
149 if (*it == privilege) return true;
154 // Looking for given default privilege when application installed.
155 bool FindPrivilegeFromCynara(const std::string& privilege_name) {
156 LOGGER(INFO) << "Finding privilege from cynara db";
157 static constexpr char kSmackLabelFilePath[] = "/proc/self/attr/current";
158 std::ifstream file(kSmackLabelFilePath);
159 if (!file.is_open()) {
160 LOGGER(ERROR) << "Failed to open " << kSmackLabelFilePath;
165 cynara* p_cynara = NULL;
166 ret = cynara_initialize(&p_cynara, 0);
167 if (CYNARA_API_SUCCESS != ret) {
168 LOGGER(ERROR) << "Failed. The result of cynara_initialize() : " << ret;
172 std::string uid = std::to_string(getuid());
173 std::string smack_label{std::istreambuf_iterator<char>(file),
174 std::istreambuf_iterator<char>()};
177 ret = cynara_check(p_cynara, smack_label.c_str(), "", uid.c_str(), privilege_name.c_str());
178 if (CYNARA_API_ACCESS_ALLOWED != ret) {
179 LOGGER(ERROR) << "Access denied. The result of cynara_check() : " << ret;
181 LOGGER(INFO) << "Access allowed! The result of cynara_check() : " << ret;
186 ret = cynara_finish(p_cynara);
187 if (CYNARA_API_SUCCESS != ret) {
188 LOGGER(ERROR) << "Failed. The result of cynara_finish() : " << ret;
195 static void SendDownloadRequest(const std::string& url) {
196 common::AppControl request;
197 request.set_operation(APP_CONTROL_OPERATION_DOWNLOAD);
198 request.set_uri(url);
199 request.LaunchRequest();
202 static void InitializeNotificationCallback(Ewk_Context* ewk_context,
203 WebApplication* app) {
204 auto show = [](Ewk_Context*, Ewk_Notification* noti, void* user_data) {
205 WebApplication* self = static_cast<WebApplication*>(user_data);
206 if (self == NULL) return;
207 uint64_t id = ewk_notification_id_get(noti);
208 std::string title(ewk_notification_title_get(noti)
209 ? ewk_notification_title_get(noti)
212 ewk_notification_body_get(noti) ? ewk_notification_body_get(noti) : "");
213 std::string icon_path = self->data_path() + "/" + kNotiIconFile;
214 if (!ewk_notification_icon_save_as_png(noti, icon_path.c_str())) {
217 if (NotificationManager::GetInstance()->Show(id, title, body, icon_path))
218 ewk_notification_showed(id);
220 auto hide = [](Ewk_Context*, uint64_t noti_id, void*) {
221 NotificationManager::GetInstance()->Hide(noti_id);
222 ewk_notification_closed(noti_id, EINA_FALSE);
224 ewk_context_notification_callbacks_set(ewk_context, show, hide, app);
227 static Eina_Bool ExitAppIdlerCallback(void* data) {
228 WebApplication* app = static_cast<WebApplication*>(data);
231 LOGGER(DEBUG) << "Terminate";
235 return ECORE_CALLBACK_CANCEL;
238 static bool ClearCookie(Ewk_Context* ewk_context) {
239 Ewk_Cookie_Manager* cookie_manager =
240 ewk_context_cookie_manager_get(ewk_context);
241 if (!cookie_manager) {
242 LOGGER(ERROR) << "Fail to get cookie manager";
245 ewk_cookie_manager_cookies_clear(cookie_manager);
249 static bool ProcessWellKnownScheme(const std::string& url) {
250 if (common::utils::StartsWith(url, "file:") ||
251 common::utils::StartsWith(url, "app:") ||
252 common::utils::StartsWith(url, "data:") ||
253 common::utils::StartsWith(url, "http:") ||
254 common::utils::StartsWith(url, "https:") ||
255 common::utils::StartsWith(url, "widget:") ||
256 common::utils::StartsWith(url, "about:") ||
257 common::utils::StartsWith(url, "blob:")) {
261 std::unique_ptr<common::AppControl> request(
262 common::AppControl::MakeAppcontrolFromURL(url));
263 if (request.get() == NULL || !request->LaunchRequest()) {
264 LOGGER(ERROR) << "Fail to send appcontrol request";
265 SLoggerE("Fail to send appcontrol request [%s]", url.c_str());
268 // Should return true, to stop the WebEngine progress step about this URL
274 std::vector<unsigned> ParseTizenVersion(const std::string& tizen_string) {
275 std::vector<unsigned> version(3, 0);
276 for (unsigned i = 0, index = 0; i < tizen_string.size(); i++) {
278 if (isdigit(tizen_string[i]) && index < version.size())
279 version[index++] = atoi(&tizen_string[i]);
281 return std::vector<unsigned>(3, 0);
282 } else if (tizen_string[i] != '.')
283 return std::vector<unsigned>(3, 0);
288 WebApplication::WebApplication(
289 NativeWindow* window,
290 common::ApplicationData* app_data)
293 verbose_mode_(false),
294 lang_changed_mode_(false),
295 is_terminate_called_(false),
297 ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH)),
298 has_ownership_of_ewk_context_(true),
300 appid_(app_data->app_id()),
302 locale_manager_(new common::LocaleManager()),
307 WebApplication::WebApplication(
308 NativeWindow* window,
309 common::ApplicationData* app_data,
310 Ewk_Context* context)
313 verbose_mode_(false),
314 is_terminate_called_(false),
315 ewk_context_(context),
316 has_ownership_of_ewk_context_(false),
318 appid_(app_data->app_id()),
320 locale_manager_(new common::LocaleManager()),
325 WebApplication::~WebApplication() {
326 window_->SetContent(NULL);
327 auto it = view_stack_.begin();
328 for (; it != view_stack_.end(); ++it) {
333 if (ewk_context_ && has_ownership_of_ewk_context_)
334 ewk_context_delete(ewk_context_);
337 bool WebApplication::Initialize() {
339 std::unique_ptr<char, decltype(std::free)*> path{app_get_data_path(),
341 app_data_path_ = path.get();
343 if (app_data_->setting_info() != NULL &&
344 app_data_->setting_info()->screen_orientation() ==
345 wgt::parse::SettingInfo::ScreenOrientation::AUTO) {
346 ewk_context_tizen_extensible_api_string_set(ewk_context_,
347 kRotationLockFeature, true);
348 window_->SetAutoRotation();
349 } else if (app_data_->setting_info() != NULL &&
350 app_data_->setting_info()->screen_orientation() ==
351 wgt::parse::SettingInfo::ScreenOrientation::PORTRAIT) {
352 window_->SetRotationLock(NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY);
353 } else if (app_data_->setting_info() != NULL &&
354 app_data_->setting_info()->screen_orientation() ==
355 wgt::parse::SettingInfo::ScreenOrientation::LANDSCAPE) {
356 window_->SetRotationLock(
357 NativeWindow::ScreenOrientation::LANDSCAPE_PRIMARY);
360 splash_screen_.reset(new SplashScreen(
361 window_, app_data_->splash_screen_info(), app_data_->application_path()));
362 resource_manager_.reset(
363 new common::ResourceManager(app_data_, locale_manager_.get()));
364 resource_manager_->set_base_resource_path(app_data_->application_path());
366 auto extension_server = extensions::XWalkExtensionServer::GetInstance();
367 extension_server->SetupIPC(ewk_context_);
370 ewk_context_cache_model_set(ewk_context_, EWK_CACHE_MODEL_DOCUMENT_BROWSER);
373 auto cookie_manager = ewk_context_cookie_manager_get(ewk_context_);
374 ewk_cookie_manager_accept_policy_set(cookie_manager,
375 EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
377 // set persistent storage path
378 std::string cookie_path = data_path() + ".cookie";
379 ewk_cookie_manager_persistent_storage_set(
380 cookie_manager, cookie_path.c_str(),
381 EWK_COOKIE_PERSISTENT_STORAGE_SQLITE);
383 // vibration callback
384 auto vibration_start_callback = [](uint64_t ms, void*) {
385 platform::VibrationManager::GetInstance()->Start(static_cast<int>(ms));
387 auto vibration_stop_callback = [](void* /*user_data*/) {
388 platform::VibrationManager::GetInstance()->Stop();
390 ewk_context_vibration_client_callbacks_set(
391 ewk_context_, vibration_start_callback, vibration_stop_callback, NULL);
393 auto download_callback = [](const char* downloadUrl, void* /*data*/) {
394 SendDownloadRequest(downloadUrl);
396 ewk_context_did_start_download_callback_set(ewk_context_, download_callback,
398 InitializeNotificationCallback(ewk_context_, this);
400 if (FindPrivilegeFromConfig(app_data_, kFullscreenPrivilege)) {
401 ewk_context_tizen_extensible_api_string_set(ewk_context_,
402 kFullscreenFeature, true);
405 if (app_data_->setting_info() != NULL &&
406 app_data_->setting_info()->background_support_enabled()) {
407 ewk_context_tizen_extensible_api_string_set(
408 ewk_context_, kVisibilitySuspendFeature, true);
409 ewk_context_tizen_extensible_api_string_set(ewk_context_,
410 kBackgroundMusicFeature, true);
412 ewk_context_tizen_extensible_api_string_set(
413 ewk_context_, kVisibilitySuspendFeature, false);
414 ewk_context_tizen_extensible_api_string_set(ewk_context_,
415 kBackgroundMusicFeature, false);
417 ewk_context_tizen_extensible_api_string_set(ewk_context_,
418 kMediastreamRecordFeature, true);
419 ewk_context_tizen_extensible_api_string_set(ewk_context_,
420 kEncryptedDatabaseFeature, true);
422 if (app_data_->setting_info() != NULL &&
423 app_data_->setting_info()->sound_mode() ==
424 wgt::parse::SettingInfo::SoundMode::EXCLUSIVE) {
425 ewk_context_tizen_extensible_api_string_set(ewk_context_, kSoundModeFeature,
429 if (app_data_->setting_info() != NULL &&
430 app_data_->setting_info()->background_vibration()) {
431 ewk_context_tizen_extensible_api_string_set(
432 ewk_context_, kBackgroundVibrationFeature, true);
435 if (app_data_->widget_info() != NULL &&
436 !app_data_->widget_info()->default_locale().empty()) {
437 locale_manager_->SetDefaultLocale(
438 app_data_->widget_info()->default_locale());
441 if (app_data_->widget_info() != NULL &&
442 app_data_->widget_info()->view_modes() == "fullscreen") {
443 window_->SetCurrentViewModeFullScreen(true);
444 window_->FullScreen(true);
447 if (app_data_->csp_info() != NULL || app_data_->csp_report_info() != NULL ||
448 app_data_->allowed_navigation_info() != NULL) {
449 security_model_version_ = 2;
450 if (app_data_->csp_info() == NULL ||
451 app_data_->csp_info()->security_rules().empty()) {
452 csp_rule_ = kDefaultCSPRule;
454 csp_rule_ = app_data_->csp_info()->security_rules();
456 if (app_data_->csp_report_info() != NULL &&
457 !app_data_->csp_report_info()->security_rules().empty()) {
458 csp_report_rule_ = app_data_->csp_report_info()->security_rules();
460 ewk_context_tizen_extensible_api_string_set(ewk_context_, kCSPFeature,
463 security_model_version_ = 1;
466 #ifdef MANUAL_ROTATE_FEATURE_SUPPORT
467 // Set manual rotation
468 window_->EnableManualRotation(true);
469 #endif // MANUAL_ROTATE_FEATURE_SUPPORT
474 void WebApplication::SetupTizenVersion() {
475 if (app_data_->tizen_application_info() != NULL &&
476 !app_data_->tizen_application_info()->required_version().empty()) {
477 std::string tizen_version = app_data_->tizen_application_info()->required_version();
478 std::vector<unsigned> parsed_tizen_version = ParseTizenVersion(tizen_version);
479 m_tizenCompatibilitySettings.m_major = parsed_tizen_version[0];
480 m_tizenCompatibilitySettings.m_minor = parsed_tizen_version[1];
481 m_tizenCompatibilitySettings.m_release = parsed_tizen_version[2];
485 bool WebApplication::tizenWebKitCompatibilityEnabled() const {
486 return m_tizenCompatibilitySettings.tizenWebKitCompatibilityEnabled();
489 void WebApplication::Launch(std::unique_ptr<common::AppControl> appcontrol) {
490 // send widget info to injected bundle
491 ewk_context_tizen_app_id_set(ewk_context_, appid_.c_str());
496 WebView* view = new WebView(window_, ewk_context_);
498 SetupWebViewCompatibilitySettings(view);
500 std::unique_ptr<common::ResourceManager::Resource> res =
501 resource_manager_->GetStartResource(appcontrol.get());
502 view->SetDefaultEncoding(res->encoding());
504 STEP_PROFILE_END("OnCreate -> URL Set");
505 STEP_PROFILE_START("URL Set -> Rendered");
507 window_->SetContent(view->evas_object());
509 #ifdef PROFILE_MOBILE
510 // rotate and resize window forcibily for landscape mode.
511 // window rotate event is generated after window show. so
512 // when app get width and height from viewport, wrong value can be returned.
513 if (app_data_->setting_info()->screen_orientation() ==
514 wgt::parse::SettingInfo::ScreenOrientation::LANDSCAPE) {
515 LOGGER(DEBUG) << "rotate and resize window for landscape mode";
516 elm_win_rotation_with_resize_set(window_->evas_object(), 270);
517 evas_norender(evas_object_evas_get(window_->evas_object()));
519 #endif // PROFILE_MOBILE
521 view->LoadUrl(res->uri(), res->mime());
522 view_stack_.push_front(view);
524 #ifdef PROFILE_WEARABLE
525 // ewk_view_bg_color_set is not working at webview initialization.
526 if (app_data_->app_type() == common::ApplicationData::WATCH) {
527 view->SetBGColor(0, 0, 0, 255);
529 #endif // PROFILE_WEARABLE
531 if (appcontrol->data(AUL_K_DEBUG) == "1") {
533 LaunchInspector(appcontrol.get());
535 if (appcontrol->data(kVerboseKey) == "true") {
536 verbose_mode_ = true;
541 #ifdef PROFILE_MOBILE
542 if (!common::utils::StartsWith(view->GetUrl(), kFileScheme)) {
543 LOGGER(DEBUG) << "Show window after launch for remote URL";
547 #endif // PROFILE_MOBILE
550 void WebApplication::AppControl(
551 std::unique_ptr<common::AppControl> appcontrol) {
552 std::unique_ptr<common::ResourceManager::Resource> res =
553 resource_manager_->GetStartResource(appcontrol.get());
555 bool do_reset = res->should_reset();
558 std::string current_page = view_stack_.front()->GetUrl();
559 std::string localized_page = res->uri();
561 if (current_page != localized_page) {
564 SendAppControlEvent();
568 // handle http://tizen.org/appcontrol/operation/main operation specially.
569 // only menu-screen app can send launch request with main operation.
570 // in this case, web app should have to resume web app not reset.
571 if (do_reset && (appcontrol->operation() == kAppControlMain)){
572 LOGGER(DEBUG) << "resume app for main operation";
574 SendAppControlEvent();
580 WebView* view = view_stack_.front();
582 SetupWebViewCompatibilitySettings(view);
583 view->SetDefaultEncoding(res->encoding());
584 view->LoadUrl(res->uri(), res->mime());
585 window_->SetContent(view->evas_object());
588 if (!debug_mode_ && appcontrol->data(AUL_K_DEBUG) == "1") {
590 LaunchInspector(appcontrol.get());
592 if (!verbose_mode_ && appcontrol->data(kVerboseKey) == "true") {
593 verbose_mode_ = true;
598 void WebApplication::SendAppControlEvent() {
599 if (view_stack_.size() > 0 && view_stack_.front() != NULL)
600 view_stack_.front()->EvalJavascript(kAppControlEventScript);
603 void WebApplication::ClearViewStack() {
604 window_->SetContent(NULL);
605 WebView* front = view_stack_.front();
606 auto it = view_stack_.begin();
607 for (; it != view_stack_.end(); ++it) {
614 view_stack_.push_front(front);
617 void WebApplication::Resume() {
618 if (view_stack_.size() > 0 && view_stack_.front() != NULL)
619 view_stack_.front()->SetVisibility(true);
621 if (app_data_->setting_info() != NULL &&
622 app_data_->setting_info()->background_support_enabled()) {
626 auto it = view_stack_.begin();
627 for (; it != view_stack_.end(); ++it) {
632 void WebApplication::Suspend() {
633 if (view_stack_.size() > 0 && view_stack_.front() != NULL)
634 view_stack_.front()->SetVisibility(false);
636 if (app_data_->setting_info() != NULL &&
637 app_data_->setting_info()->background_support_enabled()) {
638 LOGGER(DEBUG) << "gone background (backgroud support enabed)";
642 auto it = view_stack_.begin();
643 for (; it != view_stack_.end(); ++it) {
648 void WebApplication::Terminate() {
649 is_terminate_called_ = true;
651 LOGGER(DEBUG) << "terminator_";
654 LOGGER(ERROR) << "There's no registered terminator.";
657 auto extension_server = extensions::XWalkExtensionServer::GetInstance();
658 LOGGER(DEBUG) << "Shutdown extension server";
659 extension_server->Shutdown();
662 void WebApplication::ClosePageFromOnTerminate() {
664 auto it = view_stack_.begin();
665 if (it != view_stack_.end()) {
666 runtime::Runtime::is_on_terminate_called = true;
667 for (; it != view_stack_.end(); ++it) {
668 (*it)->ReplyToJavascriptDialog();
669 view_stack_.front()->SetVisibility(false);
670 LOGGER(DEBUG) << "ewk_view_page_close";
671 ewk_view_page_close((*it)->evas_object());
676 void WebApplication::OnCreatedNewWebView(WebView* /*view*/, WebView* new_view) {
677 if (view_stack_.size() > 0 && view_stack_.front() != NULL)
678 view_stack_.front()->SetVisibility(false);
680 SetupWebView(new_view);
681 SetupWebViewCompatibilitySettings(new_view);
682 view_stack_.push_front(new_view);
683 window_->SetContent(new_view->evas_object());
686 void WebApplication::RemoveWebViewFromStack(WebView* view) {
687 if (view_stack_.size() == 0)
690 WebView* current = view_stack_.front();
691 if (current == view) {
692 // In order to prevent the crash issue due to the callback
693 // which occur after destroying WebApplication class,
694 // we have to set the 'SetEventListener' to NULL.
695 view->SetEventListener(NULL);
696 view_stack_.pop_front();
698 auto found = std::find(view_stack_.begin(), view_stack_.end(), view);
699 if (found != view_stack_.end()) {
700 // In order to prevent the crash issue due to the callback
701 // which occur after destroying WebApplication class,
702 // we have to set the 'SetEventListener' to NULL.
703 view->SetEventListener(NULL);
704 view_stack_.erase(found);
708 if (view_stack_.size() == 0) {
709 // If |Terminate()| hasn't been called,
710 // main loop shouldn't be terminated here.
711 if (!is_terminate_called_) {
712 auto extension_server = XWalkExtensionServer::GetInstance();
713 LOGGER(DEBUG) << "Shutdown extension server";
714 extension_server->Shutdown();
716 } else if (current != view_stack_.front()) {
717 view_stack_.front()->SetVisibility(true);
718 window_->SetContent(view_stack_.front()->evas_object());
721 // Delete after the callback context(for ewk view) was not used
722 ecore_idler_add([](void* view) {
723 WebView* obj = static_cast<WebView*>(view);
730 Eina_Bool WebApplication::CheckPluginSession(void* user_data)
732 WebApplication* that = static_cast<WebApplication*>(user_data);
733 if(XWalkExtensionRendererController::plugin_session_count > 0) {
734 LOGGER(ERROR) << "plugin_session_count : " <<
735 XWalkExtensionRendererController::plugin_session_count;
736 return ECORE_CALLBACK_RENEW;
738 LOGGER(DEBUG) << "plugin_session_count : " <<
739 XWalkExtensionRendererController::plugin_session_count;
740 LOGGER(DEBUG) << "Execute deferred termination of main loop";
741 if (that->is_terminate_called_) {
742 ecore_main_loop_quit();
744 if (that->terminator_) {
745 LOGGER(DEBUG) << "terminator_";
748 LOGGER(ERROR) << "There's no registered terminator.";
752 return ECORE_CALLBACK_CANCEL;
755 void WebApplication::OnClosedWebView(WebView* view) {
756 Ecore_Timer* timeout_id = NULL;
757 // Reply to javascript dialog for preventing freeze issue.
758 view->ReplyToJavascriptDialog();
759 RemoveWebViewFromStack(view);
761 LOGGER(DEBUG) << "plugin_session_count : " <<
762 XWalkExtensionRendererController::plugin_session_count;
763 if (XWalkExtensionRendererController::plugin_session_count > 0) {
764 timeout_id = ecore_timer_add(TIMER_INTERVAL, CheckPluginSession, this);
766 LOGGER(ERROR) << "It's failed to create timer";
770 void WebApplication::OnReceivedWrtMessage(WebView* view,
771 Ewk_IPC_Wrt_Message_Data* msg) {
772 Eina_Stringshare* msg_type = ewk_ipc_wrt_message_data_type_get(msg);
774 #define TYPE_BEGIN(x) (!strncmp(msg_type, x, strlen(x)))
775 #define TYPE_IS(x) (!strcmp(msg_type, x))
777 if (TYPE_BEGIN("xwalk://")) {
778 auto extension_server = extensions::XWalkExtensionServer::GetInstance();
779 extension_server->HandleIPCMessage(msg);
781 Eina_Stringshare* msg_id = ewk_ipc_wrt_message_data_id_get(msg);
782 Eina_Stringshare* msg_ref_id =
783 ewk_ipc_wrt_message_data_reference_id_get(msg);
784 Eina_Stringshare* msg_value = ewk_ipc_wrt_message_data_value_get(msg);
786 if (TYPE_IS("tizen://hide")) {
789 } else if (TYPE_IS("tizen://exit")) {
791 // Reply to javascript dialog for preventing freeze issue.
792 view->ReplyToJavascriptDialog();
793 ecore_idler_add(ExitAppIdlerCallback, this);
794 } else if (TYPE_IS("tizen://changeUA")) {
796 // Change UserAgent of current WebView
798 if (view_stack_.size() > 0 && view_stack_.front() != NULL) {
799 ret = view_stack_.front()->SetUserAgent(std::string(msg_value));
802 Ewk_IPC_Wrt_Message_Data* ans = ewk_ipc_wrt_message_data_new();
803 ewk_ipc_wrt_message_data_type_set(ans, msg_type);
804 ewk_ipc_wrt_message_data_reference_id_set(ans, msg_id);
806 ewk_ipc_wrt_message_data_value_set(ans, "success");
808 ewk_ipc_wrt_message_data_value_set(ans, "failed");
809 if (!ewk_ipc_wrt_message_send(ewk_context_, ans)) {
810 LOGGER(ERROR) << "Failed to send response";
812 ewk_ipc_wrt_message_data_del(ans);
813 } else if (TYPE_IS("tizen://deleteAllCookies")) {
814 Ewk_IPC_Wrt_Message_Data* ans = ewk_ipc_wrt_message_data_new();
815 ewk_ipc_wrt_message_data_type_set(ans, msg_type);
816 ewk_ipc_wrt_message_data_reference_id_set(ans, msg_id);
817 if (ClearCookie(ewk_context_))
818 ewk_ipc_wrt_message_data_value_set(ans, "success");
820 ewk_ipc_wrt_message_data_value_set(ans, "failed");
821 if (!ewk_ipc_wrt_message_send(ewk_context_, ans)) {
822 LOGGER(ERROR) << "Failed to send response";
824 ewk_ipc_wrt_message_data_del(ans);
825 } else if (TYPE_IS("tizen://hide_splash_screen")) {
826 splash_screen_->HideSplashScreen(SplashScreen::HideReason::CUSTOM);
829 eina_stringshare_del(msg_ref_id);
830 eina_stringshare_del(msg_id);
831 eina_stringshare_del(msg_value);
837 eina_stringshare_del(msg_type);
840 void WebApplication::OnOrientationLock(
841 WebView* view, bool lock,
842 NativeWindow::ScreenOrientation preferred_rotation) {
843 if (view_stack_.size() == 0) return;
845 // Only top-most view can set the orientation relate operation
846 if (view_stack_.front() != view) return;
848 // This is for 2.4 compatibility. Requested by Webengine Team.
850 // In Tizen 2.4 WebKit locking screen orientation was possible with Web API
851 // screen.lockOrientation(). This API was deprecated and replaced with
852 // screen.orientation.lock(). But for compatibility case we need to support
854 if(!tizenWebKitCompatibilityEnabled()) {
855 auto orientaion_setting = app_data_->setting_info() != NULL
856 ? app_data_->setting_info()->screen_orientation()
857 : wgt::parse::SettingInfo::ScreenOrientation::AUTO;
858 if (wgt::parse::SettingInfo::ScreenOrientation::AUTO != orientaion_setting) {
859 // If Tizen version is 3.0, it return.
865 window_->SetRotationLock(preferred_rotation);
867 window_->SetAutoRotation();
871 void WebApplication::OnHardwareKey(WebView* view, const std::string& keyname) {
872 // NOTE: This code is added to enable back-key on remote URL
873 bool enabled = app_data_->setting_info() != NULL
874 ? app_data_->setting_info()->hwkey_enabled()
877 if (!common::utils::StartsWith(view->GetUrl(), kFileScheme)) {
878 if (kKeyNameBack == keyname) {
879 LOGGER(DEBUG) << "Back to previous page for remote URL";
881 view->EvalJavascript(kBackKeyEventScript);
882 if (!view->Backward()) {
883 LOGGER(DEBUG) << "Terminate";
890 if (enabled && kKeyNameBack == keyname) {
891 view->EvalJavascript(kBackKeyEventScript);
892 // NOTE: This code is added for backward compatibility.
893 // If the 'backbutton_presence' is true, WebView should be navigated back.
894 if ((app_data_->setting_info() != NULL &&
895 app_data_->setting_info()->backbutton_presence()) ||
896 (app_data_->widget_info() != NULL &&
897 app_data_->widget_info()->view_modes() == "windowed")) {
898 if (!view->Backward()) {
899 LOGGER(DEBUG) << "Terminate";
903 } else if (enabled && kKeyNameMenu == keyname) {
904 view->EvalJavascript(kMenuKeyEventScript);
908 void WebApplication::OnLanguageChanged() {
909 lang_changed_mode_ = true;
910 locale_manager_->UpdateSystemLocale();
911 ewk_context_cache_clear(ewk_context_);
912 auto it = view_stack_.begin();
913 for (; it != view_stack_.end(); ++it) {
918 void WebApplication::OnConsoleMessage(const std::string& msg, int level) {
919 static bool enabled = (getenv(kConsoleLogEnableKey) != NULL);
922 std::string split_msg = msg;
923 std::size_t pos = msg.find(kResWgtPath);
924 if (pos != std::string::npos) {
925 split_msg = msg.substr(pos + strlen(kResWgtPath));
928 if (debug_mode_ || verbose_mode_ || enabled) {
929 int dlog_level = DLOG_DEBUG;
931 case EWK_CONSOLE_MESSAGE_LEVEL_WARNING:
932 dlog_level = DLOG_WARN;
934 case EWK_CONSOLE_MESSAGE_LEVEL_ERROR:
935 dlog_level = DLOG_ERROR;
938 dlog_level = DLOG_DEBUG;
941 LOGGER_RAW(dlog_level, kConsoleMessageLogTag)
942 << "[" << app_data_->pkg_id() << "] " << split_msg;
946 void WebApplication::OnLowMemory() {
947 ewk_context_cache_clear(ewk_context_);
948 ewk_context_notify_low_memory(ewk_context_);
951 void WebApplication::OnSoftKeyboardChangeEvent(WebView* /*view*/,
952 SoftKeyboardChangeEventValue softkeyboard_value) {
953 LOGGER(DEBUG) << "OnSoftKeyboardChangeEvent";
954 std::stringstream script;
957 << "var __event = document.createEvent(\"CustomEvent\");\n"
958 << "var __detail = {};\n"
959 << "__event.initCustomEvent(\"softkeyboardchange\",true,true,__detail);\n"
960 << "__event.state = \"" << softkeyboard_value.state << "\";\n"
961 << "__event.width = " << softkeyboard_value.width << ";\n"
962 << "__event.height = " << softkeyboard_value.height << ";\n"
963 << "document.dispatchEvent(__event);\n"
965 << "for (var i=0; i < window.frames.length; i++)\n"
966 << "{ window.frames[i].document.dispatchEvent(__event); }"
968 std::string kSoftKeyboardScript = script.str();
969 if (view_stack_.size() > 0 && view_stack_.front() != NULL)
970 view_stack_.front()->EvalJavascript(kSoftKeyboardScript.c_str());
973 #ifdef ROTARY_EVENT_FEATURE_SUPPORT
974 void WebApplication::OnRotaryEvent(WebView* /*view*/,
975 RotaryEventType type) {
976 LOGGER(DEBUG) << "OnRotaryEvent";
977 std::stringstream script;
980 << "var __event = document.createEvent(\"CustomEvent\");\n"
981 << "var __detail = {};\n"
982 << "__event.initCustomEvent(\"rotarydetent\", true, true, __detail);\n"
983 << "__event.detail.direction = \""
984 << (type == RotaryEventType::CLOCKWISE ? "CW" : "CCW")
986 << "document.dispatchEvent(__event);\n"
988 << "for (var i=0; i < window.frames.length; i++)\n"
989 << "{ window.frames[i].document.dispatchEvent(__event); }"
991 std::string kRotaryEventScript = script.str();
992 if (view_stack_.size() > 0 && view_stack_.front() != NULL)
993 view_stack_.front()->EvalJavascript(kRotaryEventScript.c_str());
995 #endif // ROTARY_EVENT_FEATURE_SUPPORT
997 void WebApplication::OnTimeTick(long time) {
999 LOGGER(DEBUG) << "TimeTick";
1000 if (view_stack_.size() > 0 && view_stack_.front() != NULL)
1001 view_stack_.front()->EvalJavascript(kAmbientTickEventScript);
1005 void WebApplication::OnAmbientTick(long time) {
1006 LOGGER(DEBUG) << "AmbientTick";
1007 if (view_stack_.size() > 0 && view_stack_.front() != NULL)
1008 view_stack_.front()->EvalJavascript(kAmbientTickEventScript);
1011 void WebApplication::OnAmbientChanged(bool ambient_mode) {
1012 LOGGER(DEBUG) << "AmbientChanged";
1013 std::stringstream script;
1016 << "var __event = document.createEvent(\"CustomEvent\");\n"
1017 << "var __detail = {};\n"
1018 << "__event.initCustomEvent(\"ambientmodechanged\",true,true,__detail);\n"
1019 << "__event.detail.ambientMode = "
1020 << (ambient_mode ? "true" : "false") << ";\n"
1021 << "document.dispatchEvent(__event);\n"
1023 << "for (var i=0; i < window.frames.length; i++)\n"
1024 << "{ window.frames[i].document.dispatchEvent(__event); }"
1026 std::string kAmbientChangedEventScript = script.str();
1027 if (view_stack_.size() > 0 && view_stack_.front() != NULL)
1028 view_stack_.front()->EvalJavascript(kAmbientChangedEventScript.c_str());
1031 bool WebApplication::OnContextMenuDisabled(WebView* /*view*/) {
1032 return !(app_data_->setting_info() != NULL
1033 ? app_data_->setting_info()->context_menu_enabled()
1037 void WebApplication::OnLoadStart(WebView* /*view*/) {
1038 LOGGER(DEBUG) << "LoadStart";
1041 void WebApplication::OnLoadFinished(WebView* /*view*/) {
1042 LOGGER(DEBUG) << "LoadFinished";
1043 splash_screen_->HideSplashScreen(SplashScreen::HideReason::LOADFINISHED);
1046 void WebApplication::OnRendered(WebView* view) {
1047 STEP_PROFILE_END("URL Set -> Rendered");
1048 STEP_PROFILE_END("Start -> Launch Completed");
1049 LOGGER(DEBUG) << "Rendered";
1050 splash_screen_->HideSplashScreen(SplashScreen::HideReason::RENDERED);
1052 // Do not show(), active() for language change
1053 if(lang_changed_mode_ == false){
1054 // Show window after frame rendered.
1055 #ifdef PROFILE_MOBILE
1056 if (common::utils::StartsWith(view->GetUrl(), kFileScheme)) {
1060 #else // PROFILE_MOBILE
1066 lang_changed_mode_ = false;
1070 #ifdef MANUAL_ROTATE_FEATURE_SUPPORT
1071 void WebApplication::OnRotatePrepared(WebView* /*view*/) {
1072 window_->ManualRotationDone();
1074 #endif // MANUAL_ROTATE_FEATURE_SUPPORT
1076 void WebApplication::LaunchInspector(common::AppControl* appcontrol) {
1077 unsigned int port = ewk_context_inspector_server_start(ewk_context_, 0);
1078 std::stringstream ss;
1080 std::map<std::string, std::vector<std::string>> data;
1081 data[kPortKey] = {ss.str()};
1082 appcontrol->Reply(data);
1085 void WebApplication::SetupWebView(WebView* view) {
1086 view->SetEventListener(this);
1089 if (security_model_version_ == 2) {
1090 view->SetCSPRule(csp_rule_, false);
1091 if (!csp_report_rule_.empty()) {
1092 view->SetCSPRule(csp_report_rule_, true);
1096 // Setup longpolling value
1097 if (app_data_->setting_info() != NULL &&
1098 app_data_->setting_info()->long_polling()) {
1099 boost::optional <unsigned int> polling_val(app_data_->setting_info()->long_polling());
1100 unsigned long *ptr = reinterpret_cast <unsigned long *> (&polling_val.get());
1101 view->SetLongPolling(*ptr);
1105 void WebApplication::SetupWebViewCompatibilitySettings(WebView* view) {
1106 if (tizenWebKitCompatibilityEnabled()) {
1107 Ewk_Settings* settings = ewk_view_settings_get(view->evas_object());
1108 ewk_settings_tizen_compatibility_mode_set(settings,
1109 m_tizenCompatibilitySettings.m_major,
1110 m_tizenCompatibilitySettings.m_minor,
1111 m_tizenCompatibilitySettings.m_release);
1112 ewk_settings_text_autosizing_enabled_set(settings, EINA_FALSE);
1116 bool WebApplication::OnDidNavigation(WebView* /*view*/,
1117 const std::string& url) {
1119 // except(file , http, https, app) pass to appcontrol and return false
1120 if (ProcessWellKnownScheme(url)) {
1124 // send launch request for blocked URL to guarrenty backward-compatibility.
1125 if (resource_manager_->AllowNavigation(url)) {
1128 LOGGER(DEBUG) << "URL is blocked. send launch request for URL : " << url;
1129 std::unique_ptr<common::AppControl> request(
1130 common::AppControl::MakeAppcontrolFromURL(url));
1131 if (request.get() == NULL || !request->LaunchRequest()) {
1132 LOGGER(ERROR) << "Fail to send appcontrol request";
1138 void WebApplication::OnNotificationPermissionRequest(
1139 WebView*, const std::string& url,
1140 std::function<void(bool)> result_handler) {
1141 auto db = common::AppDB::GetInstance();
1142 std::string reminder =
1143 db->Get(kDBPrivateSection, kNotificationPermissionPrefix + url);
1144 if (reminder == "allowed") {
1145 result_handler(true);
1147 } else if (reminder == "denied") {
1148 result_handler(false);
1152 // Local Domain: Grant permission if defined, otherwise Popup user prompt.
1153 // Remote Domain: Popup user prompt.
1154 if (common::utils::StartsWith(url, "file://") &&
1155 FindPrivilegeFromConfig(app_data_, kNotificationPrivilege)) {
1156 result_handler(true);
1160 Popup* popup = Popup::CreatePopup(window_);
1161 popup->SetButtonType(Popup::ButtonType::AllowDenyButton);
1162 popup->SetTitle(popup_string::kPopupTitleWebNotification);
1163 popup->SetBody(popup_string::kPopupBodyWebNotification);
1164 popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
1165 popup->SetResultHandler(
1166 [db, result_handler, url](Popup* popup, void* /*user_data*/) {
1167 bool result = popup->GetButtonResult();
1168 bool remember = popup->GetCheckBoxResult();
1170 db->Set(kDBPrivateSection, kNotificationPermissionPrefix + url,
1171 result ? "allowed" : "denied");
1173 result_handler(result);
1179 void WebApplication::OnGeolocationPermissionRequest(
1180 WebView*, const std::string& url,
1181 std::function<void(bool)> result_handler) {
1182 auto db = common::AppDB::GetInstance();
1183 std::string reminder =
1184 db->Get(kDBPrivateSection, kGeolocationPermissionPrefix + url);
1185 if (reminder == "allowed") {
1186 result_handler(true);
1188 } else if (reminder == "denied") {
1189 result_handler(false);
1193 // Local Domain: Grant permission if defined, otherwise block execution.
1194 // Remote Domain: Popup user prompt if defined, otherwise block execution.
1195 if (!FindPrivilegeFromConfig(app_data_, kLocationPrivilege) &&
1196 !FindPrivilegeFromCynara(kLocationPrivilege)) {
1197 result_handler(false);
1201 if (common::utils::StartsWith(url, "file://")) {
1202 result_handler(true);
1206 Popup* popup = Popup::CreatePopup(window_);
1207 popup->SetButtonType(Popup::ButtonType::AllowDenyButton);
1208 popup->SetTitle(popup_string::kPopupTitleGeoLocation);
1209 popup->SetBody(popup_string::kPopupBodyGeoLocation);
1210 popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
1211 popup->SetResultHandler(
1212 [db, result_handler, url](Popup* popup, void* /*user_data*/) {
1213 bool result = popup->GetButtonResult();
1214 bool remember = popup->GetCheckBoxResult();
1216 db->Set(kDBPrivateSection, kGeolocationPermissionPrefix + url,
1217 result ? "allowed" : "denied");
1219 result_handler(result);
1225 void WebApplication::OnQuotaExceed(WebView*, const std::string& url,
1226 std::function<void(bool)> result_handler) {
1227 auto db = common::AppDB::GetInstance();
1228 std::string reminder =
1229 db->Get(kDBPrivateSection, kQuotaPermissionPrefix + url);
1230 if (reminder == "allowed") {
1231 result_handler(true);
1233 } else if (reminder == "denied") {
1234 result_handler(false);
1238 // Local Domain: Grant permission if defined, otherwise Popup user prompt.
1239 // Remote Domain: Popup user prompt.
1240 if (common::utils::StartsWith(url, "file://") &&
1241 FindPrivilegeFromConfig(app_data_, kStoragePrivilege)) {
1242 result_handler(true);
1246 Popup* popup = Popup::CreatePopup(window_);
1247 popup->SetButtonType(Popup::ButtonType::AllowDenyButton);
1248 popup->SetTitle(popup_string::kPopupTitleWebStorage);
1249 popup->SetBody(popup_string::kPopupBodyWebStorage);
1250 popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
1251 popup->SetResultHandler(
1252 [db, result_handler, url](Popup* popup, void* /*user_data*/) {
1253 bool result = popup->GetButtonResult();
1254 bool remember = popup->GetCheckBoxResult();
1256 db->Set(kDBPrivateSection, kQuotaPermissionPrefix + url,
1257 result ? "allowed" : "denied");
1259 result_handler(result);
1265 void WebApplication::OnAuthenticationRequest(
1266 WebView*, const std::string& /*url*/, const std::string& /*message*/,
1267 std::function<void(bool submit, const std::string& id,
1268 const std::string& password)> result_handler) {
1269 Popup* popup = Popup::CreatePopup(window_);
1270 popup->SetButtonType(Popup::ButtonType::LoginCancelButton);
1271 popup->SetFirstEntry(popup_string::kPopupLabelAuthusername,
1272 Popup::EntryType::Edit);
1273 popup->SetSecondEntry(popup_string::kPopupLabelPassword,
1274 Popup::EntryType::PwEdit);
1275 popup->SetTitle(popup_string::kPopupTitleAuthRequest);
1276 popup->SetBody(popup_string::kPopupBodyAuthRequest);
1277 popup->SetResultHandler([result_handler](Popup* popup, void* /*user_data*/) {
1278 bool result = popup->GetButtonResult();
1279 std::string id = popup->GetFirstEntryResult();
1280 std::string passwd = popup->GetSecondEntryResult();
1281 result_handler(result, id, passwd);
1287 void WebApplication::OnCertificateAllowRequest(
1288 WebView*, const std::string& url, const std::string& pem,
1289 std::function<void(bool allow)> result_handler) {
1290 auto db = common::AppDB::GetInstance();
1291 std::string reminder =
1292 db->Get(kDBPrivateSection, kCertificateAllowPrefix + pem);
1293 if (reminder == "allowed") {
1294 result_handler(true);
1296 } else if (reminder == "denied") {
1297 result_handler(false);
1301 Popup* popup = Popup::CreatePopup(window_);
1302 popup->SetButtonType(Popup::ButtonType::AllowDenyButton);
1303 popup->SetTitle(popup_string::kPopupTitleCert);
1304 popup->SetBody(popup_string::GetText(
1305 popup_string::kPopupBodyCert) + "\n\n" + url);
1306 popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
1307 popup->SetResultHandler(
1308 [db, result_handler, pem](Popup* popup, void* /*user_data*/) {
1309 bool result = popup->GetButtonResult();
1310 bool remember = popup->GetCheckBoxResult();
1312 db->Set(kDBPrivateSection, kCertificateAllowPrefix + pem,
1313 result ? "allowed" : "denied");
1315 result_handler(result);
1321 void WebApplication::OnUsermediaPermissionRequest(
1322 WebView*, const std::string& url,
1323 std::function<void(bool)> result_handler) {
1324 auto db = common::AppDB::GetInstance();
1325 std::string reminder =
1326 db->Get(kDBPrivateSection, kUsermediaPermissionPrefix + url);
1327 if (reminder == "allowed") {
1328 result_handler(true);
1330 } else if (reminder == "denied") {
1331 result_handler(false);
1335 // Local Domain: Grant permission if defined, otherwise block execution.
1336 // Remote Domain: Popup user prompt if defined, otherwise block execution.
1337 if (!FindPrivilegeFromConfig(app_data_, kUsermediaPrivilege) &&
1338 !(FindPrivilegeFromCynara(kCameraPrivilege) && FindPrivilegeFromCynara(kRecordPrivilege))) {
1339 result_handler(false);
1343 if (common::utils::StartsWith(url, "file://")) {
1344 result_handler(true);
1348 Popup* popup = Popup::CreatePopup(window_);
1349 popup->SetButtonType(Popup::ButtonType::AllowDenyButton);
1350 popup->SetTitle(popup_string::kPopupTitleUserMedia);
1351 popup->SetBody(popup_string::kPopupBodyUserMedia);
1352 popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
1353 popup->SetResultHandler(
1354 [db, result_handler, url](Popup* popup, void* /*user_data*/) {
1355 bool result = popup->GetButtonResult();
1356 bool remember = popup->GetCheckBoxResult();
1358 db->Set(kDBPrivateSection, kUsermediaPermissionPrefix + url,
1359 result ? "allowed" : "denied");
1361 result_handler(result);
1367 } // namespace runtime