• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef CHROME_BROWSER_UI_OPTIONS_OPTIONS_PAGE_BASE_H_
6 #define CHROME_BROWSER_UI_OPTIONS_OPTIONS_PAGE_BASE_H_
7 #pragma once
8 
9 #include <string>
10 
11 #include "base/basictypes.h"
12 #include "chrome/browser/metrics/user_metrics.h"
13 #include "chrome/browser/ui/options/options_window.h"
14 #include "content/common/notification_observer.h"
15 
16 class PrefService;
17 class Profile;
18 struct UserMetricsAction;
19 
20 ///////////////////////////////////////////////////////////////////////////////
21 // OptionsPageBase
22 //
23 //  A base class for Options dialog pages that handles observing preferences
24 //
25 class OptionsPageBase : public NotificationObserver {
26  public:
27   virtual ~OptionsPageBase();
28 
29   // Highlights the specified group to attract the user's attention.
HighlightGroup(OptionsGroup highlight_group)30   virtual void HighlightGroup(OptionsGroup highlight_group) { }
31 
32   // Overridden from NotificationObserver:
33   virtual void Observe(NotificationType type,
34                        const NotificationSource& source,
35                        const NotificationDetails& details);
36 
37  protected:
38   // This class cannot be instantiated directly, but its constructor must be
39   // called by derived classes.
40   explicit OptionsPageBase(Profile* profile);
41 
42   // Returns the Profile associated with this page.
profile()43   Profile* profile() const { return profile_; }
44 
45   // Records a user action and schedules the prefs file to be saved.
46   void UserMetricsRecordAction(const UserMetricsAction &action,
47                                PrefService* prefs);
48 
49   // Allows the UI to update when a preference value changes. The parameter is
50   // the specific pref that changed, or NULL if all pref UI should be
51   // validated. This should be called during setup, but with NULL as the
52   // parameter to allow initial state to be set.
NotifyPrefChanged(const std::string * pref_name)53   virtual void NotifyPrefChanged(const std::string* pref_name) {}
54 
55  private:
56   // The Profile associated with this page.
57   Profile* profile_;
58 
59   DISALLOW_COPY_AND_ASSIGN(OptionsPageBase);
60 };
61 
62 #endif  // CHROME_BROWSER_UI_OPTIONS_OPTIONS_PAGE_BASE_H_
63