Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(730)

Side by Side Diff: chrome/browser/search/one_google_bar/one_google_bar_service_factory.cc

Issue 2811353002: Local NTP: Introduce OneGoogleBarService (Closed)
Patch Set: fix memleak Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/search/one_google_bar/one_google_bar_service_factory.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/google/google_url_tracker_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/one_google_bar/one_google_bar_fetcher_impl.h"
11 #include "chrome/browser/search/one_google_bar/one_google_bar_service.h"
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
13 #include "chrome/browser/signin/signin_manager_factory.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "components/signin/core/browser/profile_oauth2_token_service.h"
16 #include "components/signin/core/browser/signin_manager.h"
17 #include "content/public/browser/browser_context.h"
18
19 // static
20 OneGoogleBarService* OneGoogleBarServiceFactory::GetForProfile(
21 Profile* profile) {
22 return static_cast<OneGoogleBarService*>(
23 GetInstance()->GetServiceForBrowserContext(profile, true));
24 }
25
26 // static
27 OneGoogleBarServiceFactory* OneGoogleBarServiceFactory::GetInstance() {
28 return base::Singleton<OneGoogleBarServiceFactory>::get();
29 }
30
31 OneGoogleBarServiceFactory::OneGoogleBarServiceFactory()
32 : BrowserContextKeyedServiceFactory(
33 "OneGoogleBarService",
34 BrowserContextDependencyManager::GetInstance()) {
35 DependsOn(SigninManagerFactory::GetInstance());
36 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
37 DependsOn(GoogleURLTrackerFactory::GetInstance());
38 }
39
40 OneGoogleBarServiceFactory::~OneGoogleBarServiceFactory() = default;
41
42 KeyedService* OneGoogleBarServiceFactory::BuildServiceInstanceFor(
43 content::BrowserContext* context) const {
44 Profile* profile = Profile::FromBrowserContext(context);
45 SigninManagerBase* signin_manager =
46 SigninManagerFactory::GetForProfile(profile);
47 OAuth2TokenService* token_service =
48 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
49 GoogleURLTracker* google_url_tracker =
50 GoogleURLTrackerFactory::GetForProfile(profile);
51 return new OneGoogleBarService(
52 signin_manager, base::MakeUnique<OneGoogleBarFetcherImpl>(
53 signin_manager, token_service,
54 profile->GetRequestContext(), google_url_tracker));
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698