Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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/metrics/variations/eula_accepted_notifier_chromeos.h" | |
| 6 | |
| 7 #include "chrome/browser/chromeos/login/wizard_controller.h" | |
| 8 #include "chrome/common/chrome_notification_types.h" | |
| 9 #include "content/public/browser/notification_service.h" | |
| 10 | |
| 11 EulaAcceptedNotifierChromeos::EulaAcceptedNotifierChromeos() { | |
| 12 } | |
| 13 | |
| 14 EulaAcceptedNotifierChromeos::~EulaAcceptedNotifierChromeos() { | |
| 15 } | |
| 16 | |
| 17 bool EulaAcceptedNotifierChromeos::IsEulaAccepted() { | |
| 18 if (chromeos::WizardController::IsEulaAccepted()) | |
| 19 return true; | |
| 20 | |
| 21 // Register for the notification, if this is the first time. | |
| 22 if (registrar_.IsEmpty()) { | |
| 23 // Note that this must listen on AllSources due to the difficulty in knowing | |
| 24 // when the WizardController instance is created, and to avoid over-coupling | |
| 25 // the Chrome OS code with the VariationsService by directly attaching as an | |
| 26 // observer. This is OK because WizardController is essentially a singleton. | |
| 27 registrar_.Add(this, chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED, | |
| 28 content::NotificationService::AllSources()); | |
|
SteveT
2013/04/05 22:16:41
nit: align content:: with "this" in the line above
Alexei Svitkine (slow)
2013/04/08 14:48:41
Done.
| |
| 29 } | |
| 30 return false; | |
| 31 } | |
| 32 | |
| 33 void EulaAcceptedNotifierChromeos::Observe( | |
| 34 int type, | |
| 35 const content::NotificationSource& source, | |
| 36 const content::NotificationDetails& details) { | |
| 37 DCHECK_EQ(chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED, type); | |
| 38 // This should only ever be received once. Remove it after this call. | |
| 39 DCHECK(!registrar_.IsEmpty()); | |
| 40 registrar_.Remove(this, chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED, | |
| 41 content::NotificationService::AllSources()); | |
| 42 | |
| 43 NotifyObserver(); | |
| 44 } | |
| 45 | |
| 46 // static | |
| 47 EulaAcceptedNotifier* EulaAcceptedNotifier::Create() { | |
| 48 #if defined(GOOGLE_CHROME_BUILD) | |
|
Alexei Svitkine (slow)
2013/04/05 19:13:05
I forgot to check GOOGLE_CHROME_BUILD here earlier
| |
| 49 return new EulaAcceptedNotifierChromeos; | |
| 50 #else | |
| 51 return NULL; | |
| 52 #endif | |
| 53 } | |
| OLD | NEW |