Refactor Add popup support for runtime and impl to allow cert errors 40/189940/7
authordeepti <d.saraswat@samsung.com>
Mon, 24 Sep 2018 10:58:14 +0000 (16:28 +0530)
committerjaekuk lee <juku1999@samsung.com>
Fri, 28 Sep 2018 00:50:03 +0000 (00:50 +0000)
Removed extra header files and made proper indent.
Removed unnecessary comments.
Updated copyright year in LICENSE file
Resolved all warnings

Change-Id: Ica52a53f219d4245003b1ccf2e2ca68ac00b8034
Signed-off-by: deepti <d.saraswat@samsung.com>
atom/browser/api/atom_api_app.cc
atom/browser/api/atom_api_app.h
tizen/common/constants.cc
tizen/src/browser/popup.cc
tizen/src/browser/popup.h
tizen/src/browser/popup_string.cc
tizen/src/browser/popup_string.h
wrt.gyp

index e5e0571a85a5a10cf5cdf0927962a78b4a8bc53d..ca50c1c44a7b08db7174c248d4bc810073881008 100644 (file)
@@ -13,6 +13,7 @@
 #include "atom/browser/atom_browser_context.h"
 #include "atom/browser/atom_browser_main_parts.h"
 #include "atom/browser/login_handler.h"
+#include "atom/browser/native_window_efl.h"
 #include "atom/browser/relauncher.h"
 #include "atom/common/atom_command_line.h"
 #include "atom/common/native_mate_converters/callback.h"
@@ -33,6 +34,7 @@
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/icon_manager.h"
 #include "chrome/common/chrome_paths.h"
+#include "common/app_db.h"
 #include "content/public/browser/browser_accessibility_state.h"
 #include "content/public/browser/client_certificate_delegate.h"
 #include "content/public/browser/gpu_data_manager.h"
@@ -43,6 +45,8 @@
 #include "native_mate/object_template_builder.h"
 #include "net/ssl/ssl_cert_request_info.h"
 #include "tizen/common/env_variables.h"
+#include "tizen/src/browser/popup.h"
+#include "tizen/src/browser/popup_string.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/gfx/image/image.h"
 
 #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
 
 
@@ -634,7 +630,6 @@ 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());
@@ -645,22 +640,19 @@ 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) {
+    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;
+    }
+    AllowCertificateDialog(web_contents, request_url.spec(), pem_certificate, callback);
+  } else {
     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,
@@ -678,22 +670,21 @@ void App::AllowCertificateDialog(content::WebContents* web_contents,
   }
 
 
-  Evas_Object* window = static_cast<atom::NativeWindowEfl*>(atom::NativeWindow::FromWebContents(web_contents))->evas_object();
+  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->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");
-
+          db->Set(kDBPrivateSection, kCertificateAllowPrefix + pem,
+              result ? "allowed" : "denied");
         }
         if(result)
           callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE);
index b8ecc6febf6dcf8385dd86aca94f5ca5f89791f3..528288fc53cc86c12e965b779c07a5d320653deb 100644 (file)
@@ -108,11 +108,6 @@ 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,
@@ -139,6 +134,11 @@ void AllowCertificateDialog(content::WebContents* web_contents,
   void DisableHardwareAcceleration(mate::Arguments* args);
   bool IsAccessibilitySupportEnabled();
   Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args);
+  void AllowCertificateDialog(content::WebContents* web_contents,
+      const std::string& url,
+      const std::string& pem,
+      const base::Callback<void(content::CertificateRequestResultType)>&
+          callback);
 #if defined(USE_NSS_CERTS)
   void ImportCertificate(const base::DictionaryValue& options,
                          const net::CompletionCallback& callback);
index 660058e5e79ba5e20a4d49c63f14374d7f314c94..f47be9d57079fa304a749dd96eb05a7090849da3 100644 (file)
  *    limitations under the License.
  */
 
