Merge pull request #6516 from brave/profile_manager

Fix #11444: Google accounts should not show in the profile menu
This commit is contained in:
Pranjal Jumde
2020-08-31 13:56:43 -07:00
committed by GitHub
22 changed files with 98 additions and 97 deletions
+4 -1
View File
@@ -401,7 +401,7 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
Show the number of blocked items on the Shields icon
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_GOOGLE_LOGIN_LABEL" desc="Label for a switch control which allows Google social buttons to be enabled/disabled">
Allow Google login for extensions and third party sites
Allow Google login buttons on third party sites
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_FACEBOOK_EMBEDDED_POSTS_LABEL" desc="Label for a switch control which allows Facebook embedded posts">
Allow Facebook logins and embedded posts
@@ -653,6 +653,9 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
<message name="IDS_SETTINGS_LOAD_CRYPTO_WALLETS_ON_STARTUP" desc="The description for always loading the Crypto Wallets extension on startup">
Load Crypto Wallets on startup
</message>
<message name="IDS_SETTINGS_GOOGLE_LOGIN_FOR_EXTENSIONS" desc="Label for a switch control which allows Google login for extension">
Allow Google login for extensions
</message>
<message name="IDS_SETTINGS_HANGOUTS_ENABLED_DESC" desc="The description for Hangouts switch in settings">
Uses Hangouts component to enable screen sharing and other features in the browser.
</message>
+1 -1
View File
@@ -124,7 +124,7 @@ IN_PROC_BROWSER_TEST_F(BraveProfilePrefsBrowserTest,
EXPECT_EQ(browser()->profile()->GetPrefs()->GetInteger(
prefs::kNetworkPredictionOptions),
chrome_browser_net::NETWORK_PREDICTION_NEVER);
EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
prefs::kSigninAllowedOnNextStartup));
// Verify cloud print is disabled.
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
@@ -21,6 +21,7 @@ cr.define('settings', function() {
isTorManaged() {}
getRestartNeeded() {}
getWeb3ProviderList() {}
wasSignInEnabledAtStartup() {}
}
/**
@@ -59,6 +60,9 @@ cr.define('settings', function() {
getWeb3ProviderList() {
return new Promise(resolve => chrome.braveWallet.getWeb3ProviderList(resolve))
}
wasSignInEnabledAtStartup() {
return loadTimeData.getBoolean('signInAllowedOnNextStartupInitialValue');
}
}
cr.addSingletonGetter(BraveDefaultExtensionsBrowserProxyImpl);
@@ -78,6 +78,18 @@
pref="{{prefs.brave.wallet.load_on_startup}}"
label="$i18n{loadCryptoWalletsOnStartupDesc}">
</settings-toggle-button>
<settings-toggle-button id="googleLoginForExtensions"
class="cr-row"
pref="{{prefs.signin.allowed_on_next_startup}}"
learn-more-url="$i18n{googleLoginLearnMoreURL}"
label="$i18n{googleLoginForExtensionsDesc}">
<template is="dom-if" if="[[shouldShowRestartForGoogleLogin_(
prefs.signin.allowed_on_next_startup.value)]]">
<cr-button on-click="restartBrowser_" slot="more-actions">
$i18n{restart}
</cr-button>
</template>
</settings-toggle-button>
<settings-toggle-button id="hangoutsEnabled"
class="cr-row"
pref="{{prefs.brave.hangouts_enabled}}"
@@ -78,7 +78,8 @@ Polymer({
this.browserProxy_.setIPFSCompanionEnabled(this.$.ipfsCompanionEnabled.checked);
},
restartBrowser_: function() {
restartBrowser_: function(e) {
e.stopPropagation();
window.open("chrome://restart", "_self");
},
@@ -101,5 +102,10 @@ Polymer({
openWebStoreUrl_: function() {
window.open(loadTimeData.getString('getMoreExtensionsUrl'));
},
shouldShowRestartForGoogleLogin_: function(value) {
return this.browserProxy_.wasSignInEnabledAtStartup() != value;
},
});
})();
@@ -115,12 +115,6 @@
preprocess="true"
compress="false"
type="BINDATA" />
<include name="IDR_SETTINGS_SOCIAL_BLOCKING_PAGE_PROXY_M_JS"
file="${root_gen_dir}/brave/browser/resources/settings/social_blocking_page/social_blocking_page_proxy.m.js"
use_base_dir="false"
preprocess="true"
compress="false"
type="BINDATA" />
<include name="IDR_SETTINGS_SOCIAL_BLOCKING_PAGE_M_JS"
file="${root_gen_dir}/brave/browser/resources/settings/social_blocking_page/social_blocking_page.m.js"
use_base_dir="false"
@@ -13,7 +13,6 @@ import("../settings.gni")
group("web_modules") {
public_deps = [
":social_blocking_page_module",
":modules",
]
}
@@ -21,15 +20,6 @@ polymer_modulizer("social_blocking_page") {
js_file = "social_blocking_page.js"
html_file = "social_blocking_page.html"
html_type = "dom-module"
auto_imports = settings_auto_imports + [
"brave/browser/resources/settings/social_blocking_page/social_blocking_page_proxy.html|SocialBlockingPageProxyImpl",
]
namespace_rewrites = settings_namespace_rewrites
}
js_modulizer("modules") {
input_files = [
"social_blocking_page_proxy.js",
]
auto_imports = settings_auto_imports
namespace_rewrites = settings_namespace_rewrites
}
@@ -2,7 +2,6 @@
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/md_select_css.html">
<link rel="import" href="social_blocking_page_proxy.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="../settings_vars_css.html">
@@ -7,34 +7,5 @@
* social blocking options
*/
Polymer({
is: 'settings-social-blocking-page',
properties: {},
/** @private {?settings.SocialBlockingPageProxy} */
browserProxy_: null,
/** @override */
created: function() {
this.browserProxy_ = settings.SocialBlockingPageProxyImpl.getInstance();
},
/** @override */
ready: function() {
this.shouldShowRestart_ = this.shouldShowRestart_.bind(this)
this.restartBrowser_ = this.restartBrowser_.bind(this)
},
shouldShowRestart_: function(value) {
return this.browserProxy_.wasSignInEnabledAtStartup() != value;
},
setSignInEnabledAtNextStartup_: function() {
this.browserProxy_.setSignInEnabledAtNextStartup(this.$.googleLoginControlType.checked);
},
restartBrowser_: function(e) {
e.stopPropagation();
window.open("chrome://restart", "_self");
},
is: 'settings-social-blocking-page'
});
@@ -1,2 +0,0 @@
<link rel="href" src="chrome://resources/html/cr.html">
<script src="social_blocking_page_proxy.js"></script>
@@ -1,43 +0,0 @@
/* Copyright (c) 2020 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/. */
// clang-format off
// #import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js';
// clang-format on
cr.define('settings', function() {
/** @interface */
class SocialBlockingPageProxy {
/**
* @param {boolean} enabled (true/false).
*/
setSignInEnabledAtNextStartup(value) {}
/**
* @return {boolean}
*/
wasSignInEnabledAtStartup() {}
}
/**
* @implements {settings.SocialBlockingPageProxy}
*/
/* #export */ class SocialBlockingPageProxyImpl {
setSignInEnabledAtNextStartup(value) {
chrome.settingsPrivate.setPref('signin.allowed_on_next_startup', value);
}
wasSignInEnabledAtStartup() {
return loadTimeData.getBoolean('signInAllowedOnNextStartupInitialValue');
}
}
cr.addSingletonGetter(SocialBlockingPageProxyImpl);
// #cr_define_end
return {
SocialBlockingPageProxy: SocialBlockingPageProxy,
SocialBlockingPageProxyImpl: SocialBlockingPageProxyImpl,
};
});
@@ -9,10 +9,16 @@
#include <utility>
#include "brave/browser/profiles/profile_util.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/grit/generated_resources.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
void BraveProfileMenuView::BuildIdentity() {
ProfileMenuView::BuildIdentity();
@@ -33,6 +39,22 @@ void BraveProfileMenuView::BuildAutofillButtons() {}
// We don't want to show any Chromium sync info.
void BraveProfileMenuView::BuildSyncInfo() {}
// We don't want feature buttons to manage google account
void BraveProfileMenuView::BuildFeatureButtons() {
Profile* profile = browser()->profile();
int window_count = chrome::GetBrowserCount(profile);
if (!profile->IsOffTheRecord() && profile->HasPrimaryOTRProfile())
window_count += chrome::GetBrowserCount(profile->GetPrimaryOTRProfile());
if (window_count > 1) {
AddFeatureButton(
l10n_util::GetPluralStringFUTF16(IDS_PROFILES_CLOSE_X_WINDOWS_BUTTON,
window_count),
base::BindRepeating(&ProfileMenuView::OnExitProfileButtonClicked,
base::Unretained(this)),
vector_icons::kCloseIcon);
}
}
gfx::ImageSkia BraveProfileMenuView::GetSyncIcon() const {
// We don't need sync overlay.
return gfx::ImageSkia();
@@ -22,6 +22,7 @@ class BraveProfileMenuView : public ProfileMenuView {
void BuildIdentity() override;
void BuildAutofillButtons() override;
void BuildSyncInfo() override;
void BuildFeatureButtons() override;
gfx::ImageSkia GetSyncIcon() const override;
DISALLOW_COPY_AND_ASSIGN(BraveProfileMenuView);
@@ -0,0 +1,15 @@
/* Copyright (c) 2020 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/. */
#include "chrome/browser/profiles/gaia_info_update_service.h"
#define ShouldUseGAIAProfileInfo ShouldUseGAIAProfileInfo_ChromiumImpl
#include "../../../../../chrome/browser/profiles/gaia_info_update_service.cc"
#undef ShouldUseGAIAProfileInfo
// static
bool GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(Profile* profile) {
return false;
}
@@ -0,0 +1,15 @@
/* Copyright (c) 2020 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/. */
#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_H_
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_H_
#define ShouldUseGAIAProfileInfo \
ShouldUseGAIAProfileInfo_ChromiumImpl(Profile* profile); \
static bool ShouldUseGAIAProfileInfo
#include "../../../../../chrome/browser/profiles/gaia_info_update_service.h"
#undef ShouldUseGAIAProfileInfo
#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_H_
@@ -40,6 +40,9 @@ void RegisterProfilePrefs(bool is_signin_profile,
// Disable spell check service
registry->SetDefaultPrefValue(
spellcheck::prefs::kSpellCheckUseSpellingService, base::Value(false));
registry->SetDefaultPrefValue(prefs::kSigninAllowedOnNextStartup,
base::Value(false));
#if defined(OS_LINUX)
// Use brave theme by default instead of gtk theme.
registry->SetDefaultPrefValue(prefs::kUsesSystemTheme, base::Value(false));
@@ -6,6 +6,7 @@
#include "brave/browser/profiles/brave_profile_manager.h"
#include "brave/browser/profiles/profile_util.h"
#include "ui/gfx/text_elider.h"
#define GetAvatarNameForProfile GetAvatarNameForProfile_ChromiumImpl
#include "../../../../../chrome/browser/profiles/profiles_state.cc"
#undef GetAvatarNameForProfile
@@ -7,7 +7,9 @@
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_TOOLBAR_BUTTON_H_
#define GetAvatarIcon virtual GetAvatarIcon
#define AvatarToolbarButtonDelegate BraveAvatarToolbarButtonDelegate
#include "../../../../../../../chrome/browser/ui/views/profiles/avatar_toolbar_button.h"
#undef AvatarToolbarButtonDelegate
#undef GetAvatarIcon
#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_TOOLBAR_BUTTON_H_
@@ -31,3 +31,6 @@ AvatarToolbarButton::State BraveAvatarToolbarButtonDelegate::GetState() const {
return state;
}
gfx::Image BraveAvatarToolbarButtonDelegate::GetGaiaAccountImage() const {
return gfx::Image();
}
@@ -33,6 +33,7 @@ class BraveAvatarToolbarButtonDelegate : public AvatarToolbarButtonDelegate {
~BraveAvatarToolbarButtonDelegate() override = default;
void Init(AvatarToolbarButton* button, Profile* profile) override;
gfx::Image GetGaiaAccountImage() const;
AvatarToolbarButton::State GetState() const override;
private:
@@ -13,8 +13,10 @@
#define BuildAutofillButtons virtual BuildAutofillButtons
#define BuildIdentity virtual BuildIdentity
#define BuildSyncInfo virtual BuildSyncInfo
#define BuildFeatureButtons virtual BuildFeatureButtons
#include "../../../../../../../chrome/browser/ui/views/profiles/profile_menu_view.h"
#undef BuildFeatureButtons
#undef BuildSyncInfo
#undef BuildIdentity
#undef BuildAutofillButtons
@@ -46,7 +46,7 @@ const char kBraveReleaseTagPrefix[] =
"https://github.com/brave/brave-browser/releases/tag/v";
const char kGoogleLoginLearnMoreURL[] =
"https://github.com/brave/brave-browser/wiki/"
"Social-Blocking:-Allow-Google-login";
"Allow-Google-login---Third-Parties-and-Extensions";
void BraveAddCommonStrings(content::WebUIDataSource* html_source,
Profile* profile) {
@@ -267,6 +267,8 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_BRAVE_WEB3_PROVIDER_DESC},
{"loadCryptoWalletsOnStartupDesc",
IDS_SETTINGS_LOAD_CRYPTO_WALLETS_ON_STARTUP},
{"googleLoginForExtensionsDesc",
IDS_SETTINGS_GOOGLE_LOGIN_FOR_EXTENSIONS},
{"hangoutsEnabledDesc",
IDS_SETTINGS_HANGOUTS_ENABLED_DESC},
{"ipfsCompanionEnabledDesc",