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 #ifndef CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ | 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ |
6 #define CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ | 6 #define CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 #include "content/browser/ssl/ssl_manager.h" | 17 #include "content/browser/ssl/ssl_manager.h" |
18 #include "content/common/navigation_types.h" | 18 #include "content/common/navigation_types.h" |
19 #include "content/common/page_transition_types.h" | 19 #include "content/common/page_transition_types.h" |
20 | 20 |
21 class NavigationEntry; | 21 class NavigationEntry; |
22 class Profile; | |
23 class SessionStorageNamespace; | 22 class SessionStorageNamespace; |
24 class SiteInstance; | 23 class SiteInstance; |
25 class TabContents; | 24 class TabContents; |
26 struct ViewHostMsg_FrameNavigate_Params; | 25 struct ViewHostMsg_FrameNavigate_Params; |
27 | 26 |
28 namespace content { | 27 namespace content { |
| 28 class BrowserContext; |
29 struct LoadCommittedDetails; | 29 struct LoadCommittedDetails; |
30 } | 30 } |
31 | 31 |
32 // A NavigationController maintains the back-forward list for a single tab and | 32 // A NavigationController maintains the back-forward list for a single tab and |
33 // manages all navigation within that list. | 33 // manages all navigation within that list. |
34 // | 34 // |
35 // The NavigationController also owns all TabContents for the tab. This is to | 35 // The NavigationController also owns all TabContents for the tab. This is to |
36 // make sure that we have at most one TabContents instance per type. | 36 // make sure that we have at most one TabContents instance per type. |
37 class NavigationController { | 37 class NavigationController { |
38 public: | 38 public: |
39 | 39 |
40 enum ReloadType { | 40 enum ReloadType { |
41 NO_RELOAD, // Normal load. | 41 NO_RELOAD, // Normal load. |
42 RELOAD, // Normal (cache-validating) reload. | 42 RELOAD, // Normal (cache-validating) reload. |
43 RELOAD_IGNORING_CACHE // Reload bypassing the cache, aka shift-reload. | 43 RELOAD_IGNORING_CACHE // Reload bypassing the cache, aka shift-reload. |
44 }; | 44 }; |
45 | 45 |
46 // --------------------------------------------------------------------------- | 46 // --------------------------------------------------------------------------- |
47 | 47 |
48 NavigationController(TabContents* tab_contents, | 48 NavigationController(TabContents* tab_contents, |
49 Profile* profile, | 49 content::BrowserContext* browser_context, |
50 SessionStorageNamespace* session_storage_namespace); | 50 SessionStorageNamespace* session_storage_namespace); |
51 ~NavigationController(); | 51 ~NavigationController(); |
52 | 52 |
53 // Returns the profile for this controller. It can never be NULL. | 53 // Returns the browser context for this controller. It can never be NULL. |
54 Profile* profile() const { | 54 content::BrowserContext* browser_context() const { |
55 return profile_; | 55 return browser_context_; |
56 } | 56 } |
57 | 57 |
58 // Sets the profile for this controller. | 58 // Sets the context for this controller. |
59 void set_profile(Profile* profile) { | 59 void set_browser_context(content::BrowserContext* browser_context) { |
60 profile_ = profile; | 60 browser_context_ = browser_context; |
61 } | 61 } |
62 | 62 |
63 // Initializes this NavigationController with the given saved navigations, | 63 // Initializes this NavigationController with the given saved navigations, |
64 // using selected_navigation as the currently loaded entry. Before this call | 64 // using selected_navigation as the currently loaded entry. Before this call |
65 // the controller should be unused (there should be no current entry). If | 65 // the controller should be unused (there should be no current entry). If |
66 // from_last_session is true, navigations are from the previous session, | 66 // from_last_session is true, navigations are from the previous session, |
67 // otherwise they are from the current session (undo tab close). This takes | 67 // otherwise they are from the current session (undo tab close). This takes |
68 // ownership of the NavigationEntrys in |entries| and clears it out. | 68 // ownership of the NavigationEntrys in |entries| and clears it out. |
69 // This is used for session restore. | 69 // This is used for session restore. |
70 void Restore(int selected_navigation, | 70 void Restore(int selected_navigation, |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // Cancels a repost that brought up a warning. | 312 // Cancels a repost that brought up a warning. |
313 void CancelPendingReload(); | 313 void CancelPendingReload(); |
314 // Continues a repost that brought up a warning. | 314 // Continues a repost that brought up a warning. |
315 void ContinuePendingReload(); | 315 void ContinuePendingReload(); |
316 | 316 |
317 // Returns true if we are navigating to the URL the tab is opened with. | 317 // Returns true if we are navigating to the URL the tab is opened with. |
318 bool IsInitialNavigation(); | 318 bool IsInitialNavigation(); |
319 | 319 |
320 // Creates navigation entry and translates the virtual url to a real one. | 320 // Creates navigation entry and translates the virtual url to a real one. |
321 // Used when navigating to a new URL using LoadURL. | 321 // Used when navigating to a new URL using LoadURL. |
322 static NavigationEntry* CreateNavigationEntry(const GURL& url, | 322 static NavigationEntry* CreateNavigationEntry( |
323 const GURL& referrer, | 323 const GURL& url, |
324 PageTransition::Type transition, | 324 const GURL& referrer, |
325 Profile* profile); | 325 PageTransition::Type transition, |
| 326 content::BrowserContext* context); |
326 | 327 |
327 private: | 328 private: |
328 class RestoreHelper; | 329 class RestoreHelper; |
329 friend class RestoreHelper; | 330 friend class RestoreHelper; |
330 friend class TabContents; // For invoking OnReservedPageIDRange. | 331 friend class TabContents; // For invoking OnReservedPageIDRange. |
331 | 332 |
332 // Classifies the given renderer navigation (see the NavigationType enum). | 333 // Classifies the given renderer navigation (see the NavigationType enum). |
333 NavigationType::Type ClassifyNavigation( | 334 NavigationType::Type ClassifyNavigation( |
334 const ViewHostMsg_FrameNavigate_Params& params) const; | 335 const ViewHostMsg_FrameNavigate_Params& params) const; |
335 | 336 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 bool IsLikelyAutoNavigation(base::TimeTicks now); | 404 bool IsLikelyAutoNavigation(base::TimeTicks now); |
404 | 405 |
405 // Inserts up to |max_index| entries from |source| into this. This does NOT | 406 // Inserts up to |max_index| entries from |source| into this. This does NOT |
406 // adjust any of the members that reference entries_ | 407 // adjust any of the members that reference entries_ |
407 // (last_committed_entry_index_, pending_entry_index_ or | 408 // (last_committed_entry_index_, pending_entry_index_ or |
408 // transient_entry_index_). | 409 // transient_entry_index_). |
409 void InsertEntriesFrom(const NavigationController& source, int max_index); | 410 void InsertEntriesFrom(const NavigationController& source, int max_index); |
410 | 411 |
411 // --------------------------------------------------------------------------- | 412 // --------------------------------------------------------------------------- |
412 | 413 |
413 // The user profile associated with this controller | 414 // The user context associated with this controller. |
414 Profile* profile_; | 415 content::BrowserContext* browser_context_; |
415 | 416 |
416 // List of NavigationEntry for this tab | 417 // List of NavigationEntry for this tab |
417 typedef std::vector<linked_ptr<NavigationEntry> > NavigationEntries; | 418 typedef std::vector<linked_ptr<NavigationEntry> > NavigationEntries; |
418 NavigationEntries entries_; | 419 NavigationEntries entries_; |
419 | 420 |
420 // An entry we haven't gotten a response for yet. This will be discarded | 421 // An entry we haven't gotten a response for yet. This will be discarded |
421 // when we navigate again. It's used only so we know what the currently | 422 // when we navigate again. It's used only so we know what the currently |
422 // displayed tab is. | 423 // displayed tab is. |
423 // | 424 // |
424 // This may refer to an item in the entries_ list if the pending_entry_index_ | 425 // This may refer to an item in the entries_ list if the pending_entry_index_ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 static size_t max_entry_count_; | 470 static size_t max_entry_count_; |
470 | 471 |
471 // If a repost is pending, its type (RELOAD or RELOAD_IGNORING_CACHE), | 472 // If a repost is pending, its type (RELOAD or RELOAD_IGNORING_CACHE), |
472 // NO_RELOAD otherwise. | 473 // NO_RELOAD otherwise. |
473 ReloadType pending_reload_; | 474 ReloadType pending_reload_; |
474 | 475 |
475 DISALLOW_COPY_AND_ASSIGN(NavigationController); | 476 DISALLOW_COPY_AND_ASSIGN(NavigationController); |
476 }; | 477 }; |
477 | 478 |
478 #endif // CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ | 479 #endif // CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_CONTROLLER_H_ |
OLD | NEW |