-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
987 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
android/java/org/chromium/chrome/browser/ntp/SponsoredRichMediaWebView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* Copyright (c) 2025 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.chromium.chrome.browser.ntp; | ||
|
||
import android.app.Activity; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
|
||
import org.chromium.base.version_info.VersionInfo; | ||
import org.chromium.chrome.browser.content.WebContentsFactory; | ||
import org.chromium.chrome.browser.profiles.Profile; | ||
import org.chromium.components.embedder_support.view.ContentView; | ||
import org.chromium.components.thinwebview.ThinWebView; | ||
import org.chromium.components.thinwebview.ThinWebViewConstraints; | ||
import org.chromium.components.thinwebview.ThinWebViewFactory; | ||
import org.chromium.content_public.browser.LoadUrlParams; | ||
import org.chromium.content_public.browser.WebContents; | ||
import org.chromium.net.NetId; | ||
import org.chromium.ui.base.ViewAndroidDelegate; | ||
import org.chromium.ui.base.WindowAndroid; | ||
|
||
public class SponsoredRichMediaWebView { | ||
private static final String NEW_TAB_TAKEOVER_URL = "chrome://new-tab-takeover"; | ||
|
||
private WebContents mWebContents; | ||
private ThinWebView mWebView; | ||
|
||
public SponsoredRichMediaWebView( | ||
Activity activity, WindowAndroid windowAndroid, Profile profile) { | ||
mWebContents = | ||
WebContentsFactory.createWebContentsWithWarmRenderer( | ||
profile, /* initiallyHidden= */ false, /* targetNetwork= */ NetId.INVALID); | ||
|
||
final ContentView webContentView = ContentView.createContentView(activity, mWebContents); | ||
mWebContents.setDelegates( | ||
VersionInfo.getProductVersion(), | ||
ViewAndroidDelegate.createBasicDelegate(webContentView), | ||
webContentView, | ||
windowAndroid, | ||
WebContents.createDefaultInternalsHolder()); | ||
|
||
mWebView = | ||
ThinWebViewFactory.create( | ||
activity, | ||
new ThinWebViewConstraints(), | ||
windowAndroid.getIntentRequestTracker()); | ||
mWebView.getView() | ||
.setLayoutParams( | ||
new FrameLayout.LayoutParams( | ||
ViewGroup.LayoutParams.MATCH_PARENT, | ||
ViewGroup.LayoutParams.MATCH_PARENT)); | ||
mWebView.attachWebContents(mWebContents, webContentView, null); | ||
} | ||
|
||
public void loadSponsoredRichMedia() { | ||
mWebContents.getNavigationController().loadUrl(new LoadUrlParams(NEW_TAB_TAKEOVER_URL)); | ||
} | ||
|
||
public View getView() { | ||
return mWebView.getView(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) 2025 The Brave Authors. All rights reserved. | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import("//brave/build/config.gni") | ||
|
||
assert(is_android) | ||
|
||
source_set("new_tab_takeover") { | ||
sources = [ | ||
"new_tab_takeover_ui.cc", | ||
"new_tab_takeover_ui.h", | ||
"new_tab_takeover_ui_config.cc", | ||
"new_tab_takeover_ui_config.h", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//brave/browser:browser_process", | ||
"//brave/browser/brave_ads:brave_ads", | ||
"//brave/browser/ntp_background", | ||
"//brave/components/brave_new_tab_ui:new_tab_takeover_generated_resources", | ||
"//brave/components/constants", | ||
"//brave/components/ntp_background_images/browser", | ||
"//chrome/browser:browser_process", | ||
"//chrome/browser:browser_public_dependencies", | ||
"//chrome/browser/profiles:profile", | ||
"//content/public/browser", | ||
"//content/public/common", | ||
"//ui/webui", | ||
"//url", | ||
] | ||
|
||
public_deps = [ | ||
"//brave/components/brave_new_tab_ui/new_tab_takeover/mojom", | ||
"//brave/components/ntp_background_images/browser/mojom", | ||
"//mojo/public/cpp/bindings", | ||
] | ||
} |
Oops, something went wrong.