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