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

Unified 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698