Skip to content

Commit

Permalink
Merge pull request #8307 from brave/cr91
Browse files Browse the repository at this point in the history
Upgrade from Chromium 90 to Chromium 91.
  • Loading branch information
mkarolin authored May 6, 2021
2 parents 7586eba + cb586a0 commit cb022ac
Show file tree
Hide file tree
Showing 657 changed files with 4,587 additions and 3,617 deletions.
5 changes: 0 additions & 5 deletions android/brave_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/rate/RateFeedbackUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/rate/RateUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/safe_browsing/settings/BraveStandardProtectionSettingsFragment.java",
"../../brave/android/java/org/chromium/chrome/browser/search_engines/settings/BraveBaseSearchEngineAdapter.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/AppearancePreferences.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BackgroundImagesPreferences.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BackgroundVideoPlaybackPreference.java",
Expand All @@ -147,16 +146,12 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveLicensePreferences.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveMainPreferencesBase.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BravePreferenceFragment.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BravePrivateSearchEnginePreference.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveRewardsPreferences.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveRewardsResetPreference.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveRewardsResetPreferenceDialog.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSearchEngineAdapter.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSearchEnginePreference.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSearchEngineUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSettingsActivity.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSettingsLauncherImpl.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveStandardSearchEnginePreference.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveStatsPreferences.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveWebrtcPolicyPreference.java",
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveWebrtcPolicyPreferencesFragment.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,17 @@ public class BraveFeedSurfaceCoordinator extends FeedSurfaceCoordinator {
private FrameLayout mRootView;

public BraveFeedSurfaceCoordinator(Activity activity, SnackbarManager snackbarManager,
TabModelSelector tabModelSelector, WindowAndroid windowAndroid,
@Nullable SnapScrollHelper snapScrollHelper, @Nullable View ntpHeader,
@Nullable SectionHeaderView sectionHeaderView, FeedV1ActionOptions actionOptions,
WindowAndroid windowAndroid, @Nullable SnapScrollHelper snapScrollHelper,
@Nullable View ntpHeader, @Nullable SectionHeaderView sectionHeaderView,
boolean showDarkBackground, FeedSurfaceDelegate delegate,
@Nullable NativePageNavigationDelegate pageNavigationDelegate, Profile profile,
boolean isPlaceholderShownInitially, BottomSheetController bottomSheetController,
Supplier<ShareDelegate> shareDelegateSupplier,
@Nullable ScrollableContainerDelegate externalScrollableContainerDelegate) {
super(activity, snackbarManager, tabModelSelector, windowAndroid, snapScrollHelper,
ntpHeader, sectionHeaderView, actionOptions, showDarkBackground, delegate,
pageNavigationDelegate, profile, isPlaceholderShownInitially, bottomSheetController,
shareDelegateSupplier, externalScrollableContainerDelegate);
super(activity, snackbarManager, windowAndroid, snapScrollHelper, ntpHeader,
sectionHeaderView, showDarkBackground, delegate, pageNavigationDelegate, profile,
isPlaceholderShownInitially, bottomSheetController, shareDelegateSupplier,
externalScrollableContainerDelegate);
}

@Override
Expand Down Expand Up @@ -77,4 +76,8 @@ void createScrollViewForPolicy() {
mScrollViewForPolicy.setFillViewport(true);
mScrollViewForPolicy.requestFocus();
}

public boolean isEnhancedProtectionPromoEnabled() {
return false;
}
}
5 changes: 5 additions & 0 deletions android/java/apk_for_test.flags
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
*** sortAndFilterUnnecessaryTemplateUrl(...);
}

-keep class org.chromium.chrome.browser.search_engines.settings.SearchEngineSettings {
*** mSearchEngineAdapter;
*** createAdapterIfNecessary(...);
}

-keep class org.chromium.base.CommandLineInitUtil {
*** initCommandLine(...);
}
Expand Down
35 changes: 16 additions & 19 deletions android/java/org/chromium/chrome/browser/BraveHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,27 @@

import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.firstrun.FirstRunStatus;
import org.chromium.chrome.browser.flags.ChromeSwitches;

