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

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

Issue 16129004: Consolidate EulaAcceptedNotifier implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 7 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_mobile.cc
===================================================================
--- chrome/browser/metrics/variations/eula_accepted_notifier_mobile.cc (revision 203226)
+++ chrome/browser/metrics/variations/eula_accepted_notifier_mobile.cc (working copy)
@@ -1,51 +0,0 @@
-// 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_mobile.h"
-
-#include "base/bind.h"
-#include "base/prefs/pref_service.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/common/pref_names.h"
-
-EulaAcceptedNotifierMobile::EulaAcceptedNotifierMobile(
- PrefService* local_state)
- : local_state_(local_state) {
-}
-
-EulaAcceptedNotifierMobile::~EulaAcceptedNotifierMobile() {
-}
-
-bool EulaAcceptedNotifierMobile::IsEulaAccepted() {
- if (local_state_->GetBoolean(prefs::kEulaAccepted))
- return true;
-
- // Register for the notification, if this is the first time.
- if (registrar_.IsEmpty()) {
- registrar_.Init(local_state_);
- registrar_.Add(prefs::kEulaAccepted,
- base::Bind(&EulaAcceptedNotifierMobile::OnPrefChanged,
- base::Unretained(this)));
- }
- return false;
-}
-
-void EulaAcceptedNotifierMobile::OnPrefChanged() {
- DCHECK(!registrar_.IsEmpty());
- registrar_.RemoveAll();
-
- DCHECK(local_state_->GetBoolean(prefs::kEulaAccepted));
- NotifyObserver();
-}
-
-// static
-EulaAcceptedNotifier* EulaAcceptedNotifier::Create() {
- PrefService* local_state = g_browser_process->local_state();
- // If the |kEulaAccepted| pref is not registered, return NULL which is
- // equivalent to not needing to check the EULA. This is the case for some
- // tests for higher-level classes that use the EulaAcceptNotifier.
- if (local_state->FindPreference(prefs::kEulaAccepted) == NULL)
- return NULL;
- return new EulaAcceptedNotifierMobile(local_state);
-}

Powered by Google App Engine
This is Rietveld 408576698