OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
6 #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/timer.h" | 12 #include "base/timer.h" |
13 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" | 13 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/web_contents_delegate.h" | 16 #include "content/public/browser/web_contents_delegate.h" |
17 | 17 |
18 class GURL; | 18 class GURL; |
19 class Profile; | 19 class Profile; |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 struct OpenURLParams; | 22 struct OpenURLParams; |
| 23 class NavigationEntry; |
23 class WebContents; | 24 class WebContents; |
24 } | 25 } |
25 | 26 |
26 // InstantLoader is used to create and maintain a WebContents where we can | 27 // InstantLoader is used to create and maintain a WebContents where we can |
27 // preload a page into. It is used by InstantOverlay and InstantNTP to | 28 // preload a page into. It is used by InstantOverlay and InstantNTP to |
28 // preload an Instant page. | 29 // preload an Instant page. |
29 class InstantLoader : public content::NotificationObserver, | 30 class InstantLoader : public content::NotificationObserver, |
30 public content::WebContentsDelegate, | 31 public content::WebContentsDelegate, |
31 public CoreTabHelperDelegate { | 32 public CoreTabHelperDelegate { |
32 public: | 33 public: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 content::WebContents* contents() const { return contents_.get(); } | 79 content::WebContents* contents() const { return contents_.get(); } |
79 | 80 |
80 // Replaces the contents held with |contents|. Any existing contents is | 81 // Replaces the contents held with |contents|. Any existing contents is |
81 // deleted. The expiration timer is not restarted. | 82 // deleted. The expiration timer is not restarted. |
82 void SetContents(scoped_ptr<content::WebContents> contents); | 83 void SetContents(scoped_ptr<content::WebContents> contents); |
83 | 84 |
84 // Releases the contents currently held. Must only be called if contents() is | 85 // Releases the contents currently held. Must only be called if contents() is |
85 // not NULL. | 86 // not NULL. |
86 scoped_ptr<content::WebContents> ReleaseContents() WARN_UNUSED_RESULT; | 87 scoped_ptr<content::WebContents> ReleaseContents() WARN_UNUSED_RESULT; |
87 | 88 |
| 89 // Returns the initial navigation entry for the most recently loaded URL. |
| 90 const content::NavigationEntry* base_navigation_entry() { |
| 91 return base_navigation_entry_.get(); |
| 92 } |
| 93 |
88 private: | 94 private: |
89 // Overridden from content::NotificationObserver: | 95 // Overridden from content::NotificationObserver: |
90 virtual void Observe(int type, | 96 virtual void Observe(int type, |
91 const content::NotificationSource& source, | 97 const content::NotificationSource& source, |
92 const content::NotificationDetails& details) OVERRIDE; | 98 const content::NotificationDetails& details) OVERRIDE; |
93 | 99 |
94 // Overridden from CoreTabHelperDelegate: | 100 // Overridden from CoreTabHelperDelegate: |
95 virtual void SwapTabContents(content::WebContents* old_contents, | 101 virtual void SwapTabContents(content::WebContents* old_contents, |
96 content::WebContents* new_contents) OVERRIDE; | 102 content::WebContents* new_contents) OVERRIDE; |
97 | 103 |
(...skipping 17 matching lines...) Expand all Loading... |
115 | 121 |
116 Delegate* const delegate_; | 122 Delegate* const delegate_; |
117 scoped_ptr<content::WebContents> contents_; | 123 scoped_ptr<content::WebContents> contents_; |
118 | 124 |
119 // The URL we will be loading. | 125 // The URL we will be loading. |
120 GURL instant_url_; | 126 GURL instant_url_; |
121 | 127 |
122 // Called when |stale_page_timer_| fires. | 128 // Called when |stale_page_timer_| fires. |
123 base::Closure on_stale_callback_; | 129 base::Closure on_stale_callback_; |
124 | 130 |
| 131 // The initial navigation entry for the URL we loaded. |
| 132 scoped_ptr<const content::NavigationEntry> base_navigation_entry_; |
| 133 |
125 // Used to mark when the page is stale. | 134 // Used to mark when the page is stale. |
126 base::Timer stale_page_timer_; | 135 base::Timer stale_page_timer_; |
127 | 136 |
128 // Used to get notifications about renderers. | 137 // Used to get notifications about renderers. |
129 content::NotificationRegistrar registrar_; | 138 content::NotificationRegistrar registrar_; |
130 | 139 |
131 DISALLOW_COPY_AND_ASSIGN(InstantLoader); | 140 DISALLOW_COPY_AND_ASSIGN(InstantLoader); |
132 }; | 141 }; |
133 | 142 |
134 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 143 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
OLD | NEW |