-//#include "tizen/common/constants.h"
 #include "constants.h"
 
 namespace runtime {
 
 const char kAppDBRuntimeSection[] = "Runtime";
 const char kAppDBRuntimeBundle[] = "encoded_bundle";
-const char kTextDomainRuntime[] = "xwalk";
+const char kTextDomainRuntime[] = "pwrt";
 
 }  // namespace runtime
index 198cf49bfca71a3ebf7f27d2cd9ef6b20e244dda..20f3b559f965b11bbe6ee5178d0f2f8331b9b49b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2018 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.
  *    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"
+#include "tizen/src/browser/popup.h"
+#include "tizen/src/browser/popup_string.h"
 
 namespace runtime {
 
 namespace {
 
-const char* kWRTEdjePath = "/usr/share/edje/xwalk/xwalk_tizen.edj";
+const char* kWRTEdjePath = "/usr/share/edje/pwrt/pwrt_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* kWRTIconDeletePath = "/usr/share/icons/pwrt/tw_ic_popup_btn_delete.png";
+const char* kWRTIconCheckPath = "/usr/share/icons/pwrt/tw_ic_popup_btn_check.png";
 
 const char* kLayoutTheme = "content/circle/buttons2";
 const char* kContentTitle = "elm.text.title";
index 9938d48b0fcef1b6e51fb9512dedc0e2c167530e..76bcc39c8fe6b8fbda6fc2843246832667497a0c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2018 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.
@@ -15,8 +15,8 @@
  */
 
 
-#ifndef XWALK_RUNTIME_BROWSER_POPUP_H_
-#define XWALK_RUNTIME_BROWSER_POPUP_H_
+#ifndef TIZEN_SRC_BROWSER_POPUP_H_
+#define TIZEN_SRC_BROWSER_POPUP_H_
 
 #include <Elementary.h>
 #include <Evas.h>
@@ -103,4 +103,4 @@ class Popup {
 
 }  // namespace runtime
 
-#endif  // XWALK_RUNTIME_BROWSER_POPUP_H_
+#endif  // TIZEN_SRC_BROWSER_POPUP_H_
index edee085292c00443acd69eb98be285639cb23796..1e6b18dab9a5a28bd406793ece5f89402787f845 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2018 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.
  *    limitations under the License.
  */
 
-#include "tizen/src/browser/popup_string.h"
 
 #include <libintl.h>
-
 #include "tizen/common/constants.h"
+#include "tizen/src/browser/popup_string.h"
 
 namespace runtime {
 
index 09a6c9aeb635fda3518a2ab222f0f30e8d739c08..62499a14f9d3faaa4fc730fadcca08e0a0cd95df 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2018 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.
@@ -15,8 +15,8 @@
  */
 
 
-#ifndef XWALK_RUNTIME_BROWSER_POPUP_STRING_H_
-#define XWALK_RUNTIME_BROWSER_POPUP_STRING_H_
+#ifndef TIZEN_SRC_BROWSER_POPUP_STRING_H_
+#define TIZEN_SRC_BROWSER_POPUP_STRING_H_
 
 #include <string>
 
@@ -55,4 +55,4 @@ std::string GetText(const std::string& msg_id);
 
 }  // namespace runtime
 
-#endif  // XWALK_RUNTIME_BROWSER_POPUP_STRING_H_
+#endif  // TIZEN_SRC_BROWSER_POPUP_STRING_H_
diff --git a/wrt.gyp b/wrt.gyp
index 1ca704696b260a96d6800f443911f5d8f3666f27..9fef526387d27ad58ffd4d81285cbd5b916e423d 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/native_web_runtime.cc',
+        'tizen/src/browser/native_web_runtime.h',
+        'tizen/src/browser/native_web_runtime_observer.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',
         'tizen/src/browser/wrt_ipc.cc',
         'tizen/src/browser/wrt_ipc.h',
         'tizen/src/browser/wrt_service.cc',