1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include <Elementary.h>
10 #include <EWebKit_internal.h>
11 #include <EWebKit_product.h>
17 #include "tizen/system_info.h"
20 static std::string kDefaultNewWindowURL = "http://www.google.com";
21 static double kMinViewScale = 1.0;
22 static double kMaxViewScale = 4.0;
23 static int kNotificationTimeoutSec = 3;
26 WindowUI::WindowUI(Window& window, Browser& browser)
32 stop_reload_button_(nullptr),
33 progress_bar_(nullptr),
34 forward_button_(nullptr),
35 back_button_(nullptr),
36 active_popup_(nullptr),
38 #if BUILDFLAG(IS_TIZEN_TV)
39 should_show_label_(true),
41 should_show_label_(browser_.IsDesktop()),
45 if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_URL_ONLY)
47 if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_MINIMAL)
50 // TODO: Workaround for http://suprem.sec.samsung.net/jira/browse/TWF-843
52 should_show_label_ = true;
53 Elm_Theme* theme = elm_theme_new();
54 elm_theme_set(theme, "tizen-HD-light");
55 elm_object_theme_set(navbar_, theme);
56 elm_theme_free(theme);
60 WindowUI::~WindowUI() {
62 evas_object_del(active_popup_);
65 void WindowUI::OnURLChanged(const char* url) {
66 log_trace("%s: %s", __PRETTY_FUNCTION__, url);
68 elm_object_text_set(url_entry_, url);
71 void WindowUI::OnLoadingStarted() {
72 log_trace("%s", __PRETTY_FUNCTION__);
74 elm_progressbar_pulse(progress_bar_, EINA_TRUE);
75 if (stop_reload_button_) {
77 elm_object_part_content_get(stop_reload_button_, "icon");
78 elm_icon_standard_set(icon, "close");
79 if (should_show_label_)
80 elm_object_text_set(stop_reload_button_, "Stop");
85 void WindowUI::OnLoadingFinished() {
86 log_trace("%s", __PRETTY_FUNCTION__);
88 elm_progressbar_pulse(progress_bar_, EINA_FALSE);
89 if (stop_reload_button_) {
91 elm_object_part_content_get(stop_reload_button_, "icon");
92 elm_icon_standard_set(icon, "refresh");
93 if (should_show_label_)
94 elm_object_text_set(stop_reload_button_, "Reload");
99 void WindowUI::EnableBackButton(bool enable) {
101 elm_object_disabled_set(back_button_, !enable);
104 void WindowUI::EnableForwardButton(bool enable) {
106 elm_object_disabled_set(forward_button_, !enable);
109 void WindowUI::ShowNotification(const char* text) {
110 log_trace("%s : %s", __PRETTY_FUNCTION__, text);
111 Evas_Object* notification = elm_notify_add(window_.GetEvasObject());
112 elm_notify_timeout_set(notification, kNotificationTimeoutSec);
113 Evas_Object* content = elm_label_add(notification);
114 elm_object_text_set(content, text);
115 elm_object_content_set(notification, content);
116 elm_notify_align_set(notification, 0.5, 0.5);
117 evas_object_show(notification);
120 void WindowUI::CreateTopBar() {
121 urlbar_ = elm_box_add(window_.GetEvasObject());
122 elm_box_horizontal_set(urlbar_, EINA_TRUE);
123 evas_object_size_hint_weight_set(urlbar_, EVAS_HINT_EXPAND, 0.0f);
124 evas_object_size_hint_align_set(urlbar_, EVAS_HINT_FILL, EVAS_HINT_FILL);
126 if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_ALL) {
127 progress_bar_ = elm_progressbar_add(window_.GetEvasObject());
128 elm_object_style_set(progress_bar_, "wheel");
129 elm_progressbar_pulse_set(progress_bar_, EINA_TRUE);
130 elm_progressbar_pulse(progress_bar_, EINA_FALSE);
131 elm_box_pack_end(urlbar_, progress_bar_);
132 evas_object_show(progress_bar_);
135 url_entry_ = elm_entry_add(urlbar_);
136 elm_entry_single_line_set(url_entry_, EINA_TRUE);
137 elm_entry_scrollable_set(url_entry_, EINA_TRUE);
138 elm_entry_input_panel_layout_set(url_entry_, ELM_INPUT_PANEL_LAYOUT_URL);
139 evas_object_size_hint_weight_set(url_entry_, EVAS_HINT_EXPAND, 1.0f);
140 evas_object_size_hint_align_set(url_entry_, EVAS_HINT_FILL, EVAS_HINT_FILL);
141 evas_object_smart_callback_add(url_entry_, "activated", OnURLEntered, this);
142 elm_box_pack_end(urlbar_, url_entry_);
143 evas_object_color_get(url_entry_, &url_entry_color_.r, &url_entry_color_.g,
144 &url_entry_color_.b, &url_entry_color_.a);
145 evas_object_show(url_entry_);
147 if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_ALL) {
148 Evas_Object* separator = elm_separator_add(urlbar_);
149 elm_separator_horizontal_set(separator, EINA_TRUE);
150 elm_box_pack_end(urlbar_, separator);
151 evas_object_show(separator);
155 void WindowUI::CreateBottomBar() {
156 navbar_ = elm_box_add(window_.GetEvasObject());
157 elm_box_horizontal_set(navbar_, EINA_TRUE);
158 elm_box_homogeneous_set(navbar_, EINA_TRUE);
159 evas_object_size_hint_weight_set(navbar_, EVAS_HINT_EXPAND, 0.0f);
160 evas_object_size_hint_align_set(navbar_, EVAS_HINT_FILL, EVAS_HINT_FILL);
162 if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_ALL) {
163 AddButton(navbar_, "file", "New Window", &WindowUI::OnCreateWindow);
164 if (browser_.IsDesktop())
165 AddButton(navbar_, "file", "New Incognito Window",
166 &WindowUI::OnCreateIncognitoWindow);
169 back_button_ = AddButton(navbar_, "arrow_left", "Back", &WindowUI::OnBack);
171 AddButton(navbar_, "arrow_right", "Forward", &WindowUI::OnForward);
172 stop_reload_button_ =
173 AddButton(navbar_, "refresh", "Reload", &WindowUI::OnStopOrReload);
174 if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_ALL)
175 AddButton(navbar_, "arrow_up", "More Actions",
176 &WindowUI::OnShowExtraActionsMenu);
178 EnableBackButton(false);
179 EnableForwardButton(false);
182 Evas_Object* WindowUI::AddButton(Evas_Object* parent,
183 const char* icon, const char* label, Evas_Smart_Cb cb) {
184 Evas_Object* bt = elm_button_add(parent);
185 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
186 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5);
187 if (label && should_show_label_)
188 elm_object_text_set(bt, label);
190 Evas_Object* icon_elm = elm_icon_add(bt);
191 elm_icon_standard_set(icon_elm, icon);
192 elm_object_part_content_set(bt, "icon", icon_elm);
194 evas_object_smart_callback_add(bt, "clicked", cb, this);
195 elm_box_pack_end(parent, bt);
196 evas_object_show(bt);
203 void _HideCtxPopup(void* data, Evas_Object* obj, void*) {
204 evas_object_hide(obj);
209 void WindowUI::CloseMenu() {
210 evas_object_hide(menu_);
211 evas_object_del(menu_);
215 Evas_Object* WindowUI::CreateExtraActionsMenu(Evas_Object* parent) {
220 menu_ = elm_ctxpopup_add(parent);
222 if ((IsMobileProfile() || IsWearableProfile())) {
224 evas_object_geometry_get(parent, 0, 0, &width, 0);
225 evas_object_size_hint_min_set(menu_, width, 0);
227 evas_object_smart_callback_add(menu_, "dismissed", _HideCtxPopup, NULL);
229 if (window_.IsFormProfileEnabled()) {
230 elm_ctxpopup_item_append(menu_, "Disable Form Profile", NULL,
231 &WindowUI::OnFormProfileChange, this);
233 elm_ctxpopup_item_append(menu_, "Enable Form Profile", NULL,
234 &WindowUI::OnFormProfileChange, this);
237 if (window_.IsRememberFormDataEnabled()) {
238 elm_ctxpopup_item_append(menu_, "Disable Remember Form Data", NULL,
239 &WindowUI::OnRememberFormDataChange, this);
241 elm_ctxpopup_item_append(menu_, "Enable Remember Form Data", NULL,
242 &WindowUI::OnRememberFormDataChange, this);
245 if (window_.IsRememberPasswordEnabled()) {
246 elm_ctxpopup_item_append(menu_, "Disable Remember Password", NULL,
247 &WindowUI::OnRememberPasswordChange, this);
249 elm_ctxpopup_item_append(menu_, "Enable Remember Password", NULL,
250 &WindowUI::OnRememberPasswordChange, this);
253 elm_ctxpopup_item_append(menu_, "Override User Agent String", NULL,
254 &WindowUI::OnUAOverride, this);
256 if (browser_.IsDesktop()) {
257 elm_ctxpopup_item_append(menu_, "Show Web Inspector", NULL,
258 &WindowUI::OnInspectorShow, this);
260 elm_ctxpopup_item_append(menu_, "Start Web Inspector server", NULL,
261 &WindowUI::OnInspectorServerStart, this);
264 elm_ctxpopup_item_append(menu_, "Use Google data proxy", NULL,
265 &WindowUI::OnUseGoogleDataProxy, this);
266 #if !BUILDFLAG(IS_TIZEN)
267 elm_ctxpopup_item_append(menu_, "Simulate screen rotation", NULL,
268 &WindowUI::OnRotate, this);
271 if (window_.AreTouchEventsEnabled()) {
272 elm_ctxpopup_item_append(menu_, "Enable mouse events", NULL,
273 &WindowUI::OnSelectMouseInput, this);
275 elm_ctxpopup_item_append(menu_, "Enable touch events", NULL,
276 &WindowUI::OnSelectTouchInput, this);
279 if (!browser_.IsTracingEnabled()) {
280 elm_ctxpopup_item_append(menu_, "Start tracing", NULL,
281 &WindowUI::OnStartTracing, this);
283 elm_ctxpopup_item_append(menu_, "Stop tracing", NULL,
284 &WindowUI::OnStopTracing, this);
287 Ewk_Settings* settings = window_.GetEwkSettings();
288 if (!ewk_settings_auto_fitting_get(settings)) {
289 elm_ctxpopup_item_append(menu_, "Enable auto fitting", NULL,
290 &WindowUI::OnAutoFittingEnabled, this);
292 elm_ctxpopup_item_append(menu_, "Disable auto fitting", NULL,
293 &WindowUI::OnAutoFittingDisabled, this);
296 if (!ewk_settings_scripts_can_open_windows_get(settings)) {
297 elm_ctxpopup_item_append(menu_, "Enable js window.open", NULL,
298 &WindowUI::OnScriptWindowOpenEnabled, this);
300 elm_ctxpopup_item_append(menu_, "Disable js window.open", NULL,
301 &WindowUI::OnScriptWindowOpenDisabled, this);
304 if (!ewk_settings_form_profile_data_enabled_get(settings) ||
305 !ewk_settings_form_candidate_data_enabled_get(settings)) {
306 elm_ctxpopup_item_append(menu_, "Enable autofill", NULL,
307 &WindowUI::OnAutoFillEnabled, this);
309 elm_ctxpopup_item_append(menu_, "Disable autofill", NULL,
310 &WindowUI::OnAutoFillDisabled, this);
313 elm_ctxpopup_item_append(menu_, "Change page zoom level", NULL,
314 &WindowUI::OnShowZoomPopup, this);
316 elm_ctxpopup_item_append(menu_, "Take screenshot async", NULL,
317 &WindowUI::OnTakeScreenshotAsync, this);
319 elm_ctxpopup_item_append(menu_, "Take screenshot sync", NULL,
320 &WindowUI::OnTakeScreenshotSync, this);
322 elm_ctxpopup_item_append(menu_, "Quit", NULL, &WindowUI::Exit, this);
327 void WindowUI::ShowPermissionPopup(const char* title,
328 const char* description, PermissionCallback cb, void* data) {
329 log_trace("%s: (%s, %s)", __PRETTY_FUNCTION__, title, description);
331 Evas_Object* popup = elm_popup_add(window_.GetEvasObject());
332 elm_object_part_text_set(popup, "title,text", title);
333 elm_object_part_text_set(popup, NULL, description);
334 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
335 active_popup_ = popup;
337 Evas_Object* btn = elm_button_add(popup);
338 elm_object_text_set(btn, "Yes");
339 PermissionPopupButtonData* buttonData = new PermissionPopupButtonData;
340 buttonData->callbackData=data;
341 buttonData->callback=cb;
342 buttonData->popupData=this;
344 evas_object_smart_callback_add(btn, "clicked", PermissionGranted,
346 elm_object_part_content_set(popup, "button1", btn);
348 btn = elm_button_add(popup);
349 elm_object_text_set(btn, "No");
350 evas_object_smart_callback_add(btn, "clicked", PermissionDeclined,
352 elm_object_part_content_set(popup, "button2", btn);
354 evas_object_show(popup);
357 void WindowUI::OnThemeColorChanged(int r, int g, int b, int a) {
358 log_trace("%s: rgba(%d, %d, %d, %d)", __PRETTY_FUNCTION__, r, g, b, a);
360 // FIXME: For darker colors font color is to close to background color in
361 // entry. It is style dependent, so style modification or change would be
362 // needed to solve that issue.
364 evas_object_color_set(url_entry_, r, g, b, a);
366 evas_object_color_set(url_entry_, url_entry_color_.r, url_entry_color_.g,
367 url_entry_color_.b, url_entry_color_.a);
371 void WindowUI::PermissionGranted(void* data, Evas_Object* button, void*) {
372 log_trace("%s", __PRETTY_FUNCTION__);
374 PermissionPopupButtonData* buttonData =(PermissionPopupButtonData*) data;
375 ClosePopup(buttonData->popupData, NULL, NULL);
376 buttonData->callback(true, buttonData->callbackData);
380 void WindowUI::PermissionDeclined(void* data, Evas_Object* button, void*) {
381 log_trace("%s", __PRETTY_FUNCTION__);
383 PermissionPopupButtonData* buttonData =(PermissionPopupButtonData*) data;
384 ClosePopup(buttonData->popupData, NULL, NULL);
385 buttonData->callback(false, buttonData->callbackData);
389 void WindowUI::ShowInspectorURLPopup(const char* url) {
390 log_trace("%s : %s", __PRETTY_FUNCTION__, url);
391 Evas_Object* popup = elm_popup_add(window_.GetEvasObject());
392 elm_object_part_text_set(popup, "title,text", url);
393 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
394 active_popup_ = popup;
396 Evas_Object* btn = elm_button_add(popup);
397 elm_object_text_set(btn, "Close");
398 evas_object_smart_callback_add(btn, "clicked", ClosePopup, this);
399 elm_object_part_content_set(popup, "button1", btn);
401 evas_object_show(popup);
404 void WindowUI::ShowTextEntryPopup(const char* title,
405 const char* initial_content,
407 log_trace("%s: (%s, %s)", __PRETTY_FUNCTION__, title, initial_content);
409 Evas_Object* popup = elm_popup_add(window_.GetEvasObject());
410 elm_object_part_text_set(popup, "title,text", title);
411 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
412 active_popup_ = popup;
414 Evas_Object* entry = elm_entry_add(popup);
415 elm_entry_single_line_set(entry, EINA_TRUE);
416 elm_entry_scrollable_set(entry, EINA_TRUE);
417 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_URL);
418 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0f);
419 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
420 evas_object_smart_callback_add(
421 entry, "activated", cb,
422 new std::pair<Evas_Object*, WindowUI*>(entry, this));
424 elm_object_part_content_set(popup, "default", entry);
425 if (initial_content) {
426 elm_object_text_set(entry, initial_content);
427 elm_entry_cursor_end_set(entry);
430 Evas_Object* btn = elm_button_add(popup);
431 elm_object_text_set(btn, "OK");
432 evas_object_smart_callback_add(
433 btn, "clicked", cb, new std::pair<Evas_Object*, WindowUI*>(entry, this));
434 elm_object_part_content_set(popup, "button1", btn);
436 btn = elm_button_add(popup);
437 elm_object_text_set(btn, "Cancel");
438 evas_object_smart_callback_add(btn, "clicked", ClosePopup, this);
439 elm_object_part_content_set(popup, "button2", btn);
441 evas_object_show(popup);
444 void WindowUI::OnCreateWindow(void* data, Evas_Object*, void*) {
445 log_trace("%s", __PRETTY_FUNCTION__);
446 WindowUI* thiz = static_cast<WindowUI*>(data);
447 if (thiz->browser_.IsDesktop()) {
448 thiz->browser_.CreateWindow().LoadURL(kDefaultNewWindowURL);
450 thiz->browser_.ActivateToolboxWindow();
454 void WindowUI::OnCreateIncognitoWindow(void* data, Evas_Object*, void*) {
455 log_trace("%s", __PRETTY_FUNCTION__);
456 WindowUI* thiz = static_cast<WindowUI*>(data);
457 thiz->browser_.CreateWindow(true).LoadURL(kDefaultNewWindowURL);
460 void WindowUI::OnBack(void* data, Evas_Object*, void*) {
461 log_trace("%s", __PRETTY_FUNCTION__);
462 static_cast<WindowUI*>(data)->window_.Back();
465 void WindowUI::OnForward(void* data, Evas_Object*, void*) {
466 log_trace("%s", __PRETTY_FUNCTION__);
467 static_cast<WindowUI*>(data)->window_.Forward();
470 void WindowUI::OnStopOrReload(void* data, Evas_Object*, void*) {
471 log_trace("%s", __PRETTY_FUNCTION__);
472 WindowUI* thiz = static_cast<WindowUI*>(data);
473 if (thiz->is_loading_)
474 thiz->window_.Stop();
476 thiz->window_.Reload();
479 void WindowUI::OnShowExtraActionsMenu(void* data, Evas_Object* obj, void*) {
480 log_trace("%s", __PRETTY_FUNCTION__);
481 WindowUI* thiz = static_cast<WindowUI*>(data);
482 Evas_Object* popup = thiz->CreateExtraActionsMenu(
483 thiz->window_.GetEvasObject());
489 evas_object_geometry_get(obj, &x, &y, 0, 0);
490 evas_object_move(popup, x, y);
491 evas_object_show(popup);
494 void WindowUI::OnURLEntered(void* data, Evas_Object*, void*) {
495 log_trace("%s", __PRETTY_FUNCTION__);
496 WindowUI* thiz = static_cast<WindowUI*>(data);
497 thiz->window_.LoadURL(elm_object_text_get(thiz->url_entry_));
498 elm_object_focus_set(thiz->url_entry_, EINA_FALSE);
501 void WindowUI::OnUAOverride(void* data, Evas_Object* obj, void*) {
502 log_trace("%s", __PRETTY_FUNCTION__);
503 WindowUI* thiz = static_cast<WindowUI*>(data);
504 const char* ua = thiz->window_.GetUserAgent();
505 thiz->ShowTextEntryPopup("User Agent Override", ua,
506 &WindowUI::OnUAOverrideEntered);
510 void WindowUI::OnUAOverrideEntered(void* data, Evas_Object*, void*) {
511 std::pair<Evas_Object*, WindowUI*>* p =
512 static_cast<std::pair<Evas_Object*, WindowUI*>*>(data);
513 p->second->window_.SetUserAgent(elm_object_text_get(p->first));
514 evas_object_del(p->second->active_popup_);
515 p->second->active_popup_ = NULL;
519 void WindowUI::OnInspectorShow(void* data, Evas_Object* obj, void*) {
520 log_trace("%s", __PRETTY_FUNCTION__);
521 WindowUI* thiz = static_cast<WindowUI*>(data);
522 thiz->browser_.ShowInspectorWindow();
526 void WindowUI::OnInspectorServerStart(void* data, Evas_Object* obj, void*) {
527 log_trace("%s", __PRETTY_FUNCTION__);
528 WindowUI* thiz = static_cast<WindowUI*>(data);
529 thiz->browser_.StartInspectorServer();
533 void WindowUI::OnUseGoogleDataProxy(void* data, Evas_Object* obj, void*) {
534 log_trace("%s", __PRETTY_FUNCTION__);
535 WindowUI* thiz = static_cast<WindowUI*>(data);
536 ewk_context_proxy_set(ewk_context_default_get(), "compress.googlezip.net:80",
538 thiz->window_.SetGoogleDataProxyHeaders();
542 void WindowUI::OnRotate(void* data, Evas_Object* obj, void*) {
543 log_trace("%s", __PRETTY_FUNCTION__);
544 WindowUI* thiz = static_cast<WindowUI*>(data);
545 thiz->window_.FakeRotate();
549 void WindowUI::OnSelectMouseInput(void* data, Evas_Object* obj, void*) {
550 log_trace("%s", __PRETTY_FUNCTION__);
551 WindowUI* thiz = static_cast<WindowUI*>(data);
552 thiz->window_.EnableTouchEvents(false);
553 thiz->window_.EnableMouseEvents(true);
554 thiz->ShowNotification("Mouse events enabled");
558 void WindowUI::OnSelectTouchInput(void* data, Evas_Object* obj, void*) {
559 log_trace("%s", __PRETTY_FUNCTION__);
560 WindowUI* thiz = static_cast<WindowUI*>(data);
561 thiz->window_.EnableTouchEvents(true);
562 thiz->window_.EnableMouseEvents(false);
563 thiz->ShowNotification("Touch events enabled");
567 void WindowUI::OnStartTracing(void* data, Evas_Object* obj, void*) {
568 log_trace("%s", __PRETTY_FUNCTION__);
569 WindowUI* thiz = static_cast<WindowUI*>(data);
570 thiz->browser_.StartTracing();
572 thiz->ShowNotification("Tracing started");
575 void WindowUI::OnStopTracing(void* data, Evas_Object* obj, void*) {
576 log_trace("%s", __PRETTY_FUNCTION__);
577 WindowUI* thiz = static_cast<WindowUI*>(data);
578 thiz->browser_.StopTracing();
580 thiz->ShowNotification("Tracing finished");
583 void WindowUI::OnAutoFittingEnabled(void* data, Evas_Object* obj, void*) {
584 log_trace("%s", __PRETTY_FUNCTION__);
585 WindowUI* thiz = static_cast<WindowUI*>(data);
586 Ewk_Settings* settings = thiz->window_.GetEwkSettings();
587 ewk_settings_auto_fitting_set(settings, true);
589 thiz->ShowNotification("Auto fitting enabled");
592 void WindowUI::OnAutoFittingDisabled(void* data, Evas_Object* obj, void*) {
593 log_trace("%s", __PRETTY_FUNCTION__);
594 WindowUI* thiz = static_cast<WindowUI*>(data);
595 Ewk_Settings* settings = thiz->window_.GetEwkSettings();
596 ewk_settings_auto_fitting_set(settings, false);
598 thiz->ShowNotification("Auto fitting disabled");
601 void WindowUI::OnAutoFillEnabled(void* data, Evas_Object* obj, void*) {
602 log_trace("%s", __PRETTY_FUNCTION__);
603 WindowUI* thiz = static_cast<WindowUI*>(data);
604 Ewk_Settings* settings = thiz->window_.GetEwkSettings();
605 ewk_settings_form_profile_data_enabled_set(settings, true);
606 ewk_settings_form_candidate_data_enabled_set(settings, true);
608 thiz->ShowNotification("Autofill enabled");
611 void WindowUI::OnAutoFillDisabled(void* data, Evas_Object* obj, void*) {
612 log_trace("%s", __PRETTY_FUNCTION__);
613 WindowUI* thiz = static_cast<WindowUI*>(data);
614 Ewk_Settings* settings = thiz->window_.GetEwkSettings();
615 ewk_settings_form_profile_data_enabled_set(settings, false);
616 ewk_settings_form_candidate_data_enabled_set(settings, false);
618 thiz->ShowNotification("Autofill disabled");
621 void WindowUI::OnScriptWindowOpenEnabled(void* data, Evas_Object* obj, void*) {
622 log_trace("%s", __PRETTY_FUNCTION__);
623 WindowUI* thiz = static_cast<WindowUI*>(data);
624 Ewk_Settings* settings = thiz->window_.GetEwkSettings();
625 ewk_settings_scripts_can_open_windows_set(settings, true);
627 thiz->ShowNotification("JS window.open enabled");
630 void WindowUI::OnScriptWindowOpenDisabled(void* data, Evas_Object* obj, void*) {
631 log_trace("%s", __PRETTY_FUNCTION__);
632 WindowUI* thiz = static_cast<WindowUI*>(data);
633 Ewk_Settings* settings = thiz->window_.GetEwkSettings();
634 ewk_settings_scripts_can_open_windows_set(settings, false);
636 thiz->ShowNotification("JS window.open disabled");
639 void WindowUI::ClosePopup(void* data, Evas_Object*, void*) {
640 WindowUI* thiz = static_cast<WindowUI*>(data);
641 evas_object_del(thiz->active_popup_);
642 thiz->active_popup_ = NULL;
645 void WindowUI::ClosePopup() {
647 evas_object_del(active_popup_);
648 active_popup_ = NULL;
652 void WindowUI::OnShowZoomPopup(void* data, Evas_Object* obj, void*) {
653 log_trace("%s", __PRETTY_FUNCTION__);
654 WindowUI* thiz = static_cast<WindowUI*>(data);
656 Evas_Object* popup = elm_popup_add(thiz->window_.GetEvasObject());
657 elm_object_part_text_set(popup, "title,text", "Change page zoom level");
658 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
659 thiz->active_popup_ = popup;
660 Evas_Object* btn = elm_button_add(popup);
662 Evas_Object* slider = elm_slider_add(popup);
663 thiz->window_.GetScaleRange(&kMinViewScale, &kMaxViewScale);
664 elm_slider_min_max_set(slider, kMinViewScale, kMaxViewScale);
665 elm_slider_value_set(slider, thiz->window_.GetScale());
666 elm_slider_indicator_format_set(slider, "%1.2f");
667 elm_slider_indicator_show_set(slider, EINA_TRUE);
668 evas_object_smart_callback_add(slider, "changed", &OnZoomChanged, thiz);
669 elm_object_part_content_set(popup, "default", slider);
671 elm_object_text_set(btn, "Close");
672 evas_object_smart_callback_add(btn, "clicked", ClosePopup, thiz);
673 elm_object_part_content_set(popup, "button1", btn);
675 evas_object_show(popup);
679 void WindowUI::OnTakeScreenshotAsync(void* data, Evas_Object* obj, void*) {
680 log_trace("%s", __PRETTY_FUNCTION__);
681 WindowUI* thiz = static_cast<WindowUI*>(data);
682 thiz->window_.TakeScreenshot(false);
686 void WindowUI::OnTakeScreenshotSync(void* data, Evas_Object* obj, void*) {
687 log_trace("%s", __PRETTY_FUNCTION__);
688 WindowUI* thiz = static_cast<WindowUI*>(data);
689 thiz->window_.TakeScreenshot(true);
693 void WindowUI::OnZoomChanged(void* data, Evas_Object* obj, void*) {
694 log_trace("%s", __PRETTY_FUNCTION__);
695 WindowUI* thiz = static_cast<WindowUI*>(data);
696 thiz->window_.SetScale(elm_slider_value_get(obj));
699 void WindowUI::OnRememberFormDataChange(void* data, Evas_Object* obj, void*) {
700 log_trace("%s", __PRETTY_FUNCTION__);
701 WindowUI* thiz = static_cast<WindowUI*>(data);
702 Ewk_Settings* settings = thiz->window_.GetEwkSettings();
703 if (thiz->window_.IsRememberFormDataEnabled()) {
704 ewk_settings_form_candidate_data_enabled_set(settings, false);
705 thiz->ShowNotification("Remember Form Data disabled");
707 ewk_settings_form_candidate_data_enabled_set(settings, true);
708 thiz->ShowNotification("Remember Form Data enabled");
713 void WindowUI::OnRememberPasswordChange(void* data, Evas_Object* obj, void*) {
714 log_trace("%s", __PRETTY_FUNCTION__);
715 WindowUI* thiz = static_cast<WindowUI*>(data);
716 Ewk_Settings* settings = thiz->window_.GetEwkSettings();
717 if (thiz->window_.IsRememberPasswordEnabled()) {
718 ewk_settings_autofill_password_form_enabled_set(settings, false);
719 thiz->ShowNotification("Remember Password disabled");
721 ewk_settings_autofill_password_form_enabled_set(settings, true);
722 thiz->ShowNotification("Remember Password enabled");
727 void WindowUI::OnFormProfileChange(void* data, Evas_Object* obj, void*) {
728 log_trace("%s", __PRETTY_FUNCTION__);
729 WindowUI* thiz = static_cast<WindowUI*>(data);
730 Ewk_Settings* settings = thiz->window_.GetEwkSettings();
731 if (thiz->window_.IsFormProfileEnabled()) {
732 ewk_settings_form_profile_data_enabled_set(settings, false);
733 thiz->ShowNotification("Form Profile disabled");
735 ewk_settings_form_profile_data_enabled_set(settings, true);
736 thiz->ShowNotification("Form Profile enabled");
741 void WindowUI::Exit(void* data, Evas_Object*, void*) {
742 WindowUI* thiz = static_cast<WindowUI*>(data);
743 thiz->window_.Exit();