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_BROWSER_WEB_CONTENTS_NAVIGATION_CONTROLLER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_NAVIGATION_CONTROLLER_IMPL_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_NAVIGATION_CONTROLLER_IMPL_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_NAVIGATION_CONTROLLER_IMPL_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "content/browser/ssl/ssl_manager.h" | 12 #include "content/browser/ssl/ssl_manager.h" |
13 #include "content/public/browser/android/navigation_controller_webview.h" | 13 #include "content/public/browser/android/navigation_controller_webview.h" |
14 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
15 #include "content/public/browser/navigation_type.h" | 15 #include "content/public/browser/navigation_type.h" |
16 | 16 |
17 class SessionStorageNamespaceImpl; | |
18 struct ViewHostMsg_FrameNavigate_Params; | 17 struct ViewHostMsg_FrameNavigate_Params; |
19 class WebContentsImpl; | 18 class WebContentsImpl; |
20 | 19 |
21 namespace content { | 20 namespace content { |
22 class NavigationEntryImpl; | 21 class NavigationEntryImpl; |
23 struct LoadCommittedDetails; | 22 struct LoadCommittedDetails; |
24 class SiteInstance; | 23 class SiteInstance; |
25 } | 24 } |
26 | 25 |
27 class CONTENT_EXPORT NavigationControllerImpl | 26 class CONTENT_EXPORT NavigationControllerImpl |
28 : public NON_EXPORTED_BASE(content::NavigationController), | 27 : public NON_EXPORTED_BASE(content::NavigationController), |
29 public NON_EXPORTED_BASE(content::NavigationControllerWebView) { | 28 public NON_EXPORTED_BASE(content::NavigationControllerWebView) { |
30 public: | 29 public: |
31 NavigationControllerImpl( | 30 NavigationControllerImpl( |
32 WebContentsImpl* web_contents, | 31 WebContentsImpl* web_contents, |
33 content::BrowserContext* browser_context, | 32 content::BrowserContext* browser_context); |
34 SessionStorageNamespaceImpl* session_storage_namespace); | |
35 virtual ~NavigationControllerImpl(); | 33 virtual ~NavigationControllerImpl(); |
36 | 34 |
37 // NavigationController implementation: | 35 // NavigationController implementation: |
38 virtual content::WebContents* GetWebContents() const OVERRIDE; | 36 virtual content::WebContents* GetWebContents() const OVERRIDE; |
39 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; | 37 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; |
40 virtual void SetBrowserContext( | 38 virtual void SetBrowserContext( |
41 content::BrowserContext* browser_context) OVERRIDE; | 39 content::BrowserContext* browser_context) OVERRIDE; |
42 virtual void Restore( | 40 virtual void Restore( |
43 int selected_navigation, | 41 int selected_navigation, |
44 bool from_last_session, | 42 bool from_last_session, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 virtual void LoadIfNecessary() OVERRIDE; | 79 virtual void LoadIfNecessary() OVERRIDE; |
82 virtual bool CanGoBack() const OVERRIDE; | 80 virtual bool CanGoBack() const OVERRIDE; |
83 virtual bool CanGoForward() const OVERRIDE; | 81 virtual bool CanGoForward() const OVERRIDE; |
84 virtual bool CanGoToOffset(int offset) const OVERRIDE; | 82 virtual bool CanGoToOffset(int offset) const OVERRIDE; |
85 virtual void GoBack() OVERRIDE; | 83 virtual void GoBack() OVERRIDE; |
86 virtual void GoForward() OVERRIDE; | 84 virtual void GoForward() OVERRIDE; |
87 virtual void GoToIndex(int index) OVERRIDE; | 85 virtual void GoToIndex(int index) OVERRIDE; |
88 virtual void GoToOffset(int offset) OVERRIDE; | 86 virtual void GoToOffset(int offset) OVERRIDE; |
89 virtual void RemoveEntryAtIndex(int index) OVERRIDE; | 87 virtual void RemoveEntryAtIndex(int index) OVERRIDE; |
90 virtual content::SessionStorageNamespace* | 88 virtual content::SessionStorageNamespace* |
91 GetSessionStorageNamespace() const OVERRIDE; | 89 GetSessionStorageNamespace(int renderer_id) OVERRIDE; |
| 90 virtual const content::SessionStorageNamespaceMap& |
| 91 GetSessionStorageNamespaceMap() const OVERRIDE; |
92 virtual void SetMaxRestoredPageID(int32 max_id) OVERRIDE; | 92 virtual void SetMaxRestoredPageID(int32 max_id) OVERRIDE; |
93 virtual int32 GetMaxRestoredPageID() const OVERRIDE; | 93 virtual int32 GetMaxRestoredPageID() const OVERRIDE; |
94 virtual bool NeedsReload() const OVERRIDE; | 94 virtual bool NeedsReload() const OVERRIDE; |
95 virtual void CancelPendingReload() OVERRIDE; | 95 virtual void CancelPendingReload() OVERRIDE; |
96 virtual void ContinuePendingReload() OVERRIDE; | 96 virtual void ContinuePendingReload() OVERRIDE; |
97 virtual bool IsInitialNavigation() OVERRIDE; | 97 virtual bool IsInitialNavigation() OVERRIDE; |
98 virtual void Reload(bool check_for_repost) OVERRIDE; | 98 virtual void Reload(bool check_for_repost) OVERRIDE; |
99 virtual void ReloadIgnoringCache(bool check_for_repost) OVERRIDE; | 99 virtual void ReloadIgnoringCache(bool check_for_repost) OVERRIDE; |
100 virtual void NotifyEntryChanged(const content::NavigationEntry* entry, | 100 virtual void NotifyEntryChanged(const content::NavigationEntry* entry, |
101 int index) OVERRIDE; | 101 int index) OVERRIDE; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // is no last committed entry, then nothing will be in-page. | 178 // is no last committed entry, then nothing will be in-page. |
179 // | 179 // |
180 // Special note: if the URLs are the same, it does NOT count as an in-page | 180 // Special note: if the URLs are the same, it does NOT count as an in-page |
181 // navigation. Neither does an input URL that has no ref, even if the rest is | 181 // navigation. Neither does an input URL that has no ref, even if the rest is |
182 // the same. This may seem weird, but when we're considering whether a | 182 // the same. This may seem weird, but when we're considering whether a |
183 // navigation happened without loading anything, the same URL would be a | 183 // navigation happened without loading anything, the same URL would be a |
184 // reload, while only a different ref would be in-page (pages can't clear | 184 // reload, while only a different ref would be in-page (pages can't clear |
185 // refs without reload, only change to "#" which we don't count as empty). | 185 // refs without reload, only change to "#" which we don't count as empty). |
186 bool IsURLInPageNavigation(const GURL& url) const; | 186 bool IsURLInPageNavigation(const GURL& url) const; |
187 | 187 |
| 188 // Sets the SessionStorageNamespace for the given |partition_id|. This is |
| 189 // used during initialization of a new NavigationController to allow |
| 190 // pre-population of the SessionStorageNamespace objects. Session restore, |
| 191 // prerendering, and the implementaion of window.open() are the primary users |
| 192 // of this API. |
| 193 // |
| 194 // Calling this function when a SessionStorageNamespace has already been |
| 195 // associated with a |partition_id| will CHECK() fail. |
| 196 void SetSessionStorageNamespace( |
| 197 const std::string& partition_id, |
| 198 content::SessionStorageNamespace* session_storage_namespace); |
| 199 |
188 // Random data --------------------------------------------------------------- | 200 // Random data --------------------------------------------------------------- |
189 | 201 |
190 SSLManager* ssl_manager() { return &ssl_manager_; } | 202 SSLManager* ssl_manager() { return &ssl_manager_; } |
191 | 203 |
192 // Maximum number of entries before we start removing entries from the front. | 204 // Maximum number of entries before we start removing entries from the front. |
193 static void set_max_entry_count_for_testing(size_t max_entry_count) { | 205 static void set_max_entry_count_for_testing(size_t max_entry_count) { |
194 max_entry_count_for_testing_ = max_entry_count; | 206 max_entry_count_for_testing_ = max_entry_count; |
195 } | 207 } |
196 static size_t max_entry_count(); | 208 static size_t max_entry_count(); |
197 | 209 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 344 |
333 // Manages the SSL security UI | 345 // Manages the SSL security UI |
334 SSLManager ssl_manager_; | 346 SSLManager ssl_manager_; |
335 | 347 |
336 // Whether we need to be reloaded when made active. | 348 // Whether we need to be reloaded when made active. |
337 bool needs_reload_; | 349 bool needs_reload_; |
338 | 350 |
339 // The time ticks at which the last document was loaded. | 351 // The time ticks at which the last document was loaded. |
340 base::TimeTicks last_document_loaded_; | 352 base::TimeTicks last_document_loaded_; |
341 | 353 |
342 // The session storage id that any (indirectly) owned RenderView should use. | 354 // Used to find the appropriate SessionStorageNamespace for the storage |
343 scoped_refptr<SessionStorageNamespaceImpl> session_storage_namespace_; | 355 // partition of a NavigationEntry. |
| 356 // |
| 357 // A NavigationController may contain NavigationEntries that correspond to |
| 358 // different StoragePartitions. Even though they are part of the same |
| 359 // NavigationController, only entries in the same StoragePartition may |
| 360 // share session storage state with one another. |
| 361 content::SessionStorageNamespaceMap session_storage_namespace_map_; |
344 | 362 |
345 // The maximum number of entries that a navigation controller can store. | 363 // The maximum number of entries that a navigation controller can store. |
346 static size_t max_entry_count_for_testing_; | 364 static size_t max_entry_count_for_testing_; |
347 | 365 |
348 // If a repost is pending, its type (RELOAD or RELOAD_IGNORING_CACHE), | 366 // If a repost is pending, its type (RELOAD or RELOAD_IGNORING_CACHE), |
349 // NO_RELOAD otherwise. | 367 // NO_RELOAD otherwise. |
350 ReloadType pending_reload_; | 368 ReloadType pending_reload_; |
351 | 369 |
352 DISALLOW_COPY_AND_ASSIGN(NavigationControllerImpl); | 370 DISALLOW_COPY_AND_ASSIGN(NavigationControllerImpl); |
353 }; | 371 }; |
354 | 372 |
355 #endif // CONTENT_BROWSER_WEB_CONTENTS_NAVIGATION_CONTROLLER_IMPL_H_ | 373 #endif // CONTENT_BROWSER_WEB_CONTENTS_NAVIGATION_CONTROLLER_IMPL_H_ |
OLD | NEW |