Skip to content

Commit

Permalink
Fix #11444: Google accounts should not show in the profile menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jumde committed Aug 30, 2020
1 parent 8786316 commit 762d135
Show file tree
Hide file tree
Showing 22 changed files with 98 additions and 97 deletions.
5 changes: 4 additions & 1 deletion app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion browser/brave_profile_prefs_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cr.define('settings', function() {
isTorManaged() {}
getRestartNeeded() {}
getWeb3ProviderList() {}
wasSignInEnabledAtStartup() {}
}

/**
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ Polymer({
this.browserProxy_.setIPFSCompanionEnabled(this.$.ipfsCompanionEnabled.checked);
},

restartBrowser_: function() {
restartBrowser_: function(e) {
e.stopPropagation();
window.open("chrome://restart", "_self");
},

Expand All @@ -101,5 +102,10 @@ Polymer({
openWebStoreUrl_: function() {
window.open(loadTimeData.getString('getMoreExtensionsUrl'));
},

shouldShowRestartForGoogleLogin_: function(value) {
return this.browserProxy_.wasSignInEnabledAtStartup() != value;
},

});
})();
6 changes: 0 additions & 6 deletions browser/resources/settings/settings_resources_generated.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 1 addition & 11 deletions browser/resources/settings/social_blocking_page/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,13 @@ import("../settings.gni")
group("web_modules") {
public_deps = [
":social_blocking_page_module",
":modules",
]
}

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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});

This file was deleted.

This file was deleted.

22 changes: 22 additions & 0 deletions browser/ui/views/profiles/brave_profile_menu_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions browser/ui/views/profiles/brave_profile_menu_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions chromium_src/chrome/browser/profiles/gaia_info_update_service.cc
Original file line number Diff line number Diff line change
@@ -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;
}
15 changes: 15 additions & 0 deletions chromium_src/chrome/browser/profiles/gaia_info_update_service.h
Original file line number Diff line number Diff line change
@@ -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_
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions chromium_src/chrome/browser/profiles/profiles_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ AvatarToolbarButton::State BraveAvatarToolbarButtonDelegate::GetState() const {
return state;
}

gfx::Image BraveAvatarToolbarButtonDelegate::GetGaiaAccountImage() const {
return gfx::Image();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 762d135

Please sign in to comment.