From 40ddc6f6ccabc5b350102fd865e59ced4b955573 Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Thu, 25 Aug 2016 18:43:08 +0800 Subject: [PATCH] Create stub IdentityProvider fix https://github.com/brave/browser-laptop/issues/3398 auditor: @bridiver --- atom/browser/autofill/atom_autofill_client.cc | 28 ++++++++++++++++++- atom/browser/autofill/atom_autofill_client.h | 4 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/atom/browser/autofill/atom_autofill_client.cc b/atom/browser/autofill/atom_autofill_client.cc index 75cce0dccb..311e012e2e 100644 --- a/atom/browser/autofill/atom_autofill_client.cc +++ b/atom/browser/autofill/atom_autofill_client.cc @@ -17,6 +17,7 @@ #include "components/user_prefs/user_prefs.h" #include "content/public/browser/render_frame_host.h" #include "content/public/common/origin_util.h" +#include "google_apis/gaia/identity_provider.h" #include "native_mate/dictionary.h" DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::AtomAutofillClient); @@ -52,6 +53,28 @@ struct Converter { }; } // namespace mate +class StubIdentityProvider : public IdentityProvider{ + public: + StubIdentityProvider() {} + ~StubIdentityProvider() override {} + + std::string GetActiveUsername() override { + return std::string(); + }; + + std::string GetActiveAccountId() override { + return std::string(); + ;} + + OAuth2TokenService* GetTokenService() override { + return nullptr; + }; + + bool RequestLogin() override { + return false; + }; +}; + namespace autofill { AtomAutofillClient::AtomAutofillClient(content::WebContents* web_contents) @@ -96,7 +119,10 @@ sync_driver::SyncService* AtomAutofillClient::GetSyncService() { } IdentityProvider* AtomAutofillClient::GetIdentityProvider() { - return nullptr; + if (!identity_provider_) { + identity_provider_.reset(new StubIdentityProvider()); + } + return identity_provider_.get(); } rappor::RapporService* AtomAutofillClient::GetRapporService() { diff --git a/atom/browser/autofill/atom_autofill_client.h b/atom/browser/autofill/atom_autofill_client.h index a04c64c67e..71cb35ea35 100644 --- a/atom/browser/autofill/atom_autofill_client.h +++ b/atom/browser/autofill/atom_autofill_client.h @@ -28,6 +28,8 @@ namespace content { class WebContents; } +class IdentityProvider; + namespace autofill { class FormStructure; @@ -91,6 +93,8 @@ class AtomAutofillClient base::WeakPtr delegate_; + std::unique_ptr identity_provider_; + DISALLOW_COPY_AND_ASSIGN(AtomAutofillClient); };