| OLD | NEW |
| 1 // Copyright (c) 2011 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/ui/webui/ntp/shown_sections_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/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" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 NewCallback(this, &ShownSectionsHandler::HandleSetShownSections)); | 66 NewCallback(this, &ShownSectionsHandler::HandleSetShownSections)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void ShownSectionsHandler::Observe(int type, | 69 void ShownSectionsHandler::Observe(int type, |
| 70 const NotificationSource& source, | 70 const NotificationSource& source, |
| 71 const NotificationDetails& details) { | 71 const NotificationDetails& details) { |
| 72 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 72 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 73 std::string* pref_name = Details<std::string>(details).ptr(); | 73 std::string* pref_name = Details<std::string>(details).ptr(); |
| 74 DCHECK(*pref_name == prefs::kNTPShownSections); | 74 DCHECK(*pref_name == prefs::kNTPShownSections); |
| 75 int sections = pref_service_->GetInteger(prefs::kNTPShownSections); | 75 int sections = pref_service_->GetInteger(prefs::kNTPShownSections); |
| 76 base::FundamentalValue sections_value(sections); | 76 base::NumberValue sections_value(sections); |
| 77 web_ui_->CallJavascriptFunction("setShownSections", sections_value); | 77 web_ui_->CallJavascriptFunction("setShownSections", sections_value); |
| 78 } else { | 78 } else { |
| 79 NOTREACHED(); | 79 NOTREACHED(); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ShownSectionsHandler::HandleSetShownSections(const ListValue* args) { | 83 void ShownSectionsHandler::HandleSetShownSections(const ListValue* args) { |
| 84 double mode_double; | 84 double mode_double; |
| 85 CHECK(args->GetDouble(0, &mode_double)); | 85 CHECK(args->GetDouble(0, &mode_double)); |
| 86 int mode = static_cast<int>(mode_double); | 86 int mode = static_cast<int>(mode_double); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 // Hide any open sections. | 147 // Hide any open sections. |
| 148 mode &= ~ALL_SECTIONS_MASK; | 148 mode &= ~ALL_SECTIONS_MASK; |
| 149 | 149 |
| 150 // Show the apps section. | 150 // Show the apps section. |
| 151 mode |= APPS; | 151 mode |= APPS; |
| 152 | 152 |
| 153 prefs->SetInteger(prefs::kNTPShownSections, mode); | 153 prefs->SetInteger(prefs::kNTPShownSections, mode); |
| 154 } | 154 } |
| 155 } | 155 } |
| OLD | NEW |