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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "content/browser/ssl/ssl_manager.h" | 14 #include "content/browser/ssl/ssl_manager.h" |
15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/navigation_type.h" | 16 #include "content/public/browser/navigation_type.h" |
17 | 17 |
18 struct ViewHostMsg_FrameNavigate_Params; | 18 struct ViewHostMsg_FrameNavigate_Params; |
19 | 19 |
20 namespace skia { | 20 namespace skia { |
21 class PlatformBitmap; | 21 class PlatformBitmap; |
22 } | 22 } |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 class NavigationEntryImpl; | 25 class NavigationEntryImpl; |
| 26 class RenderViewHost; |
26 class WebContentsImpl; | 27 class WebContentsImpl; |
27 class SiteInstance; | 28 class SiteInstance; |
28 struct LoadCommittedDetails; | 29 struct LoadCommittedDetails; |
29 | 30 |
30 class CONTENT_EXPORT NavigationControllerImpl | 31 class CONTENT_EXPORT NavigationControllerImpl |
31 : public NON_EXPORTED_BASE(NavigationController) { | 32 : public NON_EXPORTED_BASE(NavigationController) { |
32 public: | 33 public: |
33 NavigationControllerImpl( | 34 NavigationControllerImpl( |
34 WebContentsImpl* web_contents, | 35 WebContentsImpl* web_contents, |
35 BrowserContext* browser_context); | 36 BrowserContext* browser_context); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 193 |
193 // Maximum number of entries before we start removing entries from the front. | 194 // Maximum number of entries before we start removing entries from the front. |
194 static void set_max_entry_count_for_testing(size_t max_entry_count) { | 195 static void set_max_entry_count_for_testing(size_t max_entry_count) { |
195 max_entry_count_for_testing_ = max_entry_count; | 196 max_entry_count_for_testing_ = max_entry_count; |
196 } | 197 } |
197 static size_t max_entry_count(); | 198 static size_t max_entry_count(); |
198 | 199 |
199 void SetGetTimestampCallbackForTest( | 200 void SetGetTimestampCallbackForTest( |
200 const base::Callback<base::Time()>& get_timestamp_callback); | 201 const base::Callback<base::Time()>& get_timestamp_callback); |
201 | 202 |
| 203 // Takes a screenshot of the page at the current state. |
| 204 void TakeScreenshot(); |
| 205 |
| 206 void SetTakeScreenshotCallbackForTest( |
| 207 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback); |
| 208 |
202 private: | 209 private: |
203 friend class RestoreHelper; | 210 friend class RestoreHelper; |
204 friend class WebContentsImpl; // For invoking OnReservedPageIDRange. | 211 friend class WebContentsImpl; // For invoking OnReservedPageIDRange. |
205 | 212 |
206 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, Basic); | 213 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, Basic); |
207 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, SingleDuplicate); | 214 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, SingleDuplicate); |
208 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ManyDuplicates); | 215 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ManyDuplicates); |
209 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ClockBackwardsJump); | 216 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ClockBackwardsJump); |
210 | 217 |
211 // Helper class to smooth out runs of duplicate timestamps while still | 218 // Helper class to smooth out runs of duplicate timestamps while still |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // Inserts up to |max_index| entries from |source| into this. This does NOT | 312 // Inserts up to |max_index| entries from |source| into this. This does NOT |
306 // adjust any of the members that reference entries_ | 313 // adjust any of the members that reference entries_ |
307 // (last_committed_entry_index_, pending_entry_index_ or | 314 // (last_committed_entry_index_, pending_entry_index_ or |
308 // transient_entry_index_). | 315 // transient_entry_index_). |
309 void InsertEntriesFrom(const NavigationControllerImpl& source, int max_index); | 316 void InsertEntriesFrom(const NavigationControllerImpl& source, int max_index); |
310 | 317 |
311 // Returns the navigation index that differs from the current entry by the | 318 // Returns the navigation index that differs from the current entry by the |
312 // specified |offset|. The index returned is not guaranteed to be valid. | 319 // specified |offset|. The index returned is not guaranteed to be valid. |
313 int GetIndexForOffset(int offset) const; | 320 int GetIndexForOffset(int offset) const; |
314 | 321 |
315 // Takes a screenshot of the page at the current state. | |
316 void TakeScreenshot(); | |
317 | |
318 // The callback invoked when taking the screenshot of the page is complete. | 322 // The callback invoked when taking the screenshot of the page is complete. |
319 // This sets the screenshot on the navigation entry. | 323 // This sets the screenshot on the navigation entry. |
320 void OnScreenshotTaken(int unique_id, | 324 void OnScreenshotTaken(int unique_id, |
321 skia::PlatformBitmap* bitmap, | 325 skia::PlatformBitmap* bitmap, |
322 bool success); | 326 bool success); |
323 | 327 |
324 // --------------------------------------------------------------------------- | 328 // --------------------------------------------------------------------------- |
325 | 329 |
326 // The user browser context associated with this controller. | 330 // The user browser context associated with this controller. |
327 BrowserContext* browser_context_; | 331 BrowserContext* browser_context_; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 // The maximum number of entries that a navigation controller can store. | 388 // The maximum number of entries that a navigation controller can store. |
385 static size_t max_entry_count_for_testing_; | 389 static size_t max_entry_count_for_testing_; |
386 | 390 |
387 // If a repost is pending, its type (RELOAD or RELOAD_IGNORING_CACHE), | 391 // If a repost is pending, its type (RELOAD or RELOAD_IGNORING_CACHE), |
388 // NO_RELOAD otherwise. | 392 // NO_RELOAD otherwise. |
389 ReloadType pending_reload_; | 393 ReloadType pending_reload_; |
390 | 394 |
391 // Used to get timestamps for newly-created navigation entries. | 395 // Used to get timestamps for newly-created navigation entries. |
392 base::Callback<base::Time()> get_timestamp_callback_; | 396 base::Callback<base::Time()> get_timestamp_callback_; |
393 | 397 |
| 398 // A callback that gets called before taking the screenshot of the page. This |
| 399 // is used only for testing. |
| 400 base::Callback<void(RenderViewHost*)> take_screenshot_callback_; |
| 401 |
394 // Used to smooth out timestamps from |get_timestamp_callback_|. | 402 // Used to smooth out timestamps from |get_timestamp_callback_|. |
395 // Without this, whenever there is a run of redirects or | 403 // Without this, whenever there is a run of redirects or |
396 // code-generated navigations, those navigations may occur within | 404 // code-generated navigations, those navigations may occur within |
397 // the timer resolution, leading to things sometimes showing up in | 405 // the timer resolution, leading to things sometimes showing up in |
398 // the wrong order in the history view. | 406 // the wrong order in the history view. |
399 TimeSmoother time_smoother_; | 407 TimeSmoother time_smoother_; |
400 | 408 |
401 DISALLOW_COPY_AND_ASSIGN(NavigationControllerImpl); | 409 DISALLOW_COPY_AND_ASSIGN(NavigationControllerImpl); |
402 }; | 410 }; |
403 | 411 |
404 } // namespace content | 412 } // namespace content |
405 | 413 |
406 #endif // CONTENT_BROWSER_WEB_CONTENTS_NAVIGATION_CONTROLLER_IMPL_H_ | 414 #endif // CONTENT_BROWSER_WEB_CONTENTS_NAVIGATION_CONTROLLER_IMPL_H_ |
OLD | NEW |