[M85 Migration][Ubrowser] Ubrowser migration. 01/246501/2
authorsuyambu.rm <suyambu.rm@samsung.com>
Fri, 31 Mar 2017 07:59:45 +0000 (16:59 +0900)
committerBot Blink <blinkbot@samsung.com>
Tue, 3 Nov 2020 00:10:47 +0000 (00:10 +0000)
In order to perform the browser test in m56 beta, we decided to
overwrite the Ubrowser codes to m56 beta from m47 beta.

This CL applies the Ubrowser source codes to m56 beta from
latest m47 beta source codes. However the source codes which related
to "TIZEN_VIDEO_MANUAL_ROTATION_SUPPORT" and "TIZEN_VD_TOMATO" flag
for specific product target were dropped in this CL. The dropped
features will be merged in migration of m47 patches.

ewk_view_widget_get API was introduced to help us with focusing issue.
However, it didn't resolve the issue, so our clients (email,
browser, crosswalk) decided to use the old solution aka "dummy button".

The only application that still uses ewk_view_widget_get API
is ubrowser. As the API has many side effects (e.g. select picker
and context menu do not display), we made a decision to remove
it from ubrowser too.

Refeirence:
https://review.tizen.org/gerrit/224961

Change-Id: I703969fb10ef90d94be95da4477823a5da403ee3
Signed-off-by: suyambu.rm <suyambu.rm@samsung.com>
tizen_src/ewk/efl_integration/public/ewk_context.cc
tizen_src/ewk/ubrowser/BUILD.gn
tizen_src/ewk/ubrowser/browser.cc
tizen_src/ewk/ubrowser/browser.h
tizen_src/ewk/ubrowser/main.cc
tizen_src/ewk/ubrowser/window.cc
tizen_src/ewk/ubrowser/window.h
tizen_src/ewk/ubrowser/window_ui.cc
tizen_src/ewk/ubrowser/window_ui.h

