Commit 512e25f3 authored by sdefresne's avatar sdefresne Committed by Commit bot

Remove unnecessary overrides and test

SuggestionsServiceFactory::GetForProfile() returns nullptr if
Profile::IsOffTheRecord() is true. So when another factory or
client code use the helper method to get the service, it gets
a nullptr.

The SuggestionsServiceFactory::GetBrowserContextToUse() test
happens only in the GetServiceForBrowserContext() call, and
thus does not happens when client code use this helper method.

The only situation where GetBrowserContextToUse() could be
called is if code directly call GetServiceForBrowserContext
or if ServiceIsCreatedWithBrowserContext() were overridden
to returns true.

Since none of those two conditions are true, then the method
is never called with an off-the-record Profile and the default
implementation inherited from BrowserContextKeyedServiceFactory
does the right thing (i.e. returns nullptr, which in turn cause
GetServiceForBrowserContext to return nullptr).

BUG=None

Review URL: https://codereview.chromium.org/744033002

Cr-Commit-Position: refs/heads/master@{#305059}
parent 9d02b682
...@@ -28,9 +28,6 @@ namespace suggestions { ...@@ -28,9 +28,6 @@ namespace suggestions {
// static // static
SuggestionsService* SuggestionsServiceFactory::GetForProfile(Profile* profile) { SuggestionsService* SuggestionsServiceFactory::GetForProfile(Profile* profile) {
if (profile->IsOffTheRecord())
return NULL;
return static_cast<SuggestionsService*>( return static_cast<SuggestionsService*>(
GetInstance()->GetServiceForBrowserContext(profile, true)); GetInstance()->GetServiceForBrowserContext(profile, true));
} }
...@@ -49,11 +46,6 @@ SuggestionsServiceFactory::SuggestionsServiceFactory() ...@@ -49,11 +46,6 @@ SuggestionsServiceFactory::SuggestionsServiceFactory()
SuggestionsServiceFactory::~SuggestionsServiceFactory() {} SuggestionsServiceFactory::~SuggestionsServiceFactory() {}
content::BrowserContext* SuggestionsServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context);
}
KeyedService* SuggestionsServiceFactory::BuildServiceInstanceFor( KeyedService* SuggestionsServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const { content::BrowserContext* profile) const {
scoped_refptr<base::SequencedTaskRunner> background_task_runner = scoped_refptr<base::SequencedTaskRunner> background_task_runner =
......
...@@ -30,8 +30,6 @@ class SuggestionsServiceFactory : public BrowserContextKeyedServiceFactory { ...@@ -30,8 +30,6 @@ class SuggestionsServiceFactory : public BrowserContextKeyedServiceFactory {
~SuggestionsServiceFactory() override; ~SuggestionsServiceFactory() override;
// Overrides from BrowserContextKeyedServiceFactory: // Overrides from BrowserContextKeyedServiceFactory:
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
KeyedService* BuildServiceInstanceFor( KeyedService* BuildServiceInstanceFor(
content::BrowserContext* profile) const override; content::BrowserContext* profile) const override;
void RegisterProfilePrefs( void RegisterProfilePrefs(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment