1// Copyright (c) 2011 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/ui/options/options_page_base.h"
6
7#include "chrome/browser/metrics/user_metrics.h"
8#include "chrome/browser/prefs/pref_service.h"
9#include "content/common/notification_details.h"
10#include "content/common/notification_source.h"
11#include "content/common/notification_type.h"
12
13///////////////////////////////////////////////////////////////////////////////
14// OptionsPageBase
15
16OptionsPageBase::OptionsPageBase(Profile* profile)
17    : profile_(profile) {
18}
19
20OptionsPageBase::~OptionsPageBase() {
21}
22
23void OptionsPageBase::UserMetricsRecordAction(const UserMetricsAction& action,
24                                              PrefService* prefs) {
25  UserMetrics::RecordAction(action, profile());
26  if (prefs)
27    prefs->ScheduleSavePersistentPrefs();
28}
29
30///////////////////////////////////////////////////////////////////////////////
31// OptionsPageBase, NotificationObserver implementation:
32
33void OptionsPageBase::Observe(NotificationType type,
34                              const NotificationSource& source,
35                              const NotificationDetails& details) {
36  if (type == NotificationType::PREF_CHANGED)
37    NotifyPrefChanged(Details<std::string>(details).ptr());
38}
39