Index: chrome/browser/sessions/session_types.h |
diff --git a/chrome/browser/sessions/session_types.h b/chrome/browser/sessions/session_types.h |
index b8a23bf27d1d88e78780482296292e989de37ac7..0c3335b358f2ee251b6765b32b4c22c3b3793286 100644 |
--- a/chrome/browser/sessions/session_types.h |
+++ b/chrome/browser/sessions/session_types.h |
@@ -130,6 +130,15 @@ struct SessionTab { |
SessionTab(); |
virtual ~SessionTab(); |
+ // Since the current_navigation_index can be larger than the index for number |
+ // of navigations in the current sessions (chrome://newtab is not stored), we |
+ // must perform bounds checking. |
+ // Returns a normalized bounds-checked navigation_index. |
+ int normalized_navigation_index() const { |
+ return std::max(0, std::min(current_navigation_index, |
+ static_cast<int>(navigations.size() - 1))); |
+ } |
+ |
// Unique id of the window. |
SessionID window_id; |