Commit b9f0b50b authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

ThinWebView: Remove chrome layer dependency

This CL is a precursor to moving ThinWebView to components. Only
dependency on chrome layer was TabHelpers which was moved to a
ThinWebViewInitializer interface.

Bug: 1116770
Change-Id: I24fdd93e35ae24d9bede953e32c68b0fd7024ada
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2358993
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799355}
parent dcd286f7
......@@ -2625,6 +2625,8 @@ static_library("browser") {
"android/tab_printer.h",
"android/tab_web_contents_delegate_android.cc",
"android/tab_web_contents_delegate_android.h",
"android/thin_webview/chrome_thin_webview_initializer.cc",
"android/thin_webview/chrome_thin_webview_initializer.h",
"android/trusted_cdn.cc",
"android/trusted_cdn.h",
"android/usage_stats/notification_suspender.cc",
......
......@@ -6,7 +6,11 @@ import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
source_set("thin_webview") {
sources = [ "compositor_view.h" ]
sources = [
"compositor_view.h",
"thin_webview_initializer.cc",
"thin_webview_initializer.h",
]
public_deps = [ "//base" ]
}
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/thin_webview/chrome_thin_webview_initializer.h"
#include "chrome/browser/ui/tab_helpers.h"
#include "components/permissions/permission_request_manager.h"
namespace thin_webview {
namespace android {
// static
void ChromeThinWebViewInitializer::Initialize() {
ThinWebViewInitializer::SetInstance(new ChromeThinWebViewInitializer);
}
void ChromeThinWebViewInitializer::AttachTabHelpers(
content::WebContents* web_contents) {
TabHelpers::AttachTabHelpers(web_contents);
permissions::PermissionRequestManager::FromWebContents(web_contents)
->set_web_contents_supports_permission_requests(false);
}
} // namespace android
} // namespace thin_webview
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_THIN_WEBVIEW_CHROME_THIN_WEBVIEW_INITIALIZER_H_
#define CHROME_BROWSER_ANDROID_THIN_WEBVIEW_CHROME_THIN_WEBVIEW_INITIALIZER_H_
#include "chrome/browser/android/thin_webview/thin_webview_initializer.h"
namespace thin_webview {
namespace android {
// A helper class to help in attaching tab helpers.
class ChromeThinWebViewInitializer : public ThinWebViewInitializer {
public:
static void Initialize();
ChromeThinWebViewInitializer() = default;
~ChromeThinWebViewInitializer() = default;
void AttachTabHelpers(content::WebContents* web_contents) override;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeThinWebViewInitializer);
};
} // namespace android
} // namespace thin_webview
#endif // CHROME_BROWSER_ANDROID_THIN_WEBVIEW_CHROME_THIN_WEBVIEW_INITIALIZER_H_
......@@ -17,7 +17,6 @@ static_library("internal") {
":jni_headers",
"//cc",
"//chrome/browser/ui",
"//components/permissions",
"//skia",
]
......
......@@ -7,9 +7,8 @@
#include "base/android/jni_android.h"
#include "cc/layers/layer.h"
#include "chrome/browser/android/thin_webview/internal/jni_headers/ThinWebViewImpl_jni.h"
#include "chrome/browser/ui/tab_helpers.h"
#include "chrome/browser/android/thin_webview/thin_webview_initializer.h"
#include "components/embedder_support/android/delegate/web_contents_delegate_android.h"
#include "components/permissions/permission_request_manager.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/browser_controls_state.h"
......@@ -77,9 +76,7 @@ void ThinWebView::SetWebContents(content::WebContents* web_contents,
if (delegate)
web_contents->SetDelegate(delegate);
TabHelpers::AttachTabHelpers(web_contents);
permissions::PermissionRequestManager::FromWebContents(web_contents)
->set_web_contents_supports_permission_requests(false);
ThinWebViewInitializer::GetInstance()->AttachTabHelpers(web_contents);
// Disable browser controls when used for thin webview.
web_contents->GetMainFrame()->UpdateBrowserControlsState(
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/thin_webview/thin_webview_initializer.h"
namespace thin_webview {
namespace android {
ThinWebViewInitializer* g_thin_webview_initializer = nullptr;
// static
void ThinWebViewInitializer::SetInstance(ThinWebViewInitializer* instance) {
g_thin_webview_initializer = instance;
}
// static
ThinWebViewInitializer* ThinWebViewInitializer::GetInstance() {
return g_thin_webview_initializer;
}
} // namespace android
} // namespace thin_webview
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_THIN_WEBVIEW_THIN_WEBVIEW_INITIALIZER_H_
#define CHROME_BROWSER_ANDROID_THIN_WEBVIEW_THIN_WEBVIEW_INITIALIZER_H_
#include "base/macros.h"
namespace content {
class WebContents;
} // namespace content
namespace thin_webview {
namespace android {
// A helper class to help in attaching tab helpers.
class ThinWebViewInitializer {
public:
static void SetInstance(ThinWebViewInitializer* instance);
static ThinWebViewInitializer* GetInstance();
ThinWebViewInitializer() = default;
~ThinWebViewInitializer() = default;
virtual void AttachTabHelpers(content::WebContents* web_contents) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ThinWebViewInitializer);
};
} // namespace android
} // namespace thin_webview
#endif // CHROME_BROWSER_ANDROID_THIN_WEBVIEW_THIN_WEBVIEW_INITIALIZER_H_
......@@ -106,6 +106,7 @@
#if defined(OS_ANDROID)
#include "chrome/browser/android/explore_sites/explore_sites_service_factory.h"
#include "chrome/browser/android/search_permissions/search_permissions_service.h"
#include "chrome/browser/android/thin_webview/chrome_thin_webview_initializer.h"
#include "chrome/browser/media/android/cdm/media_drm_origin_id_manager_factory.h"
#else
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
......@@ -379,6 +380,9 @@ void ChromeBrowserMainExtraPartsProfiles::
#if !defined(OS_ANDROID)
ThemeServiceFactory::GetInstance();
#endif
#if defined(OS_ANDROID)
thin_webview::android::ChromeThinWebViewInitializer::Initialize();
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
ToolbarActionsModelFactory::GetInstance();
#endif
......
......@@ -23,7 +23,7 @@ class ChromePrerenderContentsDelegate;
namespace thin_webview {
namespace android {
class ThinWebView;
class ChromeThinWebViewInitializer;
}
} // namespace thin_webview
......@@ -60,7 +60,7 @@ class TabHelpers {
// ThinWebView is used to host WebContents on non-tab UIs in Android. Most
// clients of ThinWebView will need a major subset of the tab helpers.
friend class thin_webview::android::ThinWebView;
friend class thin_webview::android::ChromeThinWebViewInitializer;
// FYI: Do NOT add any more friends here. The functions above are the ONLY
// ones that need to call AttachTabHelpers; if you think you do, re-read the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment