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

Unified Diff: chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.cc

Issue 13620010: Refactor ResourceRequestAllowedNotifier EULA checking into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.cc
===================================================================
--- chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.cc (revision 0)
+++ chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.cc (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 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/metrics/variations/eula_accepted_notifier_chromeos.h"
+
+#include "chrome/browser/chromeos/login/wizard_controller.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/public/browser/notification_service.h"
+
+EulaAcceptedNotifierChromeos::EulaAcceptedNotifierChromeos() {
+}
+
+EulaAcceptedNotifierChromeos::~EulaAcceptedNotifierChromeos() {
+}
+
+bool EulaAcceptedNotifierChromeos::IsEulaAccepted() {
+ if (chromeos::WizardController::IsEulaAccepted())
+ return true;
+
+ // Register for the notification, if this is the first time.
+ if (registrar_.IsEmpty()) {
+ // Note that this must listen on AllSources due to the difficulty in knowing
+ // when the WizardController instance is created, and to avoid over-coupling
+ // the Chrome OS code with the VariationsService by directly attaching as an
+ // observer. This is OK because WizardController is essentially a singleton.
+ registrar_.Add(this, chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED,
+ content::NotificationService::AllSources());
+ }
+ return false;
+}
+
+void EulaAcceptedNotifierChromeos::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED, type);
+ // This should only ever be received once. Remove it after this call.
+ DCHECK(!registrar_.IsEmpty());
+ registrar_.Remove(this, chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED,
+ content::NotificationService::AllSources());
+
+ NotifyObserver();
+}
+
+// static
+EulaAcceptedNotifier* EulaAcceptedNotifier::Create() {
+#if defined(GOOGLE_CHROME_BUILD)
+ return new EulaAcceptedNotifierChromeos;
+#else
+ return NULL;
+#endif
+}

Powered by Google App Engine
This is Rietveld 408576698