| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 | 11 |
| 12 ShownSectionsHandler::ShownSectionsHandler(DOMUI* dom_ui) | 12 void ShownSectionsHandler::RegisterMessages() { |
| 13 : DOMMessageHandler(dom_ui), | 13 dom_ui_->RegisterMessageCallback("getShownSections", |
| 14 dom_ui_(dom_ui) { | |
| 15 dom_ui->RegisterMessageCallback("getShownSections", | |
| 16 NewCallback(this, &ShownSectionsHandler::HandleGetShownSections)); | 14 NewCallback(this, &ShownSectionsHandler::HandleGetShownSections)); |
| 17 dom_ui->RegisterMessageCallback("setShownSections", | 15 dom_ui_->RegisterMessageCallback("setShownSections", |
| 18 NewCallback(this, &ShownSectionsHandler::HandleSetShownSections)); | 16 NewCallback(this, &ShownSectionsHandler::HandleSetShownSections)); |
| 19 } | 17 } |
| 20 | 18 |
| 21 void ShownSectionsHandler::HandleGetShownSections(const Value* value) { | 19 void ShownSectionsHandler::HandleGetShownSections(const Value* value) { |
| 22 const int mode = dom_ui_->GetProfile()->GetPrefs()-> | 20 const int mode = dom_ui_->GetProfile()->GetPrefs()-> |
| 23 GetInteger(prefs::kNTPShownSections); | 21 GetInteger(prefs::kNTPShownSections); |
| 24 FundamentalValue* mode_value = new FundamentalValue(mode); | 22 FundamentalValue* mode_value = new FundamentalValue(mode); |
| 25 dom_ui_->CallJavascriptFunction(L"onShownSections", *mode_value); | 23 dom_ui_->CallJavascriptFunction(L"onShownSections", *mode_value); |
| 26 } | 24 } |
| 27 | 25 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 45 dom_ui_->GetProfile()->GetPrefs()->SetInteger( | 43 dom_ui_->GetProfile()->GetPrefs()->SetInteger( |
| 46 prefs::kNTPShownSections, StringToInt(mode_string)); | 44 prefs::kNTPShownSections, StringToInt(mode_string)); |
| 47 } | 45 } |
| 48 | 46 |
| 49 // static | 47 // static |
| 50 void ShownSectionsHandler::RegisterUserPrefs(PrefService* prefs) { | 48 void ShownSectionsHandler::RegisterUserPrefs(PrefService* prefs) { |
| 51 prefs->RegisterIntegerPref(prefs::kNTPShownSections, | 49 prefs->RegisterIntegerPref(prefs::kNTPShownSections, |
| 52 THUMB | RECENT | TIPS); | 50 THUMB | RECENT | TIPS); |
| 53 } | 51 } |
| 54 | 52 |
| OLD | NEW |