[M108 Migration] Remove EWK_BRINGUP in tizen_src/ 92/288292/3
authorBakka Uday Kiran <b.kiran@samsung.com>
Tue, 14 Feb 2023 16:23:22 +0000 (21:53 +0530)
committerBot Blink <blinkbot@samsung.com>
Wed, 15 Feb 2023 23:45:18 +0000 (23:45 +0000)
This commit migrates below EWK_BRINGUP removal patches.

Remove EWK_BRINGUP in browser_context_efl.cc
Remove EWK_BRINGUP in ContentBrowserClientEfl::CanCreateWindow
Remove EWK_BRINGUP from DownloadManagerDelegateEfl

Reference: https://review.tizen.org/gerrit/c/281750

Change-Id: I0b66de521d2b16c995af8920d8aef1a5db647430
Signed-off-by: Bakka Uday Kiran <b.kiran@samsung.com>
tizen_src/ewk/efl_integration/browser_context_efl.cc
tizen_src/ewk/efl_integration/browser_context_efl.h
tizen_src/ewk/efl_integration/content_browser_client_efl.cc
tizen_src/ewk/efl_integration/download_manager_delegate_efl.cc
tizen_src/ewk/efl_integration/download_manager_delegate_efl.h
tizen_src/ewk/efl_integration/eweb_context.cc
tizen_src/ewk/efl_integration/eweb_context.h

index 9c52220..04b4762 100644 (file)
@@ -180,9 +180,6 @@ BrowserContextEfl::BrowserContextEfl(EWebContext* web_context, bool incognito)
   autofill::AutocompleteHistoryManagerFactoryEfl::GetInstance()
       ->AutocompleteHistoryManagerAdd(this);
 #endif
