| 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 #ifndef CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 // TODO(jam): remove this file when all files have been converted. |
| 10 | 10 #include "content/browser/tab_contents/navigation_controller.h" |
| 11 #include <string> | |
| 12 #include <vector> | |
| 13 | |
| 14 #include "base/linked_ptr.h" | |
| 15 #include "base/time.h" | |
| 16 #include "googleurl/src/gurl.h" | |
| 17 #include "chrome/browser/sessions/session_id.h" | |
| 18 #include "chrome/browser/ssl/ssl_manager.h" | |
| 19 #include "chrome/common/navigation_types.h" | |
| 20 #include "chrome/common/page_transition_types.h" | |
| 21 | |
| 22 class NavigationEntry; | |
| 23 class Profile; | |
| 24 class SessionStorageNamespace; | |
| 25 class SiteInstance; | |
| 26 class TabContents; | |
| 27 class TabNavigation; | |
| 28 struct ViewHostMsg_FrameNavigate_Params; | |
| 29 | |
| 30 // A NavigationController maintains the back-forward list for a single tab and | |
| 31 // manages all navigation within that list. | |
| 32 // | |
| 33 // The NavigationController also owns all TabContents for the tab. This is to | |
| 34 // make sure that we have at most one TabContents instance per type. | |
| 35 class NavigationController { | |
| 36 public: | |
| 37 // Notification details ------------------------------------------------------ | |
| 38 | |
| 39 // Provides the details for a NOTIFY_NAV_ENTRY_CHANGED notification. | |
| 40 struct EntryChangedDetails { | |
| 41 // The changed navigation entry after it has been updated. | |
| 42 const NavigationEntry* changed_entry; | |
| 43 | |
| 44 // Indicates the current index in the back/forward list of the entry. | |
| 45 int index; | |
| 46 }; | |
| 47 | |
| 48 // Provides the details for a NOTIFY_NAV_ENTRY_COMMITTED notification. | |
| 49 // TODO(brettw) this mostly duplicates ProvisionalLoadDetails, it would be | |
| 50 // nice to unify these somehow. | |
| 51 struct LoadCommittedDetails { | |
| 52 // By default, the entry will be filled according to a new main frame | |
| 53 // navigation. | |
| 54 LoadCommittedDetails() | |
| 55 : entry(NULL), | |
| 56 type(NavigationType::UNKNOWN), | |
| 57 previous_entry_index(-1), | |
| 58 is_auto(false), | |
| 59 did_replace_entry(false), | |
| 60 is_in_page(false), | |
| 61 is_main_frame(true), | |
| 62 is_content_filtered(false), | |
| 63 http_status_code(0) { | |
| 64 } | |
| 65 | |
| 66 // The committed entry. This will be the active entry in the controller. | |
| 67 NavigationEntry* entry; | |
| 68 | |
| 69 // The type of navigation that just occurred. Note that not all types of | |
| 70 // navigations in the enum are valid here, since some of them don't actually | |
| 71 // cause a "commit" and won't generate this notification. | |
| 72 NavigationType::Type type; | |
| 73 | |
| 74 // The index of the previously committed navigation entry. This will be -1 | |
| 75 // if there are no previous entries. | |
| 76 int previous_entry_index; | |
| 77 | |
| 78 // The previous URL that the user was on. This may be empty if none. | |
| 79 GURL previous_url; | |
| 80 | |
| 81 // True when this load was non-user initated. This corresponds to a | |
| 82 // a NavigationGestureAuto call from WebKit (see webview_delegate.h). | |
| 83 // We also count reloads and meta-refreshes as "auto" to account for the | |
| 84 // fact that WebKit doesn't always set the user gesture properly in these | |
| 85 // cases (see bug 1051891). | |
| 86 bool is_auto; | |
| 87 | |
| 88 // True if the committed entry has replaced the exisiting one. | |
| 89 // A non-user initiated redirect causes such replacement. | |
| 90 // This is somewhat similiar to is_auto, but not exactly the same. | |
| 91 bool did_replace_entry; | |
| 92 | |
| 93 // True if the navigation was in-page. This means that the active entry's | |
| 94 // URL and the |previous_url| are the same except for reference fragments. | |
| 95 bool is_in_page; | |
| 96 | |
| 97 // True when the main frame was navigated. False means the navigation was a | |
| 98 // sub-frame. | |
| 99 bool is_main_frame; | |
| 100 | |
| 101 // Whether the content of this frame has been altered/blocked because it was | |
| 102 // unsafe. | |
| 103 bool is_content_filtered; | |
| 104 | |
| 105 // When the committed load is a web page from the renderer, this string | |
| 106 // specifies the security state if the page is secure. | |
| 107 // See ViewHostMsg_FrameNavigate_Params.security_info, where it comes from. | |
| 108 // Use SSLManager::DeserializeSecurityInfo to decode it. | |
| 109 std::string serialized_security_info; | |
| 110 | |
| 111 // Returns whether the user probably felt like they navigated somewhere new. | |
| 112 // We often need this logic for showing or hiding something, and this | |
| 113 // returns true only for main frame loads that the user initiated, that go | |
| 114 // to a new page. | |
| 115 bool is_user_initiated_main_frame_load() const { | |
| 116 return !is_auto && !is_in_page && is_main_frame; | |
| 117 } | |
| 118 | |
| 119 // The HTTP status code for this entry.. | |
| 120 int http_status_code; | |
| 121 }; | |
| 122 | |
| 123 // Details sent for NOTIFY_NAV_LIST_PRUNED. | |
| 124 struct PrunedDetails { | |
| 125 // If true, count items were removed from the front of the list, otherwise | |
| 126 // count items were removed from the back of the list. | |
| 127 bool from_front; | |
| 128 | |
| 129 // Number of items removed. | |
| 130 int count; | |
| 131 }; | |
| 132 | |
| 133 enum ReloadType { | |
| 134 NO_RELOAD, // Normal load. | |
| 135 RELOAD, // Normal (cache-validating) reload. | |
| 136 RELOAD_IGNORING_CACHE // Reload bypassing the cache, aka shift-reload. | |
| 137 }; | |
| 138 | |
| 139 // --------------------------------------------------------------------------- | |
| 140 | |
| 141 NavigationController(TabContents* tab_contents, | |
| 142 Profile* profile, | |
| 143 SessionStorageNamespace* session_storage_namespace); | |
| 144 ~NavigationController(); | |
| 145 | |
| 146 // Returns the profile for this controller. It can never be NULL. | |
| 147 Profile* profile() const { | |
| 148 return profile_; | |
| 149 } | |
| 150 | |
| 151 // Sets the profile for this controller. | |
| 152 void set_profile(Profile* profile) { | |
| 153 profile_ = profile; | |
| 154 } | |
| 155 | |
| 156 // Initializes this NavigationController with the given saved navigations, | |
| 157 // using selected_navigation as the currently loaded entry. Before this call | |
| 158 // the controller should be unused (there should be no current entry). If | |
| 159 // from_last_session is true, navigations are from the previous session, | |
| 160 // otherwise they are from the current session (undo tab close). | |
| 161 // This is used for session restore. | |
| 162 void RestoreFromState(const std::vector<TabNavigation>& navigations, | |
| 163 int selected_navigation, bool from_last_session); | |
| 164 | |
| 165 // Active entry -------------------------------------------------------------- | |
| 166 | |
| 167 // Returns the active entry, which is the transient entry if any, the pending | |
| 168 // entry if a navigation is in progress or the last committed entry otherwise. | |
| 169 // NOTE: This can be NULL!! | |
| 170 // | |
| 171 // If you are trying to get the current state of the NavigationController, | |
| 172 // this is the method you will typically want to call. | |
| 173 NavigationEntry* GetActiveEntry() const; | |
| 174 | |
| 175 // Returns the index from which we would go back/forward or reload. This is | |
| 176 // the last_committed_entry_index_ if pending_entry_index_ is -1. Otherwise, | |
| 177 // it is the pending_entry_index_. | |
| 178 int GetCurrentEntryIndex() const; | |
| 179 | |
| 180 // Returns the last committed entry, which may be null if there are no | |
| 181 // committed entries. | |
| 182 NavigationEntry* GetLastCommittedEntry() const; | |
| 183 | |
| 184 // Returns true if the source for the current entry can be viewed. | |
| 185 bool CanViewSource() const; | |
| 186 | |
| 187 // Returns the index of the last committed entry. | |
| 188 int last_committed_entry_index() const { | |
| 189 return last_committed_entry_index_; | |
| 190 } | |
| 191 | |
| 192 // Navigation list ----------------------------------------------------------- | |
| 193 | |
| 194 // Returns the number of entries in the NavigationController, excluding | |
| 195 // the pending entry if there is one, but including the transient entry if | |
| 196 // any. | |
| 197 int entry_count() const { | |
| 198 return static_cast<int>(entries_.size()); | |
| 199 } | |
| 200 | |
| 201 NavigationEntry* GetEntryAtIndex(int index) const { | |
| 202 return entries_.at(index).get(); | |
| 203 } | |
| 204 | |
| 205 // Returns the entry at the specified offset from current. Returns NULL | |
| 206 // if out of bounds. | |
| 207 NavigationEntry* GetEntryAtOffset(int offset) const; | |
| 208 | |
| 209 // Returns the index of the specified entry, or -1 if entry is not contained | |
| 210 // in this NavigationController. | |
| 211 int GetIndexOfEntry(const NavigationEntry* entry) const; | |
| 212 | |
| 213 // Return the index of the entry with the corresponding instance and page_id, | |
| 214 // or -1 if not found. | |
| 215 int GetEntryIndexWithPageID(SiteInstance* instance, | |
| 216 int32 page_id) const; | |
| 217 | |
| 218 // Return the entry with the corresponding instance and page_id, or NULL if | |
| 219 // not found. | |
| 220 NavigationEntry* GetEntryWithPageID(SiteInstance* instance, | |
| 221 int32 page_id) const; | |
| 222 | |
| 223 // Pending entry ------------------------------------------------------------- | |
| 224 | |
| 225 // Commits the current pending entry and issues the NOTIFY_NAV_ENTRY_COMMIT | |
| 226 // notification. No changes are made to the entry during this process, it is | |
| 227 // just moved from pending to committed. This is an alternative to | |
| 228 // RendererDidNavigate for simple TabContents types. | |
| 229 // | |
| 230 // When the pending entry is a new navigation, it will have a page ID of -1. | |
| 231 // The caller should leave this as-is. CommitPendingEntry will generate a | |
| 232 // new page ID for you and update the TabContents with that ID. | |
| 233 void CommitPendingEntry(); | |
| 234 | |
| 235 // Discards the pending and transient entries if any. | |
| 236 void DiscardNonCommittedEntries(); | |
| 237 | |
| 238 // Returns the pending entry corresponding to the navigation that is | |
| 239 // currently in progress, or null if there is none. | |
| 240 NavigationEntry* pending_entry() const { | |
| 241 return pending_entry_; | |
| 242 } | |
| 243 | |
| 244 // Returns the index of the pending entry or -1 if the pending entry | |
| 245 // corresponds to a new navigation (created via LoadURL). | |
| 246 int pending_entry_index() const { | |
| 247 return pending_entry_index_; | |
| 248 } | |
| 249 | |
| 250 // Transient entry ----------------------------------------------------------- | |
| 251 | |
| 252 // Adds an entry that is returned by GetActiveEntry(). The entry is | |
| 253 // transient: any navigation causes it to be removed and discarded. | |
| 254 // The NavigationController becomes the owner of |entry| and deletes it when | |
| 255 // it discards it. This is useful with interstitial page that need to be | |
| 256 // represented as an entry, but should go away when the user navigates away | |
| 257 // from them. | |
| 258 // Note that adding a transient entry does not change the active contents. | |
| 259 void AddTransientEntry(NavigationEntry* entry); | |
| 260 | |
| 261 // Returns the transient entry if any. Note that the returned entry is owned | |
| 262 // by the navigation controller and may be deleted at any time. | |
| 263 NavigationEntry* GetTransientEntry() const; | |
| 264 | |
| 265 // New navigations ----------------------------------------------------------- | |
| 266 | |
| 267 // Loads the specified URL. | |
| 268 void LoadURL(const GURL& url, const GURL& referrer, | |
| 269 PageTransition::Type type); | |
| 270 | |
| 271 // Loads the current page if this NavigationController was restored from | |
| 272 // history and the current page has not loaded yet. | |
| 273 void LoadIfNecessary(); | |
| 274 | |
| 275 // Renavigation -------------------------------------------------------------- | |
| 276 | |
| 277 // Navigation relative to the "current entry" | |
| 278 bool CanGoBack() const; | |
| 279 bool CanGoForward() const; | |
| 280 void GoBack(); | |
| 281 void GoForward(); | |
| 282 | |
| 283 // Navigates to the specified absolute index. | |
| 284 void GoToIndex(int index); | |
| 285 | |
| 286 // Navigates to the specified offset from the "current entry". Does nothing if | |
| 287 // the offset is out of bounds. | |
| 288 void GoToOffset(int offset); | |
| 289 | |
| 290 // Reloads the current entry. If |check_for_repost| is true and the current | |
| 291 // entry has POST data the user is prompted to see if they really want to | |
| 292 // reload the page. In nearly all cases pass in true. | |
| 293 void Reload(bool check_for_repost); | |
| 294 // Like Reload(), but don't use caches (aka "shift-reload"). | |
| 295 void ReloadIgnoringCache(bool check_for_repost); | |
| 296 | |
| 297 // Removing of entries ------------------------------------------------------- | |
| 298 | |
| 299 // Removes the entry at the specified |index|. This call dicards any pending | |
| 300 // and transient entries. |default_url| is the URL that the navigation | |
| 301 // controller navigates to if there are no more entries after the removal. | |
| 302 // If |default_url| is empty, we default to "about:blank". | |
| 303 void RemoveEntryAtIndex(int index, const GURL& default_url); | |
| 304 | |
| 305 // TabContents --------------------------------------------------------------- | |
| 306 | |
| 307 // Returns the tab contents associated with this controller. Non-NULL except | |
| 308 // during set-up of the tab. | |
| 309 TabContents* tab_contents() const { | |
| 310 // This currently returns the active tab contents which should be renamed to | |
| 311 // tab_contents. | |
| 312 return tab_contents_; | |
| 313 } | |
| 314 | |
| 315 // Called when a document has been loaded in a frame. | |
| 316 void DocumentLoadedInFrame(); | |
| 317 | |
| 318 // For use by TabContents ---------------------------------------------------- | |
| 319 | |
| 320 // Handles updating the navigation state after the renderer has navigated. | |
| 321 // This is used by the TabContents. Simpler tab contents types can use | |
| 322 // CommitPendingEntry below. | |
| 323 // | |
| 324 // If a new entry is created, it will return true and will have filled the | |
| 325 // given details structure and broadcast the NOTIFY_NAV_ENTRY_COMMITTED | |
| 326 // notification. The caller can then use the details without worrying about | |
| 327 // listening for the notification. | |
| 328 // | |
| 329 // In the case that nothing has changed, the details structure is undefined | |
| 330 // and it will return false. | |
| 331 // | |
| 332 // |extra_invalidate_flags| are an additional set of flags (InvalidateTypes) | |
| 333 // added to the flags sent to the delegate's NotifyNavigationStateChanged. | |
| 334 bool RendererDidNavigate(const ViewHostMsg_FrameNavigate_Params& params, | |
| 335 int extra_invalidate_flags, | |
| 336 LoadCommittedDetails* details); | |
| 337 | |
| 338 // Notifies us that we just became active. This is used by the TabContents | |
| 339 // so that we know to load URLs that were pending as "lazy" loads. | |
| 340 void SetActive(bool is_active); | |
| 341 | |
| 342 // Broadcasts the NOTIFY_NAV_ENTRY_CHANGED notification for the given entry | |
| 343 // (which must be at the given index). This will keep things in sync like | |
| 344 // the saved session. | |
| 345 void NotifyEntryChanged(const NavigationEntry* entry, int index); | |
| 346 | |
| 347 // Returns true if the given URL would be an in-page navigation (i.e. only | |
| 348 // the reference fragment is different) from the "last committed entry". We do | |
| 349 // not compare it against the "active entry" since the active entry can be | |
| 350 // pending and in page navigations only happen on committed pages. If there | |
| 351 // is no last committed entry, then nothing will be in-page. | |
| 352 // | |
| 353 // Special note: if the URLs are the same, it does NOT count as an in-page | |
| 354 // navigation. Neither does an input URL that has no ref, even if the rest is | |
| 355 // the same. This may seem weird, but when we're considering whether a | |
| 356 // navigation happened without loading anything, the same URL would be a | |
| 357 // reload, while only a different ref would be in-page (pages can't clear | |
| 358 // refs without reload, only change to "#" which we don't count as empty). | |
| 359 bool IsURLInPageNavigation(const GURL& url) const; | |
| 360 | |
| 361 // Copies the navigation state from the given controller to this one. This | |
| 362 // one should be empty (just created). | |
| 363 void CopyStateFrom(const NavigationController& source); | |
| 364 | |
| 365 // A variant of CopyStateFrom. Removes all entries from this except the last | |
| 366 // entry, inserts all entries from |source| before and including the active | |
| 367 // entry. This method is intended for use when the last entry of |this| is the | |
| 368 // active entry. For example: | |
| 369 // source: A B *C* D | |
| 370 // this: E F *G* (last must be active or pending) | |
| 371 // result: A B *G* | |
| 372 // This ignores the transient index of the source and honors that of 'this'. | |
| 373 void CopyStateFromAndPrune(NavigationController* source); | |
| 374 | |
| 375 // Removes all the entries except the active entry. If there is a new pending | |
| 376 // navigation it is preserved. | |
| 377 void PruneAllButActive(); | |
| 378 | |
| 379 // Random data --------------------------------------------------------------- | |
| 380 | |
| 381 // Returns the identifier used by session restore. | |
| 382 const SessionID& session_id() const { return session_id_; } | |
| 383 | |
| 384 // Identifier of the window we're in. | |
| 385 void SetWindowID(const SessionID& id); | |
| 386 const SessionID& window_id() const { return window_id_; } | |
| 387 | |
| 388 SSLManager* ssl_manager() { return &ssl_manager_; } | |
| 389 | |
| 390 // Returns true if a reload happens when activated (SetActive(true) is | |
| 391 // invoked). This is true for session/tab restore and cloned tabs. | |
| 392 bool needs_reload() const { return needs_reload_; } | |
| 393 | |
| 394 // Sets the max restored page ID this NavigationController has seen, if it | |
| 395 // was restored from a previous session. | |
| 396 void set_max_restored_page_id(int32 max_id) { | |
| 397 max_restored_page_id_ = max_id; | |
| 398 } | |
| 399 | |
| 400 // Returns the largest restored page ID seen in this navigation controller, | |
| 401 // if it was restored from a previous session. (-1 otherwise) | |
| 402 int32 max_restored_page_id() const { return max_restored_page_id_; } | |
| 403 | |
| 404 // The session storage namespace that all child render views should use. | |
| 405 SessionStorageNamespace* session_storage_namespace() const { | |
| 406 return session_storage_namespace_; | |
| 407 } | |
| 408 | |
| 409 // Disables checking for a repost and prompting the user. This is used during | |
| 410 // testing. | |
| 411 static void DisablePromptOnRepost(); | |
| 412 | |
| 413 // Maximum number of entries before we start removing entries from the front. | |
| 414 #ifdef UNIT_TEST | |
| 415 static void set_max_entry_count(size_t max_entry_count) { | |
| 416 max_entry_count_ = max_entry_count; | |
| 417 } | |
| 418 #endif | |
| 419 static size_t max_entry_count() { return max_entry_count_; } | |
| 420 | |
| 421 // Cancels a repost that brought up a warning. | |
| 422 void CancelPendingReload(); | |
| 423 // Continues a repost that brought up a warning. | |
| 424 void ContinuePendingReload(); | |
| 425 | |
| 426 // Returns true if we are navigating to the URL the tab is opened with. | |
| 427 bool IsInitialNavigation(); | |
| 428 | |
| 429 // Creates navigation entry and translates the virtual url to a real one. | |
| 430 // Used when restoring a tab from a TabNavigation object and when navigating | |
| 431 // to a new URL using LoadURL. | |
| 432 static NavigationEntry* CreateNavigationEntry(const GURL& url, | |
| 433 const GURL& referrer, | |
| 434 PageTransition::Type transition, | |
| 435 Profile* profile); | |
| 436 | |
| 437 private: | |
| 438 class RestoreHelper; | |
| 439 friend class RestoreHelper; | |
| 440 friend class TabContents; // For invoking OnReservedPageIDRange. | |
| 441 | |
| 442 // Classifies the given renderer navigation (see the NavigationType enum). | |
| 443 NavigationType::Type ClassifyNavigation( | |
| 444 const ViewHostMsg_FrameNavigate_Params& params) const; | |
| 445 | |
| 446 // Causes the controller to load the specified entry. The function assumes | |
| 447 // ownership of the pointer since it is put in the navigation list. | |
| 448 // NOTE: Do not pass an entry that the controller already owns! | |
| 449 void LoadEntry(NavigationEntry* entry); | |
| 450 | |
| 451 // Handlers for the different types of navigation types. They will actually | |
| 452 // handle the navigations corresponding to the different NavClasses above. | |
| 453 // They will NOT broadcast the commit notification, that should be handled by | |
| 454 // the caller. | |
| 455 // | |
| 456 // RendererDidNavigateAutoSubframe is special, it may not actually change | |
| 457 // anything if some random subframe is loaded. It will return true if anything | |
| 458 // changed, or false if not. | |
| 459 // | |
| 460 // The functions taking |did_replace_entry| will fill into the given variable | |
| 461 // whether the last entry has been replaced or not. | |
| 462 // See LoadCommittedDetails.did_replace_entry. | |
| 463 void RendererDidNavigateToNewPage( | |
| 464 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry); | |
| 465 void RendererDidNavigateToExistingPage( | |
| 466 const ViewHostMsg_FrameNavigate_Params& params); | |
| 467 void RendererDidNavigateToSamePage( | |
| 468 const ViewHostMsg_FrameNavigate_Params& params); | |
| 469 void RendererDidNavigateInPage( | |
| 470 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry); | |
| 471 void RendererDidNavigateNewSubframe( | |
| 472 const ViewHostMsg_FrameNavigate_Params& params); | |
| 473 bool RendererDidNavigateAutoSubframe( | |
| 474 const ViewHostMsg_FrameNavigate_Params& params); | |
| 475 | |
| 476 // Helper function for code shared between Reload() and ReloadIgnoringCache(). | |
| 477 void ReloadInternal(bool check_for_repost, ReloadType reload_type); | |
| 478 | |
| 479 // Actually issues the navigation held in pending_entry. | |
| 480 void NavigateToPendingEntry(ReloadType reload_type); | |
| 481 | |
| 482 // Allows the derived class to issue notifications that a load has been | |
| 483 // committed. This will fill in the active entry to the details structure. | |
| 484 // | |
| 485 // |extra_invalidate_flags| are an additional set of flags (InvalidateTypes) | |
| 486 // added to the flags sent to the delegate's NotifyNavigationStateChanged. | |
| 487 void NotifyNavigationEntryCommitted(LoadCommittedDetails* details, | |
| 488 int extra_invalidate_flags); | |
| 489 | |
| 490 // Updates the virtual URL of an entry to match a new URL, for cases where | |
| 491 // the real renderer URL is derived from the virtual URL, like view-source: | |
| 492 void UpdateVirtualURLToURL(NavigationEntry* entry, const GURL& new_url); | |
| 493 | |
| 494 // Invoked after session/tab restore or cloning a tab. Resets the transition | |
| 495 // type of the entries, updates the max page id and creates the active | |
| 496 // contents. See RestoreFromState for a description of from_last_session. | |
| 497 void FinishRestore(int selected_index, bool from_last_session); | |
| 498 | |
| 499 // Inserts a new entry or replaces the current entry with a new one, removing | |
| 500 // all entries after it. The new entry will become the active one. | |
| 501 void InsertOrReplaceEntry(NavigationEntry* entry, bool replace); | |
| 502 | |
| 503 // Discards the pending and transient entries. | |
| 504 void DiscardNonCommittedEntriesInternal(); | |
| 505 | |
| 506 // Discards the transient entry. | |
| 507 void DiscardTransientEntry(); | |
| 508 | |
| 509 // Returns true if the navigation is redirect. | |
| 510 bool IsRedirect(const ViewHostMsg_FrameNavigate_Params& params); | |
| 511 | |
| 512 // Returns true if the navigation is likley to be automatic rather than | |
| 513 // user-initiated. | |
| 514 bool IsLikelyAutoNavigation(base::TimeTicks now); | |
| 515 | |
| 516 // Creates a new NavigationEntry for each TabNavigation in navigations, adding | |
| 517 // the NavigationEntry to entries. This is used during session restore. | |
| 518 void CreateNavigationEntriesFromTabNavigations( | |
| 519 const std::vector<TabNavigation>& navigations, | |
| 520 std::vector<linked_ptr<NavigationEntry> >* entries); | |
| 521 | |
| 522 // Inserts up to |max_index| entries from |source| into this. This does NOT | |
| 523 // adjust any of the members that reference entries_ | |
| 524 // (last_committed_entry_index_, pending_entry_index_ or | |
| 525 // transient_entry_index_). | |
| 526 void InsertEntriesFrom(const NavigationController& source, int max_index); | |
| 527 | |
| 528 // --------------------------------------------------------------------------- | |
| 529 | |
| 530 // The user profile associated with this controller | |
| 531 Profile* profile_; | |
| 532 | |
| 533 // List of NavigationEntry for this tab | |
| 534 typedef std::vector<linked_ptr<NavigationEntry> > NavigationEntries; | |
| 535 NavigationEntries entries_; | |
| 536 | |
| 537 // An entry we haven't gotten a response for yet. This will be discarded | |
| 538 // when we navigate again. It's used only so we know what the currently | |
| 539 // displayed tab is. | |
| 540 // | |
| 541 // This may refer to an item in the entries_ list if the pending_entry_index_ | |
| 542 // == -1, or it may be its own entry that should be deleted. Be careful with | |
| 543 // the memory management. | |
| 544 NavigationEntry* pending_entry_; | |
| 545 | |
| 546 // currently visible entry | |
| 547 int last_committed_entry_index_; | |
| 548 | |
| 549 // index of pending entry if it is in entries_, or -1 if pending_entry_ is a | |
| 550 // new entry (created by LoadURL). | |
| 551 int pending_entry_index_; | |
| 552 | |
| 553 // The index for the entry that is shown until a navigation occurs. This is | |
| 554 // used for interstitial pages. -1 if there are no such entry. | |
| 555 // Note that this entry really appears in the list of entries, but only | |
| 556 // temporarily (until the next navigation). Any index pointing to an entry | |
| 557 // after the transient entry will become invalid if you navigate forward. | |
| 558 int transient_entry_index_; | |
| 559 | |
| 560 // The tab contents associated with the controller. Possibly NULL during | |
| 561 // setup. | |
| 562 TabContents* tab_contents_; | |
| 563 | |
| 564 // The max restored page ID in this controller, if it was restored. We must | |
| 565 // store this so that TabContents can tell any renderer in charge of one of | |
| 566 // the restored entries to update its max page ID. | |
| 567 int32 max_restored_page_id_; | |
| 568 | |
| 569 // Manages the SSL security UI | |
| 570 SSLManager ssl_manager_; | |
| 571 | |
| 572 // Whether we need to be reloaded when made active. | |
| 573 bool needs_reload_; | |
| 574 | |
| 575 // Unique identifier of this controller for session restore. This id is only | |
| 576 // unique within the current session, and is not guaranteed to be unique | |
| 577 // across sessions. | |
| 578 SessionID session_id_; | |
| 579 | |
| 580 // Unique identifier of the window we're in. Used by session restore. | |
| 581 SessionID window_id_; | |
| 582 | |
| 583 // The time ticks at which the last document was loaded. | |
| 584 base::TimeTicks last_document_loaded_; | |
| 585 | |
| 586 // The session storage id that any (indirectly) owned RenderView should use. | |
| 587 scoped_refptr<SessionStorageNamespace> session_storage_namespace_; | |
| 588 | |
| 589 // Should Reload check for post data? The default is true, but is set to false | |
| 590 // when testing. | |
| 591 static bool check_for_repost_; | |
| 592 | |
| 593 // The maximum number of entries that a navigation controller can store. | |
| 594 static size_t max_entry_count_; | |
| 595 | |
| 596 // If a repost is pending, its type (RELOAD or RELOAD_IGNORING_CACHE), | |
| 597 // NO_RELOAD otherwise. | |
| 598 ReloadType pending_reload_; | |
| 599 | |
| 600 DISALLOW_COPY_AND_ASSIGN(NavigationController); | |
| 601 }; | |
| 602 | 11 |
| 603 #endif // CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ | 12 #endif // CHROME_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ |
| OLD | NEW |