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

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

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 #include "chrome/browser/dom_ui/shown_sections_handler.h" 5 #include "chrome/browser/dom_ui/shown_sections_handler.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 30 matching lines...) Expand all
41 41
42 } // namespace 42 } // namespace
43 43
44 // static 44 // static
45 int ShownSectionsHandler::GetShownSections(PrefService* prefs) { 45 int ShownSectionsHandler::GetShownSections(PrefService* prefs) {
46 return prefs->GetInteger(prefs::kNTPShownSections); 46 return prefs->GetInteger(prefs::kNTPShownSections);
47 } 47 }
48 48
49 ShownSectionsHandler::ShownSectionsHandler(PrefService* pref_service) 49 ShownSectionsHandler::ShownSectionsHandler(PrefService* pref_service)
50 : pref_service_(pref_service) { 50 : pref_service_(pref_service) {
51 pref_service_->AddPrefObserver(prefs::kNTPShownSections, this); 51 registrar_.Init(pref_service);
52 } 52 registrar_.Add(prefs::kNTPShownSections, this);
53
54 ShownSectionsHandler::~ShownSectionsHandler() {
55 pref_service_->RemovePrefObserver(prefs::kNTPShownSections, this);
56 } 53 }
57 54
58 void ShownSectionsHandler::RegisterMessages() { 55 void ShownSectionsHandler::RegisterMessages() {
59 dom_ui_->RegisterMessageCallback("getShownSections", 56 dom_ui_->RegisterMessageCallback("getShownSections",
60 NewCallback(this, &ShownSectionsHandler::HandleGetShownSections)); 57 NewCallback(this, &ShownSectionsHandler::HandleGetShownSections));
61 dom_ui_->RegisterMessageCallback("setShownSections", 58 dom_ui_->RegisterMessageCallback("setShownSections",
62 NewCallback(this, &ShownSectionsHandler::HandleSetShownSections)); 59 NewCallback(this, &ShownSectionsHandler::HandleSetShownSections));
63 } 60 }
64 61
65 void ShownSectionsHandler::Observe(NotificationType type, 62 void ShownSectionsHandler::Observe(NotificationType type,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 shown_sections = APPS; 108 shown_sections = APPS;
112 else 109 else
113 shown_sections = THUMB; 110 shown_sections = THUMB;
114 111
115 changed = true; 112 changed = true;
116 } 113 }
117 114
118 if (changed) 115 if (changed)
119 pref_service->SetInteger(prefs::kNTPShownSections, shown_sections); 116 pref_service->SetInteger(prefs::kNTPShownSections, shown_sections);
120 } 117 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/shown_sections_handler.h ('k') | chrome/browser/extensions/extension_toolbar_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698