public class BraveHelper {
public static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO =
public static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO =
"displayed_data_reduction_infobar_promo";
// Used to indicate were the settings migrated to the new
// brave-core based version
public static final String PREF_TABS_SETTINGS_MIGRATED =
// Used to indicate were the settings migrated to the new
// brave-core based version
public static final String PREF_TABS_SETTINGS_MIGRATED =
"android_tabs_settings_to_core_migrated";
// New search engines settings
public static final String PRIVATE_DSE_SHORTNAME = "private_dse_shortname";
public static final String STANDARD_DSE_SHORTNAME = "standard_dse_shortname";

public BraveHelper() {}
public BraveHelper() {}

public static void DisableFREDRP() {
CommandLine.getInstance().appendSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE);
FirstRunStatus.setFirstRunFlowComplete(true);

public static void DisableFREDRP() {
CommandLine.getInstance().appendSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE);
FirstRunStatus.setFirstRunFlowComplete(true);

// Disables data reduction promo dialog
ContextUtils.getAppSharedPreferences()
.edit()
.putBoolean(SHARED_PREF_DISPLAYED_INFOBAR_PROMO, true)
.apply();
}
// Disables data reduction promo dialog
ContextUtils.getAppSharedPreferences()
.edit()
.putBoolean(SHARED_PREF_DISPLAYED_INFOBAR_PROMO, true)
.apply();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ public BraveAppMenuPropertiesDelegateImpl(Context context,
MultiWindowModeStateDispatcher multiWindowModeStateDispatcher,
TabModelSelector tabModelSelector, ToolbarManager toolbarManager, View decorView,
@Nullable OneshotSupplier<OverviewModeBehavior> overviewModeBehaviorSupplier,
ObservableSupplier<BookmarkBridge> bookmarkBridgeSupplier,
ModalDialogManager modalDialogManager, WebFeedBridge webFeedBridge) {
ObservableSupplier<BookmarkBridge> bookmarkBridgeSupplier) {
super(context, activityTabProvider, multiWindowModeStateDispatcher, tabModelSelector,
toolbarManager, decorView, overviewModeBehaviorSupplier, bookmarkBridgeSupplier,
modalDialogManager, webFeedBridge);
toolbarManager, decorView, overviewModeBehaviorSupplier, bookmarkBridgeSupplier);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.chromium.chrome.browser.toolbar.menu_button.BraveMenuButtonCoordinator;
import org.chromium.chrome.browser.ui.appmenu.AppMenuDelegate;
import org.chromium.chrome.browser.ui.appmenu.AppMenuHandler;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.ui.modaldialog.ModalDialogManager;

