From 2bcaa52c70a4af64761831276de95b9fa111a506 Mon Sep 17 00:00:00 2001 From: "jaekuk, lee" Date: Fri, 17 Aug 2018 17:31:15 +0900 Subject: [PATCH 01/16] Fix the issue that add-on doesn't work - Define noExtensions of options - Don't create WebApplication class when launching Electron app Change-Id: I0dfb8b1d33c66c3da956e8da307499ee980badac Signed-off-by: jaekuk, lee --- tizen/src/browser/api/wrt_api_core.cc | 2 ++ wrt/src/main.js | 4 +++- wrt/src/runtime.js | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) mode change 100644 => 100755 tizen/src/browser/api/wrt_api_core.cc mode change 100644 => 100755 wrt/src/main.js diff --git a/tizen/src/browser/api/wrt_api_core.cc b/tizen/src/browser/api/wrt_api_core.cc old mode 100644 new mode 100755 index 5c87593..e58d525 --- a/tizen/src/browser/api/wrt_api_core.cc +++ b/tizen/src/browser/api/wrt_api_core.cc @@ -90,6 +90,8 @@ bool WebRuntime::isTizenWebApp() const { bool WebRuntime::isElectronLaunch() const { auto app_data = common::ApplicationDataManager::GetCurrentAppData(); + if (!app_data) + return false; return app_data->IsElectronApp(); } diff --git a/wrt/src/main.js b/wrt/src/main.js old mode 100644 new mode 100755 index b84ef59..d00a8c4 --- a/wrt/src/main.js +++ b/wrt/src/main.js @@ -29,6 +29,7 @@ let parseCommandLine = function() { options.alias('h', 'help').boolean('h').describe('h', 'Print this usage message.'); options.alias('p', 'path').string('p').describe('p', 'Set contents path to load'); options.alias('s', 'window-size').string('s').describe('s', 'Set the window size'); + options.alias('E', 'no-extensions').boolean('E').describe('E', 'Do not load extensions'); let args = options.argv; if (args.help) { process.stdout.write(options.help()); @@ -39,7 +40,8 @@ let parseCommandLine = function() { appID: args.a, devMode: args.d, path: args.p, - windowSize: args.s + windowSize: args.s, + noExtensions: args.E }; }; diff --git a/wrt/src/runtime.js b/wrt/src/runtime.js index 1c13e82..c4813c9 100755 --- a/wrt/src/runtime.js +++ b/wrt/src/runtime.js @@ -60,9 +60,12 @@ class Runtime { app.once('ready', function(event) { runtime_debug('ready'); _this.extensionManager = new ExtensionManager(EXTENSIONS_PATH); - if (!options.noExtensions) { + if (!options.noExtensions) { _this.extensionManager.build(); } + if (wrt.isElectronLaunch()) { + return; + } _this.webApplication = new WebApplication(options); }); wrt.on('start-app', function() { -- 2.7.4 From 9e3af881c5133a126c01c95d95f97421ee63f84e Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Mon, 20 Aug 2018 12:52:17 +0530 Subject: [PATCH 02/16] Enable encrypted app support. Use |WrtFileProtocolHandler| for handling the file schemas. Change-Id: Ia39034af94d7ebd332e7b9e1d38924499f5cafd9 Signed-off-by: k2.nagaraju --- atom/browser/atom_browser_context.cc | 25 ++++++++++++++++++---- .../wrt/wrt_file_protocol_handler.h | 13 ++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index a2ad39f..0d56c5f 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -44,6 +44,10 @@ #include "net/url_request/url_request_intercepting_job_factory.h" #include "url/url_constants.h" +#if defined(OS_TIZEN) +#include "tizen_src/ewk/efl_integration/wrt/wrt_file_protocol_handler.h" +#endif + using content::BrowserThread; namespace atom { @@ -126,10 +130,23 @@ AtomBrowserContext::CreateURLRequestJobFactory( base::WrapUnique(new AboutProtocolHandler)); job_factory->SetProtocolHandler( url::kDataScheme, base::WrapUnique(new net::DataProtocolHandler)); - job_factory->SetProtocolHandler( - url::kFileScheme, base::WrapUnique(new asar::AsarProtocolHandler( - BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); +#if defined(OS_TIZEN) + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); + if (app_data && app_data->IsElectronApp()) { +#endif + job_factory->SetProtocolHandler( + url::kFileScheme, base::WrapUnique(new asar::AsarProtocolHandler( + BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); +#if defined(OS_TIZEN) + } else { + job_factory->SetProtocolHandler( + url::kFileScheme, base::WrapUnique(new net::WrtFileProtocolHandler( + BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); + } +#endif + job_factory->SetProtocolHandler( url::kHttpScheme, base::WrapUnique(new HttpProtocolHandler(url::kHttpScheme))); diff --git a/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrt_file_protocol_handler.h b/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrt_file_protocol_handler.h index 6fab49f..2fd9a90 100644 --- a/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrt_file_protocol_handler.h +++ b/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrt_file_protocol_handler.h @@ -19,21 +19,16 @@ namespace net { class NetworkDelegate; class URLRequestJob; -class WrtFileProtocolHandler +class __attribute__((visibility("default"))) WrtFileProtocolHandler : public URLRequestJobFactory::ProtocolHandler { public: explicit WrtFileProtocolHandler( - const scoped_refptr& file_task_runner) - : file_task_runner_(file_task_runner) {} - ~WrtFileProtocolHandler() override {} + const scoped_refptr& file_task_runner); + ~WrtFileProtocolHandler() override; URLRequestJob* MaybeCreateJob( URLRequest* request, NetworkDelegate* network_delegate) const override; - /* LCOV_EXCL_START */ - bool IsSafeRedirectTarget(const GURL& location) const override { - return false; - } - /* LCOV_EXCL_STOP */ + bool IsSafeRedirectTarget(const GURL& location) const override; private: bool GetWrtParsedUrl(const GURL& url, GURL& parsed_url) const; -- 2.7.4 From e27feba669b2cd9d5985d90179c0f4d3bd279480 Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Fri, 31 Aug 2018 15:34:49 +0530 Subject: [PATCH 03/16] Send |WrtViewMsg_ResumeScheduledTasks| IPC only if webview is suspended. With this patch approximately 100 to 150ms time is reducing. Change-Id: I77404f90de3784b262fd3d9bc7239fe0d1b28bb9 Signed-off-by: k2.nagaraju --- tizen/browser/tizen_browser_parts.cc | 9 ++++++--- tizen/browser/tizen_browser_parts.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tizen/browser/tizen_browser_parts.cc b/tizen/browser/tizen_browser_parts.cc index 41bf8d5..d7c882a 100644 --- a/tizen/browser/tizen_browser_parts.cc +++ b/tizen/browser/tizen_browser_parts.cc @@ -57,7 +57,8 @@ static bool ProcessWellKnownScheme(const std::string& url) { } // namespace TizenBrowserParts::TizenBrowserParts() - : locale_manager_(new common::LocaleManager()) { + : locale_manager_(new common::LocaleManager()), + is_suspended_(false) { } void TizenBrowserParts::Initialize() { @@ -123,16 +124,18 @@ void TizenBrowserParts::RenderViewCreated(content::RenderViewHost* render_view_h } void TizenBrowserParts::Suspend(content::RenderViewHost* rvh) { - if(!rvh) + if (is_suspended_ || !rvh) return; + is_suspended_ = true; rvh->Send(new WrtViewMsg_SuspendScheduledTask(rvh->GetRoutingID())); } void TizenBrowserParts::Resume(content::RenderViewHost* rvh) { - if(!rvh) + if (!is_suspended_ || !rvh) return; + is_suspended_ = false; rvh->Send(new WrtViewMsg_ResumeScheduledTasks(rvh->GetRoutingID())); } diff --git a/tizen/browser/tizen_browser_parts.h b/tizen/browser/tizen_browser_parts.h index 3ef4c97..19b7072 100644 --- a/tizen/browser/tizen_browser_parts.h +++ b/tizen/browser/tizen_browser_parts.h @@ -52,6 +52,7 @@ class TizenBrowserParts { common::ApplicationData* app_data_; int security_model_version_; + bool is_suspended_; std::string csp_rule_; std::string csp_report_rule_; }; -- 2.7.4 From 020a05f255f2af697b2e858f181153315eee1dd1 Mon Sep 17 00:00:00 2001 From: Suneel Kota Date: Thu, 20 Sep 2018 18:18:41 +0530 Subject: [PATCH 04/16] Add popup support for runtime and impl to allow cert erros 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 --- atom/browser/api/atom_api_app.cc | 71 ++++++- atom/browser/api/atom_api_app.h | 5 + tizen/common/constants.cc | 1 + tizen/common/constants.h | 1 + tizen/src/browser/popup.cc | 381 ++++++++++++++++++++++++++++++++++++++ tizen/src/browser/popup.h | 106 +++++++++++ tizen/src/browser/popup_string.cc | 67 +++++++ tizen/src/browser/popup_string.h | 58 ++++++ wrt.gyp | 4 + 9 files changed, 693 insertions(+), 1 deletion(-) create mode 100644 tizen/src/browser/popup.cc create mode 100644 tizen/src/browser/popup.h create mode 100644 tizen/src/browser/popup_string.cc create mode 100644 tizen/src/browser/popup_string.h diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 1471c86..e5e0571 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -51,7 +51,21 @@ #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& 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& + 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::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: "<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( diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index a87b88b..b8ecc6f 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -108,6 +108,11 @@ class App : public AtomBrowserClient::Delegate, bool expired_previous_decision, const base::Callback& callback) override; +void AllowCertificateDialog(content::WebContents* web_contents, + const std::string& url, + const std::string& pem, + const base::Callback& + callback); void SelectClientCertificate( content::WebContents* web_contents, net::SSLCertRequestInfo* cert_request_info, diff --git a/tizen/common/constants.cc b/tizen/common/constants.cc index 59f9b7a..660058e 100644 --- a/tizen/common/constants.cc +++ b/tizen/common/constants.cc @@ -21,5 +21,6 @@ namespace runtime { const char kAppDBRuntimeSection[] = "Runtime"; const char kAppDBRuntimeBundle[] = "encoded_bundle"; +const char kTextDomainRuntime[] = "xwalk"; } // namespace runtime diff --git a/tizen/common/constants.h b/tizen/common/constants.h index bada698..0c6aa96 100644 --- a/tizen/common/constants.h +++ b/tizen/common/constants.h @@ -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 index 0000000..198cf49 --- /dev/null +++ b/tizen/src/browser/popup.cc @@ -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(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::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 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); + 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 index 0000000..9938d48 --- /dev/null +++ b/tizen/src/browser/popup.h @@ -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 +#include + +#include +#include +#include +#include + + +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 + 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 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 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 index 0000000..edee085 --- /dev/null +++ b/tizen/src/browser/popup_string.cc @@ -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 + +#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 index 0000000..09a6c9a --- /dev/null +++ b/tizen/src/browser/popup_string.h @@ -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 + +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 --- a/wrt.gyp +++ b/wrt.gyp @@ -129,6 +129,10 @@ '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', -- 2.7.4 From 37b8b649de1af305354621931218a37b8b381d50 Mon Sep 17 00:00:00 2001 From: "ws29.jung" Date: Wed, 19 Sep 2018 19:59:44 +0900 Subject: [PATCH 05/16] Remove redundant CommandLine class Electron-efl had 3 different CommandLine classes which do the job not very different and they weren't a inherited class of any other. From this patch, common::CommandLine class is removed and only AtomCommandLine and base::CommandLine are left. Change-Id: Ic6a85e29a153461771f2441fc3321141f0ce3624 Signed-off-by: ws29.jung --- atom/common/atom_command_line.cc | 19 ++++++++++++++++++- atom/common/atom_command_line.h | 3 ++- tizen/common/common.gyp | 2 -- tizen/src/browser/api/wrt_api_core.cc | 7 ++----- tizen/src/wrt_main.cc | 11 +++-------- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/atom/common/atom_command_line.cc b/atom/common/atom_command_line.cc index 08880ff..4a5bfe9 100644 --- a/atom/common/atom_command_line.cc +++ b/atom/common/atom_command_line.cc @@ -11,7 +11,7 @@ namespace atom { // static std::vector AtomCommandLine::argv_; - +int AtomCommandLine::argc_; #if defined(OS_WIN) // static std::vector AtomCommandLine::wargv_; @@ -20,6 +20,7 @@ std::vector AtomCommandLine::wargv_; // static void AtomCommandLine::Init(int argc, const char* const* argv) { // Hack around with the argv pointer. Used for process.title = "blah" + argc_ = argc; char** new_argv = uv_setup_args(argc, const_cast(argv)); for (int i = 0; i < argc; ++i) { argv_.push_back(new_argv[i]); @@ -42,4 +43,20 @@ void AtomCommandLine::InitializeFromCommandLine() { } #endif +std::string AtomCommandLine::GetAppIdFromCommandLine(const std::string& program) { + if (argc_ > 0) { + std::string tmp = argv_[0]; + if (tmp == program) { + if (argv_.size() > 0) { + // Suppose that appid is at the first of arguments_ + return argv_[0]; + } + } else { + return tmp; + } + } + return std::string(); +} + + } // namespace atom diff --git a/atom/common/atom_command_line.h b/atom/common/atom_command_line.h index a834ce9..3b6d689 100644 --- a/atom/common/atom_command_line.h +++ b/atom/common/atom_command_line.h @@ -29,9 +29,10 @@ class AtomCommandLine { // it is using zygote. static void InitializeFromCommandLine(); #endif - + static std::string GetAppIdFromCommandLine(const std::string& program); private: static std::vector argv_; + static int argc_; #if defined(OS_WIN) static std::vector wargv_; diff --git a/tizen/common/common.gyp b/tizen/common/common.gyp index 637f5c4..7dbb07d 100644 --- a/tizen/common/common.gyp +++ b/tizen/common/common.gyp @@ -7,8 +7,6 @@ 'target_name': 'wrt_common', 'type': 'shared_library', 'sources': [ - 'command_line.h', - 'command_line.cc', 'constants.h', 'constants.cc', 'file_utils.h', diff --git a/tizen/src/browser/api/wrt_api_core.cc b/tizen/src/browser/api/wrt_api_core.cc index e58d525..c63f6b8 100755 --- a/tizen/src/browser/api/wrt_api_core.cc +++ b/tizen/src/browser/api/wrt_api_core.cc @@ -3,12 +3,12 @@ #include #include "atom/browser/browser.h" +#include "atom/common/atom_command_line.h" #include "atom/common/node_includes.h" #include "base/files/file_path.h" #include "base/logging.h" #include "native_mate/dictionary.h" #include "tizen/common/application_data.h" -#include "tizen/common/command_line.h" #include "tizen/src/browser/native_web_runtime.h" #include "tizen/src/browser/wrt_service.h" @@ -77,10 +77,7 @@ std::string WebRuntime::GetPath() const { } bool WebRuntime::isTizenWebApp() const { - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - if (!runtime_cmd) - return false; - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); + std::string appid = atom::AtomCommandLine::GetAppIdFromCommandLine("/usr/bin/electron"); if (appid != "electron") { // TODO: Any better distinguishing feature? return true; } else { diff --git a/tizen/src/wrt_main.cc b/tizen/src/wrt_main.cc index 38ccdfa..87fd3e8 100644 --- a/tizen/src/wrt_main.cc +++ b/tizen/src/wrt_main.cc @@ -20,7 +20,6 @@ #if defined(OS_TIZEN) #include "atom/app/runtime.h" #include "tizen/common/application_data.h" -#include "tizen/common/command_line.h" #include "tizen/loader/prelauncher.h" #include "tizen/browser/preload_manager.h" #endif @@ -42,19 +41,14 @@ int real_main(int argc, char* argv[]) { for (int i = 0; i < argc; ++i) LOG(INFO) << "argv[" << i << "] : " << argv[i]; - if (!common::CommandLine::Init(argc, argv)) { - common::CommandLine::Reset(); - common::CommandLine::Init(argc, argv); - } - if (base::CommandLine::InitializedForCurrentProcess()) { base::CommandLine::ForCurrentProcess()->SetProgram(base::FilePath(argv[0])); } else { base::CommandLine::Init(argc, argv); } - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/wrt"); + atom::AtomCommandLine::Init(argc, argv); + std::string appid = atom::AtomCommandLine::GetAppIdFromCommandLine("/usr/bin/wrt"); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); bool is_browser_process = @@ -100,6 +94,7 @@ int main(int argc, const char* argv[]) { LOG(INFO) << "run with wrt-loader"; for (int i = 0; i < argc; ++i) LOG(INFO) << "argv[" << i << "] : " << argv[i]; + int no_argument_count = 1; atom::AtomCommandLine::Init(no_argument_count, argv); -- 2.7.4 From 16c58722af987d8857abb28b97a2ce49711a0c6b Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Fri, 7 Sep 2018 13:08:55 +0530 Subject: [PATCH 06/16] Enable popup support. Change-Id: I1cb40db8153de192fa353cf36df6d02a677ce47f Signed-off-by: k2.nagaraju --- atom/app/ui_runtime.cc | 1 + atom/browser/atom_javascript_dialog_manager_efl.cc | 101 ++++++ atom/browser/atom_javascript_dialog_manager_efl.h | 62 ++++ atom/browser/atom_javascript_modal_dialog_efl.cc | 404 +++++++++++++++++++++ atom/browser/atom_javascript_modal_dialog_efl.h | 90 +++++ atom/browser/common_web_contents_delegate.cc | 6 +- atom/browser/common_web_contents_delegate.h | 5 + filenames.gypi | 4 + 8 files changed, 672 insertions(+), 1 deletion(-) create mode 100644 atom/browser/atom_javascript_dialog_manager_efl.cc create mode 100644 atom/browser/atom_javascript_dialog_manager_efl.h create mode 100644 atom/browser/atom_javascript_modal_dialog_efl.cc create mode 100644 atom/browser/atom_javascript_modal_dialog_efl.h diff --git a/atom/app/ui_runtime.cc b/atom/app/ui_runtime.cc index 7f76282..694d724 100644 --- a/atom/app/ui_runtime.cc +++ b/atom/app/ui_runtime.cc @@ -40,6 +40,7 @@ bool UiRuntime::OnCreate() { if (appdata->splash_screen_info()) { browser->SetSplashScreen(); } + return true; } diff --git a/atom/browser/atom_javascript_dialog_manager_efl.cc b/atom/browser/atom_javascript_dialog_manager_efl.cc new file mode 100644 index 0000000..ee0a9b6 --- /dev/null +++ b/atom/browser/atom_javascript_dialog_manager_efl.cc @@ -0,0 +1,101 @@ +// Copyright 2014 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 "atom/browser/atom_javascript_dialog_manager_efl.h" + +#include "atom/browser/atom_javascript_modal_dialog_efl.h" +#include "atom/browser/native_window_efl.h" +#include "base/strings/utf_string_conversions.h" +#include "common/web_contents_utils.h" +#include "content/public/browser/browser_thread.h" + +namespace atom { +AtomJavaScriptDialogManagerEfl::AtomJavaScriptDialogManagerEfl() + : dialog_(nullptr) { +} + +AtomJavaScriptDialogManagerEfl::~AtomJavaScriptDialogManagerEfl() { +} + +void AtomJavaScriptDialogManagerEfl::RunJavaScriptDialog( + content::WebContents* web_contents, + const GURL& origin_url, + content::JavaScriptMessageType javascript_message_type, + const base::string16& message_text, + const base::string16& default_prompt_text, + const DialogClosedCallback& callback, + bool* did_suppress_message) { + DCHECK(web_contents); + dialog_closed_callback_ = callback; + AtomJavaScriptModalDialogEfl::Type type = AtomJavaScriptModalDialogEfl::ALERT; + switch (javascript_message_type) { + case content::JAVASCRIPT_MESSAGE_TYPE_ALERT: { + type = AtomJavaScriptModalDialogEfl::ALERT; + break; + } + case content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM: { + type = AtomJavaScriptModalDialogEfl::CONFIRM; + break; + } + case content::JAVASCRIPT_MESSAGE_TYPE_PROMPT: { + type = AtomJavaScriptModalDialogEfl::PROMPT; + break; + } + default: + break; + } + // If "*_callback_data_" doen't exist, create default popup + dialog_.reset(AtomJavaScriptModalDialogEfl::CreateDialogAndShow( + web_contents, origin_url, type, message_text, default_prompt_text, + callback)); +} + +void AtomJavaScriptDialogManagerEfl::ExecuteDialogClosedCallback( + bool result, + const std::string prompt_data) { + // If default dialog was created, callback is handled in dtor of dialog. + if (dialog_) + dialog_.reset(nullptr); + else + dialog_closed_callback_.Run(result, base::UTF8ToUTF16(prompt_data)); +} + +void AtomJavaScriptDialogManagerEfl::SetPopupSize(int width, int height) { + if (dialog_) + dialog_->SetPopupSize(width, height); +} + +bool AtomJavaScriptDialogManagerEfl::IsShowing() { + return dialog_ && dialog_->IsShowing(); +} + +void AtomJavaScriptDialogManagerEfl::RunBeforeUnloadDialog( + content::WebContents* web_contents, + bool is_reload, + const DialogClosedCallback& callback) { + DCHECK(web_contents); + dialog_closed_callback_ = callback; + + dialog_.reset(AtomJavaScriptModalDialogEfl::CreateDialogAndShow( + web_contents, GURL(), AtomJavaScriptModalDialogEfl::NAVIGATION, + base::UTF8ToUTF16( + std::string(dgettext("WebKit", "POP LEAVE"))), + base::string16(), callback)); +} + +bool AtomJavaScriptDialogManagerEfl::HandleJavaScriptDialog( + content::WebContents* web_contents, + bool accept, + const base::string16* prompt_override) { + NOTIMPLEMENTED(); + return false; +} + +void AtomJavaScriptDialogManagerEfl::CancelDialogs( + content::WebContents* web_contents, + bool suppress_callbacks, + bool reset_state) { + NOTIMPLEMENTED(); +} +} diff --git a/atom/browser/atom_javascript_dialog_manager_efl.h b/atom/browser/atom_javascript_dialog_manager_efl.h new file mode 100644 index 0000000..c9cf8ef --- /dev/null +++ b/atom/browser/atom_javascript_dialog_manager_efl.h @@ -0,0 +1,62 @@ +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ATOM_BROWSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_EFL_H_ +#define ATOM_BROWSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_EFL_H_ + +#include + +#include "base/strings/string16.h" +#include "content/public/browser/javascript_dialog_manager.h" +#include "content/public/common/javascript_message_type.h" +#include "url/gurl.h" + +namespace atom { +class AtomJavaScriptModalDialogEfl; + +class AtomJavaScriptDialogManagerEfl: public content::JavaScriptDialogManager { + public: + AtomJavaScriptDialogManagerEfl(); + ~AtomJavaScriptDialogManagerEfl() override; + + void RunJavaScriptDialog( + content::WebContents* web_contents, + const GURL& origin_url, + content::JavaScriptMessageType javascript_message_type, + const base::string16& message_text, + const base::string16& default_prompt_text, + const DialogClosedCallback& callback, + bool* did_suppress_message) override; + void RunBeforeUnloadDialog(content::WebContents* web_contents, + bool is_reload, + const DialogClosedCallback& callback) override; + bool HandleJavaScriptDialog(content::WebContents* web_contents, + bool accept, + const base::string16* prompt_override) override; + void CancelDialogs(content::WebContents* web_contents, + bool suppress_callbacks, + bool reset_state) override; +#if defined(OS_TIZEN_TV_PRODUCT) + void OnDialogClosed(content::WebContents* web_contents) override; +#endif + + void SetPopupSize(int width, int height); + bool IsShowing(); + void ExecuteDialogClosedCallback(bool result, const std::string prompt_data); + private: + template + struct CallbackData { + CallbackData() : callback(nullptr), user_data(nullptr) {} + + CallbackType callback; + void* user_data; + }; + + std::unique_ptr dialog_; + DialogClosedCallback dialog_closed_callback_; + + DISALLOW_COPY_AND_ASSIGN(AtomJavaScriptDialogManagerEfl); +}; +} + +#endif // ATOM_BROWSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_EFL_H_ diff --git a/atom/browser/atom_javascript_modal_dialog_efl.cc b/atom/browser/atom_javascript_modal_dialog_efl.cc new file mode 100644 index 0000000..3343de0 --- /dev/null +++ b/atom/browser/atom_javascript_modal_dialog_efl.cc @@ -0,0 +1,404 @@ +// Copyright 2014 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 "atom/browser/atom_javascript_modal_dialog_efl.h" +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "base/strings/utf_string_conversions.h" +#include "common/web_contents_utils.h" +#include "content/common/paths_efl.h" +#include "ui/display/device_display_info_efl.h" + +#ifdef OS_TIZEN +#include +#endif + +namespace atom { +// static +AtomJavaScriptModalDialogEfl* AtomJavaScriptModalDialogEfl::CreateDialogAndShow( + content::WebContents* web_contents, + const GURL& origin_url, + Type type, + const base::string16& message_text, + const base::string16& default_prompt_text, + const content::JavaScriptDialogManager::DialogClosedCallback& callback) { + AtomJavaScriptModalDialogEfl* dialog = + new AtomJavaScriptModalDialogEfl(web_contents, origin_url, type, message_text, + default_prompt_text, callback); + if (!dialog->ShowJavaScriptDialog()) { + LOG(ERROR) << "Could not create javascript dialog."; + delete dialog; + return nullptr; + } + + return dialog; +} + +AtomJavaScriptModalDialogEfl::AtomJavaScriptModalDialogEfl( + content::WebContents* web_contents, + const GURL& origin_url, + Type type, + const base::string16& message_text, + const base::string16& default_prompt_text, + const content::JavaScriptDialogManager::DialogClosedCallback& callback) + : web_view_(atom::NativeWindow::FromWebContents(web_contents)), + window_(nullptr), + conformant_(nullptr), + popup_(nullptr), + prompt_entry_(nullptr), + is_callback_processed_(false), + is_showing_(false), + type_(type), + message_text_(message_text), + default_prompt_text_(default_prompt_text), + callback_(callback) { + atom::NativeWindow* parent_window = atom::NativeWindow::FromWebContents(web_contents); + Evas_Object* win = static_cast(parent_window)->evas_object(); +} + +static void PromptEntryChanged(void* data, Ecore_IMF_Context* ctx, int value) { + if (value != ECORE_IMF_INPUT_PANEL_STATE_HIDE) + return; + + Evas_Object* entry = static_cast(data); + if (entry) + elm_object_focus_set(entry, EINA_FALSE); +} + +static void PromptEnterKeyDownCallback(void* data, + Evas_Object* obj, + void* eventInfo) { + elm_entry_input_panel_hide(obj); +} + +bool AtomJavaScriptModalDialogEfl::ShowJavaScriptDialog() { + Evas_Object* top_window = static_cast(web_view_)->evas_object(); + + popup_ = CreatePopupOnNewWindow(top_window); + if (!popup_) + return false; + + switch (type_) { + case PROMPT: { + if (!CreatePromptLayout()) + return false; + break; + } + + case NAVIGATION: { + if (!CreateNavigationLayout()) + return false; + break; + } + case ALERT: { + if (!CreateAlertLayout()) + return false; + break; + } + case CONFIRM: { + if (!CreateConfirmLayout()) + return false; + break; + } + } +#if defined(OS_TIZEN) + eext_object_event_callback_add(popup_, EEXT_CALLBACK_BACK, + CancelButtonCallback, this); +#endif + evas_object_focus_set(popup_, true); + evas_object_show(popup_); + + is_showing_ = true; + + return true; +} + +Evas_Object* AtomJavaScriptModalDialogEfl::CreatePopup(Evas_Object* window) { + if (!window) + return nullptr; + + conformant_ = elm_conformant_add(window); + if (!conformant_) + return nullptr; + + evas_object_size_hint_weight_set(conformant_, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_win_resize_object_add(window, conformant_); + evas_object_show(conformant_); + Evas_Object* layout = elm_layout_add(conformant_); + if (!layout) + return nullptr; + + elm_layout_theme_set(layout, "layout", "application", "default"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(layout); + + elm_object_content_set(conformant_, layout); + + return elm_popup_add(layout); +} + +Evas_Object* AtomJavaScriptModalDialogEfl::CreatePopupOnNewWindow( + Evas_Object* top_window) { + if (!top_window) + return nullptr; + + window_ = elm_win_add(top_window, "AtomJavaScriptModalDialogEfl", ELM_WIN_BASIC); + if (!window_) + return nullptr; + + elm_win_alpha_set(window_, EINA_TRUE); + + if (elm_win_indicator_mode_get(top_window) == ELM_WIN_INDICATOR_SHOW) + elm_win_indicator_mode_set(window_, ELM_WIN_INDICATOR_SHOW); + + if (elm_win_indicator_opacity_get(top_window) == + ELM_WIN_INDICATOR_TRANSPARENT) + elm_win_indicator_opacity_set(window_, ELM_WIN_INDICATOR_TRANSPARENT); + + if (elm_win_wm_rotation_supported_get(top_window)) { + int rots[] = {0, 90, 180, 270}; + elm_win_wm_rotation_available_rotations_set(window_, rots, 4); + } + +// display::DeviceDisplayInfoEfl display_info; +// evas_object_resize(window_, display_info.GetDisplayWidth(), + // display_info.GetDisplayHeight()); + + Evas_Object* popup = CreatePopup(window_); + elm_win_conformant_set(window_, EINA_TRUE); + evas_object_show(window_); + + return popup; +} + +bool AtomJavaScriptModalDialogEfl::CreatePromptLayout() { + Evas_Object* layout = elm_layout_add(popup_); + if (!layout) + return false; + if (message_text_.c_str()) { + elm_object_part_text_set(popup_, "title,text", + UTF16ToUTF8(message_text_).c_str()); + } + + elm_layout_file_set(layout, GetEdjPath().c_str(), "prompt"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + + prompt_entry_ = elm_entry_add(popup_); + if (!prompt_entry_) + return false; + + Ecore_IMF_Context* imf_context = + static_cast(elm_entry_imf_context_get(prompt_entry_)); + ecore_imf_context_input_panel_event_callback_add( + imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, PromptEntryChanged, + prompt_entry_); + elm_entry_single_line_set(prompt_entry_, EINA_TRUE); + elm_entry_input_panel_return_key_type_set( + prompt_entry_, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE); + evas_object_smart_callback_add(prompt_entry_, "activated", + PromptEnterKeyDownCallback, this); + elm_object_text_set(prompt_entry_, UTF16ToUTF8(default_prompt_text_).c_str()); + elm_entry_scrollable_set(prompt_entry_, EINA_TRUE); + elm_entry_cursor_end_set(prompt_entry_); + elm_object_part_content_set(layout, "prompt_container", prompt_entry_); + + elm_object_content_set(popup_, layout); + Evas_Object* cancel_btn = AddButton("CANCEL", + "button1", CancelButtonCallback); + Evas_Object* ok_btn = + AddButton("OK", "button2", OkButtonCallback); + if (!cancel_btn || !ok_btn) + return false; + + evas_object_focus_set(ok_btn, true); + return true; +} + +bool AtomJavaScriptModalDialogEfl::CreateNavigationLayout() { + if (message_text_.c_str()) { + elm_object_part_text_set(popup_, "title,text", + UTF16ToUTF8(message_text_).c_str()); + } + + std::string question(dgettext("WebKit", "POP LEAVE")); + std::string message; + if (default_prompt_text_.c_str()) { + message = std::string(UTF16ToUTF8(default_prompt_text_).c_str()) + ("\n") + + question; + } else { + message = question; + } + if (!message_text_.empty()) { + elm_object_text_set(popup_, + GetPopupMessage(UTF16ToUTF8(message_text_)).c_str()); + } + Evas_Object* cancel_btn = + AddButton("CANCEL", "button1", CancelButtonCallback); + Evas_Object* ok_btn = + AddButton("OK", "button2", OkButtonCallback); + if (!cancel_btn || !ok_btn) + return false; + + evas_object_focus_set(ok_btn, true); + + return true; +} + +bool AtomJavaScriptModalDialogEfl::CreateAlertLayout() { + elm_object_part_text_set(popup_, "title,text", GetTitle().c_str()); + if (!message_text_.empty()) { + elm_object_text_set(popup_, + GetPopupMessage(UTF16ToUTF8(message_text_)).c_str()); + } + + Evas_Object* ok_btn = + AddButton("OK", "button1", OkButtonCallback); + if (!ok_btn) + return false; + + evas_object_focus_set(ok_btn, true); + return true; +} +bool AtomJavaScriptModalDialogEfl::CreateConfirmLayout() { + elm_object_part_text_set(popup_, "title,text", GetTitle().c_str()); + if (!message_text_.empty()) { + elm_object_text_set(popup_, + GetPopupMessage(UTF16ToUTF8(message_text_)).c_str()); + } + + Evas_Object* cancel_btn = AddButton("CANCEL", + "button1", CancelButtonCallback); + Evas_Object* ok_btn = + AddButton("OK", "button2", OkButtonCallback); + if (!cancel_btn || !ok_btn) + return false; + + evas_object_focus_set(ok_btn, true); + + return true; +} + +std::string AtomJavaScriptModalDialogEfl::GetTitle() { + + std::string title = + dgettext("WebKit", "HEADER MESSAGE"); + + const std::string replaceStr("%s"); + size_t pos = title.find(replaceStr); + if (pos != std::string::npos) + title.replace(pos, replaceStr.length(), UTF16ToUTF8(message_text_).c_str()); + + return title; +} + +std::string AtomJavaScriptModalDialogEfl::GetPopupMessage(const std::string& str) { + if (str.empty()) + return str; + + std::string message = std::string(elm_entry_utf8_to_markup(str.c_str())); + base::ReplaceChars(message, "\n", "
", &message); + + message = "" + message + ""; + + return message; +} + +std::string AtomJavaScriptModalDialogEfl::GetEdjPath() { + base::FilePath edj_dir; + PathService::Get(PathsEfl::EDJE_RESOURCE_DIR, &edj_dir); + return edj_dir.Append(FILE_PATH_LITERAL("JavaScriptPopup.edj")) + .AsUTF8Unsafe(); +} + +void AtomJavaScriptModalDialogEfl::CancelButtonCallback(void* data, + Evas_Object* obj, + void* event_info) { + AtomJavaScriptModalDialogEfl* dialog = + static_cast(data); + + dialog->callback_.Run(false, base::string16()); + dialog->is_callback_processed_ = true; + dialog->Close(); +} + +void AtomJavaScriptModalDialogEfl::OkButtonCallback(void* data, + Evas_Object* obj, + void* event_info) { + AtomJavaScriptModalDialogEfl* dialog = + static_cast(data); + if (dialog->type_ == PROMPT) { + std::string prompt_data; + if (dialog->prompt_entry_) + prompt_data = elm_entry_entry_get(dialog->prompt_entry_); + + dialog->callback_.Run(true, base::UTF8ToUTF16(prompt_data)); + } else { + dialog->callback_.Run(true, base::string16()); + } + dialog->is_callback_processed_ = true; + dialog->Close(); +} + +void AtomJavaScriptModalDialogEfl::Close() { + if (!is_callback_processed_) + callback_.Run(false, base::string16()); + +#if defined(OS_TIZEN) + eext_object_event_callback_del(popup_, EEXT_CALLBACK_BACK, + CancelButtonCallback); +#endif + + if (window_) { + evas_object_del(window_); + window_ = nullptr; + conformant_ = nullptr; + } else if (conformant_) { + evas_object_del(conformant_); + conformant_ = nullptr; + } + + popup_ = nullptr; + prompt_entry_ = nullptr; + + is_showing_ = false; +} + +void AtomJavaScriptModalDialogEfl::SetPopupSize(int width, int height) { + if (!popup_) + return; + + evas_object_resize(popup_, width, height); + evas_object_move(popup_, 0, 0); +} + +AtomJavaScriptModalDialogEfl::~AtomJavaScriptModalDialogEfl() { + Close(); +} + +Evas_Object* AtomJavaScriptModalDialogEfl::AddButton(const std::string& text, + const std::string& part, + Evas_Smart_Cb callback) { + Evas_Object* btn = elm_button_add(popup_); + if (!btn) + return nullptr; + elm_object_style_set(btn, "popup"); + elm_object_domain_translatable_part_text_set(btn, NULL, "WebKit", + text.c_str()); + elm_object_part_content_set(popup_, part.c_str(), btn); + evas_object_smart_callback_add(btn, "clicked", callback, this); + return btn; +} + +Evas_Object* AtomJavaScriptModalDialogEfl::AddButtonIcon(Evas_Object* btn, + const std::string& img) { + return nullptr; +} + +bool AtomJavaScriptModalDialogEfl::AddCircleLayout(const std::string& title, + const std::string& theme) { + return false; +} +} diff --git a/atom/browser/atom_javascript_modal_dialog_efl.h b/atom/browser/atom_javascript_modal_dialog_efl.h new file mode 100644 index 0000000..655fee6 --- /dev/null +++ b/atom/browser/atom_javascript_modal_dialog_efl.h @@ -0,0 +1,90 @@ +// Copyright 2014 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. + +#ifndef ATOM_BROWSER_ATOM_JAVASCRIPT_MODAL_DIALOG_EFL_H_ +#define ATOM_BROWSER_ATOM_JAVASCRIPT_MODAL_DIALOG_EFL_H_ + +#include +#include +#include + +#include "atom/browser/native_window_efl.h" +#include "base/strings/string16.h" +#include "content/public/browser/javascript_dialog_manager.h" +#include "url/gurl.h" + +namespace atom { +class AtomJavaScriptModalDialogEfl { + public: + enum Type { + ALERT, + CONFIRM, + NAVIGATION, + PROMPT + }; + static AtomJavaScriptModalDialogEfl* CreateDialogAndShow( + content::WebContents* web_contents, + const GURL& origin_url, + Type type, + const base::string16& message_text, + const base::string16& default_prompt_text, + const content::JavaScriptDialogManager::DialogClosedCallback& callback); + + virtual ~AtomJavaScriptModalDialogEfl(); + void SetPopupSize(int width, int height); + bool IsShowing() { return is_showing_; } + + private: + AtomJavaScriptModalDialogEfl( + content::WebContents* web_contents, + const GURL& origin_url, + Type type, + const base::string16& message_text, + const base::string16& default_prompt_text, + const content::JavaScriptDialogManager::DialogClosedCallback& callback); + + void Close(); + + bool ShowJavaScriptDialog(); + Evas_Object* CreatePopup(Evas_Object* window); + + Evas_Object* CreatePopupOnNewWindow(Evas_Object* top_window); + + bool CreatePromptLayout(); + bool CreateAlertLayout(); + bool CreateConfirmLayout(); + bool CreateNavigationLayout(); + + Evas_Object* AddButton(const std::string& text, + const std::string& part, + Evas_Smart_Cb callback); + Evas_Object* AddButtonIcon(Evas_Object* btn, const std::string& img); + bool AddCircleLayout(const std::string& title, const std::string& theme); + std::string GetEdjPath(); + std::string GetPopupMessage(const std::string&); + std::string GetTitle(); + + static void CancelButtonCallback(void* data, + Evas_Object* obj, + void* event_info); + static void OkButtonCallback(void* data, Evas_Object* obj, void* event_info); + + atom::NativeWindow* web_view_; + Evas_Object* window_; + Evas_Object* conformant_; + Evas_Object* popup_; + Evas_Object* prompt_entry_; + + bool is_callback_processed_; + bool is_showing_; + + Type type_; + base::string16 message_text_; + base::string16 default_prompt_text_; + std::string popup_message_; + content::JavaScriptDialogManager::DialogClosedCallback callback_; +}; +} +#endif // ATOM_BROWSER_ATOM_JAVASCRIPT_MODAL_DIALOG_EFL_H_ + diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 252e8db..552d1c1 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -10,6 +10,7 @@ #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_javascript_dialog_manager.h" +#include "atom/browser/atom_javascript_dialog_manager_efl.h" #include "atom/browser/native_window.h" #include "atom/browser/ui/file_dialog.h" #include "atom/browser/web_dialog_helper.h" @@ -232,8 +233,11 @@ content::JavaScriptDialogManager* CommonWebContentsDelegate::GetJavaScriptDialogManager( content::WebContents* source) { if (!dialog_manager_) +#if defined(USE_EFL) + dialog_manager_.reset(new AtomJavaScriptDialogManagerEfl); +#else dialog_manager_.reset(new AtomJavaScriptDialogManager); - +#endif return dialog_manager_.get(); } diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index 2720941..3d65c9d 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -21,6 +21,7 @@ namespace atom { class AtomBrowserContext; class AtomJavaScriptDialogManager; +class AtomJavaScriptDialogManagerEfl; class NativeWindow; class WebDialogHelper; @@ -147,7 +148,11 @@ class CommonWebContentsDelegate bool native_fullscreen_; std::unique_ptr web_dialog_helper_; +#if defined(USE_EFL) + std::unique_ptr dialog_manager_; +#else std::unique_ptr dialog_manager_; +#endif scoped_refptr devtools_file_system_indexer_; // Make sure BrowserContext is alwasys destroyed after WebContents. diff --git a/filenames.gypi b/filenames.gypi index 9b53138..b7bb9a8 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -184,6 +184,10 @@ 'atom/browser/atom_browser_main_parts_posix.cc', 'atom/browser/atom_javascript_dialog_manager.cc', 'atom/browser/atom_javascript_dialog_manager.h', + 'atom/browser/atom_javascript_dialog_manager_efl.cc', + 'atom/browser/atom_javascript_dialog_manager_efl.h', + 'atom/browser/atom_javascript_modal_dialog_efl.cc', + 'atom/browser/atom_javascript_modal_dialog_efl.h', 'atom/browser/atom_permission_manager.cc', 'atom/browser/atom_permission_manager.h', 'atom/browser/atom_quota_permission_context.cc', -- 2.7.4 From 52d96c8715a5fb5903b6fbddd9fdc3b774c97902 Mon Sep 17 00:00:00 2001 From: Suneel Kota Date: Mon, 17 Sep 2018 20:03:46 +0530 Subject: [PATCH 07/16] Add command line flag to enable touch events touchstart, touchend and other touch events will be enabled and the respective event handlers will only work when touch events are enabled in command line. Change-Id: I8527d5b098cb9427a567c2f0fb57ba65fd234271 Signed-off-by: Suneel Kota --- tizen/src/app/wrt_main_delegate.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tizen/src/app/wrt_main_delegate.cc b/tizen/src/app/wrt_main_delegate.cc index 55eff65..6d4afe5 100644 --- a/tizen/src/app/wrt_main_delegate.cc +++ b/tizen/src/app/wrt_main_delegate.cc @@ -5,6 +5,7 @@ #include "efl/init.h" #include "tizen/common/env_variables.h" #include "tizen/common/application_data.h" +#include "tizen/common/platform_info.h" namespace { @@ -46,6 +47,8 @@ bool WRTMainDelegate::BasicStartupComplete(int* exit_code) { command_line->AppendSwitch("enable-tizen-app-container"); command_line->AppendSwitchASCII( "injected-bundle-path", "/usr/lib/libxwalk_injected_bundle.so"); + if ( common::getProfile() != common::kPROFILE_TV) + command_line->AppendSwitchASCII("touch-events", "enabled"); return AtomMainDelegate::BasicStartupComplete(exit_code); } -- 2.7.4 From f43046922e692c0a4119280ace4bebdc4904ede6 Mon Sep 17 00:00:00 2001 From: "prathmesh.m" Date: Tue, 25 Sep 2018 11:43:03 +0530 Subject: [PATCH 08/16] Do not pause/resume app if background support is enabled If background support is enabled then the javascript must run in background even if the app is paused. Currently on Pause the application is suspended and hence the JS. With this patch if background support is enbaled window will be sent to background by platform but engine will run, ie. JS will be active in background Change-Id: Ideb74215fcc4fe3f3d31a3458c4e0611ad2c258c Signed-off-by: prathmesh.m --- atom/browser/browser.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 808e913..7313bb2 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -257,7 +257,14 @@ void Browser::OnWindowAllClosed() { } #if defined(OS_TIZEN) +// Function is same as suspend. This will be called from app lifecycle suspend void Browser::Hide() { + // If application is having background catagory enabled then do not suspend the app + auto appdata = common::ApplicationDataManager::GetCurrentAppData(); + if (appdata->setting_info() != NULL && appdata->setting_info()->background_support_enabled()) { + return; + } + NativeWindow *last_window = WindowList::GetLastWindow(); if (!last_window) return; @@ -267,7 +274,14 @@ void Browser::Hide() { atom::Browser::Get()->Suspend(rvh); } +// Function is same as resume. This will be called from app lifecycle resume void Browser::Show() { + // If application is having background catagory enabled then do not resume the app + // as its has not suspend + auto appdata = common::ApplicationDataManager::GetCurrentAppData(); + if (appdata->setting_info() != NULL && appdata->setting_info()->background_support_enabled()) { + return; + } NativeWindow *last_window = WindowList::GetLastWindow(); if (!last_window) return; -- 2.7.4 From f0079853c795fdd7c6e55e0095a2f04a1848a634 Mon Sep 17 00:00:00 2001 From: deepti Date: Mon, 24 Sep 2018 16:28:14 +0530 Subject: [PATCH 09/16] Refactor Add popup support for runtime and impl to allow cert errors 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 --- atom/browser/api/atom_api_app.cc | 51 ++++++++++++++++----------------------- atom/browser/api/atom_api_app.h | 10 ++++---- tizen/common/constants.cc | 3 +-- tizen/src/browser/popup.cc | 14 +++++------ tizen/src/browser/popup.h | 8 +++--- tizen/src/browser/popup_string.cc | 5 ++-- tizen/src/browser/popup_string.h | 8 +++--- wrt.gyp | 6 ++--- 8 files changed, 46 insertions(+), 59 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index e5e0571..ca50c1c 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -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" @@ -51,19 +55,11 @@ #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& 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::NativeWindow::FromWebContents(web_contents))->evas_object(); + Evas_Object* window = static_cast( + 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: "<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); diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index b8ecc6f..528288f 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -108,11 +108,6 @@ class App : public AtomBrowserClient::Delegate, bool expired_previous_decision, const base::Callback& callback) override; -void AllowCertificateDialog(content::WebContents* web_contents, - const std::string& url, - const std::string& pem, - const base::Callback& - 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& + callback); #if defined(USE_NSS_CERTS) void ImportCertificate(const base::DictionaryValue& options, const net::CompletionCallback& callback); diff --git a/tizen/common/constants.cc b/tizen/common/constants.cc index 660058e..f47be9d 100644 --- a/tizen/common/constants.cc +++ b/tizen/common/constants.cc @@ -14,13 +14,12 @@ * 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 diff --git a/tizen/src/browser/popup.cc b/tizen/src/browser/popup.cc index 198cf49..20f3b55 100644 --- a/tizen/src/browser/popup.cc +++ b/tizen/src/browser/popup.cc @@ -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. @@ -14,22 +14,20 @@ * 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"; diff --git a/tizen/src/browser/popup.h b/tizen/src/browser/popup.h index 9938d48..76bcc39 100644 --- a/tizen/src/browser/popup.h +++ b/tizen/src/browser/popup.h @@ -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 #include @@ -103,4 +103,4 @@ class Popup { } // namespace runtime -#endif // XWALK_RUNTIME_BROWSER_POPUP_H_ +#endif // TIZEN_SRC_BROWSER_POPUP_H_ diff --git a/tizen/src/browser/popup_string.cc b/tizen/src/browser/popup_string.cc index edee085..1e6b18d 100644 --- a/tizen/src/browser/popup_string.cc +++ b/tizen/src/browser/popup_string.cc @@ -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. @@ -14,11 +14,10 @@ * limitations under the License. */ -#include "tizen/src/browser/popup_string.h" #include - #include "tizen/common/constants.h" +#include "tizen/src/browser/popup_string.h" namespace runtime { diff --git a/tizen/src/browser/popup_string.h b/tizen/src/browser/popup_string.h index 09a6c9a..62499a1 100644 --- a/tizen/src/browser/popup_string.h +++ b/tizen/src/browser/popup_string.h @@ -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 @@ -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 1ca7046..9fef526 100644 --- a/wrt.gyp +++ b/wrt.gyp @@ -129,13 +129,13 @@ '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', -- 2.7.4 From 56a0f8bdd94a26cc8fb6a257867ed21230013595 Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Wed, 26 Sep 2018 19:31:41 +0530 Subject: [PATCH 10/16] Enable visited links chromium component Visited link component from chromium wasn't being used because of which visited pseudo attribute of link elements doesn't get activated and CSS3Colors_color_pseudo-classes fails Reference patch: https://review.tizen.org/gerrit/#/c/130333/ Depends on https://review.tizen.org/gerrit/#/c/190037/ Change-Id: I1beb18174682ae1a7652b7fcc8f780fca62a5d06 Signed-off-by: surya.kumar7 --- atom/browser/api/atom_api_web_contents.cc | 7 +++++++ atom/browser/api/atom_api_web_contents.h | 4 ++++ atom/browser/atom_browser_context.cc | 24 ++++++++++++++++++++++++ atom/browser/atom_browser_context.h | 13 ++++++++++++- atom/renderer/atom_renderer_client.cc | 13 +++++++++++++ atom/renderer/atom_renderer_client.h | 6 ++++++ 6 files changed, 66 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index fccae5a..18f375d 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -723,6 +723,13 @@ void WebContents::DidChangeThemeColor(SkColor theme_color) { Emit("did-change-theme-color", atom::ToRGBHex(theme_color)); } +void WebContents::DidNavigateAnyFrame(content::RenderFrameHost* render_frame_host, + const content::LoadCommittedDetails& details, + const content::FrameNavigateParams& params) { + static_cast(web_contents()->GetBrowserContext())-> + AddVisitedURLs(params.redirects); +} + void WebContents::DocumentLoadedInFrame( content::RenderFrameHost* render_frame_host) { if (!render_frame_host->GetParent()) diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 48d23e8..2311e0f 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -339,6 +339,10 @@ class WebContents : public mate::TrackableObject, void MediaStoppedPlaying(const MediaPlayerInfo& video_type, const MediaPlayerId& id) override; void DidChangeThemeColor(SkColor theme_color) override; + void DidNavigateAnyFrame( + content::RenderFrameHost* render_frame_host, + const content::LoadCommittedDetails& details, + const content::FrameNavigateParams& params) override; // content::NotificationObserver: void Observe(int type, diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 0d56c5f..92a589d 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -79,6 +79,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition, ct_delegate_(new AtomCTDelegate), network_delegate_(new AtomNetworkDelegate), cookie_delegate_(new AtomCookieDelegate) { + InitVisitedLinkMaster(); // Construct user agent string. Browser* browser = Browser::Get(); std::string name = RemoveWhitespace(browser->GetName()); @@ -252,4 +253,27 @@ scoped_refptr AtomBrowserContext::From( return new AtomBrowserContext(partition, in_memory, options); } +void AtomBrowserContext::InitVisitedLinkMaster() { + if (!IsOffTheRecord()) { + visitedlink_master_.reset(new visitedlink::VisitedLinkMaster(this, this, false)); + visitedlink_master_->Init(); + } +} + +void AtomBrowserContext::AddVisitedURLs(const std::vector& urls) { + if (!IsOffTheRecord()) { + DCHECK(visitedlink_master_); + visitedlink_master_->AddURLs(urls); + } +} + +void AtomBrowserContext::RebuildTable(const scoped_refptr& enumerator) { + if (!IsOffTheRecord()) { + // WebView rebuilds from WebChromeClient.getVisitedHistory. The client + // can change in the lifetime of this WebView and may not yet be set here. + // Therefore this initialization path is not used. + enumerator->OnComplete(true); + } +} + } // namespace atom diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index 340c8f4..e4f6e0d 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -10,6 +10,8 @@ #include "atom/browser/net/atom_cookie_delegate.h" #include "brightray/browser/browser_context.h" +#include "components/visitedlink/browser/visitedlink_delegate.h" +#include "components/visitedlink/browser/visitedlink_master.h" #include "net/cookies/cookie_monster.h" namespace atom { @@ -21,7 +23,8 @@ class AtomNetworkDelegate; class AtomPermissionManager; class WebViewManager; -class AtomBrowserContext : public brightray::BrowserContext { +class AtomBrowserContext : public brightray::BrowserContext, + public visitedlink::VisitedLinkDelegate { public: // Get or create the BrowserContext according to its |partition| and // |in_memory|. The |options| will be passed to constructor when there is no @@ -32,6 +35,13 @@ class AtomBrowserContext : public brightray::BrowserContext { void SetUserAgent(const std::string& user_agent); + // These methods map to Add methods in visitedlink::VisitedLinkMaster. + void AddVisitedURLs(const std::vector& urls); + // visitedlink::VisitedLinkDelegate implementation. + void RebuildTable(const scoped_refptr& enumerator) override; + // Reset visitedlink master and initialize it. + void InitVisitedLinkMaster(); + // brightray::URLRequestContextGetter::Delegate: net::NetworkDelegate* CreateNetworkDelegate() override; net::CookieMonsterDelegate* CreateCookieDelegate() override; @@ -65,6 +75,7 @@ class AtomBrowserContext : public brightray::BrowserContext { ~AtomBrowserContext() override; private: + std::unique_ptr visitedlink_master_; std::unique_ptr download_manager_delegate_; std::unique_ptr guest_manager_; std::unique_ptr permission_manager_; diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 1e55cce..2323f25 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -32,6 +32,7 @@ #include "base/command_line.h" #include "content/public/renderer/render_frame.h" #include "native_mate/dictionary.h" +#include "services/service_manager/public/cpp/interface_registry.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "tizen/common/env_variables.h" @@ -93,6 +94,9 @@ void AtomRendererClient::RenderThreadStarted() { widget_.reset(wrt_widget); content::RenderThread* thread = content::RenderThread::Get(); thread->AddObserver(wrt_widget->GetObserver()); + visited_link_slave_.reset(new visitedlink::VisitedLinkSlave()); + thread->GetInterfaceRegistry()->AddInterface( + visited_link_slave_->GetBindCallback()); std::string theme = command_line->GetSwitchValueASCII("widget-theme"); std::string encoded_bundle = command_line->GetSwitchValueASCII("widget-encoded-bundle"); std::string scale = command_line->GetSwitchValueASCII("widget-scale"); @@ -281,5 +285,14 @@ void AtomRendererClient::SetupMainWorldOverrides( ignore_result(func->Call(context, v8::Null(isolate), 1, args)); } +unsigned long long AtomRendererClient::VisitedLinkHash(const char* canonical_url, + size_t length) { + return visited_link_slave_->ComputeURLFingerprint(canonical_url, length); +} + +bool AtomRendererClient::IsLinkVisited(unsigned long long link_hash) { + return visited_link_slave_->IsVisited(link_hash); +} + } // namespace atom diff --git a/atom/renderer/atom_renderer_client.h b/atom/renderer/atom_renderer_client.h index 1a67a85..05ab527 100644 --- a/atom/renderer/atom_renderer_client.h +++ b/atom/renderer/atom_renderer_client.h @@ -9,6 +9,7 @@ #include #include "atom/renderer/renderer_client_base.h" +#include "components/visitedlink/renderer/visitedlink_slave.h" #include "tizen_src/ewk/efl_integration/wrt/wrtwidget.h" namespace atom { @@ -35,6 +36,10 @@ class AtomRendererClient : public RendererClientBase { content::RenderFrame* render_frame) override; void SetupMainWorldOverrides(v8::Handle context) override; bool isolated_world() override { return isolated_world_; } + unsigned long long VisitedLinkHash(const char* canonical_url, + size_t length); + + bool IsLinkVisited(unsigned long long link_hash); private: enum NodeIntegration { @@ -44,6 +49,7 @@ class AtomRendererClient : public RendererClientBase { DISABLE, }; std::unique_ptr widget_; + std::unique_ptr visited_link_slave_; void RenderThreadStarted() override; void RenderFrameCreated(content::RenderFrame*) override; -- 2.7.4 From 3f59248d19f124a3f253261f73a62460979505bc Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Thu, 27 Sep 2018 19:00:44 +0530 Subject: [PATCH 11/16] Add vibration capabilities in PWRT PWRT as the client is responsible for listening to events from VibrationManager and call appropriate system APIs for vibration without which tct-vibration-w3c-tests fails Depends on https://review.tizen.org/gerrit/#/c/190168/ Change-Id: I2964136795a04adeb26e45c3b32797dd6a0aee08 Signed-off-by: surya.kumar7 --- efl/build/system.gyp | 21 +++++++++++ packaging/electron-efl.spec | 1 + tizen/browser/tizen_browser_parts.cc | 4 ++- tizen/browser/vibration_manager.cc | 70 ++++++++++++++++++++++++++++++++++++ tizen/browser/vibration_manager.h | 49 +++++++++++++++++++++++++ wrt.gyp | 4 +++ 6 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 tizen/browser/vibration_manager.cc create mode 100644 tizen/browser/vibration_manager.h diff --git a/efl/build/system.gyp b/efl/build/system.gyp index 4b56c0d..3b40764 100644 --- a/efl/build/system.gyp +++ b/efl/build/system.gyp @@ -302,5 +302,26 @@ }], ], }, # tts + { + 'target_name': 'capi-system-device', + 'type': 'none', + 'conditions': [ + ['is_tizen==1', { + 'direct_dependent_settings': { + 'cflags': [ + ' +#include "device/vibration/vibration_provider_client.h" + +namespace tizen { + +class VibrationManager : public device::VibrationProviderClient { + public: + static void CreateInstance(); + VibrationManager(); + /** + * Starts the vibration for the given amount of time + * + * @param vibrationTime amount of time for which vibration should happen + */ + void Vibrate(uint64_t vibrationTime) override; + + /** + * Cancels the vibration + */ + void CancelVibration() override; + virtual ~VibrationManager(); + private: + bool Initialize(); + // haptic_devce_h was declared as int + haptic_device_h handle_; +}; + +} // namespace tizen + +#endif // TIZEN_BROWSER_VIBRATION_MANAGER_H_ diff --git a/wrt.gyp b/wrt.gyp index 9fef526..89ca833 100644 --- a/wrt.gyp +++ b/wrt.gyp @@ -18,6 +18,7 @@ '<(DEPTH)/efl/build/system.gyp:ecore', '<(DEPTH)/efl/build/system.gyp:launchpad', '<(DEPTH)/efl/build/system.gyp:capi-appfw-application', + '<(DEPTH)/efl/build/system.gyp:capi-system-device', '<(DEPTH)/efl/build/system.gyp:elementary', '<(DEPTH)/efl/build/system.gyp:tts', 'electron_shell_copy', @@ -55,6 +56,7 @@ 'dependencies': [ 'wrt_lib', '<(DEPTH)/efl/build/system.gyp:capi-appfw-application', + '<(DEPTH)/efl/build/system.gyp:capi-system-device', '<(DEPTH)/tizen/common/common.gyp:wrt_common', ], 'sources': [ @@ -142,6 +144,8 @@ 'tizen/src/browser/wrt_service.h', 'tizen/browser/tizen_browser_parts.cc', 'tizen/browser/tizen_browser_parts.h', + 'tizen/browser/vibration_manager.cc', + 'tizen/browser/vibration_manager.h', ], 'sources/': [ # chromium-efl supports only tizen webrtc using CAPI -- 2.7.4 From 8407c97d09441dcc8bf58a1040ccabae3d4956db Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Mon, 8 Oct 2018 15:30:32 +0530 Subject: [PATCH 12/16] Disable |uses_encoding_detector| in WebPreferences As per https://review.tizen.org/gerrit/#/c/136138/, if WebPreferences' encoding property is set from WRT, uses_encoding_detector property also has to be disabled Change-Id: Ic23069d31578572e25a56c75975cb756a90e7c3e Signed-off-by: surya.kumar7 --- atom/browser/atom_browser_client.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 1f5aee5..b857780 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -173,6 +173,7 @@ void AtomBrowserClient::OverrideWebkitPrefs( prefs->experimental_webgl_enabled = true; prefs->allow_running_insecure_content = false; prefs->default_encoding = kDefaultEncoding; + prefs->uses_encoding_detector = false; // Custom preferences of guest page. auto web_contents = content::WebContents::FromRenderViewHost(host); -- 2.7.4 From 8bc2a85f3ab737d3274b794cc396185e37c99540 Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Mon, 8 Oct 2018 15:18:04 +0530 Subject: [PATCH 13/16] Set encoding type based on config.xml's value If the encoding type extracted from config.xml is valid, use that, otherwise resort to default encoding(UTF-8) Depends on: https://review.tizen.org/gerrit/#/c/190889/ Depends on: https://review.tizen.org/gerrit/#/c/190893/ Change-Id: Ic95c2ade81f05e47463234b252e35db67a32463e Signed-off-by: surya.kumar7 --- atom/browser/atom_browser_client.cc | 5 ++--- tizen/browser/tizen_browser_parts.cc | 11 +++++++++++ tizen/browser/tizen_browser_parts.h | 1 + tizen/common/resource_manager.h | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index b857780..9b9cfd1 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -59,8 +59,6 @@ bool g_suppress_renderer_process_restart = false; // Custom schemes to be registered to handle service worker. std::string g_custom_service_worker_schemes = ""; -const std::string kDefaultEncoding = "UTF-8"; - void Noop(scoped_refptr) { } @@ -172,7 +170,8 @@ void AtomBrowserClient::OverrideWebkitPrefs( prefs->allow_file_access_from_file_urls = true; prefs->experimental_webgl_enabled = true; prefs->allow_running_insecure_content = false; - prefs->default_encoding = kDefaultEncoding; + // TODO: Encoding type should be set based on the app control received + prefs->default_encoding = atom::Browser::Get()->GetEncodingType(); prefs->uses_encoding_detector = false; // Custom preferences of guest page. diff --git a/tizen/browser/tizen_browser_parts.cc b/tizen/browser/tizen_browser_parts.cc index afae168..9963419 100644 --- a/tizen/browser/tizen_browser_parts.cc +++ b/tizen/browser/tizen_browser_parts.cc @@ -18,6 +18,7 @@ #include "common/string_utils.h" #include "tizen/browser/tizen_browser_parts.h" #include "tizen/browser/vibration_manager.h" +#include "tizen_src/ewk/efl_integration/text_encoding_map_efl.h" #if defined(TIZEN_VIDEO_HOLE) #include "atom/browser/native_window_efl.h" @@ -29,6 +30,8 @@ namespace tizen { namespace { +const std::string kDefaultEncoding = "UTF-8"; + const char* kDefaultCSPRule = "default-src *; script-src 'self'; style-src 'self'; object-src 'none';"; @@ -162,4 +165,12 @@ bool TizenBrowserParts::ShouldAllowNavigation(const std::string &url) { } } +std::string TizenBrowserParts::GetEncodingType() { + std::unique_ptr res = + resource_manager_->GetDefaultResource(); + if (TextEncodingMapEfl::GetInstance()->isTextEncodingValid(res->encoding().c_str())) + return res->encoding(); + else return kDefaultEncoding; +} + } // namespace tizen diff --git a/tizen/browser/tizen_browser_parts.h b/tizen/browser/tizen_browser_parts.h index 19b7072..973fe1a 100644 --- a/tizen/browser/tizen_browser_parts.h +++ b/tizen/browser/tizen_browser_parts.h @@ -35,6 +35,7 @@ class TizenBrowserParts { void Suspend(content::RenderViewHost* rvh); void Resume(content::RenderViewHost* rvh); void GetCSP(std::string& csp_rule, std::string& csp_report_rule); + std::string GetEncodingType(); bool ShouldAllowNavigation(const std::string &url); void Initialize(); diff --git a/tizen/common/resource_manager.h b/tizen/common/resource_manager.h index 298236a..3dc8989 100644 --- a/tizen/common/resource_manager.h +++ b/tizen/common/resource_manager.h @@ -80,11 +80,12 @@ class ResourceManager { std::string DecryptResource(const std::string& path); void set_base_resource_path(const std::string& base_path); + // TODO: Make it a private member again + std::unique_ptr GetDefaultResource(); private: std::unique_ptr GetMatchedResource( const wgt::parse::AppControlInfo&); - std::unique_ptr GetDefaultResource(); // for localization bool Exists(const std::string& path); -- 2.7.4 From b0e7106089fec87eb5ec686fc978ace8435fcbd7 Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Mon, 1 Oct 2018 18:37:34 +0530 Subject: [PATCH 14/16] fixup! Enable popup support. Fixed compilation issue of tv build. Change-Id: Ia602672b9b2dd1f268ec2e443ab2eb949c11e031 Signed-off-by: k2.nagaraju --- atom/browser/atom_javascript_dialog_manager_efl.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/atom/browser/atom_javascript_dialog_manager_efl.cc b/atom/browser/atom_javascript_dialog_manager_efl.cc index ee0a9b6..36cfe2c 100644 --- a/atom/browser/atom_javascript_dialog_manager_efl.cc +++ b/atom/browser/atom_javascript_dialog_manager_efl.cc @@ -98,4 +98,12 @@ void AtomJavaScriptDialogManagerEfl::CancelDialogs( bool reset_state) { NOTIMPLEMENTED(); } + +#if defined(OS_TIZEN_TV_PRODUCT) +void AtomJavaScriptDialogManagerEfl::OnDialogClosed( + content::WebContents* web_contents) { + NOTIMPLEMENTED(); +} +#endif + } -- 2.7.4 From 5ad16fd74e2b533dc4e90887e0b22da4dd684e43 Mon Sep 17 00:00:00 2001 From: Suneel Kota Date: Mon, 1 Oct 2018 18:51:48 +0530 Subject: [PATCH 15/16] Disable forking of new process for navigation currently electron forks a new process for navigation when http method is get, so navigation history is lost, resulting in failure when we test back and forth navigation. Change-Id: I1e38e3c20f9d35cedfb0a7490c20447fd87f46e3 Signed-off-by: Suneel Kota --- atom/renderer/atom_renderer_client.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 2323f25..7fa37d4 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -13,6 +13,7 @@ #include "content/common/wrt/wrt_url_parse.h" #include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_view.h" +#include "tizen/common/application_data.h" #include "tizen_src/ewk/efl_integration/wrt/wrtwidget.h" #include "third_party/WebKit/public/web/WebView.h" #endif @@ -219,6 +220,11 @@ bool AtomRendererClient::ShouldFork(blink::WebLocalFrame* frame, bool is_initial_navigation, bool is_server_redirect, bool* send_referrer) { +#if defined(USE_EFL) + auto app_data = ::common::ApplicationDataManager::GetCurrentAppData(); + if (app_data && !app_data->IsElectronApp()) + return false; +#endif // Handle all the navigations and reloads in browser. // FIXME We only support GET here because http method will be ignored when // the OpenURLFromTab is triggered, which means form posting would not work, -- 2.7.4 From d31781cac3b024a3baf8784373de328162623107 Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Wed, 17 Oct 2018 17:11:25 +0530 Subject: [PATCH 16/16] Extract appid from AtomCommandLine and remove redundant code In prelaunch atom commandLine initialized with |/usr/bin/wrt-loader|. When actual application is loaded, its command line arguments are appending to already existing command line parameters. That is the reason argv[1] is returning appid. Clearing the commandline |argv_| vector in |atom::AtomCommandLine::Init| before pushing the new command line arguments. Removed the unused files. Extract app id from atom command line and parse for base name. Change-Id: Ia4945208186ffbbe82fb15ab67d4881f7ef5305c Signed-off-by: k2.nagaraju --- atom/app/atom_main.cc | 231 ---------------------------------- atom/app/atom_main.h | 10 -- atom/app/atom_main_delegate.cc | 1 - atom/browser/browser.cc | 1 - atom/common/atom_command_line.cc | 5 +- atom/renderer/atom_renderer_client.cc | 6 +- electron.gyp | 8 +- filenames.gypi | 4 - tizen/common/command_line.cc | 147 ---------------------- tizen/common/command_line.h | 70 ----------- tizen/src/wrt_main.cc | 1 - 11 files changed, 13 insertions(+), 471 deletions(-) delete mode 100644 atom/app/atom_main.cc delete mode 100644 atom/app/atom_main.h delete mode 100644 tizen/common/command_line.cc delete mode 100644 tizen/common/command_line.h diff --git a/atom/app/atom_main.cc b/atom/app/atom_main.cc deleted file mode 100644 index c67500f..0000000 --- a/atom/app/atom_main.cc +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/app/atom_main.h" - -#include - -#if defined(OS_WIN) -#include // windows.h must be included first - -#include -#include -#include - -#include "atom/app/atom_main_delegate.h" -#include "atom/common/crash_reporter/win/crash_service_main.h" -#include "base/environment.h" -#include "base/process/launch.h" -#include "base/win/windows_version.h" -#include "content/public/app/sandbox_helper_win.h" -#include "sandbox/win/src/sandbox_types.h" -#elif defined(OS_LINUX) // defined(OS_WIN) -#include "atom/app/atom_main_delegate.h" // NOLINT -#include "content/public/app/content_main.h" -#else // defined(OS_LINUX) -#include "atom/app/atom_library_main.h" -#endif // defined(OS_MACOSX) - -#if defined(USE_EFL) -#include "efl/init.h" -#endif - -#include "atom/app/node_main.h" -#include "atom/common/atom_command_line.h" -#include "base/at_exit.h" -#include "base/i18n/icu_util.h" - -#if defined(OS_TIZEN) -#include - -#include "atom/app/runtime.h" -#include "base/logging.h" -#include "tizen/common/application_data.h" -#include "tizen/common/command_line.h" -#include "tizen/loader/prelauncher.h" -#endif - -namespace { - -const char* kRunAsNode = "ELECTRON_RUN_AS_NODE"; - -// Default command line flags for all profiles and platforms -const char* kDefaultCommandLineFlags[] = { - "allow-file-access-from-files", - "enable-tizen-app-container", -}; - -bool IsEnvSet(const char* name) { -#if defined(OS_WIN) - size_t required_size; - getenv_s(&required_size, nullptr, 0, name); - return required_size != 0; -#else - char* indicator = getenv(name); - return indicator && indicator[0] != '\0'; -#endif -} - -} // namespace - -#if defined(OS_WIN) -int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { - int argc = 0; - wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); - - bool run_as_node = IsEnvSet(kRunAsNode); - - // Make sure the output is printed to console. - if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE")) - base::RouteStdioToConsole(false); - - // Convert argv to to UTF8 - char** argv = new char*[argc]; - for (int i = 0; i < argc; i++) { - // Compute the size of the required buffer - DWORD size = WideCharToMultiByte(CP_UTF8, - 0, - wargv[i], - -1, - NULL, - 0, - NULL, - NULL); - if (size == 0) { - // This should never happen. - fprintf(stderr, "Could not convert arguments to utf8."); - exit(1); - } - // Do the actual conversion - argv[i] = new char[size]; - DWORD result = WideCharToMultiByte(CP_UTF8, - 0, - wargv[i], - -1, - argv[i], - size, - NULL, - NULL); - if (result == 0) { - // This should never happen. - fprintf(stderr, "Could not convert arguments to utf8."); - exit(1); - } - } - - if (run_as_node) { - // Now that argv conversion is done, we can finally start. - base::AtExitManager atexit_manager; - base::i18n::InitializeICU(); - return atom::NodeMain(argc, argv); - } else if (IsEnvSet("ELECTRON_INTERNAL_CRASH_SERVICE")) { - return crash_service::Main(cmd); - } - - sandbox::SandboxInterfaceInfo sandbox_info = {0}; - content::InitializeSandboxInfo(&sandbox_info); - atom::AtomMainDelegate delegate; - - content::ContentMainParams params(&delegate); - params.instance = instance; - params.sandbox_info = &sandbox_info; - atom::AtomCommandLine::Init(argc, argv); - atom::AtomCommandLine::InitW(argc, wargv); - return content::ContentMain(params); -} - -#elif defined(OS_LINUX) // defined(OS_WIN) - -#if defined(OS_TIZEN) -// For debug purpose only. -// TODO: To be removed later -bool hasTizenPackageID(int argc, const char* const* argv) { - if (argc > 3) { - if (0 == strncmp(argv[0], "/opt/usr/globalapps/", strlen("/opt/usr/globalapps/"))) { - return true; - } - } - return false; -} - -int real_main(int argc, char* argv[]) { -#else -int main(int argc, char* argv[]) { -#endif - if (IsEnvSet(kRunAsNode)) { - base::i18n::InitializeICU(); - base::AtExitManager atexit_manager; - return atom::NodeMain(argc, const_cast(argv)); - } - -#if defined(USE_EFL) - common::CommandLine::Init(argc, argv); - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); - - // load manifest - if (appid != "electron") { // TODO: Any better way to distinguish? - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); - if (!appdata->LoadManifestData()) { - return false; - } - } - - if (efl::Initialize(argc, const_cast(argv))) - return 1; - - // Add params for EFL port - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); - - static std::vector flags; - for (auto arg : kDefaultCommandLineFlags) - command_line->AppendSwitch(const_cast(arg)); - efl::AppendPortParams(*command_line); -#endif - - atom::AtomMainDelegate delegate; - content::ContentMainParams params(&delegate); - params.argc = argc; - params.argv = const_cast(argv); - atom::AtomCommandLine::Init(argc, argv); -#if defined(OS_TIZEN) - if (hasTizenPackageID(argc,argv)) { // TODO: Check to be removed later - elm_init(argc, argv); - std::unique_ptr runtime = runtime::Runtime::MakeRuntime(¶ms); - return runtime->Exec(); - } -#endif - return content::ContentMain(params); -} - -#if defined(OS_TIZEN) -__attribute__((visibility("default"))) -int main(int argc, const char* argv[]) { - if (strcmp(argv[0], "/usr/bin/wrt-loader") == 0) { - LOG(INFO) << "run with wrt-loader"; - auto preload = [argv](void) { - }; - auto did_launch = [](const std::string& app_path) { - }; - auto prelaunch = runtime::PreLauncher::Prelaunch; - return prelaunch(argc, const_cast(argv), preload, did_launch, real_main); - } else { - LOG(INFO) << "run without wrt-loader"; - return real_main(argc, const_cast(argv)); - } -} -#endif - -#else // defined(OS_LINUX) - -int main(int argc, const char* argv[]) { - if (IsEnvSet(kRunAsNode)) { - return AtomInitializeICUandStartNode(argc, const_cast(argv)); - } - - return AtomMain(argc, argv); -} - -#endif // defined(OS_MACOSX) diff --git a/atom/app/atom_main.h b/atom/app/atom_main.h deleted file mode 100644 index 30663a4..0000000 --- a/atom/app/atom_main.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ATOM_APP_ATOM_MAIN_H_ -#define ATOM_APP_ATOM_MAIN_H_ - -#include "content/public/app/content_main.h" - -#endif // ATOM_APP_ATOM_MAIN_H_ diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index 0358e7d..4bcafba 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -26,7 +26,6 @@ #include "ui/base/resource/resource_bundle.h" #if defined(OS_TIZEN) -#include "tizen/common/command_line.h" #include "atom/common/atom_command_line.h" #endif diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 7313bb2..d429a0a 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -21,7 +21,6 @@ #include "content/public/browser/render_view_host.h" #if defined(OS_TIZEN) -#include "tizen/common/command_line.h" #include "tizen/common/application_data.h" #include "tizen/src/browser/native_web_runtime.h" #include diff --git a/atom/common/atom_command_line.cc b/atom/common/atom_command_line.cc index 4a5bfe9..4f74284 100644 --- a/atom/common/atom_command_line.cc +++ b/atom/common/atom_command_line.cc @@ -5,6 +5,7 @@ #include "atom/common/atom_command_line.h" #include "base/command_line.h" +#include "common/file_utils.h" #include "node/deps/uv/include/uv.h" namespace atom { @@ -20,6 +21,7 @@ std::vector AtomCommandLine::wargv_; // static void AtomCommandLine::Init(int argc, const char* const* argv) { // Hack around with the argv pointer. Used for process.title = "blah" + argv_.clear(); argc_ = argc; char** new_argv = uv_setup_args(argc, const_cast(argv)); for (int i = 0; i < argc; ++i) { @@ -45,7 +47,7 @@ void AtomCommandLine::InitializeFromCommandLine() { std::string AtomCommandLine::GetAppIdFromCommandLine(const std::string& program) { if (argc_ > 0) { - std::string tmp = argv_[0]; + std::string tmp = common::utils::BaseName(argv_[0]); if (tmp == program) { if (argv_.size() > 0) { // Suppose that appid is at the first of arguments_ @@ -58,5 +60,4 @@ std::string AtomCommandLine::GetAppIdFromCommandLine(const std::string& program) return std::string(); } - } // namespace atom diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 7fa37d4..889ad73 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -84,7 +84,11 @@ void AtomRendererClient::RenderThreadStarted() { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine::StringVector argv = command_line->argv(); const char** c_argv = StringVectorToArgArray(argv); - atom::AtomCommandLine::Init(argv.size(), c_argv); + + // In case of tizen apps AtomCommandLine already initialized in |real_main|. + if (!::tizen::is_single_process) + atom::AtomCommandLine::Init(argv.size(), c_argv); + std::string tizen_app_id = command_line->GetSwitchValueASCII( "widget-id"); diff --git a/electron.gyp b/electron.gyp index ce3673a..c80b10b 100644 --- a/electron.gyp +++ b/electron.gyp @@ -33,13 +33,15 @@ 'app2asar', '<(project_name)_lib', ], - 'sources': [ - '<@(app_sources)', - ], 'include_dirs': [ '.', ], 'conditions': [ + ['is_tizen==0', { + 'sources': [ + '<@(app_sources)', + ], + }], ['OS=="mac"', { 'product_name': '<(product_name)', 'mac_bundle': 1, diff --git a/filenames.gypi b/filenames.gypi index b7bb9a8..7d1e999 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -1,9 +1,5 @@ { 'variables': { - 'app_sources': [ - 'atom/app/atom_main.cc', - 'atom/app/atom_main.h', - ], 'bundle_sources': [ 'atom/browser/resources/mac/electron.icns', ], diff --git a/tizen/common/command_line.cc b/tizen/common/command_line.cc deleted file mode 100644 index ecf6d3c..0000000 --- a/tizen/common/command_line.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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 "common/command_line.h" - -#include - -#include "common/file_utils.h" - -namespace common { - -namespace { - -const char* kOptionPrefix = "--"; -const char* kOptionValueSeparator = "="; - -static bool IsValidOptionString(const char* argument) { - if (NULL != argument && - strncmp(argument, kOptionPrefix, strlen(kOptionPrefix)) == 0) { - return true; - } else { - return false; - } -} - -} // namespace - -CommandLine* CommandLine::current_process_commandline_ = NULL; - -CommandLine::CommandLine(int argc, char* argv[]) : argc_(argc), argv_(argv) { - // Append option or push each arg(not option) into arguments_ - for (int i = 1; i < argc; ++i) { - if (IsValidOptionString(argv[i])) { - AppendOption(argv[i]); - } else { - arguments_.push_back(argv[i]); - } - } - - // Parse program name and appid from argv_ or arguments_ - program_ = std::string(argv[0]); -} - -CommandLine::~CommandLine() {} - -void CommandLine::AppendOption(const char* value) { - std::string option_string(value); - std::string option_name; - std::string option_value; - - int value_separator_pos = - option_string.find(kOptionValueSeparator, strlen(kOptionPrefix)); - if (value_separator_pos >= 0) { - int substr_len = value_separator_pos - strlen(kOptionPrefix); - option_name = option_string.substr(strlen(kOptionPrefix), substr_len); - option_value = option_string.substr(value_separator_pos + 1); - } else { - option_name = - option_string.substr(strlen(kOptionPrefix), value_separator_pos); - } - - options_[option_name] = option_value; -} - -bool CommandLine::HasOptionName(const std::string& option_name) { - return (options_.find(option_name) != options_.end()); -} - -std::string CommandLine::GetOptionValue(const std::string& option_name) { - if (HasOptionName(option_name)) { - return options_[option_name]; - } else { - return std::string(); - } -} - -std::string CommandLine::GetCommandString() { - std::string result; - result.append(program_); - result.append(" "); - for (auto& it : options_) { - result.append(kOptionPrefix); - result.append(it.first); - if (!it.second.empty()) { - result.append(kOptionValueSeparator); - result.append(it.second); - } - result.append(" "); - } - for (auto& it : arguments_) { - result.append(it); - result.append(" "); - } - return result; -} - -std::string CommandLine::GetAppIdFromCommandLine(const std::string& program) { - if (argc_ > 0) { - std::string tmp = utils::BaseName(program_); - if (tmp == program) { - if (arguments_.size() > 0) { - // Suppose that appid is at the first of arguments_ - return arguments_[0]; - } - } else { - return tmp; - } - } - return std::string(); -} - -// static -void CommandLine::Reset() { - if (!!current_process_commandline_) { - delete current_process_commandline_; - current_process_commandline_ = NULL; - } -} - -// static -bool CommandLine::Init(int argc, char* argv[]) { - if (!current_process_commandline_) { - current_process_commandline_ = new CommandLine(argc, argv); - return true; - } - return false; -} - -// static -CommandLine* CommandLine::ForCurrentProcess() { - return current_process_commandline_; -} - -} // namespace common diff --git a/tizen/common/command_line.h b/tizen/common/command_line.h deleted file mode 100644 index 1c7bae0..0000000 --- a/tizen/common/command_line.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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_COMMON_COMMAND_LINE_H_ -#define XWALK_COMMON_COMMAND_LINE_H_ - -#include -#include -#include - -namespace common { - -class CommandLine { - public: - // CommandLine only uses long options - typedef std::map OptionMap; - // Arguments which except for option strings - typedef std::vector Arguments; - - static bool Init(int argc, char* argv[]); - static CommandLine* ForCurrentProcess(); - static void Reset(); - - // Test if options_ has 'option_name' - bool HasOptionName(const std::string& option_name); - // Get the option's value - std::string GetOptionValue(const std::string& option_name); - // Get command string include options and arguments - std::string GetCommandString(); - - std::string GetAppIdFromCommandLine(const std::string& program); - - std::string program() const { return program_; } - const OptionMap& options() const { return options_; } - const Arguments& arguments() const { return arguments_; } - char** argv() const { return argv_; } - int argc() const { return argc_; } - - private: - CommandLine(int argc, char* argv[]); - virtual ~CommandLine(); - - void AppendOption(const char* value); - - // The singleton CommandLine instance of current process - static CommandLine* current_process_commandline_; - - std::string program_; - OptionMap options_; - Arguments arguments_; - int argc_; - char** argv_; -}; - -} // namespace common - -#endif // XWALK_COMMON_COMMAND_LINE_H_ diff --git a/tizen/src/wrt_main.cc b/tizen/src/wrt_main.cc index 87fd3e8..41141ea 100644 --- a/tizen/src/wrt_main.cc +++ b/tizen/src/wrt_main.cc @@ -67,7 +67,6 @@ int real_main(int argc, char* argv[]) { content::ContentMainParams params(&g_delegate); params.argc = argc; params.argv = const_cast(argv); - atom::AtomCommandLine::Init(argc, argv); if (is_browser_process) { auto app_data = common::ApplicationDataManager::GetCurrentAppData(); -- 2.7.4