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

Side by Side Diff: ios/chrome/browser/desktop_promotion/desktop_promotion_sync_service_factory.cc

Issue 2643723004: Add Desktop iOS promotion logging to chrome ios app. (Closed)
Patch Set: browser_state keyed service Created 3 years, 10 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 "ios/chrome/browser/desktop_promotion/desktop_promotion_sync_service_fa ctory.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "components/browser_sync/profile_sync_service.h"
9 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
10 #include "components/prefs/pref_service.h"
11 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
12 #include "ios/chrome/browser/desktop_promotion/desktop_promotion_sync_observer.h "
13 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
14
15 class DesktopPromotionSyncService : public KeyedService {
16 public:
17 DesktopPromotionSyncService(PrefService* pref_service,
18 browser_sync::ProfileSyncService* sync_service);
19 ~DesktopPromotionSyncService() override;
20
21 private:
22 DesktopPromotionSyncObserver observer_;
23 };
24
25 DesktopPromotionSyncService::DesktopPromotionSyncService(
26 PrefService* pref_service,
27 browser_sync::ProfileSyncService* sync_service)
28 : observer_(pref_service, sync_service) {}
29
30 DesktopPromotionSyncService::~DesktopPromotionSyncService() = default;
31
32 // static
33 DesktopPromotionSyncService*
34 DesktopPromotionSyncServiceFactory::GetForBrowserState(
35 ios::ChromeBrowserState* browser_state) {
36 return static_cast<DesktopPromotionSyncService*>(
37 GetInstance()->GetServiceForBrowserState(browser_state, true));
38 }
39
40 // static
41 DesktopPromotionSyncServiceFactory*
42 DesktopPromotionSyncServiceFactory::GetInstance() {
43 return base::Singleton<DesktopPromotionSyncServiceFactory>::get();
44 }
45
46 DesktopPromotionSyncServiceFactory::DesktopPromotionSyncServiceFactory()
47 : BrowserStateKeyedServiceFactory(
48 "DesktopPromotionSyncService",
49 BrowserStateDependencyManager::GetInstance()) {
50 DependsOn(IOSChromeProfileSyncServiceFactory::GetInstance());
51 }
52
53 DesktopPromotionSyncServiceFactory::~DesktopPromotionSyncServiceFactory() =
54 default;
55
56 std::unique_ptr<KeyedService>
57 DesktopPromotionSyncServiceFactory::BuildServiceInstanceFor(
58 web::BrowserState* context) const {
59 ios::ChromeBrowserState* browser_state =
60 ios::ChromeBrowserState::FromBrowserState(context);
61 return base::MakeUnique<DesktopPromotionSyncService>(
62 browser_state->GetPrefs(),
63 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state));
64 }
65
66 bool DesktopPromotionSyncServiceFactory::ServiceIsNULLWhileTesting() const {
67 return true;
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698