1 // Copyright 2014-2020 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include <Ecore_Evas.h>
9 #include <Elementary.h>
11 #include "base/bind.h"
12 #include "base/command_line.h"
13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h"
15 #include "base/json/json_string_value_serializer.h"
16 #include "base/logging.h"
17 #include "base/pickle.h"
18 #include "base/strings/escape.h"
19 #include "base/strings/utf_string_conversions.h"
20 #include "base/task/task_runner_util.h"
21 #include "browser/javascript_dialog_manager_efl.h"
22 #include "browser/javascript_interface/gin_native_bridge_dispatcher_host.h"
23 #include "browser/navigation_policy_handler_efl.h"
24 #include "browser/quota_permission_context_efl.h"
25 #include "browser/selectpicker/popup_menu_item.h"
26 #include "browser/selectpicker/popup_menu_item_private.h"
27 #include "browser/web_view_browser_message_filter.h"
28 #include "browser/web_view_evas_handler.h"
29 #include "browser_context_efl.h"
30 #include "common/content_client_efl.h"
31 #include "common/render_messages_ewk.h"
32 #include "common/version_info.h"
33 #include "common/web_contents_utils.h"
34 #include "components/sessions/content/content_serialized_navigation_builder.h"
35 #include "components/sessions/core/serialized_navigation_entry.h"
36 #include "content/browser/renderer_host/render_view_host_impl.h"
37 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
38 #include "content/browser/renderer_host/ui_events_helper.h"
39 #include "content/browser/web_contents/web_contents_impl_efl.h"
40 #include "content/browser/web_contents/web_contents_view.h"
41 #include "content/browser/web_contents/web_contents_view_aura.h"
42 #include "content/browser/web_contents/web_contents_view_aura_helper_efl.h"
43 #include "content/common/content_client_export.h"
44 #include "content/public/browser/browser_message_filter.h"
45 #include "content/public/browser/browser_task_traits.h"
46 #include "content/public/browser/browser_thread.h"
47 #include "content/public/browser/host_zoom_map.h"
48 #include "content/public/browser/navigation_controller.h"
49 #include "content/public/browser/navigation_entry.h"
50 #include "content/public/browser/navigation_handle.h"
51 #include "content/public/common/content_client.h"
52 #include "content/public/common/content_switches.h"
53 #include "content/public/common/mhtml_generation_params.h"
54 #include "content/public/common/user_agent.h"
55 #include "net/base/filename_util.h"
56 #include "permission_popup_manager.cc"
57 #include "private/ewk_app_control_private.h"
58 #include "private/ewk_back_forward_list_private.h"
59 #include "private/ewk_context_private.h"
60 #include "private/ewk_frame_private.h"
61 #include "private/ewk_policy_decision_private.h"
62 #include "private/ewk_quota_permission_request_private.h"
63 #include "private/ewk_settings_private.h"
64 #include "private/webview_delegate_ewk.h"
65 #include "public/ewk_hit_test_internal.h"
66 #include "services/network/public/cpp/resource_request_body.h"
67 #include "skia/ext/platform_canvas.h"
68 #include "third_party/blink/public/common/page/page_zoom.h"
69 #include "third_party/blink/public/platform/web_string.h"
70 #include "tizen/system_info.h"
71 #include "ui/aura/env.h"
72 #include "ui/aura/test/test_focus_client.h"
73 #include "ui/aura/test/test_window_parenting_client.h"
74 #include "ui/aura/window.h"
75 #include "ui/base/clipboard/clipboard_helper_efl.h"
76 #include "ui/base/l10n/l10n_util.h"
77 #include "ui/display/screen.h"
78 #include "ui/events/event_switches.h"
79 #include "ui/gfx/geometry/dip_util.h"
80 #include "ui/gfx/geometry/vector2d_f.h"
81 #include "ui/platform_window/platform_window_init_properties.h"
82 #include "web_contents_delegate_efl.h"
83 #include "web_contents_efl_delegate_ewk.h"
87 #if defined(TIZEN_ATK_SUPPORT)
88 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
89 #include "eweb_accessibility.h"
90 #include "eweb_accessibility_util.h"
93 using namespace content;
94 using web_contents_utils::WebViewFromWebContents;
98 const int kTitleLengthMax = 80;
99 const base::FilePath::CharType kMHTMLFileNameExtension[] =
100 FILE_PATH_LITERAL(".mhtml");
101 const base::FilePath::CharType kMHTMLExtension[] = FILE_PATH_LITERAL("mhtml");
102 const base::FilePath::CharType kDefaultFileName[] =
103 FILE_PATH_LITERAL("saved_page");
104 const char kReplaceChars[] = " ";
105 const char kReplaceWith[] = "_";
107 static const char* kRendererCrashedHTMLMessage =
108 "<html><body><h1>Renderer process has crashed!</h1></body></html>";
110 inline void SetDefaultStringIfNull(const char*& variable,
111 const char* default_string) {
113 variable = default_string;
117 void GetEinaRectFromGfxRect(const gfx::Rect& gfx_rect,
118 Eina_Rectangle* eina_rect) {
119 eina_rect->x = gfx_rect.x();
120 eina_rect->y = gfx_rect.y();
121 eina_rect->w = gfx_rect.width();
122 eina_rect->h = gfx_rect.height();
125 static content::WebContents* NullCreateWebContents(void*) {
129 base::FilePath GenerateMHTMLFilePath(const GURL& url,
130 const std::string& title,
131 const std::string& base_path) {
132 base::FilePath file_path(base_path);
134 if (base::DirectoryExists(file_path)) {
135 std::string title_part(title.substr(0, kTitleLengthMax));
136 base::ReplaceChars(title_part, kReplaceChars, kReplaceWith, &title_part);
137 base::FilePath file_name =
138 net::GenerateFileName(url, std::string(), std::string(), title_part,
139 std::string(), kDefaultFileName);
140 DCHECK(!file_name.empty());
141 file_path = file_path.Append(file_name);
144 if (file_path.Extension().empty())
145 file_path = file_path.AddExtension(kMHTMLExtension);
146 else if (!file_path.MatchesExtension(kMHTMLFileNameExtension))
147 file_path = file_path.ReplaceExtension(kMHTMLExtension);
149 if (!base::PathExists(file_path))
152 int uniquifier = base::GetUniquePathNumber(file_path);
153 if (uniquifier > 0) {
154 return file_path.InsertBeforeExtensionASCII(
155 base::StringPrintf(" (%d)", uniquifier));
158 return base::FilePath();
163 class WebViewAsyncRequestHitTestDataCallback {
165 WebViewAsyncRequestHitTestDataCallback(int x, int y, Ewk_Hit_Test_Mode mode)
166 : x_(x), y_(y), mode_(mode) {}
167 virtual ~WebViewAsyncRequestHitTestDataCallback(){};
169 virtual void Run(_Ewk_Hit_Test* hit_test, EWebView* web_view) = 0;
172 int GetX() const { return x_; }
173 int GetY() const { return y_; }
174 Ewk_Hit_Test_Mode GetMode() const { return mode_; }
179 Ewk_Hit_Test_Mode mode_;
182 class WebViewAsyncRequestHitTestDataUserCallback
183 : public WebViewAsyncRequestHitTestDataCallback {
185 WebViewAsyncRequestHitTestDataUserCallback(
188 Ewk_Hit_Test_Mode mode,
189 Ewk_View_Hit_Test_Request_Callback callback,
191 : WebViewAsyncRequestHitTestDataCallback(x, y, mode),
193 user_data_(user_data) {}
195 void Run(_Ewk_Hit_Test* hit_test, EWebView* web_view) override {
197 callback_(web_view->evas_object(), GetX(), GetY(), GetMode(), hit_test,
202 Ewk_View_Hit_Test_Request_Callback callback_;
206 #if defined(TIZEN_ATK_SUPPORT)
207 class EWebAccessibilityObserver : public EWebAccessibility::Observer {
209 explicit EWebAccessibilityObserver(EWebView* webview) : webview_(webview) {}
210 virtual ~EWebAccessibilityObserver() {}
212 // EWebAccessibility::Observer implementation
213 void OnSpatialNavigationStatusChanged(Eina_Bool enable) override {
214 webview_->UpdateSpatialNavigationStatus(enable);
217 void OnAccessibilityStatusChanged(Eina_Bool enable) override {
218 webview_->UpdateAccessibilityStatus(enable);
226 int EWebView::find_request_id_counter_ = 0;
227 content::WebContentsEflDelegate::WebContentsCreateCallback
228 EWebView::create_new_window_web_contents_cb_ =
229 base::BindRepeating(&NullCreateWebContents);
231 EWebView* EWebView::FromEvasObject(Evas_Object* eo) {
232 return WebViewDelegateEwk::GetInstance().GetWebViewFromEvasObject(eo);
235 #if !defined(USE_AURA)
236 RenderWidgetHostViewEfl* EWebView::rwhv() const {
237 return static_cast<RenderWidgetHostViewEfl*>(
238 web_contents_->GetRenderWidgetHostView());
242 void EWebView::OnViewFocusIn(void* data, Evas*, Evas_Object*, void*) {
243 auto view = static_cast<EWebView*>(data);
244 view->SetFocus(EINA_TRUE);
247 void EWebView::OnViewFocusOut(void* data, Evas*, Evas_Object*, void*) {
248 auto view = static_cast<EWebView*>(data);
249 view->SetFocus(EINA_FALSE);
252 EWebView::EWebView(Ewk_Context* context, Evas_Object* object)
254 evas_object_(object),
255 native_view_(object),
256 touch_events_enabled_(false),
257 mouse_events_enabled_(false),
258 text_zoom_factor_(1.0),
259 formIsNavigating_(false),
260 current_find_request_id_(find_request_id_counter_++),
262 hit_test_completion_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
263 base::WaitableEvent::InitialState::NOT_SIGNALED),
264 page_scale_factor_(1.0),
267 is_initialized_(false) {
269 evas_object_event_callback_add(evas_object_, EVAS_CALLBACK_FOCUS_IN,
270 OnViewFocusIn, this);
271 evas_object_event_callback_add(evas_object_, EVAS_CALLBACK_FOCUS_OUT,
272 OnViewFocusOut, this);
276 void EWebView::Initialize() {
277 if (is_initialized_) {
283 evas_event_handler_ = new WebViewEvasEventHandler(this);
285 scroll_detector_.reset(new ScrollDetector(this));
287 DCHECK(web_contents_->GetRenderViewHost());
288 // Settings (content::WebPreferences) will be initalized by
289 // RenderViewHostImpl::ComputeWebkitPrefs() based on command line switches.
290 settings_.reset(new Ewk_Settings(evas_object_,
291 web_contents_->GetOrCreateWebPreferences()));
292 #if defined(TIZEN_ATK_SUPPORT)
293 std::unique_ptr<EWebAccessibilityObserver> observer(
294 new EWebAccessibilityObserver(this));
295 eweb_accessibility_.reset(new EWebAccessibility(
296 evas_object_, web_contents_.get(), std::move(observer)));
297 lazy_initialize_atk_ = true;
300 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
301 if (cmdline->HasSwitch(switches::kTouchEventFeatureDetection)) {
302 SetTouchEventsEnabled(
303 cmdline->GetSwitchValueASCII(switches::kTouchEventFeatureDetection) ==
304 switches::kTouchEventFeatureDetectionEnabled);
306 SetMouseEventsEnabled(true);
309 std::string user_agent =
310 EflWebView::VersionInfo::GetInstance()->DefaultUserAgent();
311 web_contents_->SetUserAgentOverride(
312 blink::UserAgentOverride::UserAgentOnly(user_agent),
313 false /* override_in_new_tabs */);
318 formNavigation_.count = 1;
319 formNavigation_.position = 0;
320 formNavigation_.prevState = false;
321 formNavigation_.nextState = false;
323 // allow this object and its children to get a focus
324 elm_object_tree_focus_allow_set(native_view_, EINA_TRUE);
325 is_initialized_ = true;
327 auto cbce = static_cast<ContentBrowserClientEfl*>(
328 content::GetContentClientExport()->browser());
329 // Initialize accept languages
330 SyncAcceptLanguages(cbce->GetAcceptLangs(nullptr));
331 accept_langs_changed_callback_ =
332 base::BindOnce(&EWebView::SyncAcceptLanguages, base::Unretained(this));
333 cbce->AddAcceptLangsChangedCallback(
334 std::move(accept_langs_changed_callback_));
336 // If EWebView is created by window.open, RenderView is already created
337 // before initializing WebContents. So we should manually invoke
338 // EWebView::RenderViewReady here.
339 if (web_contents_->GetPrimaryMainFrame() &&
340 web_contents_->GetPrimaryMainFrame()->IsRenderFrameLive()) {
345 EWebView::~EWebView() {
346 auto cbce = static_cast<ContentBrowserClientEfl*>(
347 content::GetContentClientExport()->browser());
348 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
349 cbce->RemoveAcceptLangsChangedCallback(
350 std::move(accept_langs_changed_callback_));
353 #if defined(USE_WAYLAND) && !BUILDFLAG(IS_TIZEN_TV)
354 ClipboardHelperEfl::GetInstance()->MaybeInvalidateActiveWebview(this);
357 std::map<int64_t, WebViewAsyncRequestHitTestDataCallback*>::iterator
358 hit_test_callback_iterator;
359 for (hit_test_callback_iterator = hit_test_callback_.begin();
360 hit_test_callback_iterator != hit_test_callback_.end();
361 hit_test_callback_iterator++)
362 delete hit_test_callback_iterator->second;
363 hit_test_callback_.clear();
365 for (auto iter = delayed_messages_.begin(); iter != delayed_messages_.end();
369 delayed_messages_.clear();
371 if (!is_initialized_) {
375 #if defined(TIZEN_ATK_SUPPORT)
376 eweb_accessibility_.reset();
379 context_menu_.reset();
380 mhtml_callback_map_.Clear();
382 ReleasePopupMenuList();
385 popup_picker_del(popupPicker_);
387 formNavigation_.count = 1;
388 formNavigation_.position = 0;
389 formNavigation_.prevState = false;
390 formNavigation_.nextState = false;
392 // evas_object_del(evas_object());
394 // Release manually those scoped pointers to
395 // make sure they are released in correct order
396 web_contents_.reset();
397 web_contents_delegate_.reset();
399 // This code must be executed after WebContents deletion
400 // because WebContents depends on BrowserContext which
401 // is deleted along with EwkContext.
402 CHECK(!web_contents_);
404 permission_popup_manager_.reset();
406 gin_native_bridge_dispatcher_host_.reset();
409 evas_object_event_callback_del(evas_object_, EVAS_CALLBACK_FOCUS_IN,
411 evas_object_event_callback_del(evas_object_, EVAS_CALLBACK_FOCUS_OUT,
416 void EWebView::ReleasePopupMenuList() {
417 if (!popupMenuItems_)
421 EINA_LIST_FREE(popupMenuItems_, dummyItem) {
422 delete static_cast<Popup_Menu_Item*>(dummyItem);
428 content::RenderWidgetHostViewAura* EWebView::rwhva() const {
429 return static_cast<content::RenderWidgetHostViewAura*>(
430 web_contents_->GetRenderWidgetHostView());
433 content::WebContentsViewAura* EWebView::wcva() const {
434 WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_.get());
435 return static_cast<WebContentsViewAura*>(wc->GetView());
438 void EWebView::ResetContextMenuController() {
439 return context_menu_.reset();
442 void EWebView::SetFocus(Eina_Bool focus) {
443 if (!web_contents_ || !rwhva() || (HasFocus() == focus))
446 rwhva()->offscreen_helper()->Focus(focus);
449 Eina_Bool EWebView::HasFocus() const {
453 return rwhva()->offscreen_helper()->HasFocus() ? EINA_TRUE : EINA_FALSE;
456 Eina_Bool EWebView::AddJavaScriptMessageHandler(
458 Ewk_View_Script_Message_Cb callback,
460 if (!gin_native_bridge_dispatcher_host_)
463 return gin_native_bridge_dispatcher_host_->AddNamedObject(view, callback,
467 bool EWebView::SetPageVisibility(
468 Ewk_Page_Visibility_State page_visibility_state) {
472 // TODO: We should able to set 'prerender' or 'unloaded' as visibility state.
473 // http://www.w3.org/TR/page-visibility/#dom-document-visibilitystate
474 switch (page_visibility_state) {
475 case EWK_PAGE_VISIBILITY_STATE_VISIBLE:
476 rwhva()->offscreen_helper()->SetPageVisibility(true);
478 case EWK_PAGE_VISIBILITY_STATE_HIDDEN:
479 rwhva()->offscreen_helper()->SetPageVisibility(false);
481 case EWK_PAGE_VISIBILITY_STATE_PRERENDER:
491 bool EWebView::CreateNewWindow(
492 content::WebContentsEflDelegate::WebContentsCreateCallback cb) {
493 create_new_window_web_contents_cb_ = cb;
494 Evas_Object* new_object = NULL;
495 SmartCallback<EWebViewCallbacks::CreateNewWindow>().call(&new_object);
496 create_new_window_web_contents_cb_ =
497 base::BindRepeating(&NullCreateWebContents);
502 Evas_Object* EWebView::GetHostWindowDelegate(const content::WebContents* wc) {
503 EWebView* thiz = WebViewFromWebContents(wc);
504 DCHECK(thiz->evas_object_);
505 Evas_Object* parent = evas_object_above_get(thiz->evas_object_);
507 LOG(WARNING) << "Could not find and visual parents for EWK smart object!.";
508 return thiz->evas_object_;
511 if (elm_object_widget_check(parent)) {
512 Evas_Object* elm_parent = elm_object_top_widget_get(parent);
518 LOG(WARNING) << "Could not find elementary parent for WebView object!";
519 return thiz->evas_object_;
522 Evas_Object* EWebView::GetElmWindow() const {
523 Evas_Object* parent = elm_object_parent_widget_get(evas_object_);
524 return parent ? elm_object_top_widget_get(parent) : nullptr;
527 void EWebView::SetURL(const GURL& url, bool from_api) {
528 NavigationController::LoadURLParams params(url);
531 params.transition_type = ui::PageTransitionFromInt(
532 ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_FROM_API);
535 params.override_user_agent = NavigationController::UA_OVERRIDE_TRUE;
536 web_contents_->GetController().LoadURLWithParams(params);
539 const GURL& EWebView::GetURL() const {
540 return web_contents_->GetVisibleURL();
543 const GURL& EWebView::GetOriginalURL() const {
544 const auto entry = web_contents_->GetController().GetVisibleEntry();
546 return entry->GetOriginalRequestURL();
548 return web_contents_->GetVisibleURL();
551 void EWebView::Reload() {
552 web_contents_->GetController().Reload(content::ReloadType::NORMAL, true);
555 void EWebView::ReloadBypassingCache() {
556 web_contents_->GetController().Reload(content::ReloadType::BYPASSING_CACHE,
560 Eina_Bool EWebView::CanGoBack() {
561 return web_contents_->GetController().CanGoBack();
564 Eina_Bool EWebView::CanGoForward() {
565 return web_contents_->GetController().CanGoForward();
568 Eina_Bool EWebView::GoBack() {
569 if (!web_contents_->GetController().CanGoBack())
572 web_contents_->GetController().GoBack();
576 Eina_Bool EWebView::GoForward() {
577 if (!web_contents_->GetController().CanGoForward())
580 web_contents_->GetController().GoForward();
584 void EWebView::Stop() {
585 if (web_contents_->IsLoading())
586 web_contents_->Stop();
589 void EWebView::Suspend() {
590 CHECK(web_contents_);
591 RenderViewHost* rvh = web_contents_->GetRenderViewHost();
592 RenderFrameHost* rfh = web_contents_->GetPrimaryMainFrame();
595 #if !defined(EWK_BRINGUP) // FIXME: m69 bringup
596 rfh->BlockRequestsForFrame();
599 content::BrowserThread::PostTask(
600 content::BrowserThread::IO, FROM_HERE,
601 base::BindOnce(&content::ResourceDispatcherHost::BlockRequestsForFrameFromUI,
605 rvh->Send(new EwkViewMsg_SuspendScheduledTask(rvh->GetRoutingID()));
609 void EWebView::Resume() {
610 CHECK(web_contents_);
611 RenderViewHost* rvh = web_contents_->GetRenderViewHost();
612 RenderFrameHost* rfh = web_contents_->GetPrimaryMainFrame();
615 #if !defined(EWK_BRINGUP) // FIXME: m69 bringup
616 rfh->ResumeBlockedRequestsForFrame();
619 content::BrowserThread::PostTask(
620 content::BrowserThread::IO, FROM_HERE,
622 &content::ResourceDispatcherHost::ResumeBlockedRequestsForFrameFromUI,
626 rvh->Send(new EwkViewMsg_ResumeScheduledTasks(rvh->GetRoutingID()));
630 double EWebView::GetTextZoomFactor() const {
631 if (text_zoom_factor_ < 0.0)
634 return text_zoom_factor_;
637 void EWebView::SetTextZoomFactor(double text_zoom_factor) {
638 if (text_zoom_factor_ == text_zoom_factor || text_zoom_factor < 0.0)
641 text_zoom_factor_ = text_zoom_factor;
642 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
643 if (!render_view_host)
645 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
646 render_view_host->Send(new ViewMsg_SetTextZoomFactor(
647 render_view_host->GetRoutingID(), text_zoom_factor));
651 double EWebView::GetPageZoomFactor() const {
652 return blink::PageZoomLevelToZoomFactor(
653 content::HostZoomMap::GetZoomLevel(web_contents_.get()));
656 void EWebView::SetPageZoomFactor(double page_zoom_factor) {
657 content::HostZoomMap::SetZoomLevel(
658 web_contents_.get(), blink::PageZoomFactorToZoomLevel(page_zoom_factor));
661 void EWebView::ExecuteEditCommand(const char* command, const char* value) {
662 EINA_SAFETY_ON_NULL_RETURN(command);
664 value = (value == nullptr) ? "" : value;
666 absl::optional<std::u16string> optional_value =
667 absl::make_optional(base::ASCIIToUTF16(value));
669 WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_.get());
671 wc->GetFocusedFrameWidgetInputHandler()->ExecuteEditCommand(
672 std::string(command), optional_value);
676 void EWebView::SetOrientation(int orientation) {
677 if (GetOrientation() == orientation)
680 if (orientation == 0 || orientation == 90 || orientation == 180 ||
681 orientation == 270) {
682 #if !defined(USE_AURA)
683 GetWebContentsViewEfl()->SetOrientation(orientation);
687 const Ecore_Evas* ee =
688 ecore_evas_ecore_evas_get(evas_object_evas_get(evas_object_));
689 ecore_evas_screen_geometry_get(ee, nullptr, nullptr, &width, &height);
690 if (orientation == 90 || orientation == 270)
691 std::swap(width, height);
694 context_menu_->SetPopupSize(width, height);
695 if (popup_controller_)
696 popup_controller_->SetPopupSize(width, height);
697 if (JavaScriptDialogManagerEfl* dialogMG = GetJavaScriptDialogManagerEfl())
698 dialogMG->SetPopupSize(width, height);
700 popup_picker_resize(popupPicker_, width, height);
704 int EWebView::GetOrientation() {
705 #if !defined(USE_AURA)
706 return GetWebContentsViewEfl()->GetOrientation();
712 void EWebView::Show() {
713 evas_object_show(native_view_);
714 web_contents_->WasShown();
717 void EWebView::Hide() {
718 evas_object_hide(native_view_);
719 web_contents_->WasHidden();
722 void EWebView::SetViewAuthCallback(Ewk_View_Authentication_Callback callback,
724 authentication_cb_.Set(callback, user_data);
727 void EWebView::InvokeAuthCallback(LoginDelegateEfl* login_delegate,
729 const std::string& realm) {
730 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
732 auth_challenge_.reset(new _Ewk_Auth_Challenge(login_delegate, url, realm));
733 authentication_cb_.Run(evas_object_, auth_challenge_.get());
735 if (!auth_challenge_->is_decided && !auth_challenge_->is_suspended) {
736 auth_challenge_->is_decided = true;
737 auth_challenge_->login_delegate->Cancel();
741 void EWebView::InvokePolicyResponseCallback(
742 _Ewk_Policy_Decision* policy_decision,
744 SmartCallback<EWebViewCallbacks::PolicyResponseDecide>().call(
747 if (policy_decision->isSuspended()) {
752 if (!policy_decision->isDecided())
753 policy_decision->Use();
755 policy_decision->SelfDeleteIfNecessary();
758 void EWebView::InvokePolicyNavigationCallback(
759 const NavigationPolicyParams& params,
761 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
763 SmartCallback<EWebViewCallbacks::SaveSessionData>().call();
765 std::unique_ptr<_Ewk_Policy_Decision> policy_decision(
766 new _Ewk_Policy_Decision(params));
768 SmartCallback<EWebViewCallbacks::NavigationPolicyDecision>().call(
769 policy_decision.get());
771 CHECK(!policy_decision->isSuspended());
773 // TODO: Navigation can't be suspended
774 // this aproach is synchronous and requires immediate response
775 // Maybe there is different approach (like resource throttle response
776 // mechanism) that allows us to
777 // suspend navigation
778 if (!policy_decision->isDecided())
779 policy_decision->Use();
781 *handled = policy_decision->GetNavigationPolicyHandler()->GetDecision() ==
782 NavigationPolicyHandlerEfl::Handled;
785 void EWebView::HandleTouchEvents(Ewk_Touch_Event_Type type,
786 const Eina_List* points,
787 const Evas_Modifier* modifiers) {
788 #if !defined(USE_AURA)
791 EINA_LIST_FOREACH(points, l, data) {
792 const Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(data);
793 if (point->state == EVAS_TOUCH_POINT_STILL) {
794 // Chromium doesn't expect (and doesn't like) these events.
801 ui::TouchEvent touch_event =
802 MakeTouchEvent(pt, point->state, point->id, evas_object());
803 rwhv()->HandleTouchEvent(&touch_event);
809 bool EWebView::TouchEventsEnabled() const {
810 return touch_events_enabled_;
813 // TODO: Touch events use the same mouse events in EFL API.
814 // Figure out how to distinguish touch and mouse events on touch&mice devices.
815 // Currently mouse and touch support is mutually exclusive.
816 void EWebView::SetTouchEventsEnabled(bool enabled) {
817 if (touch_events_enabled_ == enabled)
820 touch_events_enabled_ = enabled;
821 #if !defined(USE_AURA)
822 GetWebContentsViewEfl()->SetTouchEventsEnabled(enabled);
824 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
825 // there is no flag touch_enabled in web preferences
826 GetSettings()->getPreferences().touch_enabled = enabled;
827 GetSettings()->getPreferences().double_tap_to_zoom_enabled = enabled;
828 GetSettings()->getPreferences().editing_behavior =
829 enabled ? content::EDITING_BEHAVIOR_ANDROID
830 : content::EDITING_BEHAVIOR_UNIX;
832 UpdateWebKitPreferences();
835 bool EWebView::MouseEventsEnabled() const {
836 return mouse_events_enabled_;
839 void EWebView::SetMouseEventsEnabled(bool enabled) {
840 if (mouse_events_enabled_ == enabled)
843 mouse_events_enabled_ = enabled;
844 #if !defined(USE_AURA)
845 GetWebContentsViewEfl()->SetTouchEventsEnabled(!enabled);
851 class JavaScriptCallbackDetails {
853 JavaScriptCallbackDetails(Ewk_View_Script_Execute_Callback callback_func,
856 : callback_func_(callback_func), user_data_(user_data), view_(view) {}
858 Ewk_View_Script_Execute_Callback callback_func_;
863 void JavaScriptComplete(JavaScriptCallbackDetails* script_callback_data,
864 base::Value result) {
865 if (!script_callback_data->callback_func_)
868 std::string return_string;
869 if (result.is_string()) {
870 // We don't want to serialize strings with JSONStringValueSerializer
871 // to avoid quotation marks.
872 return_string = result.GetString();
873 } else if (result.is_none()) {
874 // Value::TYPE_NULL is for lack of value, undefined, null
877 JSONStringValueSerializer serializer(&return_string);
878 serializer.Serialize(result);
881 script_callback_data->callback_func_(script_callback_data->view_,
882 return_string.c_str(),
883 script_callback_data->user_data_);
888 bool EWebView::ExecuteJavaScript(const char* script,
889 Ewk_View_Script_Execute_Callback callback,
891 LOG(INFO) << __FUNCTION__;
892 if (!web_contents_) {
893 LOG(ERROR) << __FUNCTION__ << "web_contents_ is null";
897 RenderFrameHost* render_frame_host = web_contents_->GetPrimaryMainFrame();
898 if (!render_frame_host) {
899 LOG(ERROR) << __FUNCTION__ << " render_frame_host is null";
903 // Note: M37. Execute JavaScript, |script| with
904 // |RenderFrameHost::ExecuteJavaScript|.
905 // @see also https://codereview.chromium.org/188893005 for more details.
906 std::u16string js_script;
907 base::UTF8ToUTF16(script, strlen(script), &js_script);
909 JavaScriptCallbackDetails* script_callback_data =
910 new JavaScriptCallbackDetails(callback, userdata, evas_object_);
911 RenderFrameHost::JavaScriptResultCallback js_callback =
912 base::BindOnce(&JavaScriptComplete, base::Owned(script_callback_data));
913 // In M47, it isn't possible anymore to execute javascript in the generic
914 // case. We need to call ExecuteJavaScriptForTests to keep the behaviour
915 // unchanged @see https://codereview.chromium.org/1123783002
916 render_frame_host->ExecuteJavaScriptWithUserGestureForTests(
917 js_script, std::move(js_callback));
919 // We use ExecuteJavaScriptWithUserGestureForTests instead of
920 // ExecuteJavaScript because
921 // ExecuteJavaScriptWithUserGestureForTests sets user_gesture to true. This
923 // behaviour is m34, and we want to keep it that way.
924 render_frame_host->ExecuteJavaScriptWithUserGestureForTests(
925 js_script, base::NullCallback());
931 bool EWebView::SetUserAgent(const char* userAgent) {
932 content::NavigationController& controller = web_contents_->GetController();
933 bool override = userAgent && strlen(userAgent);
934 for (int i = 0; i < controller.GetEntryCount(); ++i)
935 controller.GetEntryAtIndex(i)->SetIsOverridingUserAgent(override);
936 // TODO: Check if override_in_new_tabs has to be true.
937 web_contents_->SetUserAgentOverride(
938 blink::UserAgentOverride::UserAgentOnly(userAgent),
939 false /* override_in_new_tabs */);
943 bool EWebView::SetUserAgentAppName(const char* application_name) {
944 EflWebView::VersionInfo::GetInstance()->UpdateUserAgentWithAppName(
945 application_name ? application_name : "");
946 std::string user_agent =
947 EflWebView::VersionInfo::GetInstance()->DefaultUserAgent();
948 web_contents_->SetUserAgentOverride(
949 blink::UserAgentOverride::UserAgentOnly(user_agent),
950 false /* override_in_new_tabs */);
954 void EWebView::set_magnifier(bool status) {
955 #if !defined(USE_AURA)
956 rwhv()->set_magnifier(status);
960 #if BUILDFLAG(IS_TIZEN)
961 bool EWebView::SetPrivateBrowsing(bool incognito) {
962 if (context_->GetImpl()->browser_context()->IsOffTheRecord() == incognito)
964 context_->GetImpl()->browser_context()->SetOffTheRecord(incognito);
968 bool EWebView::GetPrivateBrowsing() const {
969 return context_->GetImpl()->browser_context()->IsOffTheRecord();
973 const char* EWebView::GetUserAgent() const {
974 std::string user_agent =
975 web_contents_->GetUserAgentOverride().ua_string_override;
976 if (user_agent.empty())
977 user_agent_ = content::GetContentClientExport()->browser()->GetUserAgent();
979 user_agent_ = user_agent;
981 return user_agent_.c_str();
984 const char* EWebView::GetUserAgentAppName() const {
985 user_agent_app_name_ = EflWebView::VersionInfo::GetInstance()->AppName();
986 return user_agent_app_name_.c_str();
989 const char* EWebView::CacheSelectedText() {
993 selected_text_cached_ = base::UTF16ToUTF8(rwhva()->GetSelectedText());
994 return selected_text_cached_.c_str();
997 _Ewk_Frame* EWebView::GetMainFrame() {
998 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1001 frame_.reset(new _Ewk_Frame(web_contents_->GetPrimaryMainFrame()));
1003 return frame_.get();
1006 void EWebView::UpdateWebKitPreferences() {
1007 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1009 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
1010 if (!render_view_host)
1013 web_contents_delegate_->OnUpdateSettings(settings_.get());
1014 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1015 render_view_host->UpdateWebkitPreferences(settings_->getPreferences());
1017 UpdateWebkitPreferencesEfl(render_view_host);
1020 void EWebView::UpdateWebkitPreferencesEfl(RenderViewHost* render_view_host) {
1021 DCHECK(render_view_host);
1022 #if !defined(EWK_BRINGUP) // FIXME: m108 bringup
1023 IPC::Message* message = new EwkSettingsMsg_UpdateWebKitPreferencesEfl(
1024 render_view_host->GetRoutingID(), settings_->getPreferencesEfl());
1026 if (render_view_host->IsRenderViewLive()) {
1027 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1028 render_view_host->Send(message);
1031 delayed_messages_.push_back(message);
1036 void EWebView::SetContentSecurityPolicy(const char* policy,
1037 Ewk_CSP_Header_Type type) {
1038 web_contents_delegate_->SetContentSecurityPolicy(
1039 (policy ? policy : std::string()), type);
1042 void EWebView::LoadHTMLString(const char* html,
1043 const char* base_uri,
1044 const char* unreachable_uri) {
1045 LoadData(html, std::string::npos, NULL, NULL, base_uri, unreachable_uri);
1048 void EWebView::LoadPlainTextString(const char* plain_text) {
1049 LoadData(plain_text, std::string::npos, "text/plain", NULL, NULL, NULL);
1052 void EWebView::LoadData(const char* data,
1054 const char* mime_type,
1055 const char* encoding,
1056 const char* base_uri,
1057 const char* unreachable_uri) {
1058 SetDefaultStringIfNull(mime_type, "text/html");
1059 SetDefaultStringIfNull(encoding, "utf-8");
1060 SetDefaultStringIfNull(base_uri, "about:blank"); // Webkit2 compatible
1061 SetDefaultStringIfNull(unreachable_uri, "");
1063 std::string str_data = data;
1065 if (size < str_data.length())
1066 str_data = str_data.substr(0, size);
1068 std::string url_str("data:");
1069 url_str.append(mime_type);
1070 url_str.append(";charset=");
1071 url_str.append(encoding);
1072 url_str.append(",");
1074 // GURL constructor performs canonicalization of url string, but this is not
1075 // enough for correctly escaping contents of "data:" url.
1076 url_str.append(base::EscapeUrlEncodedData(str_data, false));
1078 NavigationController::LoadURLParams data_params(GURL(url_str.c_str()));
1080 data_params.base_url_for_data_url = GURL(base_uri);
1081 data_params.virtual_url_for_data_url = GURL(unreachable_uri);
1083 data_params.load_type = NavigationController::LOAD_TYPE_DATA;
1084 data_params.should_replace_current_entry = false;
1085 data_params.override_user_agent = NavigationController::UA_OVERRIDE_TRUE;
1086 web_contents_->GetController().LoadURLWithParams(data_params);
1089 void EWebView::InvokeLoadError(const GURL& url,
1091 bool is_cancellation) {
1092 _Ewk_Error err(error_code, is_cancellation,
1093 url.possibly_invalid_spec().c_str());
1095 SmartCallback<EWebViewCallbacks::LoadError>().call(&err);
1098 void EWebView::HandlePopupMenu(std::vector<blink::mojom::MenuItemPtr> items,
1101 // Request form navigation information as early as possible,
1102 // given that is renderer will ping-back with actual requested data.
1103 RenderFrameHostImpl* render_frame_host =
1104 static_cast<RenderFrameHostImpl*>(web_contents_->GetPrimaryMainFrame());
1105 if (render_frame_host)
1106 render_frame_host->Send(new EwkFrameMsg_RequestSelectCollectionInformation(
1107 render_frame_host->GetRoutingID()));
1109 Eina_List* popupItems = 0;
1110 const size_t size = items.size();
1111 for (size_t i = 0; i < size; ++i) {
1113 eina_list_append(popupItems, new Popup_Menu_Item(std::move(items[i])));
1116 ReleasePopupMenuList();
1117 popupMenuItems_ = popupItems;
1119 if (popupPicker_ && FormIsNavigating()) {
1120 popupPicker_->multiSelect = multiple;
1121 PopupMenuUpdate(popupMenuItems_, selectedIndex);
1122 SetFormIsNavigating(false);
1127 popup_picker_del(popupPicker_);
1132 popup_picker_new(this, evas_object(), popupMenuItems_, 0, multiple);
1134 popupPicker_ = popup_picker_new(this, evas_object(), popupMenuItems_,
1135 selectedIndex, multiple);
1137 popup_picker_buttons_update(popupPicker_, formNavigation_.position,
1138 formNavigation_.count, false);
1140 // Picker has been shown on top of webview and the page content gets
1141 // partially overlapped. Decrease viewport while showing picker.
1142 AdjustViewPortHeightToPopupMenu(true /* is_popup_menu_visible */);
1143 ScrollFocusedNodeIntoView();
1146 void EWebView::HidePopupMenu() {
1150 if (FormIsNavigating())
1153 AdjustViewPortHeightToPopupMenu(false /* is_popup_menu_visible */);
1154 popup_picker_del(popupPicker_);
1158 void EWebView::UpdateFormNavigation(int formElementCount,
1159 int currentNodeIndex,
1162 formNavigation_.count = formElementCount;
1163 formNavigation_.position = currentNodeIndex;
1164 formNavigation_.prevState = prevState;
1165 formNavigation_.nextState = nextState;
1168 void EWebView::SetFormIsNavigating(bool formIsNavigating) {
1169 formIsNavigating_ = formIsNavigating;
1172 Eina_Bool EWebView::PopupMenuUpdate(Eina_List* items, int selectedIndex) {
1176 popup_picker_update(evas_object(), popupPicker_, items, selectedIndex);
1177 popup_picker_buttons_update(popupPicker_, formNavigation_.position,
1178 formNavigation_.count, false);
1182 void EWebView::FormNavigate(bool direction) {
1183 RenderFrameHostImpl* render_frame_host =
1184 static_cast<RenderFrameHostImpl*>(web_contents_->GetPrimaryMainFrame());
1185 if (!render_frame_host)
1188 popup_picker_buttons_update(popupPicker_, formNavigation_.position,
1189 formNavigation_.count, true);
1191 if ((direction && formNavigation_.nextState) ||
1192 (!direction && formNavigation_.prevState))
1193 SetFormIsNavigating(true);
1195 listClosed(popupPicker_, 0, 0, 0);
1196 render_frame_host->Send(new EwkFrameMsg_MoveToNextOrPreviousSelectElement(
1197 render_frame_host->GetRoutingID(), direction));
1200 Eina_Bool EWebView::DidSelectPopupMenuItem(int selectedIndex) {
1201 RenderFrameHostImpl* render_frame_host =
1202 static_cast<RenderFrameHostImpl*>(web_contents_->GetPrimaryMainFrame());
1203 if (!render_frame_host)
1206 if (!popupMenuItems_)
1209 // When user select empty space then no index is selected, so selectedIndex
1211 // In that case we should call valueChanged() with -1 index.That in turn call
1213 // in didChangeSelectedIndex() for reseting the value of m_popupIsVisible in
1215 if (selectedIndex != -1 &&
1216 selectedIndex >= (int)eina_list_count(popupMenuItems_))
1219 // In order to reuse RenderFrameHostImpl::DidSelectPopupMenuItems() method in
1221 // put selectedIndex into std::vector<int>.
1222 std::vector<int> selectedIndices;
1223 selectedIndices.push_back(selectedIndex);
1224 #if !defined(EWK_BRINGUP) // FIXME: m67 bringup
1225 render_frame_host->DidSelectPopupMenuItems(selectedIndices);
1230 Eina_Bool EWebView::DidMultipleSelectPopupMenuItem(
1231 std::vector<int>& selectedIndices) {
1232 RenderFrameHostImpl* render_frame_host =
1233 static_cast<RenderFrameHostImpl*>(web_contents_->GetPrimaryMainFrame());
1234 if (!render_frame_host)
1237 if (!popupMenuItems_)
1239 #if !defined(EWK_BRINGUP) // FIXME: m67 bringup
1240 render_frame_host->DidSelectPopupMenuItems(selectedIndices);
1245 void EWebView::PopupMenuClose() {
1247 ReleasePopupMenuList();
1248 wcva()->wcva_helper()->DidCancelPopupMenu();
1251 void EWebView::HandleLongPressGesture(
1252 const content::ContextMenuParams& params) {
1253 #if !defined(USE_AURA)
1254 // This menu is created in renderer process and it does not now anything about
1255 // view scaling factor and it has another calling sequence, so coordinates is
1257 content::ContextMenuParams convertedParams = params;
1258 gfx::Point convertedPoint =
1259 rwhv()->ConvertPointInViewPix(gfx::Point(params.x, params.y));
1260 convertedParams.x = convertedPoint.x();
1261 convertedParams.y = convertedPoint.y();
1264 evas_object_geometry_get(evas_object(), &x, &y, 0, 0);
1265 convertedParams.x += x;
1266 convertedParams.y += y;
1268 if (GetSelectionController() && GetSelectionController()->GetLongPressed()) {
1269 bool show_context_menu_now =
1270 !GetSelectionController()->HandleLongPressEvent(convertedPoint,
1272 if (show_context_menu_now)
1273 ShowContextMenuInternal(convertedParams);
1278 void EWebView::ShowContextMenu(const content::ContextMenuParams& params) {
1279 #if !defined(USE_AURA)
1280 // This menu is created in renderer process and it does not now anything about
1281 // view scaling factor and it has another calling sequence, so coordinates is
1283 content::ContextMenuParams convertedParams = params;
1284 gfx::Point convertedPoint =
1285 rwhv()->ConvertPointInViewPix(gfx::Point(params.x, params.y));
1286 convertedParams.x = convertedPoint.x();
1287 convertedParams.y = convertedPoint.y();
1290 evas_object_geometry_get(evas_object(), &x, &y, 0, 0);
1291 convertedParams.x += x;
1292 convertedParams.y += y;
1294 context_menu_position_ = gfx::Point(convertedParams.x, convertedParams.y);
1296 ShowContextMenuInternal(convertedParams);
1300 void EWebView::ShowContextMenuInternal(
1301 const content::ContextMenuParams& params) {
1302 context_menu_.reset(
1303 new content::ContextMenuControllerEfl(this, *web_contents_.get()));
1304 if (!context_menu_->PopulateAndShowContextMenu(params)) {
1305 context_menu_.reset();
1306 if (GetSelectionController())
1307 GetSelectionController()->HideHandles();
1311 void EWebView::CancelContextMenu(int request_id) {
1313 context_menu_->HideContextMenu();
1316 void EWebView::Find(const char* text, Ewk_Find_Options ewk_find_options) {
1317 std::u16string find_text = base::UTF8ToUTF16(text);
1318 bool find_next = (previous_text_ == find_text);
1321 current_find_request_id_ = find_request_id_counter_++;
1322 previous_text_ = find_text;
1325 auto find_options = blink::mojom::FindOptions::New();
1326 find_options->forward = !(ewk_find_options & EWK_FIND_OPTIONS_BACKWARDS);
1327 find_options->match_case =
1328 !(ewk_find_options & EWK_FIND_OPTIONS_CASE_INSENSITIVE);
1330 web_contents_->Find(current_find_request_id_, find_text,
1331 std::move(find_options));
1334 void EWebView::SetScale(double scale_factor) {
1335 // Do not cache |scale_factor| here as it may be discarded by Blink's
1336 // minimumPageScaleFactor and maximumPageScaleFactor.
1337 // |scale_factor| is cached as responde to DidChangePageScaleFactor.
1338 WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents_.get());
1339 wci->GetPrimaryMainFrame()->GetAssociatedLocalMainFrame()->SetScaleFactor(
1343 void EWebView::ScrollFocusedNodeIntoView() {
1344 if (RenderViewHost* render_view_host = web_contents_->GetRenderViewHost()) {
1345 if (auto& broadcast = static_cast<RenderViewHostImpl*>(render_view_host)
1346 ->GetAssociatedPageBroadcast())
1347 broadcast->ScrollFocusedNodeIntoView();
1351 void EWebView::AdjustViewPortHeightToPopupMenu(bool is_popup_menu_visible) {
1352 DCHECK(popupPicker_);
1354 int picker_height = 0;
1355 popup_picker_geometry_get(popupPicker_, 0, 0, 0, &picker_height);
1357 gfx::Rect rect = rwhva()->offscreen_helper()->GetViewBounds();
1358 // FIXME(g.czajkowski): detect the need of resizing viewport.
1359 // Checking the position of focused <select> element and do resize only when
1360 // the picker overlaps the element will prevent Blink from doing re-layout.
1361 // Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=15488.
1362 rwhva()->offscreen_helper()->SetCustomViewportSize(gfx::Size(
1363 rect.width(), is_popup_menu_visible ? rect.height() - picker_height
1364 : rect.height() + picker_height));
1367 void EWebView::SetScaleChangedCallback(Ewk_View_Scale_Changed_Callback callback,
1369 scale_changed_cb_.Set(callback, user_data);
1372 bool EWebView::GetScrollPosition(int* x, int* y) const {
1374 LOG(ERROR) << "rwhva() returns nullptr";
1377 if (scroll_detector_->IsScrollOffsetChanged()) {
1379 *x = previous_scroll_position_.x();
1381 *y = previous_scroll_position_.y();
1383 const gfx::Vector2d scroll_position_dip =
1384 scroll_detector_->GetLastScrollPosition();
1385 const float device_scale_factor = display::Screen::GetScreen()
1386 ->GetPrimaryDisplay()
1387 .device_scale_factor();
1389 *x = base::ClampRound((scroll_position_dip.x() - x_delta_) *
1390 device_scale_factor);
1393 *y = base::ClampRound((scroll_position_dip.y() - y_delta_) *
1394 device_scale_factor);
1400 void EWebView::ChangeScroll(int& x, int& y) {
1402 LOG(ERROR) << "rwhva() returns nullptr";
1407 GetScrollSize(&max_x, &max_y);
1408 previous_scroll_position_.set_x(std::min(std::max(x, 0), max_x));
1409 previous_scroll_position_.set_y(std::min(std::max(y, 0), max_y));
1411 const float device_scale_factor = display::Screen::GetScreen()
1412 ->GetPrimaryDisplay()
1413 .device_scale_factor();
1417 x = base::ClampCeil(x / device_scale_factor);
1418 y = base::ClampCeil(y / device_scale_factor);
1420 x_delta_ = x - (x_input / device_scale_factor);
1421 y_delta_ = y - (y_input / device_scale_factor);
1423 scroll_detector_->SetScrollOffsetChanged();
1426 void EWebView::SetScroll(int x, int y) {
1427 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
1428 if (!render_view_host)
1432 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1433 render_view_host->Send(
1434 new EwkViewMsg_SetScroll(render_view_host->GetRoutingID(), x, y));
1438 void EWebView::UseSettingsFont() {
1439 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1440 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
1441 if (render_view_host)
1442 render_view_host->Send(
1443 new EwkViewMsg_UseSettingsFont(render_view_host->GetRoutingID()));
1447 void EWebView::DidChangeContentsSize(int width, int height) {
1448 contents_size_ = gfx::Size(width, height);
1449 SmartCallback<EWebViewCallbacks::ContentsSizeChanged>().call();
1450 SetScaledContentsSize();
1453 const Eina_Rectangle EWebView::GetContentsSize() const {
1454 Eina_Rectangle rect;
1455 EINA_RECTANGLE_SET(&rect, 0, 0, contents_size_.width(),
1456 contents_size_.height());
1460 void EWebView::SetScaledContentsSize() {
1462 return; // LCOV_EXCL_LINE
1464 const float device_scale_factor =
1465 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
1466 gfx::SizeF scaled_contents_size = gfx::ConvertSizeToPixels(
1467 contents_size_, device_scale_factor * page_scale_factor_);
1468 rwhva()->offscreen_helper()->SetScaledContentSize(scaled_contents_size);
1471 void EWebView::GetScrollSize(int* width, int* height) {
1474 *width = (rwhva() &&
1475 (w = rwhva()->offscreen_helper()->GetScrollableSize().width()))
1480 *height = (rwhva() &&
1481 (h = rwhva()->offscreen_helper()->GetScrollableSize().height()))
1487 void EWebView::MoveCaret(const gfx::Point& point) {
1488 #if !defined(USE_AURA)
1490 rwhv()->MoveCaret(point);
1494 SelectionControllerEfl* EWebView::GetSelectionController() const {
1495 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
1496 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>(
1497 render_view_host->GetWidget()->GetView());
1498 return view ? view->offscreen_helper()->GetSelectionController() : 0;
1501 void EWebView::SelectLinkText(const gfx::Point& touch_point) {
1502 #if !defined(EWK_BRINGUP) // FIXME: m67 bringup
1503 float device_scale_factor =
1504 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
1505 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
1506 render_view_host->Send(new ViewMsg_SelectLinkText(
1507 render_view_host->GetRoutingID(),
1508 gfx::Point(touch_point.x() / device_scale_factor,
1509 touch_point.y() / device_scale_factor)));
1513 bool EWebView::GetSelectionRange(Eina_Rectangle* left_rect,
1514 Eina_Rectangle* right_rect) {
1515 if (left_rect && right_rect) {
1516 gfx::Rect left, right;
1517 if (GetSelectionController()) {
1518 GetSelectionController()->GetSelectionBounds(&left, &right);
1519 GetEinaRectFromGfxRect(left, left_rect);
1520 GetEinaRectFromGfxRect(right, right_rect);
1527 Eina_Bool EWebView::ClearSelection() {
1531 ResetContextMenuController();
1532 rwhva()->offscreen_helper()->SelectionChanged(std::u16string(), 0,
1535 if (GetSelectionController())
1536 return GetSelectionController()->ClearSelectionViaEWebView();
1541 _Ewk_Hit_Test* EWebView::RequestHitTestDataAt(int x,
1543 Ewk_Hit_Test_Mode mode) {
1544 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1547 EvasToBlinkCords(x, y, &view_x, &view_y);
1549 return RequestHitTestDataAtBlinkCoords(view_x, view_y, mode);
1552 Eina_Bool EWebView::AsyncRequestHitTestDataAt(
1555 Ewk_Hit_Test_Mode mode,
1556 Ewk_View_Hit_Test_Request_Callback callback,
1559 EvasToBlinkCords(x, y, &view_x, &view_y);
1560 return AsyncRequestHitTestDataAtBlinkCords(
1561 view_x, view_y, mode,
1562 new WebViewAsyncRequestHitTestDataUserCallback(x, y, mode, callback,
1566 Eina_Bool EWebView::AsyncRequestHitTestDataAtBlinkCords(
1569 Ewk_Hit_Test_Mode mode,
1570 Ewk_View_Hit_Test_Request_Callback callback,
1572 return AsyncRequestHitTestDataAtBlinkCords(
1574 new WebViewAsyncRequestHitTestDataUserCallback(x, y, mode, callback,
1578 Eina_Bool EWebView::AsyncRequestHitTestDataAtBlinkCords(
1581 Ewk_Hit_Test_Mode mode,
1582 WebViewAsyncRequestHitTestDataCallback* cb) {
1583 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1586 static int64_t request_id = 1;
1589 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
1590 DCHECK(render_view_host);
1592 if (render_view_host) {
1593 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1594 render_view_host->Send(new EwkViewMsg_DoHitTestAsync(
1595 render_view_host->GetRoutingID(), x, y, mode, request_id));
1597 hit_test_callback_[request_id] = cb;
1603 // if failed we delete callback as it is not needed anymore
1608 void EWebView::DispatchAsyncHitTestData(const Hit_Test_Params& params,
1609 int64_t request_id) {
1610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1612 std::map<int64_t, WebViewAsyncRequestHitTestDataCallback*>::iterator it =
1613 hit_test_callback_.find(request_id);
1615 if (it == hit_test_callback_.end())
1617 std::unique_ptr<_Ewk_Hit_Test> hit_test(new _Ewk_Hit_Test(params));
1619 it->second->Run(hit_test.get(), this);
1621 hit_test_callback_.erase(it);
1624 _Ewk_Hit_Test* EWebView::RequestHitTestDataAtBlinkCoords(
1627 Ewk_Hit_Test_Mode mode) {
1628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1630 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
1632 if (render_view_host) {
1633 // We wait on UI thread till hit test data is updated.
1634 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1635 render_view_host->Send(
1636 new EwkViewMsg_DoHitTest(render_view_host->GetRoutingID(), x, y, mode));
1638 hit_test_completion_.Wait();
1639 return new _Ewk_Hit_Test(hit_test_params_);
1645 void EWebView::EvasToBlinkCords(int x, int y, int* view_x, int* view_y) {
1646 DCHECK(display::Screen::GetScreen());
1647 Evas_Coord tmpX, tmpY;
1648 evas_object_geometry_get(evas_object_, &tmpX, &tmpY, NULL, NULL);
1653 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
1659 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
1663 void EWebView::UpdateHitTestData(const Hit_Test_Params& params) {
1664 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
1665 hit_test_params_ = params;
1666 hit_test_completion_.Signal();
1669 void EWebView::OnCopyFromBackingStore(bool success, const SkBitmap& bitmap) {}
1671 void EWebView::OnFocusIn() {
1672 SmartCallback<EWebViewCallbacks::FocusIn>().call();
1673 #if defined(USE_WAYLAND) && !BUILDFLAG(IS_TIZEN_TV)
1674 if (!rwhva() || !rwhva()->offscreen_helper())
1676 ClipboardHelperEfl::GetInstance()->OnWebviewFocusIn(
1677 this, rwhva()->offscreen_helper()->content_image_elm_host(),
1678 rwhva()->offscreen_helper()->IsFocusedNodeContentEditable(),
1679 base::BindRepeating(&EWebView::ExecuteEditCommand,
1680 base::Unretained(this)));
1684 void EWebView::OnFocusOut() {
1685 SmartCallback<EWebViewCallbacks::FocusOut>().call();
1686 #if defined(USE_WAYLAND) && !BUILDFLAG(IS_TIZEN_TV)
1687 ClipboardHelperEfl::GetInstance()->MaybeInvalidateActiveWebview(this);
1691 void EWebView::RenderViewReady() {
1693 rwhva()->offscreen_helper()->SetFocusInOutCallbacks(
1694 base::BindRepeating(&EWebView::OnFocusIn, base::Unretained(this)),
1695 base::BindRepeating(&EWebView::OnFocusOut, base::Unretained(this)));
1698 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
1700 SendDelayedMessages(render_view_host);
1701 UpdateWebkitPreferencesEfl(render_view_host);
1703 if (render_view_host) {
1704 WebContents* content = WebContents::FromRenderViewHost(render_view_host);
1706 RenderProcessHost* host = render_view_host->GetProcess();
1708 host->AddFilter(new WebViewBrowserMessageFilter(content));
1713 void EWebView::SetQuotaPermissionRequestCallback(
1714 Ewk_Quota_Permission_Request_Callback callback,
1716 quota_request_callback_.Set(callback, user_data);
1719 void EWebView::InvokeQuotaPermissionRequest(
1720 _Ewk_Quota_Permission_Request* request,
1721 content::QuotaPermissionContext::PermissionCallback cb) {
1722 quota_permission_request_map_[request] = std::move(cb);
1723 request->setView(evas_object());
1724 if (quota_request_callback_.IsCallbackSet())
1725 quota_request_callback_.Run(evas_object(), request);
1727 QuotaRequestCancel(request);
1730 void EWebView::QuotaRequestReply(const _Ewk_Quota_Permission_Request* request,
1732 DCHECK(quota_permission_request_map_.find(request) !=
1733 quota_permission_request_map_.end());
1735 QuotaPermissionContextEfl::DispatchCallback(
1736 std::move(quota_permission_request_map_[request]),
1737 (allow ? QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW
1738 : QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW));
1740 quota_permission_request_map_.erase(request);
1744 void EWebView::QuotaRequestCancel(
1745 const _Ewk_Quota_Permission_Request* request) {
1746 DCHECK(quota_permission_request_map_.find(request) !=
1747 quota_permission_request_map_.end());
1749 QuotaPermissionContextEfl::DispatchCallback(
1750 std::move(quota_permission_request_map_[request]),
1751 QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED);
1752 quota_permission_request_map_.erase(request);
1756 bool EWebView::GetLinkMagnifierEnabled() const {
1757 #if !defined(EWK_BRINGUP) // FIXME: m71 bringup
1758 return web_contents_->GetMutableRendererPrefs()
1759 ->tap_multiple_targets_strategy ==
1760 TAP_MULTIPLE_TARGETS_STRATEGY_POPUP;
1766 void EWebView::SetLinkMagnifierEnabled(bool enabled) {
1767 #if !defined(EWK_BRINGUP) // FIXME: m71 bringup
1768 web_contents_->GetMutableRendererPrefs()->tap_multiple_targets_strategy =
1769 enabled ? TAP_MULTIPLE_TARGETS_STRATEGY_POPUP
1770 : TAP_MULTIPLE_TARGETS_STRATEGY_NONE;
1772 web_contents_->SyncRendererPrefs();
1775 bool EWebView::GetSnapshotAsync(
1776 Eina_Rectangle rect,
1777 Ewk_Web_App_Screenshot_Captured_Callback callback,
1779 float scale_factor) {
1780 if (!rwhva() || !rwhva()->offscreen_helper())
1783 rwhva()->offscreen_helper()->RequestSnapshotAsync(
1784 gfx::Rect(rect.x, rect.y, rect.w, rect.h), callback, user_data,
1789 Evas_Object* EWebView::GetSnapshot(Eina_Rectangle rect, float scale_factor) {
1790 if (!rwhva() || !rwhva()->offscreen_helper())
1793 return rwhva()->offscreen_helper()->GetSnapshot(
1794 gfx::Rect(rect.x, rect.y, rect.w, rect.h), scale_factor);
1797 void EWebView::BackForwardListClear() {
1798 content::NavigationController& controller = web_contents_->GetController();
1800 int entry_count = controller.GetEntryCount();
1801 bool entry_removed = false;
1803 for (int i = 0; i < entry_count; i++) {
1804 if (controller.RemoveEntryAtIndex(i)) {
1805 entry_removed = true;
1806 entry_count = controller.GetEntryCount();
1811 if (entry_removed) {
1812 back_forward_list_->ClearCache();
1813 InvokeBackForwardListChangedCallback();
1817 _Ewk_Back_Forward_List* EWebView::GetBackForwardList() const {
1818 return back_forward_list_.get();
1821 void EWebView::InvokeBackForwardListChangedCallback() {
1822 SmartCallback<EWebViewCallbacks::BackForwardListChange>().call();
1825 _Ewk_History* EWebView::GetBackForwardHistory() const {
1826 return new _Ewk_History(web_contents_->GetController());
1829 bool EWebView::WebAppCapableGet(Ewk_Web_App_Capable_Get_Callback callback,
1831 RenderViewHost* renderViewHost = web_contents_->GetRenderViewHost();
1832 if (!renderViewHost) {
1835 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1836 WebApplicationCapableGetCallback* cb =
1837 new WebApplicationCapableGetCallback(callback, userData);
1838 int callbackId = web_app_capable_get_callback_map_.Add(cb);
1839 return renderViewHost->Send(new EwkViewMsg_WebAppCapableGet(
1840 renderViewHost->GetRoutingID(), callbackId));
1846 bool EWebView::WebAppIconUrlGet(Ewk_Web_App_Icon_URL_Get_Callback callback,
1848 RenderViewHost* renderViewHost = web_contents_->GetRenderViewHost();
1849 if (!renderViewHost) {
1852 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1853 WebApplicationIconUrlGetCallback* cb =
1854 new WebApplicationIconUrlGetCallback(callback, userData);
1855 int callbackId = web_app_icon_url_get_callback_map_.Add(cb);
1856 return renderViewHost->Send(new EwkViewMsg_WebAppIconUrlGet(
1857 renderViewHost->GetRoutingID(), callbackId));
1863 bool EWebView::WebAppIconUrlsGet(Ewk_Web_App_Icon_URLs_Get_Callback callback,
1865 RenderViewHost* renderViewHost = web_contents_->GetRenderViewHost();
1866 if (!renderViewHost) {
1869 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1870 WebApplicationIconUrlsGetCallback* cb =
1871 new WebApplicationIconUrlsGetCallback(callback, userData);
1872 int callbackId = web_app_icon_urls_get_callback_map_.Add(cb);
1873 return renderViewHost->Send(new EwkViewMsg_WebAppIconUrlsGet(
1874 renderViewHost->GetRoutingID(), callbackId));
1880 void EWebView::InvokeWebAppCapableGetCallback(bool capable, int callbackId) {
1881 WebApplicationCapableGetCallback* callback =
1882 web_app_capable_get_callback_map_.Lookup(callbackId);
1885 callback->Run(capable);
1886 web_app_capable_get_callback_map_.Remove(callbackId);
1889 void EWebView::InvokeWebAppIconUrlGetCallback(const std::string& iconUrl,
1891 WebApplicationIconUrlGetCallback* callback =
1892 web_app_icon_url_get_callback_map_.Lookup(callbackId);
1895 callback->Run(iconUrl);
1896 web_app_icon_url_get_callback_map_.Remove(callbackId);
1899 void EWebView::InvokeWebAppIconUrlsGetCallback(const StringMap& iconUrls,
1901 WebApplicationIconUrlsGetCallback* callback =
1902 web_app_icon_urls_get_callback_map_.Lookup(callbackId);
1906 callback->Run(iconUrls);
1907 web_app_icon_urls_get_callback_map_.Remove(callbackId);
1910 void EWebView::SetNotificationPermissionCallback(
1911 Ewk_View_Notification_Permission_Callback callback,
1913 notification_permission_callback_.Set(callback, user_data);
1916 bool EWebView::IsNotificationPermissionCallbackSet() const {
1917 return notification_permission_callback_.IsCallbackSet();
1920 bool EWebView::InvokeNotificationPermissionCallback(
1921 Ewk_Notification_Permission_Request* request) {
1922 Eina_Bool ret = EINA_FALSE;
1923 notification_permission_callback_.Run(evas_object_, request, &ret);
1927 int EWebView::SetEwkViewPlainTextGetCallback(
1928 Ewk_View_Plain_Text_Get_Callback callback,
1930 EwkViewPlainTextGetCallback* view_plain_text_callback_ptr =
1931 new EwkViewPlainTextGetCallback;
1932 view_plain_text_callback_ptr->Set(callback, user_data);
1933 return plain_text_get_callback_map_.Add(view_plain_text_callback_ptr);
1936 bool EWebView::PlainTextGet(Ewk_View_Plain_Text_Get_Callback callback,
1938 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
1939 if (!render_view_host)
1941 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
1942 int plain_text_get_callback_id =
1943 SetEwkViewPlainTextGetCallback(callback, user_data);
1944 return render_view_host->Send(new EwkViewMsg_PlainTextGet(
1945 render_view_host->GetRoutingID(), plain_text_get_callback_id));
1951 void EWebView::InvokePlainTextGetCallback(const std::string& content_text,
1952 int plain_text_get_callback_id) {
1953 EwkViewPlainTextGetCallback* view_plain_text_callback_invoke_ptr =
1954 plain_text_get_callback_map_.Lookup(plain_text_get_callback_id);
1955 view_plain_text_callback_invoke_ptr->Run(evas_object(), content_text.c_str());
1956 plain_text_get_callback_map_.Remove(plain_text_get_callback_id);
1959 void EWebView::SetViewGeolocationPermissionCallback(
1960 Ewk_View_Geolocation_Permission_Callback callback,
1962 geolocation_permission_cb_.Set(callback, user_data);
1965 bool EWebView::InvokeViewGeolocationPermissionCallback(
1966 _Ewk_Geolocation_Permission_Request* permission_context,
1967 Eina_Bool* callback_result) {
1968 return geolocation_permission_cb_.Run(evas_object_, permission_context,
1972 void EWebView::SetViewUserMediaPermissionCallback(
1973 Ewk_View_User_Media_Permission_Callback callback,
1975 user_media_permission_cb_.Set(callback, user_data);
1978 bool EWebView::InvokeViewUserMediaPermissionCallback(
1979 _Ewk_User_Media_Permission_Request* permission_context,
1980 Eina_Bool* callback_result) {
1981 return user_media_permission_cb_.Run(evas_object_, permission_context,
1985 void EWebView::SetViewUserMediaPermissionQueryCallback(
1986 Ewk_View_User_Media_Permission_Query_Callback callback,
1988 user_media_permission_query_cb_.Set(callback, user_data);
1991 Ewk_User_Media_Permission_Query_Result
1992 EWebView::InvokeViewUserMediaPermissionQueryCallback(
1993 _Ewk_User_Media_Permission_Query* permission_context) {
1994 return user_media_permission_query_cb_.Run(evas_object_, permission_context);
1997 void EWebView::SetViewUnfocusAllowCallback(
1998 Ewk_View_Unfocus_Allow_Callback callback,
2000 unfocus_allow_cb_.Set(callback, user_data);
2003 bool EWebView::InvokeViewUnfocusAllowCallback(Ewk_Unfocus_Direction direction,
2004 Eina_Bool* callback_result) {
2005 return unfocus_allow_cb_.Run(evas_object_, direction, callback_result);
2008 void EWebView::StopFinding() {
2009 web_contents_->StopFinding(content::STOP_FIND_ACTION_CLEAR_SELECTION);
2012 void EWebView::SetProgressValue(double progress) {
2013 progress_ = progress;
2016 double EWebView::GetProgressValue() {
2020 const char* EWebView::GetTitle() {
2021 title_ = base::UTF16ToUTF8(web_contents_->GetTitle());
2022 return title_.c_str();
2025 bool EWebView::SaveAsPdf(int width, int height, const std::string& filename) {
2026 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
2027 if (!render_view_host)
2029 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
2030 return render_view_host->Send(
2031 new EwkViewMsg_PrintToPdf(render_view_host->GetRoutingID(), width, height,
2032 base::FilePath(filename)));
2038 bool EWebView::GetMHTMLData(Ewk_View_MHTML_Data_Get_Callback callback,
2040 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
2041 if (!render_view_host)
2044 MHTMLCallbackDetails* callback_details = new MHTMLCallbackDetails;
2045 callback_details->Set(callback, user_data);
2046 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
2047 int mhtml_callback_id = mhtml_callback_map_.Add(callback_details);
2048 return render_view_host->Send(new EwkViewMsg_GetMHTMLData(
2049 render_view_host->GetRoutingID(), mhtml_callback_id));
2055 void EWebView::OnMHTMLContentGet(const std::string& mhtml_content,
2057 MHTMLCallbackDetails* callback_details =
2058 mhtml_callback_map_.Lookup(callback_id);
2059 callback_details->Run(evas_object(), mhtml_content.c_str());
2060 mhtml_callback_map_.Remove(callback_id);
2063 bool EWebView::SavePageAsMHTML(const std::string& path,
2064 Ewk_View_Save_Page_Callback callback,
2069 GURL url(web_contents_->GetLastCommittedURL());
2070 std::u16string title(web_contents_->GetTitle());
2072 // Post function that has file access to blocking task runner.
2073 return base::PostTaskAndReplyWithResult(
2074 base::ThreadPool::CreateSequencedTaskRunner(
2075 {base::MayBlock(), base::TaskPriority::BEST_EFFORT,
2076 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})
2079 base::BindOnce(&GenerateMHTMLFilePath, url, base::UTF16ToUTF8(title),
2081 base::BindOnce(&EWebView::GenerateMHTML, base::Unretained(this), callback,
2085 void EWebView::GenerateMHTML(Ewk_View_Save_Page_Callback callback,
2087 const base::FilePath& file_path) {
2088 if (file_path.empty()) {
2089 LOG(ERROR) << "Generating file path was failed";
2090 callback(evas_object_, nullptr, user_data);
2094 MHTMLGenerationParams params(file_path);
2095 web_contents_->GenerateMHTML(
2096 params, base::BindOnce(&EWebView::MHTMLGenerated, base::Unretained(this),
2097 callback, user_data, file_path));
2100 void EWebView::MHTMLGenerated(Ewk_View_Save_Page_Callback callback,
2102 const base::FilePath& file_path,
2103 int64_t file_size) {
2104 callback(evas_object_, file_size > 0 ? file_path.value().c_str() : nullptr,
2108 bool EWebView::GetBackgroundColor(
2109 Ewk_View_Background_Color_Get_Callback callback,
2113 BackgroundColorGetCallback* cb =
2114 new BackgroundColorGetCallback(callback, user_data);
2115 int callback_id = background_color_get_callback_map_.Add(cb);
2117 rwhva()->host()->RequestBackgroundColor(callback_id);
2121 void EWebView::OnGetBackgroundColor(int callback_id, SkColor bg_color) {
2122 BackgroundColorGetCallback* cb =
2123 background_color_get_callback_map_.Lookup(callback_id);
2128 cb->Run(evas_object(), SkColorGetR(bg_color), SkColorGetG(bg_color),
2129 SkColorGetB(bg_color), SkColorGetA(bg_color));
2130 background_color_get_callback_map_.Remove(callback_id);
2133 bool EWebView::IsFullscreen() {
2134 return web_contents_delegate_->IsFullscreenForTabOrPending(
2135 web_contents_.get());
2138 void EWebView::ExitFullscreen() {
2139 WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents_.get());
2140 wci->ExitFullscreen(false);
2143 double EWebView::GetScale() {
2144 return page_scale_factor_;
2147 void EWebView::DidChangePageScaleFactor(double scale_factor) {
2148 page_scale_factor_ = scale_factor;
2149 wcva()->wcva_helper()->SetPageScaleFactor(scale_factor);
2150 SetScaledContentsSize();
2152 // Notify app about the scale change.
2153 scale_changed_cb_.Run(evas_object_, scale_factor);
2156 inline JavaScriptDialogManagerEfl* EWebView::GetJavaScriptDialogManagerEfl() {
2157 return static_cast<JavaScriptDialogManagerEfl*>(
2158 web_contents_delegate_->GetJavaScriptDialogManager(web_contents_.get()));
2161 void EWebView::SetJavaScriptAlertCallback(
2162 Ewk_View_JavaScript_Alert_Callback callback,
2164 GetJavaScriptDialogManagerEfl()->SetAlertCallback(callback, user_data);
2167 void EWebView::JavaScriptAlertReply() {
2168 GetJavaScriptDialogManagerEfl()->ExecuteDialogClosedCallBack(true,
2170 SmartCallback<EWebViewCallbacks::PopupReplyWaitFinish>().call(0);
2173 void EWebView::SetJavaScriptConfirmCallback(
2174 Ewk_View_JavaScript_Confirm_Callback callback,
2176 GetJavaScriptDialogManagerEfl()->SetConfirmCallback(callback, user_data);
2179 void EWebView::JavaScriptConfirmReply(bool result) {
2180 GetJavaScriptDialogManagerEfl()->ExecuteDialogClosedCallBack(result,
2182 SmartCallback<EWebViewCallbacks::PopupReplyWaitFinish>().call(0);
2185 void EWebView::SetJavaScriptPromptCallback(
2186 Ewk_View_JavaScript_Prompt_Callback callback,
2188 GetJavaScriptDialogManagerEfl()->SetPromptCallback(callback, user_data);
2191 void EWebView::JavaScriptPromptReply(const char* result) {
2192 GetJavaScriptDialogManagerEfl()->ExecuteDialogClosedCallBack(
2193 true, (std::string(result)));
2194 SmartCallback<EWebViewCallbacks::PopupReplyWaitFinish>().call(0);
2197 void EWebView::GetPageScaleRange(double* min_scale, double* max_scale) {
2198 auto prefs = web_contents_->GetOrCreateWebPreferences();
2200 *min_scale = prefs.default_minimum_page_scale_factor;
2202 *max_scale = prefs.default_maximum_page_scale_factor;
2205 void EWebView::SetDrawsTransparentBackground(bool enabled) {
2206 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
2207 if (!render_view_host)
2209 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
2210 render_view_host->Send(new EwkViewMsg_SetDrawsTransparentBackground(
2211 render_view_host->GetRoutingID(), enabled));
2215 void EWebView::GetSessionData(const char** data, unsigned* length) const {
2216 static const int MAX_SESSION_ENTRY_SIZE = std::numeric_limits<int>::max();
2218 NavigationController& navigationController = web_contents_->GetController();
2219 base::Pickle sessionPickle;
2220 const int itemCount = navigationController.GetEntryCount();
2222 sessionPickle.WriteInt(itemCount);
2223 sessionPickle.WriteInt(navigationController.GetCurrentEntryIndex());
2225 for (int i = 0; i < itemCount; i++) {
2226 NavigationEntry* navigationEntry = navigationController.GetEntryAtIndex(i);
2227 sessions::SerializedNavigationEntry serializedEntry =
2228 sessions::ContentSerializedNavigationBuilder::FromNavigationEntry(
2229 i, navigationEntry);
2230 serializedEntry.WriteToPickle(MAX_SESSION_ENTRY_SIZE, &sessionPickle);
2233 *data = static_cast<char*>(malloc(sizeof(char) * sessionPickle.size()));
2234 memcpy(const_cast<char*>(*data), sessionPickle.data(), sessionPickle.size());
2235 *length = sessionPickle.size();
2238 bool EWebView::RestoreFromSessionData(const char* data, unsigned length) {
2239 base::Pickle sessionPickle(data, length);
2240 base::PickleIterator pickleIterator(sessionPickle);
2244 if (!pickleIterator.ReadInt(&entryCount))
2246 if (!pickleIterator.ReadInt(¤tEntry))
2249 std::vector<sessions::SerializedNavigationEntry> serializedEntries;
2250 serializedEntries.resize(entryCount);
2251 for (int i = 0; i < entryCount; ++i) {
2252 if (!serializedEntries.at(i).ReadFromPickle(&pickleIterator))
2262 std::vector<std::unique_ptr<content::NavigationEntry>> scopedEntries =
2263 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries(
2264 serializedEntries, context()->browser_context());
2266 NavigationController& navigationController = web_contents_->GetController();
2268 if (currentEntry < 0)
2271 if (currentEntry >= static_cast<int>(scopedEntries.size()))
2272 currentEntry = scopedEntries.size() - 1;
2274 navigationController.Restore(currentEntry, RestoreType::kRestored,
2279 void EWebView::SetBrowserFont() {
2280 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
2281 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
2282 if (render_view_host) {
2283 IPC::Message* message =
2284 new EwkViewMsg_SetBrowserFont(render_view_host->GetRoutingID());
2286 if (render_view_host->IsRenderViewLive())
2287 render_view_host->Send(message);
2289 delayed_messages_.push_back(message);
2294 bool EWebView::IsDragging() const {
2295 return wcva()->wcva_helper()->IsDragging();
2298 void EWebView::ShowFileChooser(content::RenderFrameHost* render_frame_host,
2299 const blink::mojom::FileChooserParams& params) {
2300 if (!IsMobileProfile() && !IsWearableProfile())
2303 #if !defined(EWK_BRINGUP) // FIXME: m71 bringup
2304 if (params.capture) {
2305 const std::string capture_types[] = {"video/*", "audio/*", "image/*"};
2306 unsigned int capture_types_num =
2307 sizeof(capture_types) / sizeof(*capture_types);
2308 for (unsigned int i = 0; i < capture_types_num; ++i) {
2309 for (unsigned int j = 0; j < params.accept_types.size(); ++j) {
2310 if (UTF16ToUTF8(params.accept_types[j]) == capture_types[i]) {
2311 filechooser_mode_ = params.mode;
2312 LaunchCamera(params.accept_types[j]);
2318 file_chooser_.reset(
2319 new content::FileChooserControllerEfl(render_frame_host, ¶ms));
2320 file_chooser_->Open();
2324 #if !defined(EWK_BRINGUP) // FIXME: m67 bringup
2325 void EWebView::SetViewMode(blink::WebViewMode view_mode) {
2326 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
2327 if (!render_view_host)
2330 IPC::Message* message =
2331 new ViewMsg_SetViewMode(render_view_host->GetRoutingID(), view_mode);
2332 if (render_view_host->IsRenderViewLive()) {
2333 render_view_host->Send(message);
2335 delayed_messages_.push_back(message);
2340 gfx::Point EWebView::GetContextMenuPosition() const {
2341 return context_menu_position_;
2344 void EWebView::ShowContentsDetectedPopup(const char* message) {
2345 popup_controller_.reset(new PopupControllerEfl(this));
2346 popup_controller_->openPopup(message);
2349 void EWebView::RequestColorPicker(int r, int g, int b, int a) {
2350 input_picker_.reset(new InputPicker(this));
2351 input_picker_->ShowColorPicker(r, g, b, a);
2354 bool EWebView::SetColorPickerColor(int r, int g, int b, int a) {
2355 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
2356 web_contents_->DidChooseColorInColorChooser(SkColorSetARGB(a, r, g, b));
2361 void EWebView::InputPickerShow(ui::TextInputType input_type,
2363 content::DateTimeChooserEfl* date_time_chooser) {
2364 input_picker_.reset(new InputPicker(this));
2365 date_time_chooser_ = date_time_chooser;
2366 input_picker_->ShowDatePicker(input_type, input_value);
2369 void EWebView::LoadNotFoundErrorPage(const std::string& invalidUrl) {
2370 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
2371 RenderFrameHost* render_frame_host = web_contents_->GetPrimaryMainFrame();
2372 if (render_frame_host)
2373 render_frame_host->Send(new EwkFrameMsg_LoadNotFoundErrorPage(
2374 render_frame_host->GetRoutingID(), invalidUrl));
2378 std::string EWebView::GetPlatformLocale() {
2379 char* local_default = setlocale(LC_CTYPE, 0);
2381 return std::string("en-US");
2382 std::string locale = std::string(local_default);
2383 size_t position = locale.find('_');
2384 if (position != std::string::npos)
2385 locale.replace(position, 1, "-");
2386 position = locale.find('.');
2387 if (position != std::string::npos)
2388 locale = locale.substr(0, position);
2392 int EWebView::StartInspectorServer(int port) {
2393 return context_->InspectorServerStart(port);
2396 bool EWebView::StopInspectorServer() {
2397 return context_->InspectorServerStop();
2400 void EWebView::InvokeWebProcessCrashedCallback() {
2401 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2402 const GURL last_url = GetURL();
2403 bool callback_handled = false;
2404 SmartCallback<EWebViewCallbacks::WebProcessCrashed>().call(&callback_handled);
2405 if (!callback_handled)
2406 LoadHTMLString(kRendererCrashedHTMLMessage, NULL,
2407 last_url.possibly_invalid_spec().c_str());
2410 void EWebView::SyncAcceptLanguages(const std::string& accept_languages) {
2411 web_contents_->GetMutableRendererPrefs()->accept_languages = accept_languages;
2412 web_contents_->SyncRendererPrefs();
2415 void EWebView::HandleRendererProcessCrash() {
2416 base::ThreadPool::PostTask(
2417 FROM_HERE, {BrowserThread::UI},
2418 base::BindOnce(&EWebView::InvokeWebProcessCrashedCallback,
2419 base::Unretained(this)));
2422 void EWebView::InitializeContent() {
2423 WebContents* new_contents = create_new_window_web_contents_cb_.Run(this);
2424 if (!new_contents) {
2425 WebContents::CreateParams params(context_->browser_context());
2426 web_contents_.reset(
2427 new WebContentsImplEfl(context_->browser_context(), this));
2428 static_cast<WebContentsImpl*>(web_contents_.get())
2429 ->Init(params, blink::FramePolicy());
2431 web_contents_.reset(new_contents);
2433 // When a new webview is created in response to a request from the
2434 // engine, the BrowserContext instance of the originator WebContents
2435 // is used by the newly created WebContents object.
2436 // See more in WebContentsImplEfl::HandleNewWebContentsCreate.
2438 // Hence, if as part of the WebView creation, the embedding APP
2439 // passes in a Ewk_Context instance that wraps a different instance of
2440 // BrowserContext than the one the originator WebContents holds,
2441 // undefined behavior can be seen.
2443 // This is a snippet code that illustrate the scenario:
2446 // evas_object_smart_callback_add(web_view_, "create,window",
2447 // &OnNewWindowRequest, this);
2450 // void OnNewWindowRequest(void *data, Evas_Object*, void* out_view) {
2452 // EvasObject* new_web_view = ewk_view_add_with_context(GetEvas(),
2453 // ewk_context_new());
2454 // *static_cast<Evas_Object**>(out_view) = new_web_view;
2458 // The new Ewk_Context object created and passed in as parameter to
2459 // ewk_view_add_with_context wraps a different instance of BrowserContext
2460 // than the one the new WebContents object will hold.
2462 // CHECK below aims at catching misuse of this API.
2463 bool should_crash = context_->GetImpl()->browser_context() !=
2464 web_contents_->GetBrowserContext();
2467 << "BrowserContext of new WebContents does not match EWebView's. "
2468 << "Please see 'ewk_view_add*' documentation. "
2469 << "Aborting execution ...";
2472 web_contents_delegate_.reset(new WebContentsDelegateEfl(this));
2473 web_contents_->SetDelegate(web_contents_delegate_.get());
2474 WebContentsImplEfl* wc_efl =
2475 static_cast<WebContentsImplEfl*>(web_contents_.get());
2476 wc_efl->SetEflDelegate(new WebContentsEflDelegateEwk(this));
2477 wcva()->wcva_helper()->SetEflDelegate(wc_efl->GetEflDelegate());
2479 back_forward_list_.reset(new _Ewk_Back_Forward_List(web_contents_.get()));
2481 permission_popup_manager_.reset(new PermissionPopupManager(evas_object_));
2482 gin_native_bridge_dispatcher_host_.reset(
2483 new content::GinNativeBridgeDispatcherHost(web_contents_.get()));
2486 static_cast<WebContentsImplEfl*>(web_contents_.get())->GetEflNativeView();
2487 evas_object_smart_member_add(native_view_, evas_object_);
2488 static_cast<WebContentsImpl*>(web_contents_.get())
2489 ->set_ewk_view(evas_object_);
2490 InitializeWindowTreeHost();
2493 void EWebView::InitializeWindowTreeHost() {
2494 CHECK(aura::Env::GetInstance());
2496 int x, y, width, height;
2498 ecore_evas_ecore_evas_get(evas_object_evas_get(native_view_));
2499 ecore_evas_geometry_get(ee, &x, &y, &width, &height);
2501 gfx::Rect bounds(x, y, width, height);
2502 ui::PlatformWindowInitProperties properties;
2503 properties.bounds = bounds;
2505 host_ = aura::WindowTreeHost::Create(std::move(properties));
2507 host_->window()->Show();
2510 std::make_unique<aura::test::TestFocusClient>(host_->window());
2511 window_parenting_client_ =
2512 std::make_unique<aura::test::TestWindowParentingClient>(host_->window());
2514 aura::Window* content = web_contents_->GetNativeView();
2515 aura::Window* parent = host_->window();
2516 if (!parent->Contains(content)) {
2517 parent->AddChild(content);
2520 content->SetBounds(bounds);
2521 RenderWidgetHostView* host_view = web_contents_->GetRenderWidgetHostView();
2523 host_view->SetSize(bounds.size());
2526 #if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
2527 void EWebView::cameraResultCb(service_h request,
2529 service_result_e result,
2531 if (!IsMobileProfile() && !IsWearableProfile())
2534 EWebView* webview = static_cast<EWebView*>(data);
2535 RenderViewHost* render_view_host =
2536 webview->web_contents_->GetRenderViewHost();
2537 if (result == SERVICE_RESULT_SUCCEEDED) {
2541 ret = service_get_extra_data_array(reply, SERVICE_DATA_SELECTED,
2542 &filesarray, &number);
2544 for (int i = 0; i < number; i++) {
2545 std::vector<ui::SelectedFileInfo> files;
2546 if (!render_view_host) {
2549 if (filesarray[i]) {
2550 GURL url(filesarray[i]);
2551 if (!url.is_valid()) {
2552 base::FilePath path(url.SchemeIsFile() ? url.path()
2554 files.push_back(ui::SelectedFileInfo(path, base::FilePath()));
2557 render_view_host->FilesSelectedInChooser(files,
2558 webview->filechooser_mode_);
2562 std::vector<ui::SelectedFileInfo> files;
2563 if (render_view_host) {
2564 render_view_host->FilesSelectedInChooser(files,
2565 webview->filechooser_mode_);
2570 bool EWebView::LaunchCamera(std::u16string mimetype) {
2571 service_h svcHandle = 0;
2572 if (service_create(&svcHandle) < 0 || !svcHandle) {
2573 LOG(ERROR) << __FUNCTION__ << " Service Creation Failed ";
2576 service_set_operation(svcHandle, SERVICE_OPERATION_CREATE_CONTENT);
2577 service_set_mime(svcHandle, UTF16ToUTF8(mimetype).c_str());
2578 service_add_extra_data(svcHandle, "CALLER", "Browser");
2580 int ret = service_send_launch_request(svcHandle, cameraResultCb, this);
2581 if (ret != SERVICE_ERROR_NONE) {
2582 LOG(ERROR) << __FUNCTION__ << " Service Launch Failed ";
2583 service_destroy(svcHandle);
2586 service_destroy(svcHandle);
2591 void EWebView::UrlRequestSet(
2593 content::NavigationController::LoadURLType loadtype,
2597 content::NavigationController::LoadURLParams params(gurl);
2598 params.load_type = loadtype;
2599 params.override_user_agent = NavigationController::UA_OVERRIDE_TRUE;
2602 std::string s(body);
2604 network::ResourceRequestBody::CreateFromBytes(s.data(), s.size());
2607 net::HttpRequestHeaders header;
2609 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2611 while (eina_iterator_next(it, reinterpret_cast<void**>(&t))) {
2613 const char* value_str =
2614 t->data ? static_cast<const char*>(t->data) : "";
2615 base::StringPiece name = static_cast<const char*>(t->key);
2616 base::StringPiece value = value_str;
2617 header.SetHeader(name, value);
2618 // net::HttpRequestHeaders.ToString() returns string with newline
2619 params.extra_headers += header.ToString();
2622 eina_iterator_free(it);
2625 web_contents_->GetController().LoadURLWithParams(params);
2628 bool EWebView::HandleShow() {
2636 bool EWebView::HandleHide() {
2644 bool EWebView::HandleMove(int x, int y) {
2647 evas_object_move(native_view_, x, y);
2651 bool EWebView::HandleResize(int width, int height) {
2654 evas_object_resize(native_view_, width, height);
2658 bool EWebView::HandleTextSelectionDown(int x, int y) {
2659 if (!GetSelectionController())
2661 return GetSelectionController()->TextSelectionDown(x, y);
2664 bool EWebView::HandleTextSelectionUp(int x, int y) {
2665 if (!GetSelectionController())
2667 return GetSelectionController()->TextSelectionUp(x, y);
2670 void EWebView::HandleTapGestureForSelection(bool is_content_editable) {
2671 if (!GetSelectionController())
2674 GetSelectionController()->PostHandleTapGesture(is_content_editable);
2677 void EWebView::HandleZoomGesture(blink::WebGestureEvent& event) {
2678 blink::WebInputEvent::Type event_type = event.GetType();
2679 if (event_type == blink::WebInputEvent::Type::kGestureDoubleTap ||
2680 event_type == blink::WebInputEvent::Type::kGesturePinchBegin) {
2681 SmartCallback<EWebViewCallbacks::ZoomStarted>().call();
2683 if (event_type == blink::WebInputEvent::Type::kGestureDoubleTap ||
2684 event_type == blink::WebInputEvent::Type::kGesturePinchEnd) {
2685 SmartCallback<EWebViewCallbacks::ZoomFinished>().call();
2689 bool EWebView::GetHorizontalPanningHold() const {
2692 return rwhva()->offscreen_helper()->GetHorizontalPanningHold();
2695 void EWebView::SetHorizontalPanningHold(bool hold) {
2697 rwhva()->offscreen_helper()->SetHorizontalPanningHold(hold);
2700 bool EWebView::GetVerticalPanningHold() const {
2703 return rwhva()->offscreen_helper()->GetVerticalPanningHold();
2706 void EWebView::SetVerticalPanningHold(bool hold) {
2708 rwhva()->offscreen_helper()->SetVerticalPanningHold(hold);
2711 void EWebView::SendDelayedMessages(RenderViewHost* render_view_host) {
2712 DCHECK(render_view_host);
2714 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
2715 base::ThreadPool::PostTask(
2716 FROM_HERE, {BrowserThread::UI},
2717 base::BindOnce(&EWebView::SendDelayedMessages, base::Unretained(this),
2722 for (auto iter = delayed_messages_.begin(); iter != delayed_messages_.end();
2724 IPC::Message* message = *iter;
2725 message->set_routing_id(render_view_host->GetRoutingID());
2726 #if !defined(EWK_BRINGUP) // FIXME: m94 bringup
2727 render_view_host->Send(message);
2731 delayed_messages_.clear();
2734 void EWebView::ClosePage() {
2735 web_contents_->ClosePage();
2738 void EWebView::OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
2739 const gfx::Vector2dF& latest_overscroll_delta) {
2740 const gfx::Vector2dF old_overscroll =
2741 accumulated_overscroll - latest_overscroll_delta;
2743 if (latest_overscroll_delta.x() && !old_overscroll.x()) {
2744 latest_overscroll_delta.x() < 0
2745 ? SmartCallback<EWebViewCallbacks::OverscrolledLeft>().call()
2746 : SmartCallback<EWebViewCallbacks::OverscrolledRight>().call();
2748 if (latest_overscroll_delta.y() && !old_overscroll.y()) {
2749 latest_overscroll_delta.y() < 0
2750 ? SmartCallback<EWebViewCallbacks::OverscrolledTop>().call()
2751 : SmartCallback<EWebViewCallbacks::OverscrolledBottom>().call();
2755 void EWebView::SetDidChangeThemeColorCallback(
2756 Ewk_View_Did_Change_Theme_Color_Callback callback,
2758 did_change_theme_color_callback_.Set(callback, user_data);
2761 void EWebView::DidChangeThemeColor(const SkColor& color) {
2762 did_change_theme_color_callback_.Run(evas_object_, color);
2765 #if BUILDFLAG(IS_TIZEN_TV)
2766 void EWebView::DrawLabel(Evas_Object* image, Eina_Rectangle rect) {
2768 rwhva()->offscreen_helper()->DrawLabel(image, rect);
2771 void EWebView::ClearLabels() {
2773 rwhva()->offscreen_helper()->ClearLabels();
2777 void EWebView::RequestManifest(Ewk_View_Request_Manifest_Callback callback,
2779 web_contents_delegate_->RequestManifestInfo(callback, user_data);
2782 void EWebView::DidRespondRequestManifest(
2783 _Ewk_View_Request_Manifest* manifest,
2784 Ewk_View_Request_Manifest_Callback callback,
2786 callback(evas_object_, manifest, user_data);
2789 void EWebView::SetSessionTimeout(uint64_t timeout) {
2790 if (web_contents_->GetPrimaryMainFrame()->IsRenderFrameLive() && rwhva())
2791 rwhva()->host()->SetLongPollingGlobalTimeout(timeout);
2794 void EWebView::SetExceededIndexedDatabaseQuotaCallback(
2795 Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback,
2797 exceeded_indexed_db_quota_callback_.Set(callback, user_data);
2798 content::BrowserContextEfl* browser_context =
2799 static_cast<content::BrowserContextEfl*>(
2800 web_contents_->GetBrowserContext());
2801 if (browser_context) {
2802 browser_context->GetSpecialStoragePolicyEfl()->SetQuotaExceededCallback(
2803 base::BindOnce(&EWebView::InvokeExceededIndexedDatabaseQuotaCallback,
2804 base::Unretained(this)));
2808 void EWebView::InvokeExceededIndexedDatabaseQuotaCallback(
2810 int64_t current_quota) {
2811 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
2812 base::ThreadPool::PostTask(
2813 FROM_HERE, {BrowserThread::UI},
2814 base::BindOnce(&EWebView::InvokeExceededIndexedDatabaseQuotaCallback,
2815 base::Unretained(this), origin, current_quota));
2818 LOG(INFO) << __func__ << "()" << origin << ", " << current_quota;
2819 CHECK(!exceeded_indexed_db_quota_origin_.get());
2820 exceeded_indexed_db_quota_origin_.reset(new Ewk_Security_Origin(origin));
2821 exceeded_indexed_db_quota_callback_.Run(
2822 evas_object_, exceeded_indexed_db_quota_origin_.get(), current_quota);
2825 void EWebView::ExceededIndexedDatabaseQuotaReply(bool allow) {
2826 if (!exceeded_indexed_db_quota_origin_.get()) {
2827 LOG(WARNING) << __func__ << "() : callback is not invoked!";
2830 LOG(INFO) << __func__ << "()" << exceeded_indexed_db_quota_origin_->GetURL()
2832 content::BrowserContextEfl* browser_context =
2833 static_cast<content::BrowserContextEfl*>(
2834 web_contents_->GetBrowserContext());
2835 if (browser_context) {
2836 browser_context->GetSpecialStoragePolicyEfl()->SetUnlimitedStoragePolicy(
2837 exceeded_indexed_db_quota_origin_->GetURL(), allow);
2839 exceeded_indexed_db_quota_origin_.reset();
2842 bool EWebView::ShouldIgnoreNavigation(
2843 content::NavigationHandle* navigation_handle) {
2844 if (!navigation_handle->GetURL().is_valid() ||
2845 !navigation_handle->GetURL().SchemeIs("appcontrol") ||
2846 (!navigation_handle->HasUserGesture() &&
2847 !navigation_handle->WasServerRedirect())) {
2851 _Ewk_App_Control app_control(
2852 this, navigation_handle->GetURL().possibly_invalid_spec());
2853 return app_control.Proceed();
2856 bool EWebView::SetVisibility(bool enable) {
2861 web_contents_->WasShown();
2863 web_contents_->WasHidden();
2868 #if defined(TIZEN_ATK_SUPPORT)
2869 void EWebView::UpdateSpatialNavigationStatus(Eina_Bool enable) {
2870 if (settings_->getPreferences().spatial_navigation_enabled == enable)
2873 settings_->getPreferences().spatial_navigation_enabled = enable;
2874 WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_.get());
2876 wc->SetSpatialNavigationEnabled(enable);
2879 void EWebView::UpdateAccessibilityStatus(Eina_Bool enable) {
2880 if (settings_->getPreferences().atk_enabled == enable)
2883 settings_->getPreferences().atk_enabled = enable;
2884 WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_.get());
2886 wc->SetAtkEnabled(enable);
2889 void EWebView::InitAtk() {
2890 EWebAccessibilityUtil::GetInstance()->ToggleAtk(lazy_initialize_atk_);
2893 /* LCOV_EXCL_START */
2894 bool EWebView::GetAtkStatus() {
2895 auto state = content::BrowserAccessibilityStateImpl::GetInstance();
2898 return state->IsAccessibleBrowser();
2900 /* LCOV_EXCL_STOP */