5769c58317639f6fc1e8f38f1e7b29aa6625d7ba
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / ubrowser / window_ui.cc
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.
4
5 #include "window_ui.h"
6
7 #include <assert.h>
8 #include <Elementary.h>
9 #include <ewk_context.h>
10 #include <ewk_settings.h>
11 #if defined(OS_TIZEN_MOBILE)
12 #include <efl_extension.h>
13 #endif
14
15 #include "browser.h"
16 #include "logger.h"
17 #include "window.h"
18
19 namespace {
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;
24 }
25
26 WindowUI::WindowUI(Window& window, Browser& browser)
27     : window_(window)
28     , browser_(browser)
29     , active_popup_(NULL)
30     , menu_(0)
31     , is_loading_(false) {
32   navbar_ = elm_box_add(window_.GetEvasObject());
33   elm_box_horizontal_set(navbar_, EINA_TRUE);
34   elm_box_homogeneous_set(navbar_, EINA_TRUE);
35   evas_object_size_hint_weight_set(navbar_, EVAS_HINT_EXPAND, 0.0f);
36   evas_object_size_hint_align_set(navbar_, EVAS_HINT_FILL, EVAS_HINT_FILL);
37
38   AddButton(navbar_, "file", "New Window", &WindowUI::OnCreateWindow);
39   if (browser_.IsDesktop())
40     AddButton(navbar_, "file", "New Incognito Window",
41               &WindowUI::OnCreateIncognitoWindow);
42   back_button_ = AddButton(navbar_, "arrow_left", "Back", &WindowUI::OnBack);
43   forward_button_ = AddButton(navbar_, "arrow_right", "Forward",
44                               &WindowUI::OnForward);
45   stop_reload_button_ = AddButton(navbar_, "refresh", "Reload",
46                                   &WindowUI::OnStopOrReload);
47   AddButton(navbar_, "arrow_up", "More Actions",
48             &WindowUI::OnShowExtraActionsMenu);
49
50   urlbar_ = elm_box_add(window_.GetEvasObject());
51   elm_box_horizontal_set(urlbar_, EINA_TRUE);
52   evas_object_size_hint_weight_set(urlbar_, EVAS_HINT_EXPAND, 0.0f);
53   evas_object_size_hint_align_set(urlbar_, EVAS_HINT_FILL, EVAS_HINT_FILL);
54
55   progress_bar_ = elm_progressbar_add(window_.GetEvasObject());
56   elm_object_style_set(progress_bar_, "wheel");
57   elm_progressbar_pulse_set(progress_bar_, EINA_TRUE);
58   elm_progressbar_pulse(progress_bar_, EINA_FALSE);
59   elm_box_pack_end(urlbar_, progress_bar_);
60   evas_object_show(progress_bar_);
61
62   url_entry_ = elm_entry_add(urlbar_);
63   elm_entry_single_line_set(url_entry_, EINA_TRUE);
64   elm_entry_scrollable_set(url_entry_, EINA_TRUE);
65   elm_entry_input_panel_layout_set(url_entry_, ELM_INPUT_PANEL_LAYOUT_URL);
66   evas_object_size_hint_weight_set(url_entry_, EVAS_HINT_EXPAND, 1.0f);
67   evas_object_size_hint_align_set(url_entry_, EVAS_HINT_FILL, EVAS_HINT_FILL);
68   evas_object_smart_callback_add(url_entry_, "activated", OnURLEntered, this);
69   elm_box_pack_end(urlbar_, url_entry_);
70   evas_object_show(url_entry_);
71
72   Evas_Object* separator = elm_separator_add(urlbar_);
73   elm_separator_horizontal_set(separator, EINA_TRUE);
74   elm_box_pack_end(urlbar_, separator);
75   evas_object_show(separator);
76
77 #if defined(OS_TIZEN_MOBILE)
78   eext_object_event_callback_add(window_.GetEvasObject(), EEXT_CALLBACK_BACK, WindowUI::OnBack, this);
79 #endif
80
81   EnableBackButton(false);
82   EnableForwardButton(false);
83 }
84
85 WindowUI::~WindowUI() {
86   if (active_popup_)
87     evas_object_del(active_popup_);
88 }
89
90 void WindowUI::OnURLChanged(const char* url) {
91   log_trace("%s: %s", __PRETTY_FUNCTION__, url);
92   elm_object_text_set(url_entry_, url);
93 }
94
95 void WindowUI::OnLoadingStarted() {
96   log_trace("%s", __PRETTY_FUNCTION__);
97   elm_progressbar_pulse(progress_bar_, EINA_TRUE);
98   Evas_Object* icon = elm_object_part_content_get(stop_reload_button_, "icon");
99   elm_icon_standard_set(icon, "close");
100   if (browser_.IsDesktop())
101     elm_object_text_set(stop_reload_button_, "Stop");
102   is_loading_ = true;
103 }
104
105 void WindowUI::OnLoadingFinished() {
106   log_trace("%s", __PRETTY_FUNCTION__);
107   elm_progressbar_pulse(progress_bar_, EINA_FALSE);
108   Evas_Object* icon = elm_object_part_content_get(stop_reload_button_, "icon");
109   elm_icon_standard_set(icon, "refresh");
110   if (browser_.IsDesktop())
111     elm_object_text_set(stop_reload_button_, "Reload");
112   is_loading_ = false;
113 }
114
115 void WindowUI::EnableBackButton(bool enable) {
116   elm_object_disabled_set(back_button_, !enable);
117 }
118
119 void WindowUI::EnableForwardButton(bool enable) {
120   elm_object_disabled_set(forward_button_, !enable);
121 }
122
123 void WindowUI::ShowNotification(const char* text) {
124   log_trace("%s : %s", __PRETTY_FUNCTION__, text);
125   Evas_Object* notification = elm_notify_add(window_.GetEvasObject());
126   elm_notify_timeout_set(notification, kNotificationTimeoutSec);
127   Evas_Object* content = elm_label_add(notification);
128   elm_object_text_set(content, text);
129   elm_object_content_set(notification, content);
130   elm_notify_align_set(notification, 0.5, 0.5);
131   evas_object_show(notification);
132 }
133
134 Evas_Object* WindowUI::AddButton(Evas_Object* parent,
135     const char* icon, const char* label, Evas_Smart_Cb cb) {
136   Evas_Object* bt = elm_button_add(parent);
137   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
138   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5);
139   if (label && browser_.IsDesktop())
140     elm_object_text_set(bt, label);
141   if (icon) {
142     Evas_Object* icon_elm = elm_icon_add(bt);
143     elm_icon_standard_set(icon_elm, icon);
144     elm_object_part_content_set(bt, "icon", icon_elm);
145   }
146   evas_object_smart_callback_add(bt, "clicked", cb, this);
147   elm_box_pack_end(parent, bt);
148   evas_object_show(bt);
149
150   return bt;
151 }
152
153 namespace {
154
155 void _HideCtxPopup(void* data, Evas_Object* obj, void*) {
156   evas_object_hide(obj);
157 }
158
159 } // namespace
160
161 void WindowUI::CloseMenu() {
162   evas_object_hide(menu_);
163   evas_object_del(menu_);
164   menu_ = 0;
165 }
166
167 Evas_Object* WindowUI::CreateExtraActionsMenu(Evas_Object* parent) {
168   if (menu_) {
169     CloseMenu();
170     return 0;
171   }
172   menu_ =  elm_ctxpopup_add(parent);
173
174 #if defined(OS_TIZEN_MOBILE)
175   int width;
176   evas_object_geometry_get(parent, 0, 0, &width, 0);
177   evas_object_size_hint_min_set(menu_, width, 0);
178 #endif
179   evas_object_smart_callback_add(menu_, "dismissed", _HideCtxPopup, NULL);
180
181   if (window_.IsFormProfileEnabled()) {
182     elm_ctxpopup_item_append(menu_, "Disable Form Profile", NULL,
183                              &WindowUI::OnFormProfileChange, this);
184   } else {
185     elm_ctxpopup_item_append(menu_, "Enable Form Profile", NULL,
186                              &WindowUI::OnFormProfileChange, this);
187   }
188
189   if (window_.IsRememberFormDataEnabled()) {
190     elm_ctxpopup_item_append(menu_, "Disable Remember Form Data", NULL,
191                              &WindowUI::OnRememberFormDataChange, this);
192   } else {
193     elm_ctxpopup_item_append(menu_, "Enable Remember Form Data", NULL,
194                              &WindowUI::OnRememberFormDataChange, this);
195   }
196
197   if (window_.IsRememberPasswordEnabled()) {
198     elm_ctxpopup_item_append(menu_, "Disable Remember Password", NULL,
199                              &WindowUI::OnRememberPasswordChange, this);
200   } else {
201     elm_ctxpopup_item_append(menu_, "Enable Remember Password", NULL,
202                              &WindowUI::OnRememberPasswordChange, this);
203   }
204
205   elm_ctxpopup_item_append(menu_, "Override User Agent String", NULL,
206                            &WindowUI::OnUAOverride, this);
207
208   if (browser_.IsDesktop()) {
209     elm_ctxpopup_item_append(menu_, "Show Web Inspector", NULL,
210                              &WindowUI::OnInspectorShow, this);
211   } else {
212     elm_ctxpopup_item_append(menu_, "Start Web Inspector server", NULL,
213                              &WindowUI::OnInspectorServerStart, this);
214   }
215 #if !defined(OS_TIZEN)
216   elm_ctxpopup_item_append(menu_, "Simulate screen rotation", NULL,
217       &WindowUI::OnRotate, this);
218 #endif
219
220   if (window_.AreTouchEventsEnabled()) {
221     elm_ctxpopup_item_append(menu_, "Enable mouse events", NULL,
222                              &WindowUI::OnSelectMouseInput, this);
223   } else {
224     elm_ctxpopup_item_append(menu_, "Enable touch events", NULL,
225                              &WindowUI::OnSelectTouchInput, this);
226   }
227
228   if (!browser_.IsTracingEnabled()) {
229     elm_ctxpopup_item_append(menu_, "Start tracing", NULL,
230                              &WindowUI::OnStartTracing, this);
231   } else {
232     elm_ctxpopup_item_append(menu_, "Stop tracing", NULL,
233                              &WindowUI::OnStopTracing, this);
234   }
235
236   Ewk_Settings* settings = window_.GetEwkSettings();
237   if (!ewk_settings_auto_fitting_get(settings)) {
238     elm_ctxpopup_item_append(menu_, "Enable auto fitting", NULL,
239                              &WindowUI::OnAutoFittingEnabled, this);
240   } else {
241     elm_ctxpopup_item_append(menu_, "Disable auto fitting", NULL,
242                              &WindowUI::OnAutoFittingDisabled, this);
243   }
244
245   if (!ewk_settings_form_profile_data_enabled_get(settings) ||
246      !ewk_settings_form_candidate_data_enabled_get(settings)) {
247     elm_ctxpopup_item_append(menu_, "Enable autofill", NULL,
248                              &WindowUI::OnAutoFillEnabled, this);
249   } else {
250     elm_ctxpopup_item_append(menu_, "Disable autofill", NULL,
251                              &WindowUI::OnAutoFillDisabled, this);
252   }
253
254   if (window_.IsPrivateBrowsingEnabled()) {
255     elm_ctxpopup_item_append(menu_, "Disable Private Browsing", NULL,
256                              &WindowUI::OnPrivateBrowsingChange, this);
257   } else {
258     elm_ctxpopup_item_append(menu_, "Enable PrivateBrowsing", NULL,
259                              &WindowUI::OnPrivateBrowsingChange, this);
260   }
261
262   elm_ctxpopup_item_append(menu_, "Change page zoom level", NULL,
263                            &WindowUI::OnShowZoomPopup, this);
264
265   elm_ctxpopup_item_append(menu_, "Quit", NULL, &WindowUI::Exit, this);
266
267   return menu_;
268 }
269
270 void WindowUI::ShowPermissionPopup(const char* title,
271     const char* description, PermissionCallback cb, void* data) {
272   log_trace("%s: (%s, %s)", __PRETTY_FUNCTION__, title, description);
273
274   Evas_Object* popup = elm_popup_add(window_.GetEvasObject());
275   elm_object_part_text_set(popup, "title,text", title);
276   elm_object_part_text_set(popup, NULL, description);
277   elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
278   active_popup_ = popup;
279
280   Evas_Object* btn = elm_button_add(popup);
281   elm_object_text_set(btn, "Yes");
282   PermissionPopupButtonData* buttonData = new PermissionPopupButtonData;
283   buttonData->callbackData=data;
284   buttonData->callback=cb;
285   buttonData->popupData=this;
286
287   evas_object_smart_callback_add(btn, "clicked", PermissionGranted,
288                                  buttonData);
289   elm_object_part_content_set(popup, "button1", btn);
290
291   btn = elm_button_add(popup);
292   elm_object_text_set(btn, "No");
293   evas_object_smart_callback_add(btn, "clicked", PermissionDeclined,
294                                  buttonData);
295   elm_object_part_content_set(popup, "button2", btn);
296
297   evas_object_show(popup);
298 }
299
300 void WindowUI::PermissionGranted(void* data, Evas_Object* button, void*) {
301   log_trace("%s", __PRETTY_FUNCTION__);
302
303   PermissionPopupButtonData* buttonData =(PermissionPopupButtonData*) data;
304   ClosePopup(buttonData->popupData, NULL, NULL);
305   buttonData->callback(true, buttonData->callbackData);
306   delete buttonData;
307 }
308
309 void WindowUI::PermissionDeclined(void* data, Evas_Object* button, void*) {
310   log_trace("%s", __PRETTY_FUNCTION__);
311
312   PermissionPopupButtonData* buttonData =(PermissionPopupButtonData*) data;
313   ClosePopup(buttonData->popupData, NULL, NULL);
314   buttonData->callback(false, buttonData->callbackData);
315   delete buttonData;
316 }
317
318 void WindowUI::ShowTextEntryPopup(const char* title,
319                                   const char* initial_content,
320                                   Evas_Smart_Cb cb) {
321   log_trace("%s: (%s, %s)", __PRETTY_FUNCTION__, title, initial_content);
322
323   Evas_Object* popup = elm_popup_add(window_.GetEvasObject());
324   elm_object_part_text_set(popup, "title,text", title);
325   elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
326   active_popup_ = popup;
327
328   Evas_Object* entry = elm_entry_add(popup);
329   elm_entry_single_line_set(entry, EINA_TRUE);
330   elm_entry_scrollable_set(entry, EINA_TRUE);
331   elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_URL);
332   evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0f);
333   evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
334   evas_object_smart_callback_add(
335       entry, "activated", cb,
336       new std::pair<Evas_Object*, WindowUI*>(entry, this));
337
338   elm_object_part_content_set(popup, "default", entry);
339   if (initial_content) {
340     elm_object_text_set(entry, initial_content);
341     elm_entry_cursor_end_set(entry);
342   }
343
344   Evas_Object* btn = elm_button_add(popup);
345   elm_object_text_set(btn, "OK");
346   evas_object_smart_callback_add(
347       btn, "clicked", cb, new std::pair<Evas_Object*, WindowUI*>(entry, this));
348   elm_object_part_content_set(popup, "button1", btn);
349
350   btn = elm_button_add(popup);
351   elm_object_text_set(btn, "Cancel");
352   evas_object_smart_callback_add(btn, "clicked", ClosePopup, this);
353   elm_object_part_content_set(popup, "button2", btn);
354
355   evas_object_show(popup);
356 }
357
358 void WindowUI::OnCreateWindow(void* data, Evas_Object*, void*) {
359   log_trace("%s", __PRETTY_FUNCTION__);
360   WindowUI* thiz = static_cast<WindowUI*>(data);
361   if (thiz->browser_.IsDesktop()) {
362     thiz->browser_.CreateWindow().LoadURL(kDefaultNewWindowURL);
363   } else {
364     thiz->browser_.ActivateToolboxWindow();
365   }
366 }
367
368 void WindowUI::OnCreateIncognitoWindow(void* data, Evas_Object*, void*) {
369   log_trace("%s", __PRETTY_FUNCTION__);
370   WindowUI* thiz = static_cast<WindowUI*>(data);
371   thiz->browser_.CreateWindow(true).LoadURL(kDefaultNewWindowURL);
372 }
373
374 void WindowUI::OnBack(void* data, Evas_Object*, void*) {
375   log_trace("%s", __PRETTY_FUNCTION__);
376   static_cast<WindowUI*>(data)->window_.Back();
377 }
378
379 void WindowUI::OnForward(void* data, Evas_Object*, void*) {
380   log_trace("%s", __PRETTY_FUNCTION__);
381   static_cast<WindowUI*>(data)->window_.Forward();
382 }
383
384 void WindowUI::OnStopOrReload(void* data, Evas_Object*, void*) {
385   log_trace("%s", __PRETTY_FUNCTION__);
386   WindowUI* thiz = static_cast<WindowUI*>(data);
387   if (thiz->is_loading_)
388     thiz->window_.Stop();
389   else
390     thiz->window_.Reload();
391 }
392
393 void WindowUI::OnShowExtraActionsMenu(void* data, Evas_Object* obj, void*) {
394   log_trace("%s", __PRETTY_FUNCTION__);
395   WindowUI* thiz = static_cast<WindowUI*>(data);
396   Evas_Object* popup = thiz->CreateExtraActionsMenu(
397       thiz->window_.GetEvasObject());
398
399   if (!popup)
400     return;
401
402   int x, y;
403   evas_object_geometry_get(obj, &x, &y, 0, 0);
404   evas_object_move(popup, x, y);
405   evas_object_show(popup);
406 }
407
408 void WindowUI::OnURLEntered(void* data, Evas_Object*, void*) {
409   log_trace("%s", __PRETTY_FUNCTION__);
410   WindowUI* thiz = static_cast<WindowUI*>(data);
411   thiz->window_.LoadURL(elm_object_text_get(thiz->url_entry_));
412   elm_object_focus_set(thiz->url_entry_, EINA_FALSE);
413 }
414
415 void WindowUI::OnUAOverride(void* data, Evas_Object* obj, void*) {
416   log_trace("%s", __PRETTY_FUNCTION__);
417   WindowUI* thiz = static_cast<WindowUI*>(data);
418   const char* ua = thiz->window_.GetUserAgent();
419   thiz->ShowTextEntryPopup("User Agent Override", ua,
420                            &WindowUI::OnUAOverrideEntered);
421   thiz->CloseMenu();
422 }
423
424 void WindowUI::OnUAOverrideEntered(void* data, Evas_Object*, void*) {
425   std::pair<Evas_Object*, WindowUI*>* p =
426       static_cast<std::pair<Evas_Object*, WindowUI*>*>(data);
427   p->second->window_.SetUserAgent(elm_object_text_get(p->first));
428   evas_object_del(p->second->active_popup_);
429   p->second->active_popup_ = NULL;
430   delete p;
431 }
432
433 void WindowUI::OnInspectorShow(void* data, Evas_Object* obj, void*) {
434   log_trace("%s", __PRETTY_FUNCTION__);
435   WindowUI* thiz = static_cast<WindowUI*>(data);
436   thiz->browser_.ShowInspectorWindow();
437   thiz->CloseMenu();
438 }
439
440 void WindowUI::OnInspectorServerStart(void* data, Evas_Object* obj, void*) {
441     log_trace("%s", __PRETTY_FUNCTION__);
442     WindowUI* thiz = static_cast<WindowUI*>(data);
443     thiz->browser_.StartInspectorServer();
444     thiz->CloseMenu();
445 }
446
447 void WindowUI::OnRotate(void* data, Evas_Object* obj, void*) {
448   log_trace("%s", __PRETTY_FUNCTION__);
449   WindowUI* thiz = static_cast<WindowUI*>(data);
450   thiz->window_.FakeRotate();
451   thiz->CloseMenu();
452 }
453
454 void WindowUI::OnSelectMouseInput(void* data, Evas_Object* obj, void*) {
455   log_trace("%s", __PRETTY_FUNCTION__);
456   WindowUI* thiz = static_cast<WindowUI*>(data);
457   thiz->window_.EnableTouchEvents(false);
458   thiz->window_.EnableMouseEvents(true);
459   thiz->ShowNotification("Mouse events enabled");
460   thiz->CloseMenu();
461 }
462
463 void WindowUI::OnSelectTouchInput(void* data, Evas_Object* obj, void*) {
464   log_trace("%s", __PRETTY_FUNCTION__);
465   WindowUI* thiz = static_cast<WindowUI*>(data);
466   thiz->window_.EnableTouchEvents(true);
467   thiz->window_.EnableMouseEvents(false);
468   thiz->ShowNotification("Touch events enabled");
469   thiz->CloseMenu();
470 }
471
472 void WindowUI::OnStartTracing(void* data, Evas_Object* obj, void*) {
473   log_trace("%s", __PRETTY_FUNCTION__);
474   WindowUI* thiz = static_cast<WindowUI*>(data);
475   thiz->browser_.StartTracing();
476   thiz->CloseMenu();
477   thiz->ShowNotification("Tracing started");
478 }
479
480 void WindowUI::OnStopTracing(void* data, Evas_Object* obj, void*) {
481   log_trace("%s", __PRETTY_FUNCTION__);
482   WindowUI* thiz = static_cast<WindowUI*>(data);
483   thiz->browser_.StopTracing();
484   thiz->CloseMenu();
485   thiz->ShowNotification("Tracing finished");
486 }
487
488 void WindowUI::OnAutoFittingEnabled(void* data, Evas_Object* obj, void*) {
489   log_trace("%s", __PRETTY_FUNCTION__);
490   WindowUI* thiz = static_cast<WindowUI*>(data);
491   Ewk_Settings* settings = thiz->window_.GetEwkSettings();
492   ewk_settings_auto_fitting_set(settings, true);
493   thiz->CloseMenu();
494   thiz->ShowNotification("Auto fitting enabled");
495 }
496
497 void WindowUI::OnAutoFittingDisabled(void* data, Evas_Object* obj, void*) {
498   log_trace("%s", __PRETTY_FUNCTION__);
499   WindowUI* thiz = static_cast<WindowUI*>(data);
500   Ewk_Settings* settings = thiz->window_.GetEwkSettings();
501   ewk_settings_auto_fitting_set(settings, false);
502   thiz->CloseMenu();
503   thiz->ShowNotification("Auto fitting disabled");
504 }
505
506 void WindowUI::OnAutoFillEnabled(void* data, Evas_Object* obj, void*) {
507   log_trace("%s", __PRETTY_FUNCTION__);
508   WindowUI* thiz = static_cast<WindowUI*>(data);
509   Ewk_Settings* settings = thiz->window_.GetEwkSettings();
510   ewk_settings_form_profile_data_enabled_set(settings, true);
511   ewk_settings_form_candidate_data_enabled_set(settings, true);
512   thiz->CloseMenu();
513   thiz->ShowNotification("Autofill enabled");
514 }
515
516 void WindowUI::OnAutoFillDisabled(void* data, Evas_Object* obj, void*) {
517   log_trace("%s", __PRETTY_FUNCTION__);
518   WindowUI* thiz = static_cast<WindowUI*>(data);
519   Ewk_Settings* settings = thiz->window_.GetEwkSettings();
520   ewk_settings_form_profile_data_enabled_set(settings, false);
521   ewk_settings_form_candidate_data_enabled_set(settings, false);
522   thiz->CloseMenu();
523   thiz->ShowNotification("Autofill disabled");
524 }
525
526 void WindowUI::ClosePopup(void* data, Evas_Object*, void*) {
527   WindowUI* thiz = static_cast<WindowUI*>(data);
528   evas_object_del(thiz->active_popup_);
529   thiz->active_popup_ = NULL;
530 }
531
532 void WindowUI::OnShowZoomPopup(void* data, Evas_Object* obj, void*) {
533   log_trace("%s", __PRETTY_FUNCTION__);
534   WindowUI* thiz = static_cast<WindowUI*>(data);
535
536   Evas_Object* popup = elm_popup_add(thiz->window_.GetEvasObject());
537   elm_object_part_text_set(popup, "title,text", "Change page zoom level");
538   elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
539   thiz->active_popup_ = popup;
540   Evas_Object* btn = elm_button_add(popup);
541
542   Evas_Object* slider = elm_slider_add(popup);
543   elm_slider_min_max_set(slider, kMinViewScale, kMaxViewScale);
544   elm_slider_value_set(slider, thiz->window_.GetScale());
545   elm_slider_indicator_format_set(slider, "%1.2f");
546   elm_slider_indicator_show_set(slider, EINA_TRUE);
547   evas_object_smart_callback_add(slider, "changed", &OnZoomChanged, thiz);
548   elm_object_part_content_set(popup, "default", slider);
549
550   elm_object_text_set(btn, "Close");
551   evas_object_smart_callback_add(btn, "clicked", ClosePopup, thiz);
552   elm_object_part_content_set(popup, "button1", btn);
553
554   evas_object_show(popup);
555   thiz->CloseMenu();
556 }
557
558 void WindowUI::OnZoomChanged(void* data, Evas_Object* obj, void*) {
559   log_trace("%s", __PRETTY_FUNCTION__);
560   WindowUI* thiz = static_cast<WindowUI*>(data);
561   thiz->window_.SetScale(elm_slider_value_get(obj));
562 }
563
564 void WindowUI::OnRememberFormDataChange(void* data, Evas_Object* obj, void*) {
565   log_trace("%s", __PRETTY_FUNCTION__);
566   WindowUI* thiz = static_cast<WindowUI*>(data);
567   Ewk_Settings* settings = thiz->window_.GetEwkSettings();
568   if (thiz->window_.IsRememberFormDataEnabled()) {
569     ewk_settings_form_candidate_data_enabled_set(settings, false);
570     thiz->ShowNotification("Remember Form Data disabled");
571   } else {
572     ewk_settings_form_candidate_data_enabled_set(settings, true);
573     thiz->ShowNotification("Remember Form Data enabled");
574   }
575   thiz->CloseMenu();
576 }
577
578 void WindowUI::OnRememberPasswordChange(void* data, Evas_Object* obj, void*) {
579   log_trace("%s", __PRETTY_FUNCTION__);
580   WindowUI* thiz = static_cast<WindowUI*>(data);
581   Ewk_Settings* settings = thiz->window_.GetEwkSettings();
582   if (thiz->window_.IsRememberPasswordEnabled()) {
583     ewk_settings_autofill_password_form_enabled_set(settings, false);
584     thiz->ShowNotification("Remember Password disabled");
585   } else {
586     ewk_settings_autofill_password_form_enabled_set(settings, true);
587     thiz->ShowNotification("Remember Password enabled");
588   }
589   thiz->CloseMenu();
590 }
591
592 void WindowUI::OnFormProfileChange(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   if (thiz->window_.IsFormProfileEnabled()) {
597     ewk_settings_form_profile_data_enabled_set(settings, false);
598     thiz->ShowNotification("Form Profile disabled");
599   } else {
600     ewk_settings_form_profile_data_enabled_set(settings, true);
601     thiz->ShowNotification("Form Profile enabled");
602   }
603   thiz->CloseMenu();
604 }
605
606 void WindowUI::OnPrivateBrowsingChange(void* data, Evas_Object* obj, void*) {
607   log_trace("%s", __PRETTY_FUNCTION__);
608   WindowUI* thiz = static_cast<WindowUI*>(data);
609   Ewk_Settings* settings = thiz->window_.GetEwkSettings();
610   if (thiz->window_.IsPrivateBrowsingEnabled()) {
611     ewk_settings_private_browsing_enabled_set(settings, false);
612     thiz->ShowNotification("Private browsing disabled");
613   } else {
614     ewk_settings_private_browsing_enabled_set(settings, true);
615     thiz->ShowNotification("Private browsing enabled");
616   }
617   thiz->CloseMenu();
618 }
619
620 void WindowUI::Exit(void* data, Evas_Object*, void*) {
621   WindowUI* thiz = static_cast<WindowUI*>(data);
622   thiz->window_.Exit();
623 }