| OLD | NEW |
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 APPS | MINIMIZED_THUMB | MINIMIZED_RECENT); | 99 APPS | MINIMIZED_THUMB | MINIMIZED_RECENT); |
| 100 #else | 100 #else |
| 101 pref_service->RegisterIntegerPref(prefs::kNTPShownSections, THUMB); | 101 pref_service->RegisterIntegerPref(prefs::kNTPShownSections, THUMB); |
| 102 #endif | 102 #endif |
| 103 } | 103 } |
| 104 | 104 |
| 105 // static | 105 // static |
| 106 void ShownSectionsHandler::MigrateUserPrefs(PrefService* pref_service, | 106 void ShownSectionsHandler::MigrateUserPrefs(PrefService* pref_service, |
| 107 int old_pref_version, | 107 int old_pref_version, |
| 108 int new_pref_version) { | 108 int new_pref_version) { |
| 109 // Nothing to migrate for default kNTPShownSections value. |
| 110 const PrefService::Preference* shown_sections_pref = |
| 111 pref_service->FindPreference(prefs::kNTPShownSections); |
| 112 if (shown_sections_pref->IsDefaultValue()) |
| 113 return; |
| 114 |
| 109 bool changed = false; | 115 bool changed = false; |
| 110 int shown_sections = pref_service->GetInteger(prefs::kNTPShownSections); | 116 int shown_sections = pref_service->GetInteger(prefs::kNTPShownSections); |
| 111 | 117 |
| 112 if (old_pref_version < 3) { | 118 if (old_pref_version < 3) { |
| 113 // In version 3, we went from being able to show multiple sections to being | 119 // In version 3, we went from being able to show multiple sections to being |
| 114 // able to show only one expanded at a time. The only two expandable | 120 // able to show only one expanded at a time. The only two expandable |
| 115 // sections are APPS and THUMBS. | 121 // sections are APPS and THUMBS. |
| 116 if (shown_sections & APPS) | 122 if (shown_sections & APPS) |
| 117 shown_sections = APPS; | 123 shown_sections = APPS; |
| 118 else | 124 else |
| (...skipping 17 matching lines...) Expand all Loading... |
| 136 | 142 |
| 137 // Hide any open sections. | 143 // Hide any open sections. |
| 138 mode &= ~ALL_SECTIONS_MASK; | 144 mode &= ~ALL_SECTIONS_MASK; |
| 139 | 145 |
| 140 // Show the apps section. | 146 // Show the apps section. |
| 141 mode |= APPS; | 147 mode |= APPS; |
| 142 | 148 |
| 143 prefs->SetInteger(prefs::kNTPShownSections, mode); | 149 prefs->SetInteger(prefs::kNTPShownSections, mode); |
| 144 } | 150 } |
| 145 } | 151 } |
| OLD | NEW |