| Index: chrome/browser/chromeos/policy/consumer_management_notification_factory.cc
|
| diff --git a/chrome/browser/chromeos/policy/consumer_management_notification_factory.cc b/chrome/browser/chromeos/policy/consumer_management_notification_factory.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4636604e8ec804fb4a4a73a797378e6efe84a248
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/policy/consumer_management_notification_factory.cc
|
| @@ -0,0 +1,63 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/chromeos/policy/consumer_management_notification_factory.h"
|
| +
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/browser_process_platform_part.h"
|
| +#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
|
| +#include "chrome/browser/chromeos/policy/consumer_management_notification.h"
|
| +#include "chrome/browser/chromeos/profiles/profile_helper.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
| +
|
| +namespace policy {
|
| +
|
| +// static
|
| +ConsumerManagementNotification*
|
| +ConsumerManagementNotificationFactory::GetForBrowserContext(
|
| + content::BrowserContext* context) {
|
| + return static_cast<ConsumerManagementNotification*>(
|
| + GetInstance()->GetServiceForBrowserContext(context, true));
|
| +}
|
| +
|
| +// static
|
| +ConsumerManagementNotificationFactory*
|
| +ConsumerManagementNotificationFactory::GetInstance() {
|
| + return Singleton<ConsumerManagementNotificationFactory>::get();
|
| +}
|
| +
|
| +ConsumerManagementNotificationFactory::ConsumerManagementNotificationFactory()
|
| + : BrowserContextKeyedServiceFactory(
|
| + "ConsumerManagementNotification",
|
| + BrowserContextDependencyManager::GetInstance()) {
|
| +}
|
| +
|
| +ConsumerManagementNotificationFactory::~ConsumerManagementNotificationFactory()
|
| +{
|
| +}
|
| +
|
| +KeyedService* ConsumerManagementNotificationFactory::BuildServiceInstanceFor(
|
| + content::BrowserContext* context) const {
|
| + // On a fresh device, the first time the owner signs in, IsOwnerProfile()
|
| + // will return false. But it is okay since there's no notification to show.
|
| + Profile* profile = Profile::FromBrowserContext(context);
|
| + if (!chromeos::ProfileHelper::IsOwnerProfile(profile))
|
| + return nullptr;
|
| +
|
| + ConsumerManagementService* service =
|
| + g_browser_process->platform_part()->browser_policy_connector_chromeos()->
|
| + GetConsumerManagementService();
|
| + if (!service)
|
| + return nullptr;
|
| +
|
| + return new ConsumerManagementNotification(profile, service);
|
| +}
|
| +
|
| +bool ConsumerManagementNotificationFactory::ServiceIsCreatedWithBrowserContext()
|
| + const {
|
| + return true;
|
| +}
|
| +
|
| +} // namespace policy
|
|
|