From 16c58722af987d8857abb28b97a2ce49711a0c6b Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Fri, 7 Sep 2018 13:08:55 +0530 Subject: [PATCH] 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