Add popup support for runtime and impl to allow cert erros 92/189792/1
authorSuneel Kota <suneel.kota@samsung.com>
Thu, 20 Sep 2018 12:48:41 +0000 (18:18 +0530)
committerSuneel Kota <suneel.kota@samsung.com>
Thu, 20 Sep 2018 13:04:15 +0000 (18:34 +0530)
this patch adds the popup support, it also adds
the required implementation for providing option
to ALLOW or DENY when certificate error occurs and
remember the old option selected.

Change-Id: Ie479998172322434ad2d948bbacfe91bf00675ac
Signed-off-by: Suneel Kota <suneel.kota@samsung.com>
atom/browser/api/atom_api_app.cc
atom/browser/api/atom_api_app.h
tizen/common/constants.cc
tizen/common/constants.h
tizen/src/browser/popup.cc [new file with mode: 0644]
tizen/src/browser/popup.h [new file with mode: 0644]
tizen/src/browser/popup_string.cc [new file with mode: 0644]
tizen/src/browser/popup_string.h [new file with mode: 0644]
wrt.gyp

index 1471c86..e5e0571 100644 (file)
 #include "base/strings/utf_string_conversions.h"
 #endif
 
+#include "tizen/src/browser/popup.h"
+#include "tizen/src/browser/popup_string.h"
+#include "atom/browser/native_window_efl.h"
+
+#include "common/app_db.h"
+
 using atom::Browser;
+namespace {
+  const char* kCertificateAllowPrefix = "__WRT_CERTIPERM_";
+  const char* kDbInitedCheckKey = "__WRT_DB_INITED__";
+  const char* kDBPublicSection = "public";
+  const char* kDBPrivateSection = "private";
+  const char* kReadOnlyPrefix = "_READONLY_KEY_";
+}  // namespace
+
 
 namespace mate {
 
@@ -620,6 +634,7 @@ void App::AllowCertificateError(
     bool expired_previous_decision,
     const base::Callback<void(content::CertificateRequestResultType)>&
         callback) {
+  LOG(ERROR)<<__FUNCTION__;
   if (!::tizen::is_single_process)
     v8::Locker locker(isolate());
   v8::HandleScope handle_scope(isolate());
@@ -630,9 +645,63 @@ void App::AllowCertificateError(
                               ssl_info.cert,
                               callback);
 
+  std::string pem_certificate;
+  if (!net::X509Certificate::GetPEMEncoded(ssl_info.cert->os_cert_handle(), &pem_certificate)) {
+    LOG(INFO) << "Certificate for URL: " << request_url.spec()  << " could not be opened";
+    callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
+    return;
+  }
+
   // Deny the certificate by default.
-  if (!prevent_default)
/* if (!prevent_default)
     callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
+  else*/
+    //callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE);
+   
+
+  AllowCertificateDialog(web_contents, request_url.spec(), pem_certificate, callback);
+}
+void App::AllowCertificateDialog(content::WebContents* web_contents,
+        const std::string& url,
+        const std::string& pem,
+        const base::Callback<void(content::CertificateRequestResultType)>&
+        callback) {
+  auto db = common::AppDB::GetInstance();
+  std::string reminder =
+      db->Get(kDBPrivateSection, kCertificateAllowPrefix + pem);
+  if (reminder == "allowed") {
+    callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE);
+    return;
+  } else if (reminder == "denied") {
+    callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
+    return;
+  }
+
+
+  Evas_Object* window = static_cast<atom::NativeWindowEfl*>(atom::NativeWindow::FromWebContents(web_contents))->evas_object();
+  runtime::Popup* popup = runtime::Popup::CreatePopup(window);
+  popup->SetButtonType(runtime::Popup::ButtonType::AllowDenyButton);
+  popup->SetTitle(runtime::popup_string::kPopupTitleCert);
+  popup->SetBody(runtime::popup_string::GetText(runtime::popup_string::kPopupBodyCert) + "\n\n" + url);
+  popup->SetCheckBox(runtime::popup_string::kPopupCheckRememberPreference);
+  popup->SetResultHandler(
+      [db, callback, pem](runtime::Popup* popup, void* /*user_data*/) {
+      //[db, result_handler, pem](Popup* popup, void* /*user_data*/) {
+        bool result = popup->GetButtonResult();
+        bool remember = popup->GetCheckBoxResult();
+        if (remember) {
+           LOG(ERROR)<<"pem: "<<pem;
+           db->Set(kDBPrivateSection, kCertificateAllowPrefix + pem,
+                  result ? "allowed" : "denied");
+
+        }
+        if(result)
+          callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE);
+        else
+          callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
+      },
+      this);
+  popup->Show();
 }
 
 void App::SelectClientCertificate(
index a87b88b..b8ecc6f 100644 (file)
@@ -108,6 +108,11 @@ class App : public AtomBrowserClient::Delegate,
       bool expired_previous_decision,
       const base::Callback<void(content::CertificateRequestResultType)>&
           callback) override;
