OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/dom_ui/new_tab_ui.h" | 7 #include "chrome/browser/dom_ui/new_tab_ui.h" |
8 | 8 |
9 #include "app/animation.h" | 9 #include "app/animation.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 | 1211 |
1212 if (tab_restore_service_) | 1212 if (tab_restore_service_) |
1213 TabRestoreServiceChanged(tab_restore_service_); | 1213 TabRestoreServiceChanged(tab_restore_service_); |
1214 } | 1214 } |
1215 | 1215 |
1216 void RecentlyClosedTabsHandler::TabRestoreServiceChanged( | 1216 void RecentlyClosedTabsHandler::TabRestoreServiceChanged( |
1217 TabRestoreService* service) { | 1217 TabRestoreService* service) { |
1218 const TabRestoreService::Entries& entries = service->entries(); | 1218 const TabRestoreService::Entries& entries = service->entries(); |
1219 ListValue list_value; | 1219 ListValue list_value; |
1220 int added_count = 0; | 1220 int added_count = 0; |
| 1221 const int max_count = NewTabUI::UseOldNewTabPage() ? 3 : 6; |
1221 | 1222 |
1222 // We filter the list of recently closed to only show 'interesting' entries, | 1223 // We filter the list of recently closed to only show 'interesting' entries, |
1223 // where an interesting entry is either a closed window or a closed tab | 1224 // where an interesting entry is either a closed window or a closed tab |
1224 // whose selected navigation is not the new tab ui. | 1225 // whose selected navigation is not the new tab ui. |
1225 for (TabRestoreService::Entries::const_iterator it = entries.begin(); | 1226 for (TabRestoreService::Entries::const_iterator it = entries.begin(); |
1226 it != entries.end() && added_count < 3; ++it) { | 1227 it != entries.end() && added_count < max_count; ++it) { |
1227 TabRestoreService::Entry* entry = *it; | 1228 TabRestoreService::Entry* entry = *it; |
1228 DictionaryValue* value = new DictionaryValue(); | 1229 DictionaryValue* value = new DictionaryValue(); |
1229 if ((entry->type == TabRestoreService::TAB && | 1230 if ((entry->type == TabRestoreService::TAB && |
1230 TabToValue(*static_cast<TabRestoreService::Tab*>(entry), value)) || | 1231 TabToValue(*static_cast<TabRestoreService::Tab*>(entry), value)) || |
1231 (entry->type == TabRestoreService::WINDOW && | 1232 (entry->type == TabRestoreService::WINDOW && |
1232 WindowToValue(*static_cast<TabRestoreService::Window*>(entry), | 1233 WindowToValue(*static_cast<TabRestoreService::Window*>(entry), |
1233 value))) { | 1234 value))) { |
1234 value->SetInteger(L"sessionId", entry->id); | 1235 value->SetInteger(L"sessionId", entry->id); |
1235 list_value.Append(value); | 1236 list_value.Append(value); |
1236 added_count++; | 1237 added_count++; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 bool NewTabUI::UseOldNewTabPage() { | 1504 bool NewTabUI::UseOldNewTabPage() { |
1504 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1505 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1505 return command_line->HasSwitch(switches::kOldNewTabPage); | 1506 return command_line->HasSwitch(switches::kOldNewTabPage); |
1506 } | 1507 } |
1507 | 1508 |
1508 // static | 1509 // static |
1509 bool NewTabUI::WebResourcesDisabled() { | 1510 bool NewTabUI::WebResourcesDisabled() { |
1510 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1511 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1511 return command_line->HasSwitch(switches::kDisableWebResources); | 1512 return command_line->HasSwitch(switches::kDisableWebResources); |
1512 } | 1513 } |
OLD | NEW |