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/sessions/session_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "content/public/browser/navigation_details.h" | 36 #include "content/public/browser/navigation_details.h" |
37 #include "content/public/browser/navigation_entry.h" | 37 #include "content/public/browser/navigation_entry.h" |
38 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/notification_details.h" | 39 #include "content/public/browser/notification_details.h" |
40 | 40 |
41 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
42 #include "chrome/browser/app_controller_cppsafe_mac.h" | 42 #include "chrome/browser/app_controller_cppsafe_mac.h" |
43 #endif | 43 #endif |
44 | 44 |
45 using base::Time; | 45 using base::Time; |
| 46 using content::NavigationEntry; |
46 | 47 |
47 // Identifier for commands written to file. | 48 // Identifier for commands written to file. |
48 static const SessionCommand::id_type kCommandSetTabWindow = 0; | 49 static const SessionCommand::id_type kCommandSetTabWindow = 0; |
49 // OBSOLETE Superseded by kCommandSetWindowBounds3. | 50 // OBSOLETE Superseded by kCommandSetWindowBounds3. |
50 // static const SessionCommand::id_type kCommandSetWindowBounds = 1; | 51 // static const SessionCommand::id_type kCommandSetWindowBounds = 1; |
51 static const SessionCommand::id_type kCommandSetTabIndexInWindow = 2; | 52 static const SessionCommand::id_type kCommandSetTabIndexInWindow = 2; |
52 static const SessionCommand::id_type kCommandTabClosed = 3; | 53 static const SessionCommand::id_type kCommandTabClosed = 3; |
53 static const SessionCommand::id_type kCommandWindowClosed = 4; | 54 static const SessionCommand::id_type kCommandWindowClosed = 4; |
54 static const SessionCommand::id_type | 55 static const SessionCommand::id_type |
55 kCommandTabNavigationPathPrunedFromBack = 5; | 56 kCommandTabNavigationPathPrunedFromBack = 5; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 new SessionCommand(kCommandTabNavigationPathPrunedFromFront, | 356 new SessionCommand(kCommandTabNavigationPathPrunedFromFront, |
356 sizeof(payload)); | 357 sizeof(payload)); |
357 memcpy(command->contents(), &payload, sizeof(payload)); | 358 memcpy(command->contents(), &payload, sizeof(payload)); |
358 ScheduleCommand(command); | 359 ScheduleCommand(command); |
359 } | 360 } |
360 | 361 |
361 void SessionService::UpdateTabNavigation( | 362 void SessionService::UpdateTabNavigation( |
362 const SessionID& window_id, | 363 const SessionID& window_id, |
363 const SessionID& tab_id, | 364 const SessionID& tab_id, |
364 int index, | 365 int index, |
365 const content::NavigationEntry& entry) { | 366 const NavigationEntry& entry) { |
366 if (!ShouldTrackEntry(entry.GetVirtualURL()) || | 367 if (!ShouldTrackEntry(entry.GetVirtualURL()) || |
367 !ShouldTrackChangesToWindow(window_id)) { | 368 !ShouldTrackChangesToWindow(window_id)) { |
368 return; | 369 return; |
369 } | 370 } |
370 | 371 |
371 if (tab_to_available_range_.find(tab_id.id()) != | 372 if (tab_to_available_range_.find(tab_id.id()) != |
372 tab_to_available_range_.end()) { | 373 tab_to_available_range_.end()) { |
373 std::pair<int, int>& range = tab_to_available_range_[tab_id.id()]; | 374 std::pair<int, int>& range = tab_to_available_range_[tab_id.id()]; |
374 range.first = std::min(index, range.first); | 375 range.first = std::min(index, range.first); |
375 range.second = std::max(index, range.second); | 376 range.second = std::max(index, range.second); |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 } | 1133 } |
1133 TabContentsWrapper* wrapper = | 1134 TabContentsWrapper* wrapper = |
1134 TabContentsWrapper::GetCurrentWrapperForContents(tab->tab_contents()); | 1135 TabContentsWrapper::GetCurrentWrapperForContents(tab->tab_contents()); |
1135 if (wrapper->extension_tab_helper()->extension_app()) { | 1136 if (wrapper->extension_tab_helper()->extension_app()) { |
1136 commands->push_back( | 1137 commands->push_back( |
1137 CreateSetTabExtensionAppIDCommand( | 1138 CreateSetTabExtensionAppIDCommand( |
1138 kCommandSetExtensionAppID, session_id.id(), | 1139 kCommandSetExtensionAppID, session_id.id(), |
1139 wrapper->extension_tab_helper()->extension_app()->id())); | 1140 wrapper->extension_tab_helper()->extension_app()->id())); |
1140 } | 1141 } |
1141 for (int i = min_index; i < max_index; ++i) { | 1142 for (int i = min_index; i < max_index; ++i) { |
1142 const content::NavigationEntry* entry = (i == pending_index) ? | 1143 const NavigationEntry* entry = (i == pending_index) ? |
1143 tab->tab_contents()->GetController().GetPendingEntry() : | 1144 tab->tab_contents()->GetController().GetPendingEntry() : |
1144 tab->tab_contents()->GetController().GetEntryAtIndex(i); | 1145 tab->tab_contents()->GetController().GetEntryAtIndex(i); |
1145 DCHECK(entry); | 1146 DCHECK(entry); |
1146 if (ShouldTrackEntry(entry->GetVirtualURL())) { | 1147 if (ShouldTrackEntry(entry->GetVirtualURL())) { |
1147 commands->push_back( | 1148 commands->push_back( |
1148 CreateUpdateTabNavigationCommand( | 1149 CreateUpdateTabNavigationCommand( |
1149 kCommandUpdateTabNavigation, session_id.id(), i, *entry)); | 1150 kCommandUpdateTabNavigation, session_id.id(), i, *entry)); |
1150 } | 1151 } |
1151 } | 1152 } |
1152 commands->push_back( | 1153 commands->push_back( |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 50); | 1512 50); |
1512 if (use_long_period) { | 1513 if (use_long_period) { |
1513 std::string long_name_("SessionRestore.SaveLongPeriod"); | 1514 std::string long_name_("SessionRestore.SaveLongPeriod"); |
1514 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, | 1515 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, |
1515 delta, | 1516 delta, |
1516 save_delay_in_mins_, | 1517 save_delay_in_mins_, |
1517 save_delay_in_hrs_, | 1518 save_delay_in_hrs_, |
1518 50); | 1519 50); |
1519 } | 1520 } |
1520 } | 1521 } |
OLD | NEW |