-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 3650: Enable google sign in for extensions
- Loading branch information
Showing
18 changed files
with
222 additions
and
26 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
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
50 changes: 50 additions & 0 deletions
50
browser/ui/webui/settings/brave_social_blocking_handler.cc
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,50 @@ | ||
/* 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 "brave/browser/ui/webui/settings/brave_social_blocking_handler.h" | ||
|
||
#include <string> | ||
|
||
#include "base/bind.h" | ||
#include "base/values.h" | ||
#include "brave/common/pref_names.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/common/pref_names.h" | ||
#include "components/prefs/pref_service.h" | ||
#include "content/public/browser/web_ui.h" | ||
#include "content/public/browser/web_ui_data_source.h" | ||
|
||
BraveSocialBlockingHandler::BraveSocialBlockingHandler() | ||
: weak_ptr_factory_(this) {} | ||
|
||
BraveSocialBlockingHandler::~BraveSocialBlockingHandler() {} | ||
|
||
void BraveSocialBlockingHandler::RegisterMessages() { | ||
profile_ = Profile::FromWebUI(web_ui()); | ||
web_ui()->RegisterMessageCallback( | ||
"setGoogleLoginEnabled", | ||
base::BindRepeating(&BraveSocialBlockingHandler::SetGoogleLoginEnabled, | ||
base::Unretained(this))); | ||
} | ||
|
||
void BraveSocialBlockingHandler::SetGoogleLoginEnabled( | ||
const base::ListValue* args) { | ||
CHECK_EQ(args->GetSize(), 1U); | ||
CHECK(profile_); | ||
bool enabled; | ||
args->GetBoolean(0, &enabled); | ||
|
||
profile_->GetPrefs()->SetBoolean(prefs::kSigninAllowedOnNextStartup, enabled); | ||
} | ||
|
||
// static | ||
void BraveSocialBlockingHandler::AddLoadTimeData( | ||
content::WebUIDataSource* data_source, | ||
Profile* profile) { | ||
data_source->AddBoolean( | ||
"googleLoginEnabledAtStartup", | ||
profile->GetPrefs()->GetBoolean(prefs::kSigninAllowedOnNextStartup)); | ||
} |
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) 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_BROWSER_UI_WEBUI_SETTINGS_BRAVE_SOCIAL_BLOCKING_HANDLER_H_ | ||
#define BRAVE_BROWSER_UI_WEBUI_SETTINGS_BRAVE_SOCIAL_BLOCKING_HANDLER_H_ | ||
|
||
#include <string> | ||
|
||
#include "base/memory/weak_ptr.h" | ||
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | ||
|
||
class Profile; | ||
|
||
namespace content { | ||
class WebUIDataSource; | ||
} | ||
|
||
class BraveSocialBlockingHandler : public settings::SettingsPageUIHandler { | ||
public: | ||
BraveSocialBlockingHandler(); | ||
~BraveSocialBlockingHandler() override; | ||
static void AddLoadTimeData(content::WebUIDataSource* data_source, | ||
Profile* profile); | ||
|
||
private: | ||
void RegisterMessages() override; | ||
void OnJavascriptAllowed() override {} | ||
void OnJavascriptDisallowed() override {} | ||
|
||
void SetGoogleLoginEnabled(const base::ListValue* args); | ||
|
||
Profile* profile_ = nullptr; | ||
base::WeakPtrFactory<BraveSocialBlockingHandler> weak_ptr_factory_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveSocialBlockingHandler); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_WEBUI_SETTINGS_BRAVE_SOCIAL_BLOCKING_HANDLER_H_ |
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
20 changes: 20 additions & 0 deletions
20
chromium_src/components/signin/internal/identity_manager/primary_account_manager.cc
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,20 @@ | ||
/* 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 "components/signin/internal/identity_manager/primary_account_manager.h" | ||
|
||
#include "extensions/common/url_pattern.h" | ||
#include "google_apis/gaia/gaia_urls.h" | ||
#include "url/gurl.h" | ||
|
||
// Ensures that requests to accounts.google.com is not initiated at startup if | ||
// google login for extensions is enabled | ||
#define BRAVE_NO_GAIA_REQUEST_ON_STARTUP \ | ||
if (account_tracker_service_->GetAccounts().empty()) { \ | ||
return; \ | ||
} \ | ||
|
||
#include "../../../../../../components/signin/internal/identity_manager/primary_account_manager.cc" | ||
#undef BRAVE_NO_GAIA_REQUEST_ON_STARTUP |
13 changes: 13 additions & 0 deletions
13
chromium_src/components/sync/driver/sync_session_durations_metrics_recorder.cc
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,13 @@ | ||
/* 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 "components/sync/driver/sync_session_durations_metrics_recorder.h" | ||
|
||
// Ensures that sync driver metrics are disabled if google login for extensions | ||
// is enabled | ||
#define BRAVE_NO_SYNC_METRICS return; | ||
|
||
#include "../../../../../components/sync/driver/sync_session_durations_metrics_recorder.cc" // NOLINT | ||
#undef BRAVE_NO_SYNC_METRICS |
15 changes: 0 additions & 15 deletions
15
patches/chrome-browser-signin-account_consistency_mode_manager.cc.patch
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
patches/chrome-browser-ui-startup-bad_flags_prompt.cc.patch
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,14 @@ | ||
diff --git a/chrome/browser/ui/startup/bad_flags_prompt.cc b/chrome/browser/ui/startup/bad_flags_prompt.cc | ||
index c8522bc517cb1e7c0c588f786474676295ec1f18..e1f3437ac6205b14d68219cc823dd114127688b3 100644 | ||
--- a/chrome/browser/ui/startup/bad_flags_prompt.cc | ||
+++ b/chrome/browser/ui/startup/bad_flags_prompt.cc | ||
@@ -80,7 +80,9 @@ static const char* kBadFlags[] = { | ||
switches::kIgnoreCertificateErrors, | ||
|
||
// These flags change the URLs that handle PII. | ||
+#if !defined(BRAVE_CHROMIUM_BUILD) | ||
switches::kGaiaUrl, | ||
+#endif | ||
translate::switches::kTranslateScriptURL, | ||
|
||
#if BUILDFLAG(ENABLE_EXTENSIONS) |
12 changes: 12 additions & 0 deletions
12
patches/components-signin-internal-identity_manager-primary_account_manager.cc.patch
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,12 @@ | ||
diff --git a/components/signin/internal/identity_manager/primary_account_manager.cc b/components/signin/internal/identity_manager/primary_account_manager.cc | ||
index aebcdb1d75a1f1ae91a39fa5c8a1087df5e19111..e3c714c83feafc077f687553d7aff9ec54b6bbdc 100644 | ||
--- a/components/signin/internal/identity_manager/primary_account_manager.cc | ||
+++ b/components/signin/internal/identity_manager/primary_account_manager.cc | ||
@@ -126,6 +126,7 @@ void PrimaryAccountManager::Initialize(PrefService* local_state) { | ||
// It is important to only load credentials after starting to observe the | ||
// token service. | ||
token_service_->AddObserver(this); | ||
+ BRAVE_NO_GAIA_REQUEST_ON_STARTUP | ||
token_service_->LoadCredentials(GetAuthenticatedAccountId()); | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
patches/components-sync-driver-sync_session_durations_metrics_recorder.cc.patch
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,12 @@ | ||
diff --git a/components/sync/driver/sync_session_durations_metrics_recorder.cc b/components/sync/driver/sync_session_durations_metrics_recorder.cc | ||
index e8ab17ed1cbaaf50017421d20b0d27eac8388f4f..4a6e81ad4a8662b45baf6d6a5894df0db0723830 100644 | ||
--- a/components/sync/driver/sync_session_durations_metrics_recorder.cc | ||
+++ b/components/sync/driver/sync_session_durations_metrics_recorder.cc | ||
@@ -28,6 +28,7 @@ SyncSessionDurationsMetricsRecorder::SyncSessionDurationsMetricsRecorder( | ||
SyncService* sync_service, | ||
signin::IdentityManager* identity_manager) | ||
: sync_service_(sync_service), identity_manager_(identity_manager) { | ||
+ BRAVE_NO_SYNC_METRICS | ||
// |sync_service| can be null if sync is disabled by a command line flag. | ||
if (sync_service_) { | ||
sync_observer_.Add(sync_service_); |