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/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" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 double mode_double; | 94 double mode_double; |
95 CHECK(args->GetReal(0, &mode_double)); | 95 CHECK(args->GetDouble(0, &mode_double)); |
96 int mode = static_cast<int>(mode_double); | 96 int mode = static_cast<int>(mode_double); |
97 int old_mode = pref_service_->GetInteger(prefs::kNTPShownSections); | 97 int old_mode = pref_service_->GetInteger(prefs::kNTPShownSections); |
98 | 98 |
99 if (old_mode != mode) { | 99 if (old_mode != mode) { |
100 NotifySectionDisabled(mode, old_mode, dom_ui_->GetProfile()); | 100 NotifySectionDisabled(mode, old_mode, dom_ui_->GetProfile()); |
101 pref_service_->SetInteger(prefs::kNTPShownSections, mode); | 101 pref_service_->SetInteger(prefs::kNTPShownSections, mode); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 // static | 105 // static |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 // Hide any open sections. | 154 // Hide any open sections. |
155 mode &= ~ALL_SECTIONS_MASK; | 155 mode &= ~ALL_SECTIONS_MASK; |
156 | 156 |
157 // Show the apps section. | 157 // Show the apps section. |
158 mode |= APPS; | 158 mode |= APPS; |
159 | 159 |
160 prefs->SetInteger(prefs::kNTPShownSections, mode); | 160 prefs->SetInteger(prefs::kNTPShownSections, mode); |
161 } | 161 } |
162 } | 162 } |
OLD | NEW |