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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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());
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)
49 return new EulaAcceptedNotifierChromeos;
50 #else
51 return NULL;
52 #endif
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698