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. |
| 395 // This ignores any pending or transient entries in |source|. Callers must |
| 396 // ensure that |CanPruneAllButVisible| returns true before calling this, or it |
| 397 // will crash. |
396 virtual void CopyStateFromAndPrune(NavigationController* source) = 0; | 398 virtual void CopyStateFromAndPrune(NavigationController* source) = 0; |
397 | 399 |
398 // Removes all the entries except the active entry. If there is a new pending | 400 // Returns whether it is safe to call PruneAllButVisible or |
399 // navigation it is preserved. | 401 // CopyStateFromAndPrune. There must be a last committed entry, no transient |
400 virtual void PruneAllButActive() = 0; | 402 // entry, and if there is a pending entry, it must be new and not an existing |
| 403 // entry. |
| 404 // |
| 405 // If there were no last committed entry, the pending entry might not commit, |
| 406 // leaving us with a blank page. This is unsafe when used with |
| 407 // |CopyStateFromAndPrune|, which would show an existing entry above the blank |
| 408 // page. |
| 409 // If there were a transient entry, we would not want to prune the other |
| 410 // entries, which the transient entry could be referring to. |
| 411 // If there were an existing pending entry, we could not prune the last |
| 412 // committed entry, in case it did not commit. That would leave us with no |
| 413 // sensible place to put the pending entry when it did commit, after all other |
| 414 // entries are pruned. For example, it could be going back several entries. |
| 415 // (New pending entries are safe, because they can always commit to the end.) |
| 416 virtual bool CanPruneAllButVisible() = 0; |
| 417 |
| 418 // Removes all the entries except the last committed entry. If there is a new |
| 419 // pending navigation it is preserved. Callers must ensure |
| 420 // |CanPruneAllButVisible| returns true before calling this, or it will crash. |
| 421 virtual void PruneAllButVisible() = 0; |
401 | 422 |
402 // Clears all screenshots associated with navigation entries in this | 423 // Clears all screenshots associated with navigation entries in this |
403 // controller. Useful to reduce memory consumption in low-memory situations. | 424 // controller. Useful to reduce memory consumption in low-memory situations. |
404 virtual void ClearAllScreenshots() = 0; | 425 virtual void ClearAllScreenshots() = 0; |
405 | 426 |
406 private: | 427 private: |
407 // This interface should only be implemented inside content. | 428 // This interface should only be implemented inside content. |
408 friend class NavigationControllerImpl; | 429 friend class NavigationControllerImpl; |
409 NavigationController() {} | 430 NavigationController() {} |
410 }; | 431 }; |
411 | 432 |
412 } // namespace content | 433 } // namespace content |
413 | 434 |
414 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 435 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ |
OLD | NEW |