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

Side by Side Diff: chrome/browser/chromeos/policy/consumer_management_notification_factory.cc

Issue 733613005: Move the notification part out of ConsumerEnrollmentHandler so that it can be reused for unenrollme… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@enroll
Patch Set: Created 6 years, 1 month 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 2014 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/chromeos/policy/consumer_management_notification_factor y.h"
6
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/browser_process_platform_part.h"
9 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
10 #include "chrome/browser/chromeos/policy/consumer_management_notification.h"
11 #include "chrome/browser/chromeos/profiles/profile_helper.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14
15 namespace policy {
16
17 // static
18 ConsumerManagementNotification*
19 ConsumerManagementNotificationFactory::GetForBrowserContext(
20 content::BrowserContext* context) {
21 return static_cast<ConsumerManagementNotification*>(
22 GetInstance()->GetServiceForBrowserContext(context, true));
23 }
24
25 // static
26 ConsumerManagementNotificationFactory*
27 ConsumerManagementNotificationFactory::GetInstance() {
28 return Singleton<ConsumerManagementNotificationFactory>::get();
29 }
30
31 ConsumerManagementNotificationFactory::ConsumerManagementNotificationFactory()
32 : BrowserContextKeyedServiceFactory(
33 "ConsumerManagementNotification",
34 BrowserContextDependencyManager::GetInstance()) {
35 }
36
37 ConsumerManagementNotificationFactory::~ConsumerManagementNotificationFactory()
38 {
39 }
40
41 KeyedService* ConsumerManagementNotificationFactory::BuildServiceInstanceFor(
42 content::BrowserContext* context) const {
43 // On a fresh device, the first time the owner signs in, IsOwnerProfile()
44 // will return false. But it is okay since there's no notification to show.
45 Profile* profile = Profile::FromBrowserContext(context);
46 if (!chromeos::ProfileHelper::IsOwnerProfile(profile))
47 return nullptr;
48
49 ConsumerManagementService* service =
50 g_browser_process->platform_part()->browser_policy_connector_chromeos()->
51 GetConsumerManagementService();
52 if (!service)
53 return nullptr;
54
55 return new ConsumerManagementNotification(profile, service);
56 }
57
58 bool ConsumerManagementNotificationFactory::ServiceIsCreatedWithBrowserContext()
59 const {
60 return true;
61 }
62
63 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698