Enable orientation event, fix a related crash and APIs
authorKamil Klimek <k.klimek@partner.samsung.com>
Mon, 7 Jul 2014 20:33:39 +0000 (13:33 -0700)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Change-Id: I948e70e9b7b1344ccd2dc7f2d6264b98e01a961a

Conflicts:

impl/eweb_view.cc

tizen_src/impl/browser/javascript_dialog_manager_efl.cc
tizen_src/impl/eweb_view.cc
tizen_src/impl/web_contents_delegate_efl.cc
tizen_src/impl/web_contents_delegate_efl.h

index 6b6a72077c7d4cbce05448749bce5c0858e40920..23550aeb0e221b921ebf9abaa2eea16af291d86e 100644 (file)
@@ -2,6 +2,10 @@
 #include "browser/javascript_dialog_manager_efl.h"
 #include "browser/javascript_modal_dialog_efl.h"
 
+#include <content/public/browser/browser_thread.h>
+
+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 =
index ab850ece6da2cc3d544af585639337dd33bc1f53..3048a8376f2500d7502b24b8e600f7f373f6ec07 100755 (executable)
@@ -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
 }
 
index 2d504b3131aca92afd41effc1ee8d3be678aa8b4..7d3dd43a44dfc1396a2fdd918feb082f46e75c36 100755 (executable)
@@ -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) {
index 43f3052a81fd6ac3b5b59a1370f99330f0f97a50..834d1ec455e8f2da1f2df1908c9a41686983dbd6 100755 (executable)
@@ -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<WebContents> web_contents_;
+  WebContents* web_contents_;
 
   struct ContentSecurityPolicy {
     ContentSecurityPolicy(const std::string& p, tizen_webview::ContentSecurityPolicyType type)
@@ -201,7 +202,7 @@ class WebContentsDelegateEfl
   scoped_ptr<ContentSecurityPolicy> pending_content_security_policy_;
   bool document_created_;
   bool should_open_new_window_;
-  scoped_ptr<JavaScriptDialogManagerEfl> dialog_manager_;
+  JavaScriptDialogManagerEfl* dialog_manager_;
   int forward_backward_list_count_;
   scoped_ptr<FaviconDownloader> favicon_downloader_;
   base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;