OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_PRERENDER_PRERENDER_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 22 matching lines...) Expand all Loading... | |
33 // it is never allowed to navigate across a SiteInstance boundary. | 33 // it is never allowed to navigate across a SiteInstance boundary. |
34 class PrerenderContents : public RenderViewHostDelegate, | 34 class PrerenderContents : public RenderViewHostDelegate, |
35 public RenderViewHostDelegate::View, | 35 public RenderViewHostDelegate::View, |
36 public NotificationObserver, | 36 public NotificationObserver, |
37 public JavaScriptAppModalDialogDelegate { | 37 public JavaScriptAppModalDialogDelegate { |
38 public: | 38 public: |
39 PrerenderContents(PrerenderManager* prerender_manager, Profile* profile, | 39 PrerenderContents(PrerenderManager* prerender_manager, Profile* profile, |
40 const GURL& url); | 40 const GURL& url); |
41 virtual ~PrerenderContents(); | 41 virtual ~PrerenderContents(); |
42 virtual void StartPrerendering(); | 42 virtual void StartPrerendering(); |
43 void AddAliasURLs(const std::vector<GURL>& alias_urls); | |
cbentzel
2011/01/12 23:49:53
Why not just pass in the alias_urls to the Prerend
tburkard
2011/01/13 19:14:16
Done.
| |
43 | 44 |
44 RenderViewHost* render_view_host() { return render_view_host_; } | 45 RenderViewHost* render_view_host() { return render_view_host_; } |
45 // Allows replacing of the RenderViewHost owned by this class, including | 46 // Allows replacing of the RenderViewHost owned by this class, including |
46 // replacing with a NULL value. When a caller uses this, the caller will | 47 // replacing with a NULL value. When a caller uses this, the caller will |
47 // own (and is responsible for freeing) the old RVH. | 48 // own (and is responsible for freeing) the old RVH. |
48 void set_render_view_host(RenderViewHost* rvh) { render_view_host_ = rvh; } | 49 void set_render_view_host(RenderViewHost* rvh) { render_view_host_ = rvh; } |
49 ViewHostMsg_FrameNavigate_Params* navigate_params() { | 50 ViewHostMsg_FrameNavigate_Params* navigate_params() { |
50 return navigate_params_.get(); | 51 return navigate_params_.get(); |
51 } | 52 } |
52 string16 title() const { return title_; } | 53 string16 title() const { return title_; } |
53 int32 page_id() const { return page_id_; } | 54 int32 page_id() const { return page_id_; } |
54 | 55 |
56 // Indicates whether this prerendered page can be used for the provided | |
57 // URL, i.e. whether there is a match. | |
58 bool MatchesUrl(const GURL& url); | |
cbentzel
2011/01/12 23:49:53
Nit: MatchesURL instead of MatchesUrl to be consis
tburkard
2011/01/13 19:14:16
Done.
| |
59 | |
55 // RenderViewHostDelegate implementation. | 60 // RenderViewHostDelegate implementation. |
56 virtual RenderViewHostDelegate::View* GetViewDelegate(); | 61 virtual RenderViewHostDelegate::View* GetViewDelegate(); |
57 virtual const GURL& GetURL() const; | 62 virtual const GURL& GetURL() const; |
58 virtual ViewType::Type GetRenderViewType() const; | 63 virtual ViewType::Type GetRenderViewType() const; |
59 virtual int GetBrowserWindowID() const; | 64 virtual int GetBrowserWindowID() const; |
60 virtual void DidNavigate(RenderViewHost* render_view_host, | 65 virtual void DidNavigate(RenderViewHost* render_view_host, |
61 const ViewHostMsg_FrameNavigate_Params& params); | 66 const ViewHostMsg_FrameNavigate_Params& params); |
62 virtual void UpdateTitle(RenderViewHost* render_view_host, | 67 virtual void UpdateTitle(RenderViewHost* render_view_host, |
63 int32 page_id, | 68 int32 page_id, |
64 const std::wstring& title); | 69 const std::wstring& title); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 const std::wstring& prompt); | 131 const std::wstring& prompt); |
127 virtual void SetSuppressMessageBoxes(bool suppress_message_boxes) {} | 132 virtual void SetSuppressMessageBoxes(bool suppress_message_boxes) {} |
128 virtual gfx::NativeWindow GetMessageBoxRootWindow(); | 133 virtual gfx::NativeWindow GetMessageBoxRootWindow(); |
129 virtual TabContents* AsTabContents(); | 134 virtual TabContents* AsTabContents(); |
130 virtual ExtensionHost* AsExtensionHost(); | 135 virtual ExtensionHost* AsExtensionHost(); |
131 | 136 |
132 virtual void UpdateInspectorSetting(const std::string& key, | 137 virtual void UpdateInspectorSetting(const std::string& key, |
133 const std::string& value); | 138 const std::string& value); |
134 virtual void ClearInspectorSettings(); | 139 virtual void ClearInspectorSettings(); |
135 | 140 |
141 protected: | |
142 // from renderViewHostDelegate. | |
143 virtual bool OnMessageReceived(const IPC::Message& message); | |
cbentzel
2011/01/12 23:49:53
I think it's OK to make this private as well.
tburkard
2011/01/13 19:14:16
TabContents has it protected, too, so i figured pr
| |
144 | |
136 private: | 145 private: |
146 // Message handlers. | |
147 void OnDidStartProvisionalLoadForFrame(int64 frame_id, | |
148 bool main_frame, | |
149 const GURL& url); | |
150 void OnDidRedirectProvisionalLoad(int32 page_id, | |
151 const GURL& source_url, | |
152 const GURL& target_url); | |
153 | |
154 void AddMatchingUrl(const GURL& url); | |
cbentzel
2011/01/12 23:49:53
Nit: AddMatchingURL
tburkard
2011/01/13 19:14:16
Done.
| |
155 | |
137 // The prerender manager owning this object. | 156 // The prerender manager owning this object. |
138 PrerenderManager* prerender_manager_; | 157 PrerenderManager* prerender_manager_; |
139 | 158 |
140 // The host for our HTML content. | 159 // The host for our HTML content. |
141 RenderViewHost* render_view_host_; | 160 RenderViewHost* render_view_host_; |
142 | 161 |
143 // Common implementations of some RenderViewHostDelegate::View methods. | 162 // Common implementations of some RenderViewHostDelegate::View methods. |
144 RenderViewHostDelegateViewHelper delegate_view_helper_; | 163 RenderViewHostDelegateViewHelper delegate_view_helper_; |
145 | 164 |
146 // The URL being prerendered. | 165 // The URL being prerendered. |
147 GURL prerender_url_; | 166 GURL prerender_url_; |
148 | 167 |
149 // The NavigationParameters of the finished navigation. | 168 // The NavigationParameters of the finished navigation. |
150 scoped_ptr<ViewHostMsg_FrameNavigate_Params> navigate_params_; | 169 scoped_ptr<ViewHostMsg_FrameNavigate_Params> navigate_params_; |
151 | 170 |
152 // The profile being used | 171 // The profile being used |
153 Profile* profile_; | 172 Profile* profile_; |
154 | 173 |
155 // Information about the title and URL of the page that this class as a | 174 // Information about the title and URL of the page that this class as a |
156 // RenderViewHostDelegate has received from the RenderView. | 175 // RenderViewHostDelegate has received from the RenderView. |
157 // Used to apply to the new RenderViewHost delegate that might eventually | 176 // Used to apply to the new RenderViewHost delegate that might eventually |
158 // own the contained RenderViewHost when the prerendered page is shown | 177 // own the contained RenderViewHost when the prerendered page is shown |
159 // in a TabContents. | 178 // in a TabContents. |
160 string16 title_; | 179 string16 title_; |
161 int32 page_id_; | 180 int32 page_id_; |
162 GURL url_; | 181 GURL url_; |
163 NotificationRegistrar registrar_; | 182 NotificationRegistrar registrar_; |
164 | 183 |
184 // A vector of URLs that this prerendered page matches against. | |
185 // This array can contain more than element as a result of redirects, | |
186 // such as HTTP redirects or javascript redirects. | |
187 std::vector<GURL> matching_urls_; | |
188 | |
165 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 189 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
166 }; | 190 }; |
167 | 191 |
168 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 192 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
OLD | NEW |