| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 void ShownSectionsHandler::HandleGetShownSections(const ListValue* args) { | 87 void ShownSectionsHandler::HandleGetShownSections(const ListValue* args) { |
| 88 int sections = GetShownSections(pref_service_); | 88 int sections = GetShownSections(pref_service_); |
| 89 FundamentalValue sections_value(sections); | 89 FundamentalValue sections_value(sections); |
| 90 dom_ui_->CallJavascriptFunction(L"onShownSections", sections_value); | 90 dom_ui_->CallJavascriptFunction(L"onShownSections", sections_value); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void ShownSectionsHandler::HandleSetShownSections(const ListValue* args) { | 93 void ShownSectionsHandler::HandleSetShownSections(const ListValue* args) { |
| 94 int mode; | 94 double mode_double; |
| 95 CHECK(ExtractIntegerValue(args, &mode)); | 95 CHECK(args->GetReal(0, &mode_double)); |
| 96 int mode = static_cast<int>(mode_double); |
| 96 int old_mode = pref_service_->GetInteger(prefs::kNTPShownSections); | 97 int old_mode = pref_service_->GetInteger(prefs::kNTPShownSections); |
| 97 | 98 |
| 98 if (old_mode != mode) { | 99 if (old_mode != mode) { |
| 99 NotifySectionDisabled(mode, old_mode, dom_ui_->GetProfile()); | 100 NotifySectionDisabled(mode, old_mode, dom_ui_->GetProfile()); |
| 100 pref_service_->SetInteger(prefs::kNTPShownSections, mode); | 101 pref_service_->SetInteger(prefs::kNTPShownSections, mode); |
| 101 } | 102 } |
| 102 } | 103 } |
| 103 | 104 |
| 104 // static | 105 // static |
| 105 void ShownSectionsHandler::RegisterUserPrefs(PrefService* pref_service) { | 106 void ShownSectionsHandler::RegisterUserPrefs(PrefService* pref_service) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 153 |
| 153 // Hide any open sections. | 154 // Hide any open sections. |
| 154 mode &= ~ALL_SECTIONS_MASK; | 155 mode &= ~ALL_SECTIONS_MASK; |
| 155 | 156 |
| 156 // Show the apps section. | 157 // Show the apps section. |
| 157 mode |= APPS; | 158 mode |= APPS; |
| 158 | 159 |
| 159 prefs->SetInteger(prefs::kNTPShownSections, mode); | 160 prefs->SetInteger(prefs::kNTPShownSections, mode); |
| 160 } | 161 } |
| 161 } | 162 } |
| OLD | NEW |