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

Side by Side Diff: chrome/browser/dom_ui/shown_sections_handler.h

Issue 3304015: Use PrefChangeRegistrar everywhere (Closed)
Patch Set: final version for commit Created 10 years, 2 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_DOM_UI_SHOWN_SECTIONS_HANDLER_H_ 5 #ifndef CHROME_BROWSER_DOM_UI_SHOWN_SECTIONS_HANDLER_H_
6 #define CHROME_BROWSER_DOM_UI_SHOWN_SECTIONS_HANDLER_H_ 6 #define CHROME_BROWSER_DOM_UI_SHOWN_SECTIONS_HANDLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/dom_ui/dom_ui.h" 9 #include "chrome/browser/dom_ui/dom_ui.h"
10 #include "chrome/common/notification_observer.h" 10 #include "chrome/common/notification_observer.h"
11 #include "chrome/browser/prefs/pref_change_registrar.h"
11 12
12 class DOMUI; 13 class DOMUI;
13 class Value; 14 class Value;
14 class PrefService; 15 class PrefService;
15 16
16 // Use for the shown sections bitmask. 17 // Use for the shown sections bitmask.
17 // Currently, only the THUMB and APPS sections can be toggled by the user. Other 18 // Currently, only the THUMB and APPS sections can be toggled by the user. Other
18 // sections are shown automatically if they have data, and hidden otherwise. 19 // sections are shown automatically if they have data, and hidden otherwise.
19 enum Section { 20 enum Section {
20 THUMB = 1, 21 THUMB = 1,
21 APPS = 64 22 APPS = 64
22 }; 23 };
23 24
24 class ShownSectionsHandler : public DOMMessageHandler, 25 class ShownSectionsHandler : public DOMMessageHandler,
25 public NotificationObserver { 26 public NotificationObserver {
26 public: 27 public:
27 explicit ShownSectionsHandler(PrefService* pref_service); 28 explicit ShownSectionsHandler(PrefService* pref_service);
28 virtual ~ShownSectionsHandler(); 29 virtual ~ShownSectionsHandler() {}
29 30
30 // Helper to get the current shown sections. 31 // Helper to get the current shown sections.
31 static int GetShownSections(PrefService* pref_service); 32 static int GetShownSections(PrefService* pref_service);
32 33
33 // DOMMessageHandler implementation. 34 // DOMMessageHandler implementation.
34 virtual void RegisterMessages(); 35 virtual void RegisterMessages();
35 36
36 // NotificationObserver implementation. 37 // NotificationObserver implementation.
37 virtual void Observe(NotificationType type, 38 virtual void Observe(NotificationType type,
38 const NotificationSource& source, 39 const NotificationSource& source,
39 const NotificationDetails& details); 40 const NotificationDetails& details);
40 41
41 // Callback for "getShownSections" message. 42 // Callback for "getShownSections" message.
42 void HandleGetShownSections(const ListValue* args); 43 void HandleGetShownSections(const ListValue* args);
43 44
44 // Callback for "setShownSections" message. 45 // Callback for "setShownSections" message.
45 void HandleSetShownSections(const ListValue* args); 46 void HandleSetShownSections(const ListValue* args);
46 47
47 static void RegisterUserPrefs(PrefService* pref_service); 48 static void RegisterUserPrefs(PrefService* pref_service);
48 49
49 static void MigrateUserPrefs(PrefService* pref_service, 50 static void MigrateUserPrefs(PrefService* pref_service,
50 int old_pref_version, 51 int old_pref_version,
51 int new_pref_version); 52 int new_pref_version);
52 53
53 private: 54 private:
54 PrefService* pref_service_; 55 PrefService* pref_service_;
56 PrefChangeRegistrar registrar_;
55 57
56 DISALLOW_COPY_AND_ASSIGN(ShownSectionsHandler); 58 DISALLOW_COPY_AND_ASSIGN(ShownSectionsHandler);
57 }; 59 };
58 60
59 #endif // CHROME_BROWSER_DOM_UI_SHOWN_SECTIONS_HANDLER_H_ 61 #endif // CHROME_BROWSER_DOM_UI_SHOWN_SECTIONS_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/ntp_resource_cache.cc ('k') | chrome/browser/dom_ui/shown_sections_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698