OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 // Broadcasts the NOTIFY_NAV_ENTRY_CHANGED notification for the given entry | 379 // Broadcasts the NOTIFY_NAV_ENTRY_CHANGED notification for the given entry |
380 // (which must be at the given index). This will keep things in sync like | 380 // (which must be at the given index). This will keep things in sync like |
381 // the saved session. | 381 // the saved session. |
382 virtual void NotifyEntryChanged(const NavigationEntry* entry, int index) = 0; | 382 virtual void NotifyEntryChanged(const NavigationEntry* entry, int index) = 0; |
383 | 383 |
384 // Copies the navigation state from the given controller to this one. This | 384 // Copies the navigation state from the given controller to this one. This |
385 // one should be empty (just created). | 385 // one should be empty (just created). |
386 virtual void CopyStateFrom(const NavigationController& source) = 0; | 386 virtual void CopyStateFrom(const NavigationController& source) = 0; |
387 | 387 |
388 // A variant of CopyStateFrom. Removes all entries from this except the last | 388 // A variant of CopyStateFrom. Removes all entries from this except the last |
389 // entry, inserts all entries from |source| before and including the active | 389 // committed entry, and inserts all entries from |source| before and including |
390 // entry. This method is intended for use when the last entry of |this| is the | 390 // its last committed entry. For example: |
391 // active entry. For example: | |
392 // source: A B *C* D | 391 // source: A B *C* D |
393 // this: E F *G* (last must be active or pending) | 392 // this: E F *G* |
394 // result: A B C *G* | 393 // result: A B C *G* |
395 // This ignores the transient index of the source and honors that of 'this'. | 394 // If there is a pending entry after *G* in |this|, it is also preserved. |
396 virtual void CopyStateFromAndPrune(NavigationController* source) = 0; | 395 // This ignores any pending or transient entries in |source|, and it returns |
396 // false if it is unsafe to call (see CanPruneAllButVisible). | |
397 virtual bool CopyStateFromAndPrune(NavigationController* source) = 0; | |
cbentzel
2013/05/28 18:39:17
The bool return argument for this (as well as Prun
Charlie Reis
2013/05/28 23:22:00
The current approach was partly driven by my level
| |
397 | 398 |
398 // Removes all the entries except the active entry. If there is a new pending | 399 // Returns whether it is safe to call PruneAllButVisible or |
399 // navigation it is preserved. | 400 // CopyStateFromAndPrune. There must be a last committed entry, no transient |
400 virtual void PruneAllButActive() = 0; | 401 // entry, and if there is a pending entry, it must be new and not an existing |
402 // entry. | |
403 // | |
404 // If there were no last committed entry, the pending entry might not commit, | |
405 // leaving us with a blank page. This is unsafe when used with | |
406 // |CopyStateFromAndPrune|, which would show an existing entry above the blank | |
407 // page. | |
408 // If there were a transient entry, we would not want to prune the other | |
409 // entries, which the transient entry could be referring to. | |
410 // If there were an existing pending entry, we could not prune the last | |
411 // committed entry, in case it did not commit. That would leave us with no | |
412 // sensible place to put the pending entry when it did commit, after all other | |
413 // entries are pruned. For example, it could be going back several entries. | |
414 // (New pending entries are safe, because they can always commit to the end.) | |
415 virtual bool CanPruneAllButVisible() = 0; | |
416 | |
417 // Removes all the entries except the last committed entry. If there is a new | |
418 // pending navigation it is preserved. Returns false if it is unsafe to call | |
419 // (see CanPruneAllButVisible). | |
420 virtual bool PruneAllButVisible() = 0; | |
401 | 421 |
402 // Clears all screenshots associated with navigation entries in this | 422 // Clears all screenshots associated with navigation entries in this |
403 // controller. Useful to reduce memory consumption in low-memory situations. | 423 // controller. Useful to reduce memory consumption in low-memory situations. |
404 virtual void ClearAllScreenshots() = 0; | 424 virtual void ClearAllScreenshots() = 0; |
405 | 425 |
406 private: | 426 private: |
407 // This interface should only be implemented inside content. | 427 // This interface should only be implemented inside content. |
408 friend class NavigationControllerImpl; | 428 friend class NavigationControllerImpl; |
409 NavigationController() {} | 429 NavigationController() {} |
410 }; | 430 }; |
411 | 431 |
412 } // namespace content | 432 } // namespace content |
413 | 433 |
414 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 434 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ |
OLD | NEW |