+void AllowCertificateDialog(content::WebContents* web_contents,
+        const std::string& url,
+        const std::string& pem,
+        const base::Callback<void(content::CertificateRequestResultType)>&
+        callback);
   void SelectClientCertificate(
       content::WebContents* web_contents,
       net::SSLCertRequestInfo* cert_request_info,
index 59f9b7a..660058e 100644 (file)
@@ -21,5 +21,6 @@ namespace runtime {
 
 const char kAppDBRuntimeSection[] = "Runtime";
 const char kAppDBRuntimeBundle[] = "encoded_bundle";
+const char kTextDomainRuntime[] = "xwalk";
 
 }  // namespace runtime
index bada698..0c6aa96 100644 (file)
@@ -19,6 +19,7 @@ namespace runtime {
 
 extern const char kAppDBRuntimeSection[];
 extern const char kAppDBRuntimeBundle[];
+extern const char kTextDomainRuntime[];
 
 }  // namespace runtime
 
diff --git a/tizen/src/browser/popup.cc b/tizen/src/browser/popup.cc
new file mode 100644 (file)
index 0000000..198cf49
--- /dev/null
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include "tizen/src/browser/popup.h"
+
+//#include "common/logger.h"
+#include "atom/browser/native_window.h"
+#include "tizen/src/browser/popup_string.h"
+#include "tizen/common/constants.h"
+
+namespace runtime {
+
+namespace {
+
+const char* kWRTEdjePath = "/usr/share/edje/xwalk/xwalk_tizen.edj";
+
+#ifdef MODEL_FORMFACTOR_CIRCLE
+const char* kWRTIconDeletePath = "/usr/share/icons/xwalk/tw_ic_popup_btn_delete.png";
+const char* kWRTIconCheckPath = "/usr/share/icons/xwalk/tw_ic_popup_btn_check.png";
+
+const char* kLayoutTheme = "content/circle/buttons2";
+const char* kContentTitle = "elm.text.title";
+const char* kContentText = "elm.text";
+
+const char* kStylePopup = "circle";
+const char* kStyleCheck = "small";
+const char* kStyleButtonLeft = "popup/circle/left";
+const char* kStyleButtonRight = "popup/circle/right";
+#else
+const char* kContentTitle = "title,text";
+const char* kContentText = NULL;
+
+const char* kStylePopup = "default";
+const char* kStyleCheck = "default";
+const char* kStyleButtonLeft = "popup";
+const char* kStyleButtonRight = "popup";
+#endif  // MODEL_FORMFACTOR_CIRCLE
+
+const char* kContentButton1 = "button1";
+const char* kContentButton2 = "button2";
+
+const char* kStyleLabel = "popup/default";
+const char* kStyleButton = "popup";
+const char* kStyleEditPw = "editfield/password/popup";
+
+const char* kSignalEdit = "elm,action,hide,search_icon";
+
+const char* kStateActivated = "activated";
+const char* kStateClicked = "clicked";
+
+static void ButtonClickedCallback(void* data,
+                                  Evas_Object* obj, void* /*eventInfo*/) {
+  Popup* popup = static_cast<Popup*>(data);
+  if (!popup) {
+    LOG(ERROR) << "Fail to get Popup instance";
+    return;
+  }
+  popup->Result(popup->IsPositiveButton(obj));
+  popup->Hide();
+}
+
+// caution: not Evas_Object* but Popup*
+static Evas_Object* AddButton(Popup* popup, const char* str_id,
+                                  const char* content,
+                                  const char* style_button) {
+  Evas_Object* btn = elm_button_add(popup->popup());
+  elm_object_style_set(btn, style_button);
+  elm_object_domain_translatable_part_text_set(btn, 0,
+                                               kTextDomainRuntime,
+                                               str_id);
+  elm_object_part_content_set(popup->popup(), content, btn);
+  evas_object_smart_callback_add(btn, kStateClicked,
+                                 ButtonClickedCallback, popup);
+#ifdef MODEL_FORMFACTOR_CIRCLE
+  Evas_Object* icon = elm_image_add(btn);
+  if (!strcmp(content, kContentButton1)) {
+    elm_image_file_set(icon, kWRTIconDeletePath, NULL);
+  } else {
+    elm_image_file_set(icon, kWRTIconCheckPath, NULL);
+  }
+  evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  elm_object_part_content_set(btn, "elm.swallow.content", icon);
+  evas_object_show(icon);
+#endif  // MODEL_FORMFACTOR_CIRCLE
+  return btn;
+}
+
+static Evas_Object* AddEntry(Evas_Object* parent, Popup::EntryType type) {
+  Evas_Object* entry = elm_entry_add(parent);
+  elm_object_style_set(entry, kStyleEditPw);
+  elm_entry_single_line_set(entry, EINA_TRUE);
+  elm_entry_scrollable_set(entry, EINA_TRUE);
+  evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
+  elm_entry_prediction_allow_set(entry, EINA_FALSE);
+  elm_object_signal_emit(entry, kSignalEdit, "");
+  elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_NONE);
+
+  if (type == Popup::EntryType::Edit) {
+    evas_object_smart_callback_add(entry, kStateActivated,
+                                   [](void*, Evas_Object* obj, void*) {
+                                     elm_object_focus_set(obj, EINA_TRUE);
+                                   }, NULL);
+  } else {
+    elm_entry_password_set(entry, EINA_TRUE);
+    elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
+  }
+
+  return entry;
+}
+
+static Evas_Object* AddEntrySet(Evas_Object* parent,
+                                const char* str_id, Popup::EntryType type) {
+  Evas_Object* entry = AddEntry(parent, type);
+  evas_object_show(entry);
+
+  Evas_Object* layout = elm_layout_add(parent);
+  elm_layout_file_set(layout, kWRTEdjePath, "PopupTextEntrySet");
+
+  Evas_Object* rectangle = evas_object_rectangle_add(
+                             evas_object_evas_get(layout));
+  evas_object_color_set(rectangle, 0, 0, 0, 0);
+  evas_object_resize(rectangle, 100, 100);
+  evas_object_size_hint_min_set(rectangle, 100, 100);
+  evas_object_show(rectangle);
+  elm_object_part_content_set(layout, "entry.rectangle", rectangle);
+  evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+  elm_object_domain_translatable_part_text_set(layout, "entry.text",
+                                               kTextDomainRuntime,
+                                               str_id);
+  elm_layout_content_set(layout, "entry.swallow", entry);
+
+  evas_object_show(layout);
+  elm_box_pack_end(parent, layout);
+
+  return entry;
+}
+
+static Evas_Object* AddCheckBox(Evas_Object* parent) {
+  Evas_Object* check = elm_check_add(parent);
+  elm_object_style_set(check, kStyleCheck);
+  evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
+#ifndef MODEL_FORMFACTOR_CIRCLE
+  elm_object_style_set(check, "multiline");
+#endif  // MODEL_FORMFACTOR_CIRCLE
+  elm_check_state_set(check, EINA_TRUE);
+  return check;
+}
+
+}  // namespace
+
+// static variable initialize
+std::set<Popup*> Popup::opened_popups_;
+
+Popup* Popup::CreatePopup(Evas_Object* window) {
+  Evas_Object* popup = elm_popup_add(window);
+  evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  elm_object_style_set(popup, kStylePopup);
+
+  Evas_Object* layout = elm_layout_add(popup);
+#ifdef MODEL_FORMFACTOR_CIRCLE
+  elm_layout_theme_set(layout, "layout", "popup", kLayoutTheme);
+  elm_object_content_set(popup, layout);
+
+  Evas_Object* box = elm_box_add(layout);
+#else
+  Evas_Object* box = elm_box_add(popup);
+#endif  // MODEL_FORMFACTOR_CIRCLE
+
+  elm_box_padding_set(box, 0, 10);
+  evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+#ifdef MODEL_FORMFACTOR_CIRCLE
+  elm_object_part_content_set(layout, "elm.swallow.content", box);
+#else
+  elm_object_part_content_set(popup, "default", box);
+#endif  // MODEL_FORMFACTOR_CIRCLE
+  evas_object_show(box);
+
+  evas_object_event_callback_add(popup, EVAS_CALLBACK_RESIZE, NULL, NULL);
+
+  return new Popup(popup, layout, box);
+
+}
+
+void Popup::ForceCloseAllPopup() {
+  auto backup = opened_popups_;
+  for (auto& popup : backup) {
+    // will cause modification of opened_popups_
+    popup->Hide();
+  }
+}
+
+void Popup::SetButtonType(ButtonType type) {
+  enable_button_ = true;
+  LOG(ERROR)<<"SetButtonType";
+  switch (type) {
+    case ButtonType::OkButton:
+      button1_ = AddButton(this, popup_string::kPopupButtonOk,
+                           kContentButton1, kStyleButton);
+      break;
+    case ButtonType::OkCancelButton:
+      button1_ = AddButton(this, popup_string::kPopupButtonCancel,
+                           kContentButton1, kStyleButtonLeft);
+      button2_ = AddButton(this, popup_string::kPopupButtonOk,
+                           kContentButton2, kStyleButtonRight);
+      break;
+    case ButtonType::LoginCancelButton:
+      button1_ = AddButton(this, popup_string::kPopupButtonCancel,
+                           kContentButton1, kStyleButtonLeft);
+      button2_ = AddButton(this, popup_string::kPopupButtonLogin,
+                           kContentButton2, kStyleButtonRight);
+      break;
+    case ButtonType::AllowDenyButton:
+      LOG(ERROR)<<"ALLOW DENY";
+      button1_ = AddButton(this, popup_string::kPopupButtonDeny,
+                           kContentButton1, kStyleButtonLeft);
+      button2_ = AddButton(this, popup_string::kPopupButtonAllow,
+                           kContentButton2, kStyleButtonRight);
+      break;
+  }
+}
+
+bool Popup::IsPositiveButton(Evas_Object* button) {
+  if (button == NULL || button1_ == NULL)
+    return false;
+  else
+    return button == button2_;
+}
+
+bool Popup::GetButtonResult() const {
+  return result_button_;
+}
+
+void Popup::SetFirstEntry(const std::string& str_id, EntryType type) {
+  enable_entry_ = true;
+  entry1_ = AddEntrySet(box_, str_id.c_str(), type);
+}
+
+// suppose that it is called after SetFirstEntry()
+void Popup::SetSecondEntry(const std::string& str_id, EntryType type) {
+  if (!enable_entry_ || !entry1_) {
+    LOG(ERROR) << "SetFirstEntry() is not called yet";
+    return;
+  }
+  entry2_ = AddEntrySet(box_, str_id.c_str(), type);
+}
+
+std::string Popup::GetFirstEntryResult() const {
+  return result_entry1_;
+}
+
+std::string Popup::GetSecondEntryResult() const {
+  return result_entry2_;
+}
+
+void Popup::SetCheckBox(const std::string& str_id) {
+  enable_check_box_ = true;
+  check_box_ = AddCheckBox(box_);
+  if (!str_id.empty()) {
+    elm_object_domain_translatable_part_text_set(
+        check_box_, kContentText,
+        kTextDomainRuntime,
+        str_id.c_str());
+  }
+#ifdef MODEL_FORMFACTOR_CIRCLE
+  elm_object_part_content_set(box_, "elm.swallow.checkbox", check_box_);
+  evas_object_size_hint_min_set(check_box_, 0, 80);
+#endif  // MODEL_FORMFACTOR_CIRCLE
+  elm_box_pack_end(box_, check_box_);
+  evas_object_show(check_box_);
+}
+
+bool Popup::GetCheckBoxResult() const {
+  return result_check_box_;
+}
+
+void Popup::SetTitle(const std::string& str_id) {
+  elm_object_domain_translatable_part_text_set(
+#ifdef MODEL_FORMFACTOR_CIRCLE
+      layout_,
+#else
+      popup_,
+#endif  // MODEL_FORMFACTOR_CIRCLE
+      kContentTitle,
+      kTextDomainRuntime,
+      str_id.c_str());
+}
+
+void Popup::SetBody(const std::string& str_id) {
+  Evas_Object* label = elm_label_add(box_);
+  elm_object_style_set(label, kStyleLabel);
+  elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
+  elm_object_domain_translatable_part_text_set(
+                                   label, kContentText, kTextDomainRuntime,
+                                   elm_entry_utf8_to_markup(str_id.c_str()));
+  evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
+#ifdef MODEL_FORMFACTOR_CIRCLE
+  evas_object_color_set(label, 255, 255, 255, 255);
+  elm_object_part_content_set(box_, "elm.swallow.label", label);
+#else
+  evas_object_color_set(label, 0, 0, 0, 255);
+#endif  // MODEL_FORMFACTOR_CIRCLE
+  elm_box_pack_end(box_, label);
+  evas_object_show(label);
+}
+
+void Popup::SetResultHandler(std::function<void
+    (Popup* popup, void* user_data)> handler, void* user_data) {
+  handler_ = handler;
+  user_data_ = user_data;
+}
+
+void Popup::Show() {
+  evas_object_show(popup_);
+  opened_popups_.insert(this);
+}
+
+void Popup::Hide() {
+  evas_object_hide(popup_);
+  ecore_idler_add([](void* popup) {
+      Popup* obj = static_cast<Popup*>(popup);
+      delete obj;
+      return EINA_FALSE;
+    }, this);
+  auto found = opened_popups_.find(this);
+  if (found != opened_popups_.end()) {
+    opened_popups_.erase(found);
+  }
+}
+
+void Popup::Result(bool is_positive) {
+  if (enable_button_) {
+    result_button_ = is_positive;
+  }
+  if (enable_entry_ && !!entry1_) {
+    const char* text = elm_entry_entry_get(entry1_);
+    if (text)
+      result_entry1_ = text;
+    if (!!entry2_) {
+      text = elm_entry_entry_get(entry2_);
+      if (text)
+        result_entry2_ = text;
+    }
+  }
+  if (enable_check_box_) {
+    result_check_box_ = elm_check_state_get(check_box_);
+  }
+
+  handler_(this, user_data_);
+}
+
+Popup::Popup(Evas_Object* popup, Evas_Object* layout, Evas_Object* box)
+  : popup_(popup), layout_(layout), box_(box), button1_(NULL), button2_(NULL),
+    entry1_(NULL), entry2_(NULL), check_box_(NULL), user_data_(NULL),
+    enable_button_(false), result_button_(false), enable_entry_(false),
+    enable_check_box_(false), result_check_box_(false) {}
+
+Popup::~Popup() {
+  if (popup_)
+    evas_object_del(popup_);
+  popup_ = NULL;
+}
+
+}  // namespace runtime
diff --git a/tizen/src/browser/popup.h b/tizen/src/browser/popup.h
new file mode 100644 (file)
index 0000000..9938d48
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+
+#ifndef XWALK_RUNTIME_BROWSER_POPUP_H_
+#define XWALK_RUNTIME_BROWSER_POPUP_H_
+
+#include <Elementary.h>
+#include <Evas.h>
+
+#include <functional>
+#include <set>
+#include <string>
+#include <vector>
+
+
+namespace runtime {
+
+
+class Popup {
+ public:
+  enum class ButtonType {
+    OkButton,
+    OkCancelButton,
+    LoginCancelButton,
+    AllowDenyButton
+  };
+
+  enum class EntryType {
+    Edit,
+    PwEdit
+  };
+
+  static Popup* CreatePopup(Evas_Object* window);
+  static void ForceCloseAllPopup();
+
+  // button
+  void SetButtonType(ButtonType type);
+  bool IsPositiveButton(Evas_Object* button);
+  bool GetButtonResult() const;  // yes/allow/ok: true, the others: false
+
+  void SetFirstEntry(const std::string& str_id, EntryType type);
+  void SetSecondEntry(const std::string& str_id, EntryType type);
+  std::string GetFirstEntryResult() const;
+  std::string GetSecondEntryResult() const;
+
+  // check box
+  void SetCheckBox(const std::string& str_id = std::string());
+  bool GetCheckBoxResult() const;
+
+  // etc.
+  void SetTitle(const std::string& str_id);
+  void SetBody(const std::string& str_id);
+  void SetResultHandler(std::function
+      <void(Popup* popup, void* user_data)> handler, void* user_data);
+
+  // Popup's actions
+  void Show();
+  void Hide();
+  void Result(bool is_positive);
+
+  // getter
+  Evas_Object* popup() { return popup_; }
+
+ private:
+  Popup(Evas_Object* popup, Evas_Object* layout, Evas_Object* box);
+  ~Popup();
+
+  Evas_Object* popup_;
+  Evas_Object* layout_;
+  Evas_Object* box_;
+  Evas_Object* button1_;
+  Evas_Object* button2_;
+  Evas_Object* entry1_;
+  Evas_Object* entry2_;
+  Evas_Object* check_box_;
+
+  std::function<void(Popup* popup, void* user_data)> handler_;
+  void* user_data_;
+
+  bool enable_button_;
+  bool result_button_;
+  bool enable_entry_;
+  std::string result_entry1_;
+  std::string result_entry2_;
+  bool enable_check_box_;
+  bool result_check_box_;
+  static std::set<Popup*> opened_popups_;
+};
+
+}  // namespace runtime
+
+#endif  // XWALK_RUNTIME_BROWSER_POPUP_H_
diff --git a/tizen/src/browser/popup_string.cc b/tizen/src/browser/popup_string.cc
new file mode 100644 (file)
index 0000000..edee085
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include "tizen/src/browser/popup_string.h"
+
+#include <libintl.h>
+
+#include "tizen/common/constants.h"
+
+namespace runtime {
+
+namespace popup_string {
+
+
+const char kPopupTitleAuthRequest[] = "IDS_SA_BODY_USER_AUTHENTICATION";
+const char kPopupTitleCert[] = "IDS_BR_HEADER_CERTIFICATE_INFO";
+const char kPopupTitleGeoLocation[] = "IDS_WRT_OPT_ACCESS_USER_LOCATION";
+const char kPopupTitleUserMedia[] = "IDS_WRT_OPT_USE_USER_MEDIA";
+const char kPopupTitleWebNotification[] =
+  "IDS_BR_HEADER_WEB_NOTIFICATION";
+const char kPopupTitleWebStorage[] = "IDS_WRT_OPT_USE_STORE_WEB_DATA";
+
+const char kPopupBodyAuthRequest[] =
+  "IDS_BR_BODY_DESTINATIONS_AUTHENTICATION_REQUIRED";
+const char kPopupBodyCert[] =
+  "IDS_BR_BODY_SECURITY_CERTIFICATE_PROBLEM_MSG";
+const char kPopupBodyGeoLocation[] =
+  "IDS_WRT_BODY_ALLOWS_THIS_SITE_TO_ACCESS_YOUR_LOCATION_INFORMATION";
+const char kPopupBodyUserMedia[] =
+  "IDS_BR_POP_P1SS_HP2SS_IS_REQUESTING_PERMISSION_TO_USE_YOUR_CAMERA";
+const char kPopupBodyWebNotification[] =
+  "IDS_WRT_BODY_ALLOWS_THIS_SITE_TO_DISPLAY_NOTIFICATIONS";
+const char kPopupBodyWebStorage[] =
+  "IDS_WRT_BODY_ALLOWS_THIS_SITE_TO_SAVE_A_LARGE_AMOUNT_OF_DATA_ON_YOUR_DEVICE";
+
+const char kPopupCheckRememberPreference[] =
+  "IDS_BR_BODY_REMEMBER_PREFERENCE";
+
+const char kPopupLabelAuthusername[] = "IDS_BR_BODY_AUTHUSERNAME";
+const char kPopupLabelPassword[] =  "IDS_BR_BODY_AUTHPASSWORD";
+
+const char kPopupButtonOk[] = "IDS_BR_SK_OK";
+const char kPopupButtonLogin[] = "IDS_BR_BODY_LOGIN";
+const char kPopupButtonCancel[] = "IDS_BR_SK_CANCEL";
+const char kPopupButtonAllow[] = "IDS_BR_OPT_ALLOW";
+const char kPopupButtonDeny[] = "IDS_COM_BODY_DENY";
+
+std::string GetText(const std::string& msg_id) {
+  return dgettext(kTextDomainRuntime, msg_id.c_str());
+}
+
+}  // namespace popup_string
+
+}  // namespace runtime
diff --git a/tizen/src/browser/popup_string.h b/tizen/src/browser/popup_string.h
new file mode 100644 (file)
index 0000000..09a6c9a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+
+#ifndef XWALK_RUNTIME_BROWSER_POPUP_STRING_H_
+#define XWALK_RUNTIME_BROWSER_POPUP_STRING_H_
+
+#include <string>
+
+namespace runtime {
+
+namespace popup_string {
+
+extern const char kPopupTitleAuthRequest[];
+extern const char kPopupTitleCert[];
+extern const char kPopupTitleGeoLocation[];
+extern const char kPopupTitleUserMedia[];
+extern const char kPopupTitleWebNotification[];
+extern const char kPopupTitleWebStorage[];
+
+extern const char kPopupBodyAuthRequest[];
+extern const char kPopupBodyCert[];
+extern const char kPopupBodyGeoLocation[];
+extern const char kPopupBodyUserMedia[];
+extern const char kPopupBodyWebNotification[];
+extern const char kPopupBodyWebStorage[];
+
+extern const char kPopupCheckRememberPreference[];
+
+extern const char kPopupLabelAuthusername[];
+extern const char kPopupLabelPassword[];
+
+extern const char kPopupButtonOk[];
+extern const char kPopupButtonLogin[];
+extern const char kPopupButtonCancel[];
+extern const char kPopupButtonAllow[];
+extern const char kPopupButtonDeny[];
+
+std::string GetText(const std::string& msg_id);
+
+}  // namespace popup_string
+
+}  // namespace runtime
+
+#endif  // XWALK_RUNTIME_BROWSER_POPUP_STRING_H_
diff --git a/wrt.gyp b/wrt.gyp
index e0a24b3..1ca7046 100644 (file)
--- a/wrt.gyp
+++ b/wrt.gyp
         'tizen/src/app/wrt_main_delegate.h',
         'tizen/src/browser/api/wrt_api_core.cc',
         'tizen/src/browser/api/wrt_api_core.h',
+        'tizen/src/browser/popup.cc',
+        'tizen/src/browser/popup.h',
+        'tizen/src/browser/popup_string.cc',
+        'tizen/src/browser/popup_string.h',
         'tizen/src/browser/native_web_runtime.cc',
         'tizen/src/browser/native_web_runtime.h',
         'tizen/src/browser/native_web_runtime_observer.h',