index 9765cdd..d4da429 100644 (file)
@@ -898,3 +898,8 @@ void ewk_context_form_autofill_credit_card_changed_callback_set(
 {
   LOG_EWK_API_MOCKUP();
 }
+
+void ewk_context_default_zoom_factor_set(Ewk_Context* context,
+                                         double zoom_factor) {
+  LOG_EWK_API_MOCKUP();
+}
index 715b2c2..ad15938 100644 (file)
@@ -65,5 +65,11 @@ executable("ubrowser") {
   if (is_tizen) {
     configs += [ "//tizen_src/build:capi-appfw-application" ]
     configs += [ "//tizen_src/build:libcapi-appfw-application" ]
+    if (tizen_product_tv) {
+      configs += [ "//tizen_src/build:ecore-wayland" ]
+      configs += [ "//tizen_src/build:libecore-wayland" ]
+      configs += [ "//tizen_src/build:vd-win-util" ]
+      configs += [ "//tizen_src/build:libvd-win-util" ]
+    }
   }
 }
index 1fdc4ca..2145c1a 100644 (file)
@@ -4,31 +4,82 @@
 
 #include "browser.h"
 
-#include "logger.h"
-#include "tizen/system_info.h"
-
+#include <arpa/inet.h>
 #include <assert.h>
+#include <ifaddrs.h>
+#include <net/if.h>
+
 #include <EWebKit.h>
 #include <EWebKit_internal.h>
 #include <EWebKit_product.h>
 
+#include "logger.h"
+#include "tizen/system_info.h"
+
 static std::string kHomePage = "http://www.google.com";
 static int kDefaultMobileWindowWidth = 360;
 static int kDefaultMobileWindowHeight = 640;
+#if defined(OS_TIZEN_TV_PRODUCT)
+static std::string kDefaultCookiePath = "/home/owner/.cookie";
+static std::string kDefaultCertificatePath = "/usr/share/cert/webbrowser.pem";
+static double kDefaultZoomFactor = 1.5;
+static int kDefaultDesktopWindowWidth = 1920;
+static int kDefaultDesktopWindowHeight = 1048;
+#else
 static int kDefaultDesktopWindowWidth = 1600;
 static int kDefaultDesktopWindowHeight = 900;
+#endif
 static int kToolboxWindowWidth = 640;
 static int kToolboxWindowHeight = 400;
+static unsigned kInspectorServerPort = 7777;
 
 Window* Browser::selected_window_ = NULL;
 
-Browser::Browser(bool desktop)
-  : toolbox_window_(NULL)
-  , window_list_(NULL)
-  , desktop_(desktop)
-  , inspector_started_(false)
-  , tracing_enabled_(false) {
+static std::string GetConfigPath() {
+#if defined(OS_TIZEN_TV_PRODUCT)
+  return kDefaultCookiePath;
+#elif defined(OS_TIZEN) && defined(TIZEN_APP)
+  // Since ubrowser is not being created in Tizen specific way
+  // app_get_data_path() returns null.
+  // TODO: determine proper path using tizen API once TIZEN_APP
+  // gets enabled.
+  log_error("GetConfigPath is not implemented");
+  return std::string();
+#else
+  std::string path;
+  char* config_path = getenv("XDG_CONFIG_HOME");
+  if (config_path) {
+    path = config_path;
+  } else {
+    // Fallback code, on Mobile XDG_CONFIG_HOME is not set.
+    char* home_path = getenv("HOME");
+    if (!home_path) {
+      log_error("Could not determine home directory");
+      return std::string();
+    }
+    path = home_path + std::string("/.config");
+  }
+  return path + "/ubrowser";
+#endif
+}
 
+Browser::Browser(bool desktop,
+                 GUILevel gui_level,
+                 std::string ua,
+                 std::string tizen_version)
+    : toolbox_window_(nullptr),
+      window_list_(nullptr),
+      desktop_(desktop),
+      inspector_started_(false),
+      tracing_enabled_(false),
+      user_agent_(ua),
+      tizen_version_(tizen_version),
+#if defined(OS_TIZEN)
+      haptic_timer_id_(nullptr),
+      haptic_handle_(nullptr),
+      haptic_effect_(nullptr),
+#endif
+      gui_level_(gui_level) {
   log_info("UI type: %s", desktop_ ? "desktop" : "mobile");
 
   if (IsDesktopProfile()) {
@@ -48,7 +99,7 @@ Browser::Browser(bool desktop)
   }
 
   if (IsEmulatorArch()) {
-    log_info("Runtime Architecture : EMUULATOR : ", IsEmulatorArch());
+    log_info("Runtime Architecture : EMULATOR : ", IsEmulatorArch());
   }
 
   // If we don't call ewk_context_default_get here, ubrowser crashes in desktop
@@ -56,56 +107,80 @@ Browser::Browser(bool desktop)
   // FIXME: find a real fix
   Ewk_Context* ctx = ewk_context_default_get();
 
+  // Developers usually kill ubrowser by Ctrl+C which ends
+  // ecore main loop resulting in not call ewk_shutdown and
+  // all jobs that saves something on disk do not take place.
+  // Add SIGINT handler to properly close ubrowser app.
+  signal(SIGINT, Browser::OnSignalHandler);
+
+  std::string config_path = GetConfigPath();
+  if (!config_path.empty()) {
+    ewk_cookie_manager_persistent_storage_set(
+        ewk_context_cookie_manager_get(ctx), config_path.c_str(),
+        EWK_COOKIE_PERSISTENT_STORAGE_SQLITE);
+  }
+
+  ewk_context_cache_model_set(ctx, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER);
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+  ewk_context_default_zoom_factor_set(ctx, kDefaultZoomFactor);
+  ewk_context_certificate_file_set(ctx, kDefaultCertificatePath.c_str());
+  ewk_context_cache_disabled_set(ctx, EINA_FALSE);
+#endif
+
   if (desktop_)
     return;
 
-  toolbox_window_ = elm_win_util_standard_add(
-      "ubrowser-toolbox", "uBrowser ToolBox");
+  ewk_context_vibration_client_callbacks_set(ctx, &Browser::OnVibrationStart,
+                                             &Browser::OnVibrationStop, this);
 
-  evas_object_resize(toolbox_window_,
-                     kToolboxWindowWidth, kToolboxWindowHeight);
-  elm_win_autodel_set(toolbox_window_, EINA_TRUE);
+  if (GetGUILevel() == UBROWSER_GUI_LEVEL_ALL) {
+    toolbox_window_ =
+        elm_win_util_standard_add("ubrowser-toolbox", "uBrowser ToolBox");
 
-  Evas_Object* box = elm_box_add(toolbox_window_);
-  evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-  elm_win_resize_object_add(toolbox_window_, box);
-  evas_object_show(box);
+    evas_object_resize(toolbox_window_, kToolboxWindowWidth,
+                       kToolboxWindowHeight);
 
-  window_list_ = elm_list_add(toolbox_window_);
-  elm_list_select_mode_set(window_list_, ELM_OBJECT_SELECT_MODE_ALWAYS);
-  evas_object_size_hint_weight_set(window_list_, EVAS_HINT_EXPAND,
-                                   EVAS_HINT_EXPAND);
-  evas_object_size_hint_align_set(window_list_, EVAS_HINT_FILL,
-                                  EVAS_HINT_FILL);
-  elm_box_pack_end(box, window_list_);
-  evas_object_show(window_list_);
-
-  Evas_Object* bbox = elm_box_add(toolbox_window_);
-  elm_box_horizontal_set(bbox, EINA_TRUE);
-  evas_object_size_hint_weight_set(bbox, EVAS_HINT_EXPAND, 0);
-  evas_object_size_hint_align_set(bbox, EVAS_HINT_FILL, 0);
-  elm_box_pack_end(box, bbox);
-  evas_object_show(bbox);
-
-  AddButton(bbox, "New Window", "add", NULL, OnNewWindowRequest);
-  AddButton(bbox, "New Incognito Window", "add", NULL,
-            OnNewIncognitoWindowRequest);
-
-  if (elm_win_wm_rotation_supported_get(toolbox_window_)) {
-    static const int rots[] = {0, 90, 270};
-    elm_win_wm_rotation_available_rotations_set(
-        toolbox_window_, rots, (sizeof(rots) / sizeof(int)));
-  }
+    elm_win_autodel_set(toolbox_window_, EINA_TRUE);
+
+    Evas_Object* box = elm_box_add(toolbox_window_);
+    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    elm_win_resize_object_add(toolbox_window_, box);
+    evas_object_show(box);
+
+    window_list_ = elm_list_add(toolbox_window_);
+    elm_list_select_mode_set(window_list_, ELM_OBJECT_SELECT_MODE_ALWAYS);
+
+    evas_object_size_hint_weight_set(window_list_, EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
+
+    evas_object_size_hint_align_set(window_list_, EVAS_HINT_FILL,
+                                    EVAS_HINT_FILL);
+
+    elm_box_pack_end(box, window_list_);
+    evas_object_show(window_list_);
 
-  evas_object_smart_callback_add(toolbox_window_, "delete,request",
-                                 &Browser::OnToolboxWindowDelRequest, this);
+    Evas_Object* bbox = elm_box_add(toolbox_window_);
+    elm_box_horizontal_set(bbox, EINA_TRUE);
+    evas_object_size_hint_weight_set(bbox, EVAS_HINT_EXPAND, 0);
+    evas_object_size_hint_align_set(bbox, EVAS_HINT_FILL, 0);
+    elm_box_pack_end(box, bbox);
+    evas_object_show(bbox);
 
-  ewk_context_vibration_client_callbacks_set(ctx,
-                                             &Browser::OnVibrationStart,
-                                             &Browser::OnVibrationStop,
-                                             this);
+    AddButton(bbox, "New Window", "add", NULL, OnNewWindowRequest);
+    AddButton(bbox, "New Incognito Window", "add", NULL,
+              OnNewIncognitoWindowRequest);
 
-  evas_object_show(toolbox_window_);
+    if (elm_win_wm_rotation_supported_get(toolbox_window_)) {
+      static const int rots[] = {0, 90, 270};
+      elm_win_wm_rotation_available_rotations_set(toolbox_window_, rots,
+                                                  (sizeof(rots) / sizeof(int)));
+    }
+
+    evas_object_smart_callback_add(toolbox_window_, "delete,request",
+                                   &Browser::OnToolboxWindowDelRequest, this);
+    evas_object_show(toolbox_window_);
+  }
 }
 
 Browser::~Browser() {
@@ -168,9 +243,40 @@ void Browser::ShowInspectorWindow() {
 
 void Browser::StartInspectorServer() {
   Ewk_Context* ctx = ewk_context_default_get();
-  unsigned int port = ewk_context_inspector_server_start(ctx, 7777);
-  assert(port != 0);
-  log_trace("Inspector server started at port: %d\n", port);
+  unsigned port = ewk_context_inspector_server_start(ctx, kInspectorServerPort);
+  if (port)
+    DidStartInspectorServer(port);
+  else
+    log_error("Could not start Web Inspector Server at %u",
+              kInspectorServerPort);
+}
+
+void Browser::DidStartInspectorServer(unsigned port) {
+  // Get IP address.
+  struct ifaddrs* addrs;
+  getifaddrs(&addrs);
+  char url[32] = {0};
+  // Find non local, up IP address.
+  for (struct ifaddrs* iter = addrs; iter && iter->ifa_addr;
+       iter = iter->ifa_next) {
+    if (iter->ifa_addr->sa_family == AF_INET &&
+        (iter->ifa_flags & IFF_LOOPBACK) == 0 &&
+        (iter->ifa_flags & IFF_RUNNING) != 0) {
+      struct sockaddr_in* p_addr =
+          reinterpret_cast<struct sockaddr_in*>(iter->ifa_addr);
+      snprintf(url, sizeof(url) / sizeof(url[0]), "http://%s:%u",
+               inet_ntoa(p_addr->sin_addr), port);
+      break;
+    }
+  }
+  freeifaddrs(addrs);
+
+  if (strlen(url)) {
+    if (selected_window_)
+      selected_window_->ShowInspectorURL(url);
+  } else
+    log_error("Web Inspector has started at %u port but its IP is unknown",
+              kInspectorServerPort);
 }
 
 void Browser::ActivateToolboxWindow() {
@@ -345,6 +451,13 @@ Eina_Bool Browser::OnVibrationTimeout(void* data) {
   return ECORE_CALLBACK_CANCEL;
 }
 
+void Browser::OnSignalHandler(int sig) {
+  if (sig == SIGINT) {
+    if (selected_window_)
+      selected_window_->Exit();
+  }
+}
+
 void Browser::Exit() const {
 #if defined(OS_TIZEN) && defined(TIZEN_APP)
   ui_app_exit();
@@ -352,3 +465,13 @@ void Browser::Exit() const {
   elm_exit();
 #endif
 }
+
+void Browser::SetDefaultZoomFactor(double zoom) {
+  Ewk_Context* ctx = ewk_context_default_get();
+  ewk_context_default_zoom_factor_set(ctx, zoom);
+}
+
+double Browser::DefaultZoomFactor() {
+  Ewk_Context* ctx = ewk_context_default_get();
+  return ewk_context_default_zoom_factor_get(ctx);
+}
index 7423b95..b882e8b 100644 (file)
 
 class Browser {
  public:
-  Browser(bool desktop);
+  enum GUILevel {
+    UBROWSER_GUI_LEVEL_NONE = 0,
+    UBROWSER_GUI_LEVEL_URL_ONLY,
+    UBROWSER_GUI_LEVEL_MINIMAL,
+    UBROWSER_GUI_LEVEL_ALL,
+  };
+
+  Browser(bool desktop,
+          GUILevel gui_level,
+          std::string ua,
+          std::string tizen_version);
   ~Browser();
 
   Window& CreateWindow(bool = false);
@@ -26,6 +36,9 @@ class Browser {
   void ActivateToolboxWindow();
   bool IsDesktop() const { return desktop_; }
   bool IsTracingEnabled() const { return tracing_enabled_; }
+  std::string GetUserAgent() const { return user_agent_; }
+  std::string GetTizenVersion() const { return tizen_version_; }
+  GUILevel GetGUILevel() const { return gui_level_; }
   void StartTracing();
   void StopTracing();
   void StartVibration(uint64_t);
@@ -38,11 +51,14 @@ class Browser {
   void OnWindowLoadFinished(Window::IdType id);
 
   void Exit() const;
+  void SetDefaultZoomFactor(double zoom);
+  double DefaultZoomFactor();
 
  private:
   void AddButton(Evas_Object*, const char*, const char*,
                  const char*, Evas_Smart_Cb);
   Evas_Object* CreateControlButtons(Evas_Object*);
+  void DidStartInspectorServer(unsigned port);
 
   static void OnToolboxWindowDelRequest(void* data, Evas_Object*, void*);
   static void OnWindowElementClicked(void* data, Evas_Object*, void*);
@@ -52,6 +68,7 @@ class Browser {
   static void OnVibrationStart(uint64_t vibration_time, void*);
   static void OnVibrationStop(void*);
   static Eina_Bool OnVibrationTimeout(void*);
+  static void OnSignalHandler(int);
 
   typedef struct _WindowMapData {
     Window*          window;
@@ -70,12 +87,15 @@ class Browser {
   bool desktop_;
   bool inspector_started_;
   bool tracing_enabled_;
+  std::string user_agent_;
+  std::string tizen_version_;
 
 #if defined(OS_TIZEN)
   Ecore_Timer* haptic_timer_id_;
   haptic_device_h haptic_handle_;
   haptic_effect_h haptic_effect_;
 #endif
+  GUILevel gui_level_;
 };
 
 #endif // _BROWSER_H_
index 03f3053..94b53e2 100644 (file)
@@ -1,9 +1,8 @@
-// Copyright 2014 Samsung Electronics. All rights reserved.
+// Copyright 2016 Samsung Electronics. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #include <EWebKit_internal.h>
-#include <ewk_chromium.h>
 #include <Elementary.h>
 #include <getopt.h>
 #include <unistd.h>
 #include "browser.h"
 #include "logger.h"
 
+// Default command line flags for all profiles and platforms
+const char* kDefaultCommandLineFlags[] = {
+    "allow-file-access-from-files",
+    "process-per-tab",
+};
+
 // Default command line flags added by default when
 // ubrowser is started with --mobile|-m flag.
 const char* kMobileFlags[] = {
@@ -27,10 +32,14 @@ const char* kMobileFlags[] = {
 
 extern int logger_show_trace;
 extern int logger_use_color;
-#if defined(OS_TIZEN)
-int desktop_ui = 0;
+std::string user_agent;
+std::string tizen_version;
+Browser::GUILevel gui_level = Browser::UBROWSER_GUI_LEVEL_URL_ONLY;
+double zoom_factor = 0;
+#if defined(OS_TIZEN) && !defined(OS_TIZEN_TV_PRODUCT)
+int desktop_mode = 0;
 #else
-int desktop_ui = 1;
+int desktop_mode = 1;
 #endif
 
 struct AppData {
@@ -44,30 +53,66 @@ struct AppData {
 void show_help_and_exit(const char* app_name) {
   printf("Usage: %s [OPTION]... [URL]...\n\n", app_name);
   printf("Available options:\n");
-  printf("  -v, --verbose   Print verbose application logs\n");
-  printf("  -n, --no-color  Don't use colors in application logs\n");
-  printf("  -d, --desktop   Run application UI in desktop mode\n");
-  printf("  -m, --mobile    Run application UI in mobile mode\n");
-  printf("  -h, --help      Show this help message\n");
+  printf("  -v, --verbose    Print verbose application logs\n");
+  printf("  -n, --no-color   Don't use colors in application logs\n");
+  printf("  -d, --desktop    Run application UI in desktop mode\n");
+  printf("  -m, --mobile     Run application UI in mobile mode\n");
+  printf("  -u, --user-agent Set user agent string\n");
+  printf("  -l, --gui-level  Run application different GUI elements\n");
+  printf("        0 - no GUI\n");
+  printf("        1 - show URL bar only, default option\n");
+  printf("        2 - minimal GUI\n");
+  printf("        3 - full GUI\n");
+  printf("  -z, --zoom       Set zoom factor using double number\n");
+  printf("  -h, --help       Show this help message\n");
+  printf("  -t, --tizen      Run WebView with compliance to Tizen version,\n");
+  printf("                   for example, -t 2.4 or -t 2.3.1 etc.\n");
   exit(0);
 }
 
-void parse_options(int argc, char** argv) {
+static bool verify_gui_level(const char* value) {
+  int level = atoi(value);
+
+  if ((level == 0 && value[0] != '0') ||
+      level < Browser::UBROWSER_GUI_LEVEL_NONE ||
+      level > Browser::UBROWSER_GUI_LEVEL_ALL) {
+    log_error("Unsupported GUI level!");
+    return false;
+  }
+
+  gui_level = static_cast<Browser::GUILevel>(level);
+  return true;
+}
+
+static bool verify_zoom_factor(const char* value) {
+  double zoom = atof(value);
+
+  if (zoom <= 0 || zoom > 5) {
+    log_error("Unsupported Zoom factor!");
+    return false;
+  }
+
+  zoom_factor = zoom;
+  return true;
+}
+
+void parse_options(int argc, char** argv, AppData* data) {
   int show_help = 0;
-  int c;
 
   while (1) {
+    int c = -1;
     static struct option long_options[] = {
-      {"verbose",  no_argument, &logger_show_trace, 1},
-      {"no-color", no_argument, &logger_use_color,  0},
-      {"desktop",  no_argument, &desktop_ui, 1},
-      {"mobile",   no_argument, &desktop_ui, 0},
-      {"help",     no_argument, &show_help, 1},
-      {0, 0, 0, 0}
-    };
+        {"desktop", no_argument, &desktop_mode, 1},
+        {"mobile", no_argument, &desktop_mode, 0},
+        {"user-agent", required_argument, 0, 'u'},
+        {"gui-level", required_argument, 0, 'l'},
+        {"zoom", required_argument, 0, 'z'},
+        {"help", no_argument, &show_help, 1},
+        {"tizen-version", required_argument, 0, 't'},
+        {0, 0, 0, 0}};
 
     int option_index = 0;
-    c = getopt_long (argc, argv, "vndmh", long_options, &option_index);
+    c = getopt_long(argc, argv, "vndmhu:l:z:t:", long_options, &option_index);
 
     if (c == -1)
       break;
@@ -80,14 +125,28 @@ void parse_options(int argc, char** argv) {
       logger_use_color = 0;
       break;
     case 'd':
-      desktop_ui = 1;
+      desktop_mode = 1;
       break;
     case 'm':
-      desktop_ui = 0;
+      desktop_mode = 0;
       break;
     case 'h':
       show_help = 1;
       break;
+    case 'u':
+      user_agent = optarg;
+      break;
+    case 'l':
+      if (!verify_gui_level(optarg))
+        show_help = 1;
+      break;
+    case 'z':
+      if (!verify_zoom_factor(optarg))
+        show_help = 1;
+      break;
+    case 't':
+        tizen_version = optarg;
+        break;
     default:
       // Ignore EFL or chromium specific options,
       // ewk_set_arguments should handle them
@@ -97,6 +156,13 @@ void parse_options(int argc, char** argv) {
 
   if (show_help)
     show_help_and_exit(argv[0]);
+
+  for (int i = optind; i < argc; ++i)
+    if (argv[i][0] != '-')
+      data->urls.push_back(std::string(argv[i]));
+
+  if (data->urls.empty())
+    data->urls.push_back("http://www.google.com");
 }
 
 static bool app_create(void* data) {
@@ -107,7 +173,10 @@ static bool app_create(void* data) {
 
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
 
-  app_data->browser = new Browser(desktop_ui);
+  app_data->browser =
+      new Browser(desktop_mode, gui_level, user_agent, tizen_version);
+  if (zoom_factor > 0)
+    app_data->browser->SetDefaultZoomFactor(zoom_factor);
   std::vector<std::string>::iterator it = app_data->urls.begin();
   for (;it != app_data->urls.end(); ++it)
     app_data->browser->CreateWindow().LoadURL(*it);
@@ -134,30 +203,34 @@ static void app_resume(void* data) {
 }
 #endif // OS_TIZEN
 
-int main(int argc, char** argv) {
-  AppData data;
+// Passes user args and adds custom ubrowser flags.
+static void set_arguments(int argc, char** argv) {
+  static std::vector<char*> ubrowser_argv;
+  // Copy original params first.
+  for (int i = 0; i < argc; i++)
+    ubrowser_argv.push_back(argv[i]);
 
-  for (int i = 1; i < argc; ++i)
-    if (argv[i][0] != '-')
-      data.urls.push_back(std::string(argv[i]));
+  // Add a default command lines.
+  for (auto arg : kDefaultCommandLineFlags)
+    ubrowser_argv.push_back(const_cast<char*>(arg));
 
-  if (data.urls.empty())
-    data.urls.push_back("http://www.google.com");
+    // Add mobile flags for desktop ubrowser --mobile|-m.
+#if !defined(OS_TIZEN)
+  if (!desktop_mode) {
+    for (auto arg : kMobileFlags)
+      ubrowser_argv.push_back(const_cast<char*>(arg));
+  }
+#endif
+  ewk_set_arguments(ubrowser_argv.size(), ubrowser_argv.data());
+}
 
-  ewk_set_arguments(argc, argv);
+int main(int argc, char** argv) {
   elm_init(argc, argv);
   elm_config_accel_preference_set("opengl");
-  parse_options(argc, argv);
 
-// Do not propagate mobile flags for all TIZEN builds.
-// They are controlled by command_line_efl.cc.
-#if !defined(OS_TIZEN)
-  if (!desktop_ui) {
-    int size = sizeof(kMobileFlags) / sizeof(kMobileFlags[0]);
-    for (int i = 0; i < size; ++i)
-      ewk_chromium_append_command_line_flag(kMobileFlags[i]);
-  }
-#endif
+  AppData data;
+  parse_options(argc, argv, &data);
+  set_arguments(argc, argv);
 
   int ret = 0;
 // Enable the section below once ubrowser is ready
index 0b3fe19..f652715 100644 (file)
@@ -4,21 +4,60 @@
 
 #include "window.h"
 
-#include <assert.h>
 #include <EWebKit.h>
 #include <EWebKit_internal.h>
 #include <EWebKit_product.h>
 #include <Elementary.h>
+#include <assert.h>
+#include <vector>
 
 #include "browser.h"
 #include "logger.h"
 #include "window_ui.h"
 
+#include "tizen/system_info.h"
+
+#if defined(OS_TIZEN)
+#include <efl_extension.h>
+#endif
+
 #if defined(OS_TIZEN_TV_PRODUCT)
 #include "ecore_x_wayland_wrapper.h"
 #include <cursor_module.h>
 #endif
 
+#if defined(OS_TIZEN)
+#if !defined(EWK_BRINGUP)
+//#include "tizen_src/ewk/efl_integration/public/ewk_media_playback_info.h"
+#endif
+static Ewk_Application_Type application_type = EWK_APPLICATION_TYPE_OTHER;
+#endif
+#if defined(OS_TIZEN_TV_PRODUCT)
+#if !defined(EWK_BRINGUP)
+#include "tizen_src/ewk/efl_integration/public/ewk_media_subtitle_info.h"
+#endif
+#endif
+
+// Parses tizen version string (2.4 | 2.3.1 | 3.0 etc).
+// Output std::vector where
+//   std::vector[0] = major,
+//   std::vector[1] = minor,
+//   std::vector[2] = release,
+// In case of failure all values of vector are zero.
+std::vector<unsigned> ParseTizenVersion(const std::string& tizen_string) {
+  std::vector<unsigned> version(3, 0);
+  for (unsigned i = 0, index = 0; i < tizen_string.size(); i++) {
+    if ((i % 2) == 0) {
+      if (isdigit(tizen_string[i]) && index < version.size())
+        version[index++] = atoi(&tizen_string[i]);
+      else
+        return std::vector<unsigned>(3, 0);
+     } else if (tizen_string[i] != '.')
+        return std::vector<unsigned>(3, 0);
+  }
+  return version;
+}
+
 Window::Window(Browser& browser, int width, int height, bool incognito)
     : browser_(browser)
     , is_fullscreen_(false) {
@@ -26,6 +65,11 @@ Window::Window(Browser& browser, int width, int height, bool incognito)
   evas_object_resize(window_, width, height);
   elm_win_autodel_set(window_, EINA_TRUE);
 
+  if (IsMobileProfile() && !IsWearableProfile()) {
+    elm_win_indicator_mode_set(window_, ELM_WIN_INDICATOR_SHOW);
+    elm_win_indicator_opacity_set(window_, ELM_WIN_INDICATOR_OPAQUE);
+  }
+
   Evas_Object* conform = elm_conformant_add(window_);
   evas_object_size_hint_weight_set(conform,
                                    EVAS_HINT_EXPAND,
@@ -42,33 +86,58 @@ Window::Window(Browser& browser, int width, int height, bool incognito)
   elm_box_pack_end(box, ui_->GetURLBar());
   evas_object_show(ui_->GetURLBar());
 
+  // Add elm_bg for focusing
+  web_view_elm_host_ = elm_bg_add(window_);
+  evas_object_size_hint_align_set(web_view_elm_host_, EVAS_HINT_FILL,
+                                  EVAS_HINT_FILL);
+  evas_object_size_hint_weight_set(web_view_elm_host_, EVAS_HINT_EXPAND,
+                                   EVAS_HINT_EXPAND);
+  elm_box_pack_end(box, web_view_elm_host_);
+  elm_object_focus_allow_set(web_view_elm_host_, EINA_TRUE);
+  elm_object_focus_set(web_view_elm_host_, EINA_TRUE);
+  evas_object_show(web_view_elm_host_);
+
   Evas* evas = evas_object_evas_get(window_);
+
   if (incognito)
     web_view_ = ewk_view_add_in_incognito_mode(evas);
   else
     web_view_ = ewk_view_add(evas);
+
   evas_object_resize(web_view_, width, height);
-  evas_object_size_hint_align_set(web_view_, EVAS_HINT_FILL, EVAS_HINT_FILL);
-  evas_object_size_hint_weight_set(web_view_, EVAS_HINT_EXPAND,
-                                   EVAS_HINT_EXPAND);
-  elm_box_pack_end(box, web_view_);
-  evas_object_show(web_view_);
+  elm_object_part_content_set(web_view_elm_host_, "overlay", web_view_);
+
+  Evas_Object* navbar = ui_->GetNavBar();
+  if (navbar) {
+    elm_box_pack_end(box, navbar);
+    evas_object_show(navbar);
+  }
+
+  std::string ua = browser_.GetUserAgent();
+  if (!ua.empty())
+    SetUserAgent(ua.c_str());
 
-  elm_box_pack_end(box, ui_->GetNavBar());
-  evas_object_show(ui_->GetNavBar());
+  evas_object_smart_callback_add(web_view_elm_host_, "focused",
+                                 &Window::OnHostFocusedIn, this);
+  evas_object_smart_callback_add(web_view_elm_host_, "unfocused",
+                                 &Window::OnHostFocusedOut, this);
 
   evas_object_smart_callback_add(web_view_, "title,changed",
                                  &Window::OnTitleChanged, this);
   evas_object_smart_callback_add(web_view_, "url,changed",
                                  &Window::OnURLChanged, this);
-  evas_object_smart_callback_add(web_view_, "load,progress,started",
+  evas_object_smart_callback_add(web_view_, "load,started",
                                  &Window::OnLoadStarted, this);
-  evas_object_smart_callback_add(web_view_, "load,progress,finished",
+  evas_object_smart_callback_add(web_view_, "load,finished",
                                  &Window::OnLoadFinished, this);
   evas_object_smart_callback_add(web_view_, "create,window",
                                  &Window::OnNewWindowRequest, this);
   evas_object_smart_callback_add(web_view_, "console,message",
                                  &Window::OnConsoleMessage, NULL);
+#if defined(TIZEN_TBM_SUPPORT) && defined(OS_TIZEN_TV_PRODUCT)
+  evas_object_smart_callback_add(web_view_, "notify,video,texturing",
+                                 &Window::OnVideotexturing, NULL);
+#endif
   evas_object_smart_callback_add(web_view_, "policy,newwindow,decide",
                                  &Window::OnNewWindowPolicyDecide, NULL);
   evas_object_smart_callback_add(web_view_, "back,forward,list,changed",
@@ -81,26 +150,82 @@ Window::Window(Browser& browser, int width, int height, bool incognito)
                                  &Window::OnEnterFullScreenRequest, this);
   evas_object_smart_callback_add(web_view_, "fullscreen,exitfullscreen",
                                  &Window::OnExitFullScreenRequest, this);
-
+  evas_object_smart_callback_add(web_view_, "form,repost,warning,show",
+                                 &Window::OnFormRepostWarningShow, this);
+  evas_object_smart_callback_add(web_view_, "before,repost,warning,show",
+                                 &Window::OnBeforeFormRepostWarningShow, this);
+
+#if defined(OS_TIZEN)
+  if (IsTvProfile()) {
+    evas_object_event_callback_add(web_view_, EVAS_CALLBACK_KEY_DOWN,
+                                   &Window::OnKeyDown, this);
+    if (application_type == EWK_APPLICATION_TYPE_HBBTV) {
+#if defined(OS_TIZEN_TV_PRODUCT)
+      evas_object_smart_callback_add(web_view_, "notify,subtitle,play",
+                                     &Window::On_Notify_Subtitle_Play, this);
+      evas_object_smart_callback_add(web_view_, "notify,subtitle,stop",
+                                     &Window::On_Notify_Subtitle_Stop, this);
+      evas_object_smart_callback_add(web_view_, "notify,video,pause",
+                                     &Window::On_Notify_Video_Pause, this);
+      evas_object_smart_callback_add(web_view_, "notify,video,resume",
+                                     &Window::On_Notify_Video_Resume, this);
+      evas_object_smart_callback_add(web_view_, "notify,video,seek,start",
+                                     &Window::On_Notify_Video_Seek_Start, this);
+      evas_object_smart_callback_add(web_view_, "notify,video,seek,completed",
+                                     &Window::On_Notify_Video_Seek_Completed,
+                                     this);
+      evas_object_smart_callback_add(web_view_, "on,subtitle,data",
+                                     &Window::On_Subtitle_Data, this);
+      evas_object_smart_callback_add(web_view_, "video,playback,load",
+                                     &Window::On_Video_Playback_Load, this);
+      evas_object_smart_callback_add(web_view_, "notification,playback,ready",
+                                     &Window::On_Video_Playback_Ready, this);
+      evas_object_smart_callback_add(web_view_, "video,playback,start",
+                                     &Window::On_Video_Playback_Start, this);
+      evas_object_smart_callback_add(web_view_, "video,playback,stop",
+                                     &Window::On_Video_Playback_Stop, this);
+      ewk_settings_media_subtitle_notification_set(GetEwkSettings(), true);
+#endif
+      ewk_settings_media_playback_notification_set(GetEwkSettings(), true);
+      Ewk_Context* context = ewk_view_context_get(web_view_);
+      ewk_context_application_type_set(context, application_type);
+    }
+  }
+#endif
   ewk_view_quota_permission_request_callback_set(
       web_view_, &Window::OnQuotaPermissionRequest, this);
+  ewk_view_did_change_theme_color_callback_set(
+      web_view_, &Window::OnThemeColorChanged, this);
 
   ewk_settings_form_profile_data_enabled_set(GetEwkSettings(), true);
   ewk_settings_form_candidate_data_enabled_set(GetEwkSettings(), true);
+  ewk_settings_uses_keypad_without_user_action_set(GetEwkSettings(), false);
 
   // Auto fit is already turned on for mobile, enable it for "ubrowser --mobile" as well.
   ewk_settings_auto_fitting_set(GetEwkSettings(), !browser_.IsDesktop());
 
+#if defined(OS_TIZEN)
+  eext_object_event_callback_add(window_, EEXT_CALLBACK_BACK, &Window::OnHWBack,
+                                 this);
+#endif
+
   if (elm_win_wm_rotation_supported_get(window_)) {
-    static const int rots[] = {0, 90, 270};
-    elm_win_wm_rotation_available_rotations_set(
-        window_, rots, (sizeof(rots) / sizeof(int)));
+    SetAutoRotate();
     evas_object_smart_callback_add(window_, "wm,rotation,changed",
                                    &Window::OnOrientationChanged, this);
   }
 
-  EnableMouseEvents(browser_.IsDesktop());
-  EnableTouchEvents(!browser_.IsDesktop());
+  if (IsTvProfile()) {
+    // In tv profile, we should use MouseEvent.
+    EnableMouseEvents(true);
+    EnableTouchEvents(false);
+  } else {
+    EnableMouseEvents(browser_.IsDesktop());
+    EnableTouchEvents(!browser_.IsDesktop());
+  }
+#if defined(OS_TIZEN_TV_PRODUCT)
+  CreateMouseCursor();
+#endif
 
   evas_object_show(window_);
 }
@@ -110,6 +235,11 @@ Window::~Window() {
   // deleting view will release context
   evas_object_del(web_view_);
   delete ui_;
+
+#if defined(OS_TIZEN)
+  eext_object_event_callback_del(window_, EEXT_CALLBACK_BACK,
+                                 &Window::OnHWBack);
+#endif
 }
 
 Ewk_Settings* Window::GetEwkSettings() const {
@@ -121,12 +251,14 @@ void Window::LoadURL(std::string url) {
   const static std::string https = "https://";
   const static std::string file = "file://";
   const static std::string about = "about:";
+  const static std::string chrome = "chrome://";
   if (url.compare(0, 1, "/") == 0) {
     url = "file://" + url;
   } else if (url.compare(0, http.length(), http) != 0 &&
-      url.compare(0, https.length(), https) != 0 &&
-      url.compare(0, file.length(), file) != 0 &&
-      url.compare(0, about.length(), about) != 0) {
+             url.compare(0, https.length(), https) != 0 &&
+             url.compare(0, file.length(), file) != 0 &&
+             url.compare(0, about.length(), about) != 0 &&
+             url.compare(0, chrome.length(), chrome) != 0) {
     url = "http://" + url;
   }
   log_info("Loading URL: %s", url.c_str());
@@ -263,10 +395,152 @@ void Window::SetScale(double scale) {
   ewk_view_scale_set(web_view_, scale, 0, 0);
 }
 
+void Window::ShowInspectorURL(const char* url) {
+  ui_->ShowInspectorURLPopup(url);
+}
+
 Window::IdType Window::Id() const {
   return window_;
 }
 
+void Window::SetAutoRotate() {
+  static const int rots[] = {0, 90, 180, 270};
+  elm_win_wm_rotation_available_rotations_set(window_, rots,
+                                              (sizeof(rots) / sizeof(int)));
+}
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+void Window::On_Video_Playback_Load(void* data,
+                                    Evas_Object*,
+                                    void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  Ewk_Media_Playback_Info* playbackInfo = (Ewk_Media_Playback_Info*)event_info;
+  const char* video_url = ewk_media_playback_info_media_url_get(playbackInfo);
+  const char* mime_type = ewk_media_playback_info_mime_type_get(playbackInfo);
+  char translated_url[] =
+      "http://www.w3schools.com/html/mov_bbb.mp4";  // for test
+  log_trace(
+      ">> video playback start: video_url(%s),  mime_type(%s), "
+      "translated_url(%s)\n",
+      video_url, mime_type, translated_url);
+  ewk_media_playback_info_translated_url_set(playbackInfo, translated_url);
+}
+
+void Window::On_Video_Playback_Ready(void* data,
+                                     Evas_Object*,
+                                     void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+}
+
+void Window::On_Video_Playback_Start(void* data,
+                                     Evas_Object*,
+                                     void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+
+  Ewk_Media_Playback_Info* playbackInfo = (Ewk_Media_Playback_Info*)event_info;
+  const char* video_url = ewk_media_playback_info_media_url_get(playbackInfo);
+  const char* mime_type = ewk_media_playback_info_mime_type_get(playbackInfo);
+  char translated_url[] =
+      "http://www.w3schools.com/html/mov_bbb.mp4";  // for test
+
+  log_trace(
+      ">> video playback start: video_url(%s),  mime_type(%s), "
+      "translated_url(%s)\n",
+      video_url, mime_type, translated_url);
+  ewk_media_playback_info_media_resource_acquired_set(playbackInfo, 1);
+}
+
+void Window::On_Video_Playback_Stop(void* data,
+                                    Evas_Object*,
+                                    void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+
+  Ewk_Media_Playback_Info* playbackInfo = (Ewk_Media_Playback_Info*)event_info;
+  const char* video_url = ewk_media_playback_info_media_url_get(playbackInfo);
+  log_trace("<< video playback stop : video_url(%s)\n", video_url);
+
+  Window* thiz = static_cast<Window*>(data);
+  char translated_url[] =
+      "http://www.w3schools.com/html/mov_bbb.mp4";  // for test
+  // TODO: Once the ewk api is added, remove EWK_BRINGUP
+#if !defined(EWK_BRINGUP)
+  ewk_media_translated_url_set(thiz->web_view_, translated_url);
+#endif
+}
+
+#if defined(TIZEN_TBM_SUPPORT)
+void Window::OnVideotexturing(void* data, Evas_Object*, void* event_info) {
+  log_message(INFO, true, "%s", __PRETTY_FUNCTION__);
+}
+#endif
+#endif  // defined(OS_TIZEN_TV_PRODUCT)
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+void Window::current_time_call(Evas_Object*, double ct, void* user_data) {
+  double timestamp = ct;
+  log_trace("<< current_time_call : timestamp (%f)\n", timestamp);
+}
+
+void Window::On_Notify_Subtitle_Play(void* data,
+                                     Evas_Object*,
+                                     void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+
+  Ewk_Media_Subtitle_Info* subtitleInfo = (Ewk_Media_Subtitle_Info*)event_info;
+  int id = ewk_media_subtitle_info_id_get(subtitleInfo);
+  const char* url = ewk_media_subtitle_info_url_get(subtitleInfo);
+  const char* lang = ewk_media_subtitle_info_lang_get(subtitleInfo);
+
+  log_trace("<< notify subtitle play : id(%d), url(%s), lang(%s)\n", id, url,
+            lang);
+}
+
+void Window::On_Notify_Subtitle_Stop(void* data,
+                                     Evas_Object*,
+                                     void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+}
+
+void Window::On_Notify_Video_Pause(void* data, Evas_Object*, void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+}
+
+void Window::On_Notify_Video_Resume(void* data,
+                                    Evas_Object*,
+                                    void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+}
+
+void Window::On_Notify_Video_Seek_Start(void* data,
+                                        Evas_Object*,
+                                        void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  double timestamp = *(double*)event_info;
+
+  log_trace("notify video seek start timestamp%s", timestamp);
+}
+
+void Window::On_Notify_Video_Seek_Completed(void* data,
+                                            Evas_Object*,
+                                            void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+}
+
+void Window::On_Subtitle_Data(void* data, Evas_Object*, void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  Ewk_Media_Subtitle_Data* subtitleData = (Ewk_Media_Subtitle_Data*)event_info;
+  int id = ewk_media_subtitle_data_id_get(subtitleData);
+  double timestamp = ewk_media_subtitle_data_timestamp_get(subtitleData);
+  unsigned size = ewk_media_subtitle_data_size_get(subtitleData);
+  const char* subtitile_data =
+      (const char*)(ewk_media_subtitle_data_get(subtitleData));
+  log_trace(
+      "<< notify subtitle data : id(%d), ts(%f), size(%d), "
+      "subtitile_data(%s)\n",
+      id, timestamp, size, subtitile_data);
+}
+#endif
+
 void Window::OnEnterFullScreenRequest(void* data, Evas_Object*,
                                       void* event_info) {
   log_trace("%s", __PRETTY_FUNCTION__);
@@ -281,6 +555,59 @@ void Window::OnExitFullScreenRequest(void* data, Evas_Object*,
   thiz->is_fullscreen_ = false;
 }
 
+void Window::OnBeforeFormRepostWarningShow(void* data,
+                                           Evas_Object*,
+                                           void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  Window* thiz = static_cast<Window*>(data);
+  thiz->ui_->ClosePopup();
+}
+
+void Window::OnUserFormRepostDecisionTaken(bool decision, void* data) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  Ewk_Form_Repost_Decision_Request* request =
+      static_cast<Ewk_Form_Repost_Decision_Request*>(data);
+  ewk_form_repost_decision_request_reply(request, decision);
+}
+
+void Window::OnFormRepostWarningShow(void* data,
+                                     Evas_Object*,
+                                     void* event_info) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  Ewk_Form_Repost_Decision_Request* request =
+      static_cast<Ewk_Form_Repost_Decision_Request*>(event_info);
+  Window* thiz = static_cast<Window*>(data);
+  thiz->ui_->ShowPermissionPopup(
+      "form repost warning",
+      "The page that you're looking for used information that you entered. "
+      "Returning to that page might cause any action that you took to be "
+      "repeated. Do you want to continue?",
+      OnUserFormRepostDecisionTaken, request);
+}
+
+#if defined(OS_TIZEN)
+void Window::OnKeyDown(void* data,
+                       Evas_Object*,
+                       Evas_Object* obj,
+                       void* event_info) {
+  if (IsTvProfile()) {
+    log_trace("%s", __PRETTY_FUNCTION__);
+    Window* thiz = static_cast<Window*>(data);
+
+    if (!event_info)
+      return;
+
+    const Evas_Event_Key_Down* key_down =
+        static_cast<Evas_Event_Key_Down*>(event_info);
+
+    if (!key_down->key)
+      return;
+    if (!strcmp(key_down->key, "XF86Back"))
+      thiz->Back();
+  }
+}
+#endif
+
 #if defined(OS_TIZEN_TV_PRODUCT)
 void Window::CreateMouseCursor() {
   log_trace("%s", __PRETTY_FUNCTION__);
@@ -334,7 +661,8 @@ void Window::CreateMouseCursor() {
 }
 #endif
 
-void Window::OnUserMediaPermissionRequest(void* data, Evas_Object*,
+void Window::OnUserMediaPermissionRequest(void* data,
+                                          Evas_Object*,
                                           void* event_info) {
   log_trace("%s", __PRETTY_FUNCTION__);
   Window* thiz = static_cast<Window*>(data);
@@ -432,10 +760,21 @@ void Window::OnOrientationChanged(void* data, Evas_Object *obj, void* event) {
   int rotation = elm_win_rotation_get(thiz->window_);
   // ewk_view_orientation_send expects angles: 0, 90, -90, 180.
   if (rotation == 270)
+    rotation = 90;
+  else if (rotation == 90)
     rotation = -90;
   ewk_view_orientation_send(thiz->web_view_, rotation);
 }
 
+#if defined(OS_TIZEN)
+void Window::OnHWBack(void* data, Evas_Object*, void*) {
+  Window* thiz = static_cast<Window*>(data);
+  log_trace("%s", __PRETTY_FUNCTION__);
+
+  thiz->Back();
+}
+#endif
+
 void Window::OnNewWindowPolicyDecide(void*, Evas_Object*, void* policy) {
   log_trace("%s", __PRETTY_FUNCTION__);
   Ewk_Policy_Decision *policy_decision = static_cast<Ewk_Policy_Decision*>(policy);
@@ -456,6 +795,36 @@ void Window::OnQuotaPermissionRequest(Evas_Object*, const Ewk_Quota_Permission_R
   ewk_view_quota_permission_request_reply(request, true);
 }
 
+void Window::OnThemeColorChanged(Evas_Object* o,
+                                 int r,
+                                 int g,
+                                 int b,
+                                 int a,
+                                 void* data) {
+  Window* thiz = static_cast<Window*>(data);
+  thiz->ui_->OnThemeColorChanged(r, g, b, a);
+}
+
+void Window::OnHostFocusedIn(void* data, Evas_Object*, void*) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  Window* thiz = static_cast<Window*>(data);
+  ewk_view_focus_set(thiz->web_view_, EINA_TRUE);
+}
+
+void Window::OnHostFocusedOut(void* data, Evas_Object*, void*) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  Window* thiz = static_cast<Window*>(data);
+  ewk_view_focus_set(thiz->web_view_, EINA_FALSE);
+}
+
+void Window::SetGoogleDataProxyHeaders() const {
+  ewk_view_custom_header_add(
+      web_view_, "Chrome-Proxy",
+      "ps=1477491020-304034222-240280515-829909815, "
+      "sid=b37590d308108e0b7a229352dee265d8, b=2704, p=103, c=linux");
+  ewk_view_custom_header_add(web_view_, "accept", "image/webp,*/*;q=0.8");
+}
+
 void Window::Exit() const {
   browser_.Exit();
 }
index 3243023..52bd135 100644 (file)
 #include <ewk_settings_internal.h>
 #include <ewk_quota_permission_request_internal.h>
 
-#if defined(OS_TIZEN_TV_PRODUCT)
-#include "chromium_impl/build/tizen_version.h"
-#endif
-
 class Browser;
 class WindowUI;
 
@@ -50,6 +46,9 @@ class Window {
   double GetScale() const;
   void GetScaleRange(double* minScale, double* maxScale) const;
   void SetScale(double);
+  void ShowInspectorURL(const char* url);
+  void SetGoogleDataProxyHeaders() const;
+  void SetAutoRotate();
   void Exit() const;
 
   IdType Id() const;
@@ -70,6 +69,53 @@ class Window {
   static void OnUserMediaPermissionDecisionTaken(bool decision, void* data);
   static void OnEnterFullScreenRequest(void*, Evas_Object*, void*);
   static void OnExitFullScreenRequest(void*, Evas_Object*, void*);
+  static void OnHostFocusedIn(void* data, Evas_Object*, void*);
+  static void OnHostFocusedOut(void* data, Evas_Object*, void*);
+  static void OnBeforeFormRepostWarningShow(void*, Evas_Object*, void*);
+  static void OnFormRepostWarningShow(void*, Evas_Object*, void*);
+  static void OnUserFormRepostDecisionTaken(bool decision, void* data);
+  static void OnThemeColorChanged(Evas_Object* o,
+                                  int r,
+                                  int g,
+                                  int b,
+                                  int a,
+                                  void* data);
+#if defined(OS_TIZEN)
+  static void OnHWBack(void*, Evas_Object*, void*);
+#endif
+
+#if defined(PWE_SUPPORT)
+  static void OnServiceWorkerRegistrationResult(Ewk_Context*,
+                                                const char*,
+                                                const char*,
+                                                Eina_Bool,
+                                                void*);
+  static void OnServiceWorkerUnregistrationResult(Ewk_Context*,
+                                                  const char*,
+                                                  Eina_Bool,
+                                                  void*);
+#endif
+
+#if defined(OS_TIZEN)
+  static void OnKeyDown(void*, Evas*, Evas_Object*, void*);
+#endif
+#if defined(OS_TIZEN_TV_PRODUCT)
+  static void On_Notify_Subtitle_Play(void*, Evas_Object*, void*);
+  static void On_Notify_Subtitle_Stop(void*, Evas_Object*, void*);
+  static void On_Notify_Video_Pause(void*, Evas_Object*, void*);
+  static void On_Notify_Video_Resume(void*, Evas_Object*, void*);
+  static void On_Notify_Video_Seek_Start(void*, Evas_Object*, void*);
+  static void On_Notify_Video_Seek_Completed(void*, Evas_Object*, void*);
+  static void On_Subtitle_Data(void*, Evas_Object*, void*);
+  static void current_time_call(Evas_Object*, double, void*);
+  static void On_Video_Playback_Load(void*, Evas_Object*, void*);
+  static void On_Video_Playback_Ready(void*, Evas_Object*, void*);
+  static void On_Video_Playback_Start(void*, Evas_Object*, void*);
+  static void On_Video_Playback_Stop(void*, Evas_Object*, void*);
+#if defined(TIZEN_TBM_SUPPORT)
+  static void OnVideotexturing(void*, Evas_Object*, void*);
+#endif  // defined(TIZEN_TBM_SUPPORT)
+#endif
 #if defined(OS_TIZEN_TV_PRODUCT)
   void CreateMouseCursor();
 #endif
@@ -77,6 +123,7 @@ class Window {
   WindowUI* ui_;
   Evas_Object* window_;
   Evas_Object* web_view_;
+  Evas_Object* web_view_elm_host_;
   bool is_fullscreen_;
 };
 
index 147c27a..3123a58 100644 (file)
 #include <EWebKit_internal.h>
 #include <EWebKit_product.h>
 
-#ifdef OS_TIZEN
-#include <efl_extension.h>
-#endif
-
 #include "browser.h"
 #include "logger.h"
 #include "window.h"
@@ -28,62 +24,36 @@ static int kNotificationTimeoutSec = 3;
 }
 
 WindowUI::WindowUI(Window& window, Browser& browser)
-    : window_(window)
-    , browser_(browser)
-    , active_popup_(NULL)
-    , menu_(0)
-    , is_loading_(false) {
-  navbar_ = elm_box_add(window_.GetEvasObject());
-  elm_box_horizontal_set(navbar_, EINA_TRUE);
-  elm_box_homogeneous_set(navbar_, EINA_TRUE);
-  evas_object_size_hint_weight_set(navbar_, EVAS_HINT_EXPAND, 0.0f);
-  evas_object_size_hint_align_set(navbar_, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
-  AddButton(navbar_, "file", "New Window", &WindowUI::OnCreateWindow);
-  if (browser_.IsDesktop())
-    AddButton(navbar_, "file", "New Incognito Window",
-              &WindowUI::OnCreateIncognitoWindow);
-  back_button_ = AddButton(navbar_, "arrow_left", "Back", &WindowUI::OnBack);
-  forward_button_ = AddButton(navbar_, "arrow_right", "Forward",
-                              &WindowUI::OnForward);
-  stop_reload_button_ = AddButton(navbar_, "refresh", "Reload",
-                                  &WindowUI::OnStopOrReload);
-  AddButton(navbar_, "arrow_up", "More Actions",
-            &WindowUI::OnShowExtraActionsMenu);
-
-  urlbar_ = elm_box_add(window_.GetEvasObject());
-  elm_box_horizontal_set(urlbar_, EINA_TRUE);
-  evas_object_size_hint_weight_set(urlbar_, EVAS_HINT_EXPAND, 0.0f);
-  evas_object_size_hint_align_set(urlbar_, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
-  progress_bar_ = elm_progressbar_add(window_.GetEvasObject());
-  elm_object_style_set(progress_bar_, "wheel");
-  elm_progressbar_pulse_set(progress_bar_, EINA_TRUE);
-  elm_progressbar_pulse(progress_bar_, EINA_FALSE);
-  elm_box_pack_end(urlbar_, progress_bar_);
-  evas_object_show(progress_bar_);
-
-  url_entry_ = elm_entry_add(urlbar_);
-  elm_entry_single_line_set(url_entry_, EINA_TRUE);
-  elm_entry_scrollable_set(url_entry_, EINA_TRUE);
-  elm_entry_input_panel_layout_set(url_entry_, ELM_INPUT_PANEL_LAYOUT_URL);
-  evas_object_size_hint_weight_set(url_entry_, EVAS_HINT_EXPAND, 1.0f);
-  evas_object_size_hint_align_set(url_entry_, EVAS_HINT_FILL, EVAS_HINT_FILL);
-  evas_object_smart_callback_add(url_entry_, "activated", OnURLEntered, this);
-  elm_box_pack_end(urlbar_, url_entry_);
-  evas_object_show(url_entry_);
-
-  Evas_Object* separator = elm_separator_add(urlbar_);
-  elm_separator_horizontal_set(separator, EINA_TRUE);
-  elm_box_pack_end(urlbar_, separator);
-  evas_object_show(separator);
-
-#if defined(OS_TIZEN)
-  eext_object_event_callback_add(window_.GetEvasObject(), EEXT_CALLBACK_BACK, WindowUI::OnBack, this);
+    : window_(window),
+      browser_(browser),
+      navbar_(nullptr),
+      urlbar_(nullptr),
+      url_entry_(nullptr),
+      stop_reload_button_(nullptr),
+      progress_bar_(nullptr),
+      forward_button_(nullptr),
+      back_button_(nullptr),
+      active_popup_(nullptr),
+      menu_(nullptr),
+#if defined(OS_TIZEN_TV_PRODUCT)
+      should_show_label_(true),
+#else
+      should_show_label_(browser_.IsDesktop()),
 #endif
-
-  EnableBackButton(false);
-  EnableForwardButton(false);
+      is_loading_(false) {
+  if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_URL_ONLY)
+    CreateTopBar();
+  if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_MINIMAL)
+    CreateBottomBar();
+
+  // TODO: Workaround for http://suprem.sec.samsung.net/jira/browse/TWF-843
+  if (IsTvProfile()) {
+    should_show_label_ = true;
+    Elm_Theme* theme = elm_theme_new();
+    elm_theme_set(theme, "tizen-HD-light");
+    elm_object_theme_set(navbar_, theme);
+    elm_theme_free(theme);
+  }
 }
 
 WindowUI::~WindowUI() {
@@ -93,35 +63,46 @@ WindowUI::~WindowUI() {
 
 void WindowUI::OnURLChanged(const char* url) {
   log_trace("%s: %s", __PRETTY_FUNCTION__, url);
-  elm_object_text_set(url_entry_, url);
+  if (url_entry_)
+    elm_object_text_set(url_entry_, url);
 }
 
 void WindowUI::OnLoadingStarted() {
   log_trace("%s", __PRETTY_FUNCTION__);
-  elm_progressbar_pulse(progress_bar_, EINA_TRUE);
-  Evas_Object* icon = elm_object_part_content_get(stop_reload_button_, "icon");
-  elm_icon_standard_set(icon, "close");
-  if (browser_.IsDesktop())
-    elm_object_text_set(stop_reload_button_, "Stop");
+  if (progress_bar_)
+    elm_progressbar_pulse(progress_bar_, EINA_TRUE);
+  if (stop_reload_button_) {
+    Evas_Object* icon =
+        elm_object_part_content_get(stop_reload_button_, "icon");
+    elm_icon_standard_set(icon, "close");
+    if (should_show_label_)
+      elm_object_text_set(stop_reload_button_, "Stop");
+  }
   is_loading_ = true;
 }
 
 void WindowUI::OnLoadingFinished() {
   log_trace("%s", __PRETTY_FUNCTION__);
-  elm_progressbar_pulse(progress_bar_, EINA_FALSE);
-  Evas_Object* icon = elm_object_part_content_get(stop_reload_button_, "icon");
-  elm_icon_standard_set(icon, "refresh");
-  if (browser_.IsDesktop())
-    elm_object_text_set(stop_reload_button_, "Reload");
+  if (progress_bar_)
+    elm_progressbar_pulse(progress_bar_, EINA_FALSE);
+  if (stop_reload_button_) {
+    Evas_Object* icon =
+        elm_object_part_content_get(stop_reload_button_, "icon");
+    elm_icon_standard_set(icon, "refresh");
+    if (should_show_label_)
+      elm_object_text_set(stop_reload_button_, "Reload");
+  }
   is_loading_ = false;
 }
 
 void WindowUI::EnableBackButton(bool enable) {
-  elm_object_disabled_set(back_button_, !enable);
+  if (back_button_)
+    elm_object_disabled_set(back_button_, !enable);
 }
 
 void WindowUI::EnableForwardButton(bool enable) {
-  elm_object_disabled_set(forward_button_, !enable);
+  if (forward_button_)
+    elm_object_disabled_set(forward_button_, !enable);
 }
 
 void WindowUI::ShowNotification(const char* text) {
@@ -135,12 +116,74 @@ void WindowUI::ShowNotification(const char* text) {
   evas_object_show(notification);
 }
 
+void WindowUI::CreateTopBar() {
+  urlbar_ = elm_box_add(window_.GetEvasObject());
+  elm_box_horizontal_set(urlbar_, EINA_TRUE);
+  evas_object_size_hint_weight_set(urlbar_, EVAS_HINT_EXPAND, 0.0f);
+  evas_object_size_hint_align_set(urlbar_, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+  if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_ALL) {
+    progress_bar_ = elm_progressbar_add(window_.GetEvasObject());
+    elm_object_style_set(progress_bar_, "wheel");
+    elm_progressbar_pulse_set(progress_bar_, EINA_TRUE);
+    elm_progressbar_pulse(progress_bar_, EINA_FALSE);
+    elm_box_pack_end(urlbar_, progress_bar_);
+    evas_object_show(progress_bar_);
+  }
+
+  url_entry_ = elm_entry_add(urlbar_);
+  elm_entry_single_line_set(url_entry_, EINA_TRUE);
+  elm_entry_scrollable_set(url_entry_, EINA_TRUE);
+  elm_entry_input_panel_layout_set(url_entry_, ELM_INPUT_PANEL_LAYOUT_URL);
+  evas_object_size_hint_weight_set(url_entry_, EVAS_HINT_EXPAND, 1.0f);
+  evas_object_size_hint_align_set(url_entry_, EVAS_HINT_FILL, EVAS_HINT_FILL);
+  evas_object_smart_callback_add(url_entry_, "activated", OnURLEntered, this);
+  elm_box_pack_end(urlbar_, url_entry_);
+  evas_object_color_get(url_entry_, &url_entry_color_.r, &url_entry_color_.g,
+                        &url_entry_color_.b, &url_entry_color_.a);
+  evas_object_show(url_entry_);
+
+  if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_ALL) {
+    Evas_Object* separator = elm_separator_add(urlbar_);
+    elm_separator_horizontal_set(separator, EINA_TRUE);
+    elm_box_pack_end(urlbar_, separator);
+    evas_object_show(separator);
+  }
+}
+
+void WindowUI::CreateBottomBar() {
+  navbar_ = elm_box_add(window_.GetEvasObject());
+  elm_box_horizontal_set(navbar_, EINA_TRUE);
+  elm_box_homogeneous_set(navbar_, EINA_TRUE);
+  evas_object_size_hint_weight_set(navbar_, EVAS_HINT_EXPAND, 0.0f);
+  evas_object_size_hint_align_set(navbar_, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+  if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_ALL) {
+    AddButton(navbar_, "file", "New Window", &WindowUI::OnCreateWindow);
+    if (browser_.IsDesktop())
+      AddButton(navbar_, "file", "New Incognito Window",
+                &WindowUI::OnCreateIncognitoWindow);
+  }
+
+  back_button_ = AddButton(navbar_, "arrow_left", "Back", &WindowUI::OnBack);
+  forward_button_ =
+      AddButton(navbar_, "arrow_right", "Forward", &WindowUI::OnForward);
+  stop_reload_button_ =
+      AddButton(navbar_, "refresh", "Reload", &WindowUI::OnStopOrReload);
+  if (browser_.GetGUILevel() >= Browser::UBROWSER_GUI_LEVEL_ALL)
+    AddButton(navbar_, "arrow_up", "More Actions",
+              &WindowUI::OnShowExtraActionsMenu);
+
+  EnableBackButton(false);
+  EnableForwardButton(false);
+}
+
 Evas_Object* WindowUI::AddButton(Evas_Object* parent,
     const char* icon, const char* label, Evas_Smart_Cb cb) {
   Evas_Object* bt = elm_button_add(parent);
   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5);
-  if (label && browser_.IsDesktop())
+  if (label && should_show_label_)
     elm_object_text_set(bt, label);
   if (icon) {
     Evas_Object* icon_elm = elm_icon_add(bt);
@@ -175,12 +218,11 @@ Evas_Object* WindowUI::CreateExtraActionsMenu(Evas_Object* parent) {
   }
   menu_ =  elm_ctxpopup_add(parent);
 
-  if (IsMobileProfile() || IsWearableProfile()) {
+  if ((IsMobileProfile() || IsWearableProfile())) {
     int width;
     evas_object_geometry_get(parent, 0, 0, &width, 0);
     evas_object_size_hint_min_set(menu_, width, 0);
   }
-
   evas_object_smart_callback_add(menu_, "dismissed", _HideCtxPopup, NULL);
 
   if (window_.IsFormProfileEnabled()) {
@@ -217,6 +259,9 @@ Evas_Object* WindowUI::CreateExtraActionsMenu(Evas_Object* parent) {
     elm_ctxpopup_item_append(menu_, "Start Web Inspector server", NULL,
                              &WindowUI::OnInspectorServerStart, this);
   }
+
+  elm_ctxpopup_item_append(menu_, "Use Google data proxy", NULL,
+                           &WindowUI::OnUseGoogleDataProxy, this);
 #if !defined(OS_TIZEN)
   elm_ctxpopup_item_append(menu_, "Simulate screen rotation", NULL,
       &WindowUI::OnRotate, this);
@@ -247,6 +292,14 @@ Evas_Object* WindowUI::CreateExtraActionsMenu(Evas_Object* parent) {
                              &WindowUI::OnAutoFittingDisabled, this);
   }
 
+  if (!ewk_settings_scripts_can_open_windows_get(settings)) {
+    elm_ctxpopup_item_append(menu_, "Enable js window.open", NULL,
+                             &WindowUI::OnScriptWindowOpenEnabled, this);
+  } else {
+    elm_ctxpopup_item_append(menu_, "Disable js window.open", NULL,
+                             &WindowUI::OnScriptWindowOpenDisabled, this);
+  }
+
   if (!ewk_settings_form_profile_data_enabled_get(settings) ||
      !ewk_settings_form_candidate_data_enabled_get(settings)) {
     elm_ctxpopup_item_append(menu_, "Enable autofill", NULL,
@@ -294,6 +347,20 @@ void WindowUI::ShowPermissionPopup(const char* title,
   evas_object_show(popup);
 }
 
+void WindowUI::OnThemeColorChanged(int r, int g, int b, int a) {
+  log_trace("%s: rgba(%d, %d, %d, %d)", __PRETTY_FUNCTION__, r, g, b, a);
+  if (url_entry_) {
+    // FIXME: For darker colors font color is to close to background color in
+    // entry. It is style dependent, so style modification or change would be
+    // needed to solve that issue.
+    if (a != 0)
+      evas_object_color_set(url_entry_, r, g, b, a);
+    else
+      evas_object_color_set(url_entry_, url_entry_color_.r, url_entry_color_.g,
+                            url_entry_color_.b, url_entry_color_.a);
+  }
+}
+
 void WindowUI::PermissionGranted(void* data, Evas_Object* button, void*) {
   log_trace("%s", __PRETTY_FUNCTION__);
 
@@ -312,6 +379,21 @@ void WindowUI::PermissionDeclined(void* data, Evas_Object* button, void*) {
   delete buttonData;
 }
 
+void WindowUI::ShowInspectorURLPopup(const char* url) {
+  log_trace("%s : %s", __PRETTY_FUNCTION__, url);
+  Evas_Object* popup = elm_popup_add(window_.GetEvasObject());
+  elm_object_part_text_set(popup, "title,text", url);
+  elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
+  active_popup_ = popup;
+
+  Evas_Object* btn = elm_button_add(popup);
+  elm_object_text_set(btn, "Close");
+  evas_object_smart_callback_add(btn, "clicked", ClosePopup, this);
+  elm_object_part_content_set(popup, "button1", btn);
+
+  evas_object_show(popup);
+}
+
 void WindowUI::ShowTextEntryPopup(const char* title,
                                   const char* initial_content,
                                   Evas_Smart_Cb cb) {
@@ -441,6 +523,15 @@ void WindowUI::OnInspectorServerStart(void* data, Evas_Object* obj, void*) {
     thiz->CloseMenu();
 }
 
+void WindowUI::OnUseGoogleDataProxy(void* data, Evas_Object* obj, void*) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  WindowUI* thiz = static_cast<WindowUI*>(data);
+  ewk_context_proxy_set(ewk_context_default_get(), "compress.googlezip.net:80",
+                        "<local>");
+  thiz->window_.SetGoogleDataProxyHeaders();
+  thiz->CloseMenu();
+}
+
 void WindowUI::OnRotate(void* data, Evas_Object* obj, void*) {
   log_trace("%s", __PRETTY_FUNCTION__);
   WindowUI* thiz = static_cast<WindowUI*>(data);
@@ -520,12 +611,37 @@ void WindowUI::OnAutoFillDisabled(void* data, Evas_Object* obj, void*) {
   thiz->ShowNotification("Autofill disabled");
 }
 
+void WindowUI::OnScriptWindowOpenEnabled(void* data, Evas_Object* obj, void*) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  WindowUI* thiz = static_cast<WindowUI*>(data);
+  Ewk_Settings* settings = thiz->window_.GetEwkSettings();
+  ewk_settings_scripts_can_open_windows_set(settings, true);
+  thiz->CloseMenu();
+  thiz->ShowNotification("JS window.open enabled");
+}
+
+void WindowUI::OnScriptWindowOpenDisabled(void* data, Evas_Object* obj, void*) {
+  log_trace("%s", __PRETTY_FUNCTION__);
+  WindowUI* thiz = static_cast<WindowUI*>(data);
+  Ewk_Settings* settings = thiz->window_.GetEwkSettings();
+  ewk_settings_scripts_can_open_windows_set(settings, false);
+  thiz->CloseMenu();
+  thiz->ShowNotification("JS window.open disabled");
+}
+
 void WindowUI::ClosePopup(void* data, Evas_Object*, void*) {
   WindowUI* thiz = static_cast<WindowUI*>(data);
   evas_object_del(thiz->active_popup_);
   thiz->active_popup_ = NULL;
 }
 
+void WindowUI::ClosePopup() {
+  if (active_popup_) {
+    evas_object_del(active_popup_);
+    active_popup_ = NULL;
+  }
+}
+
 void WindowUI::OnShowZoomPopup(void* data, Evas_Object* obj, void*) {
   log_trace("%s", __PRETTY_FUNCTION__);
   WindowUI* thiz = static_cast<WindowUI*>(data);
index 940e38b..0a05495 100644 (file)
@@ -33,16 +33,28 @@ class WindowUI {
   void EnableBackButton(bool);
   void EnableForwardButton(bool);
 
-  void ShowNotification(const char* text);
   void ShowPermissionPopup(const char* title, const char* description,
                            PermissionCallback, void* data);
+  void ShowInspectorURLPopup(const char* url);
+
+  void OnThemeColorChanged(int r, int g, int b, int a);
+  void ClosePopup();
 
  private:
+  void CreateTopBar();
+  void CreateBottomBar();
   Evas_Object* AddButton(Evas_Object*, const char*,
                          const char*, Evas_Smart_Cb);
   Evas_Object* CreateExtraActionsMenu(Evas_Object*);
   void ShowTextEntryPopup(const char* title,
                           const char* initial_content, Evas_Smart_Cb);
+  void ShowNotification(const char* text);
+#if defined(PWE_SUPPORT)
+  void ShowTextEntriesPopup(const char* title,
+                            const std::vector<const char*>& keys,
+                            Evas_Smart_Cb cb);
+#endif
+
   void CloseMenu();
 
   // Nav bar callbacks
@@ -61,6 +73,7 @@ class WindowUI {
   static void OnUAOverrideEntered(void* data, Evas_Object*, void*);
   static void OnInspectorShow(void* data, Evas_Object*, void*);
   static void OnInspectorServerStart(void* data, Evas_Object* obj, void*);
+  static void OnUseGoogleDataProxy(void* data, Evas_Object* obj, void*);
   static void OnRotate(void* data, Evas_Object*, void*);
   static void OnSelectMouseInput(void* data, Evas_Object*, void*);
   static void OnSelectTouchInput(void* data, Evas_Object*, void*);
@@ -71,6 +84,9 @@ class WindowUI {
   static void OnAutoFillEnabled(void* data, Evas_Object*, void*);
   static void OnAutoFillDisabled(void* data, Evas_Object*, void*);
 
+  static void OnScriptWindowOpenEnabled(void* data, Evas_Object* obj, void*);
+  static void OnScriptWindowOpenDisabled(void* data, Evas_Object* obj, void*);
+
   static void ClosePopup(void* data, Evas_Object*, void*);
   static void OnShowZoomPopup(void* data, Evas_Object*, void*);
   static void OnZoomChanged(void* data, Evas_Object*, void*);
@@ -96,7 +112,15 @@ class WindowUI {
   Evas_Object* active_popup_;
   Evas_Object* menu_;
 
+  bool should_show_label_;
   bool is_loading_;
+
+  struct Color {
+    int r;
+    int g;
+    int b;
+    int a;
+  } url_entry_color_;
 };
 
 #endif // _WINDOW_UI_H_