public class BraveTabbedAppMenuPropertiesDelegate extends TabbedAppMenuPropertiesDelegate {
Expand All @@ -48,10 +49,10 @@ public BraveTabbedAppMenuPropertiesDelegate(Context context,
AppMenuDelegate appMenuDelegate,
OneshotSupplier<OverviewModeBehavior> overviewModeBehaviorSupplier,
ObservableSupplier<BookmarkBridge> bookmarkBridgeSupplier,
ModalDialogManager modalDialogManager, WebFeedBridge webFeedBridge) {
SnackbarManager snackbarManager, WebFeedBridge webFeedBridge) {
super(context, activityTabProvider, multiWindowModeStateDispatcher, tabModelSelector,
toolbarManager, decorView, appMenuDelegate, overviewModeBehaviorSupplier,
bookmarkBridgeSupplier, modalDialogManager, webFeedBridge);
bookmarkBridgeSupplier, snackbarManager, webFeedBridge);

mAppMenuDelegate = appMenuDelegate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@ public static void addOrEditBookmark(@Nullable BookmarkItem existingBookmarkItem
return;
}

boolean isAddToOptionVariation =
CachedFeatureFlags.isEnabled(
ChromeFeatureList.TABBED_APP_OVERFLOW_MENU_THREE_BUTTON_ACTIONBAR)
&& AppMenuPropertiesDelegateImpl.THREE_BUTTON_ACTION_BAR_VARIATION.getValue()
.equals("add_to_option");
if (CachedFeatureFlags.isEnabled(ChromeFeatureList.READ_LATER) && !isAddToOptionVariation) {
if (CachedFeatureFlags.isEnabled(ChromeFeatureList.READ_LATER)) {
// Show a bottom sheet to let the user select target bookmark folder.
showBookmarkBottomSheet(bookmarkModel, tab, snackbarManager, bottomSheetController,
activity, fromCustomTab, callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import androidx.preference.PreferenceViewHolder;

import org.chromium.chrome.R;
import org.chromium.chrome.browser.night_mode.R;

public class BraveRadioButtonGroupThemePreference extends RadioButtonGroupThemePreference {
public BraveRadioButtonGroupThemePreference(Context context, AttributeSet attrs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,20 @@ public BraveNewTabPage(Activity activity,

@Override
protected void initializeMainView(Activity activity, WindowAndroid windowAndroid,
SnackbarManager snackbarManager, TabModelSelector tabModelSelector, NewTabPageUma uma,
boolean isInNightMode, BottomSheetController bottomSheetController,
SnackbarManager snackbarManager, NewTabPageUma uma, boolean isInNightMode,
BottomSheetController bottomSheetController,
ObservableSupplier<ShareDelegate> shareDelegateSupplier) {
super.initializeMainView(activity, windowAndroid, snackbarManager, tabModelSelector, uma,
isInNightMode, bottomSheetController, shareDelegateSupplier);
super.initializeMainView(activity, windowAndroid, snackbarManager, uma, isInNightMode,
bottomSheetController, shareDelegateSupplier);
// Override surface provider
Profile profile = Profile.fromWebContents(mTab.getWebContents());

assert !FeedFeatures.isFeedEnabled();
mFeedSurfaceProvider = new BraveFeedSurfaceCoordinator(activity, snackbarManager,
tabModelSelector, windowAndroid,
new SnapScrollHelper(mNewTabPageManager, mNewTabPageLayout), mNewTabPageLayout,
null, null, isInNightMode, this, mNewTabPageManager.getNavigationDelegate(),
profile, false, bottomSheetController, shareDelegateSupplier, null);
windowAndroid, new SnapScrollHelper(mNewTabPageManager, mNewTabPageLayout),
mNewTabPageLayout, null, isInNightMode, this,
mNewTabPageManager.getNavigationDelegate(), profile,
/* isPlaceholderShownInitially= */ false, bottomSheetController,
shareDelegateSupplier, /* externalScrollableContainerDelegate= */ null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,10 @@ public void startTimer() {
countDownTimer = new Timer();
final Handler handler = new Handler();
countDownTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
@Override
public void run() {
if (BinanceWidgetManager.getInstance()
.isUserAuthenticatedForBinance()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/.

import("//build/config/android/rules.gni")

android_library("java") {
sources = [
"BraveBaseSearchEngineAdapter.java",
"BravePrivateSearchEnginePreference.java",
"BraveSearchEngineAdapter.java",
"BraveSearchEnginePreference.java",
"BraveStandardSearchEnginePreference.java",
]
deps = [
":java_resources",
"//base:base_java",
"//chrome/browser/search_engines/android:java",
"//components/search_engines/android:java",
"//third_party/androidx:androidx_annotation_annotation_java",
]

resources_package = "org.chromium.chrome.browser.search_engines"
}

android_resources("java_resources") {
deps = [
"//brave/build/android:android_brave_strings_grd",
"//chrome/browser/search_engines/android:java_resources",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.chromium.chrome.browser.settings;
package org.chromium.chrome.browser.search_engines.settings;

public class BravePrivateSearchEnginePreference extends BraveSearchEnginePreference {
public BravePrivateSearchEnginePreference() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */

package org.chromium.chrome.browser.search_engines.settings;

import android.content.Context;
import android.content.SharedPreferences;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.chromium.base.ContextUtils;
import org.chromium.chrome.browser.search_engines.R;
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
import org.chromium.components.search_engines.TemplateUrl;

import java.util.List;

public class BraveSearchEngineAdapter extends SearchEngineAdapter {
public static final String PRIVATE_DSE_SHORTNAME = "private_dse_shortname";
public static final String STANDARD_DSE_SHORTNAME = "standard_dse_shortname";

private boolean mIsPrivate;

static public void setDSEPrefs(TemplateUrl templateUrl, boolean isPrivate) {
SharedPreferences.Editor sharedPreferencesEditor =
ContextUtils.getAppSharedPreferences().edit();
sharedPreferencesEditor.putString(
isPrivate ? PRIVATE_DSE_SHORTNAME : STANDARD_DSE_SHORTNAME,
templateUrl.getShortName());
sharedPreferencesEditor.apply();
}

static public void updateActiveDSE(boolean isPrivate) {
TemplateUrl templateUrl = getTemplateUrlByShortName(getDSEShortName(isPrivate));
if (templateUrl == null) {
return;
}
String keyword = templateUrl.getKeyword();
TemplateUrlServiceFactory.get().setSearchEngine(keyword);
}

static public String getDSEShortName(boolean isPrivate) {
String defaultSearchEngineName = null;
TemplateUrl dseTemplateUrl =
TemplateUrlServiceFactory.get().getDefaultSearchEngineTemplateUrl();
if (dseTemplateUrl != null) defaultSearchEngineName = dseTemplateUrl.getShortName();

return ContextUtils.getAppSharedPreferences().getString(
isPrivate ? PRIVATE_DSE_SHORTNAME : STANDARD_DSE_SHORTNAME,
defaultSearchEngineName);
}

static public TemplateUrl getTemplateUrlByShortName(String name) {
List<TemplateUrl> templateUrls = TemplateUrlServiceFactory.get().getTemplateUrls();
for (int index = 0; index < templateUrls.size(); ++index) {
TemplateUrl templateUrl = templateUrls.get(index);
if (templateUrl.getShortName().equals(name)) {
return templateUrl;
}
}
assert false : "This should not happen!";
return null;
}

public BraveSearchEngineAdapter(Context context, boolean isPrivate) {
super(context);
mIsPrivate = isPrivate;
}

@Override
public void onClick(View view) {
super.onClick(view);

if (view.getTag() == null) {
return;
}

TemplateUrl templateUrl = (TemplateUrl) getItem((int) view.getTag());
setDSEPrefs(templateUrl, mIsPrivate);
}

@Override
public void start() {
updateActiveDSE(mIsPrivate);
super.start();
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView url = (TextView) view.findViewById(R.id.url);
if (url != null) {
url.setVisibility(View.GONE);
}
return view;
}
}
Loading

0 comments on commit cb022ac

Please sign in to comment.