-#if !defined(EWK_BRINGUP)  // FIXME: m85 bringup
-  BrowserContext::Initialize(this, GetPath());
-#endif
 }
 
 std::unique_ptr<ZoomLevelDelegate> BrowserContextEfl::CreateZoomLevelDelegate(
@@ -194,6 +191,14 @@ ResourceContext* BrowserContextEfl::GetResourceContext() {
   return GetResourceContextEfl();
 }
 
+DownloadManagerDelegate* BrowserContextEfl::GetDownloadManagerDelegate() {
+  if (!download_manager_delegate_.get()) {
+    download_manager_delegate_ =
+        std::make_unique<DownloadManagerDelegateEfl>(GetDownloadManager());
+  }
+  return download_manager_delegate_.get();
+}
+
 BrowserContextEfl::ResourceContextEfl*
 BrowserContextEfl::GetResourceContextEfl() {
   if (!resource_context_) {
index 9fa369c..8ddf8c8 100644 (file)
@@ -98,9 +98,7 @@ class BrowserContextEfl : public BrowserContext,
     return nullptr;
   }
   ResourceContext* GetResourceContext() override;
-  content::DownloadManagerDelegate* GetDownloadManagerDelegate() override {
-    return &download_manager_delegate_;
-  }
+  DownloadManagerDelegate* GetDownloadManagerDelegate() override;
   BrowserPluginGuestManager* GetGuestManager() override { return 0; }
   storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override {
     return GetSpecialStoragePolicyEfl();
@@ -154,7 +152,7 @@ class BrowserContextEfl : public BrowserContext,
   std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_writer_;
   ResourceContextEfl* resource_context_;
   EWebContext* web_context_;
-  DownloadManagerDelegateEfl download_manager_delegate_;
+  std::unique_ptr<DownloadManagerDelegateEfl> download_manager_delegate_;
   base::ScopedTempDir temp_dir_;
   bool temp_dir_creation_attempted_;
   std::unique_ptr<PrefService> user_pref_service_;
index ddd5c0a..f7777a2 100644 (file)
@@ -298,15 +298,13 @@ bool ContentBrowserClientEfl::CanCreateWindow(
     bool user_gesture,
     bool opener_suppressed,
     bool* no_javascript_access) {
-#if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
   if (!user_gesture) {
     *no_javascript_access = true;
-    BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
-                            base::BindOnce(&DispatchPopupBlockedOnUIThread,
-                                           render_process_id, target_url));
+    base::ThreadPool::PostTask(FROM_HERE, {BrowserThread::UI},
+                   base::BindOnce(&DispatchPopupBlockedOnUIThread,
+                                  opener->GetProcess()->GetID(), target_url));
     return false;
   }
-#endif
 
   // User_gesture is modified on renderer side to true if javascript
   // is allowed to open windows without user gesture. If we've got user gesture
index c7dfc6e..74c01a6 100644 (file)
@@ -9,28 +9,32 @@
 #include "components/download/public/common/download_danger_type.h"
 #include "components/download/public/common/download_item.h"
 #include "content/common/paths_efl.h"
+#include "content/public/browser/download_manager.h"
 #include "ewk/efl_integration/browser_context_efl.h"
 #include "ewk/efl_integration/eweb_view.h"
 #include "third_party/blink/public/common/mime_util/mime_util.h"
 
+DownloadManagerDelegateEfl::DownloadManagerDelegateEfl(
+    content::DownloadManager* download_manager)
+    : download_manager_(download_manager) {}
+
+DownloadManagerDelegateEfl::~DownloadManagerDelegateEfl() {
+  if (download_manager_) {
+    DCHECK_EQ(static_cast<content::DownloadManagerDelegate*>(this),
+              download_manager_->GetDelegate());
+    download_manager_->SetDelegate(nullptr);
+    download_manager_ = nullptr;
+  }
+}
+
 bool DownloadManagerDelegateEfl::TriggerExternalDownloadManager(
     download::DownloadItem* item) const {
-#if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
-  content::BrowserContextEfl* browser_context =
-      static_cast<content::BrowserContextEfl*>(item->GetBrowserContext());
-#else
-  content::BrowserContextEfl* browser_context = nullptr;
-#endif
-  if (browser_context) {
-    auto start_download_callback =
-        browser_context->WebContext()->DidStartDownloadCallback();
-    if (start_download_callback) {
-      DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-      start_download_callback->TriggerCallback(item->GetURL().spec());
-      return true;
-    }
-  }
-  return false;
+  auto* browser_context = static_cast<content::BrowserContextEfl*>(
+      download_manager_->GetBrowserContext());
+  return browser_context
+             ? browser_context->WebContext()->TriggerDidStartDownloadCallback(
+                   item->GetURL().spec())
+             : false;
 }
 
 base::FilePath DownloadManagerDelegateEfl::GetPlatformDownloadPath(
index bcf99cd..fc9141c 100644 (file)
@@ -7,10 +7,20 @@
 
 #include "content/public/browser/download_manager_delegate.h"
 
+namespace content {
+class DownloadManager;
+}
+
 // This is the EFL side helper for the download system.
 class DownloadManagerDelegateEfl : public content::DownloadManagerDelegate {
 public:
- ~DownloadManagerDelegateEfl() override = default;
+ explicit DownloadManagerDelegateEfl(
+     content::DownloadManager* download_manager);
+
+ DownloadManagerDelegateEfl(const DownloadManagerDelegateEfl&) = delete;
+ DownloadManagerDelegateEfl& operator=(const DownloadManagerDelegateEfl&) = delete;
+
+ ~DownloadManagerDelegateEfl() override;
 
  // content::DownloadManagerDelegate implementation.
  bool DetermineDownloadTarget(download::DownloadItem*,
@@ -22,11 +32,13 @@ public:
  void GetNextId(content::DownloadIdCallback) override;
 
 private:
   // If the external download manager is available, trigger download
   // with it and return true, otherwise return false.
+ // If the external download manager is available, trigger download
+ // with it and return true, otherwise return false.
  bool TriggerExternalDownloadManager(download::DownloadItem* item) const;
 
  base::FilePath GetPlatformDownloadPath(download::DownloadItem* item) const;
+
+ content::DownloadManager* download_manager_;
 };
 
 #endif // DOWNLOAD_MANAGER_DELEGATE_EFL_H
index a895558..a8254fc 100644 (file)
@@ -545,6 +545,15 @@ void EWebContext::SetDidStartDownloadCallback(
       new EwkDidStartDownloadCallback(callback, user_data));
 }
 
+bool EWebContext::TriggerDidStartDownloadCallback(const std::string& url) {
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  if (!start_download_callback_)
+    return false;
+
+  start_download_callback_->TriggerCallback(url);
+  return true;
+}
+
 EwkDidStartDownloadCallback* EWebContext::DidStartDownloadCallback() {
   return start_download_callback_.get();
 }
index ef6c20c..3e6cdf0 100644 (file)
@@ -116,6 +116,7 @@ class EWebContext {
   //download start callback handlers
   void SetDidStartDownloadCallback(Ewk_Context_Did_Start_Download_Callback callback,
                                    void* user_data);
+  bool TriggerDidStartDownloadCallback(const std::string& url);
   EwkDidStartDownloadCallback* DidStartDownloadCallback();
   void DeleteAllApplicationCache();
   void DeleteApplicationCacheForSite(const GURL&);