From: Kamil Klimek Date: Mon, 7 Jul 2014 20:33:39 +0000 (-0700) Subject: Enable orientation event, fix a related crash and APIs X-Git-Tag: submit/tizen/20190801.160004~2508 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b12a964ee54c111c23f405e4dd766c92189e1a85;p=platform%2Fframework%2Fweb%2Fchromium-efl.git Enable orientation event, fix a related crash and APIs Change-Id: I948e70e9b7b1344ccd2dc7f2d6264b98e01a961a Conflicts: impl/eweb_view.cc --- diff --git a/tizen_src/impl/browser/javascript_dialog_manager_efl.cc b/tizen_src/impl/browser/javascript_dialog_manager_efl.cc index 6b6a72077c7d..23550aeb0e22 100644 --- a/tizen_src/impl/browser/javascript_dialog_manager_efl.cc +++ b/tizen_src/impl/browser/javascript_dialog_manager_efl.cc @@ -2,6 +2,10 @@ #include "browser/javascript_dialog_manager_efl.h" #include "browser/javascript_modal_dialog_efl.h" +#include + +using content::BrowserThread; + JavaScriptModalCallbacksData::JavaScriptModalCallbacksData(content::JavaScriptMessageType javascript_message_type, void* user_data) : alert_callback_(NULL), user_data_(user_data), javascript_message_type_(javascript_message_type) @@ -81,6 +85,7 @@ void JavaScriptDialogManagerEfl::RunJavaScriptDialog(content::WebContents* web_c const base::string16& default_prompt_text, const DialogClosedCallback& callback, bool* did_suppress_message) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(web_contents); dialog_closed_callback_ = callback; content::WebContentsDelegateEfl* web_contents_delegate = diff --git a/tizen_src/impl/eweb_view.cc b/tizen_src/impl/eweb_view.cc index ab850ece6da2..3048a8376f25 100755 --- a/tizen_src/impl/eweb_view.cc +++ b/tizen_src/impl/eweb_view.cc @@ -604,8 +604,20 @@ void EWebView::SendOrientationChangeEventIfNeeded(int orientation) { #warning "[M37] Fix screen orientation" #if 0 //send new orientation value to RenderView Host to pass to renderer - if(rvhi && rvhi->GetOrientation() != orientation) - rvhi->SendOrientationChangeEvent(orientation); + if(rvhi && rvhi->GetOrientation() != orientation) { + switch(orientation) { + case -90: + case 0: + case 90: + case 180: + rvhi->SendOrientationChangeEvent(orientation); + break; + + default: + NOTREACHED(); + break; + } + } #endif } diff --git a/tizen_src/impl/web_contents_delegate_efl.cc b/tizen_src/impl/web_contents_delegate_efl.cc index 2d504b3131ac..7d3dd43a44df 100755 --- a/tizen_src/impl/web_contents_delegate_efl.cc +++ b/tizen_src/impl/web_contents_delegate_efl.cc @@ -55,38 +55,51 @@ void WritePdfDataToFile(printing::PdfMetafileSkia* metafile, const base::FilePat } WebContentsDelegateEfl::WebContentsDelegateEfl(EWebView* view) - : web_view_(view), - document_created_(false), - should_open_new_window_(true), - forward_backward_list_count_(0), - weak_ptr_factory_(this) { + : web_view_(view) + , is_fullscreen_(false) + , web_contents_(NULL) + , document_created_(false) + , should_open_new_window_(true) + , dialog_manager_(NULL) + , forward_backward_list_count_(0) + , weak_ptr_factory_(this) { BrowserContext* browser_context = web_view_->context()->browser_context(); - web_contents_.reset(WebContents::Create(WebContents::CreateParams(browser_context))); + web_contents_ = WebContents::Create(WebContents::CreateParams(browser_context)); web_contents_->SetDelegate(this); - Observe(web_contents_.get()); + Observe(web_contents_); #ifdef TIZEN_AUTOFILL_SUPPORT - AutofillManagerDelegateEfl::CreateForWebContents(web_contents_.get()); + AutofillManagerDelegateEfl::CreateForWebContents(web_contents_); AutofillManagerDelegateEfl * autofill_manager = - AutofillManagerDelegateEfl::FromWebContents(web_contents_.get()); + AutofillManagerDelegateEfl::FromWebContents(web_contents_); autofill_manager->SetEWebView(view); - AutofillDriverImpl::CreateForWebContentsAndDelegate(web_contents_.get(), + AutofillDriverImpl::CreateForWebContentsAndDelegate(web_contents_, autofill_manager, EWebView::GetPlatformLocale(), AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); - PasswordManagerClientEfl::CreateForWebContents(web_contents_.get()); + PasswordManagerClientEfl::CreateForWebContents(web_contents_); #endif } WebContentsDelegateEfl::WebContentsDelegateEfl(EWebView* view, WebContents* contents) - : WebContentsObserver(contents), - web_view_(view), - web_contents_(contents), - document_created_(false), - should_open_new_window_(true), - forward_backward_list_count_(0), - weak_ptr_factory_(this) { + : WebContentsObserver(contents) + , web_view_(view) + , is_fullscreen_(false) + , web_contents_(contents) + , document_created_(false) + , should_open_new_window_(true) + , dialog_manager_(NULL) + , forward_backward_list_count_(0) + , weak_ptr_factory_(this) { web_contents_->SetDelegate(this); } +WebContentsDelegateEfl::~WebContentsDelegateEfl() { + // It's important to delete web_contents_ before dialog_manager_ + // destructor of web contents uses dialog_manager_ + + delete web_contents_; + delete dialog_manager_; +} + void WebContentsDelegateEfl::NavigationStateChanged(const WebContents* source, unsigned changed_flags) { if (changed_flags & content::INVALIDATE_TYPE_URL) { const char* url = source->GetVisibleURL().spec().c_str(); @@ -407,8 +420,8 @@ void WebContentsDelegateEfl::FindReply(WebContents* web_contents, JavaScriptDialogManager* WebContentsDelegateEfl::GetJavaScriptDialogManager() { if (!dialog_manager_) - dialog_manager_.reset(new JavaScriptDialogManagerEfl()); - return dialog_manager_.get(); + dialog_manager_ = new JavaScriptDialogManagerEfl(); + return dialog_manager_; } bool WebContentsDelegateEfl::OnMessageReceived(const IPC::Message& message) { diff --git a/tizen_src/impl/web_contents_delegate_efl.h b/tizen_src/impl/web_contents_delegate_efl.h index 43f3052a81fd..834d1ec455e8 100755 --- a/tizen_src/impl/web_contents_delegate_efl.h +++ b/tizen_src/impl/web_contents_delegate_efl.h @@ -36,6 +36,7 @@ class WebContentsDelegateEfl public WebContentsObserver { public: WebContentsDelegateEfl(EWebView*); + ~WebContentsDelegateEfl(); // Reusing the given WebContents instead of creating a new one. WebContentsDelegateEfl(EWebView*, WebContents*); @@ -93,7 +94,7 @@ class WebContentsDelegateEfl CertificateRequestResultType* result); EWebView* web_view() const { return web_view_; } - WebContents* web_contents() const { return web_contents_.get(); } + WebContents* web_contents() const { return web_contents_; } virtual void DidStartProvisionalLoadForFrame(int64 frame_id, int64 parent_frame_id, @@ -176,7 +177,7 @@ class WebContentsDelegateEfl EWebView* web_view_; bool is_fullscreen_; - scoped_ptr web_contents_; + WebContents* web_contents_; struct ContentSecurityPolicy { ContentSecurityPolicy(const std::string& p, tizen_webview::ContentSecurityPolicyType type) @@ -201,7 +202,7 @@ class WebContentsDelegateEfl scoped_ptr pending_content_security_policy_; bool document_created_; bool should_open_new_window_; - scoped_ptr dialog_manager_; + JavaScriptDialogManagerEfl* dialog_manager_; int forward_backward_list_count_; scoped_ptr favicon_downloader_; base::WeakPtrFactory weak_ptr_factory_;