| 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 19 matching lines...) Expand all Loading... |
| 30 // have any visible display. Its navigation is not managed by a | 30 // have any visible display. Its navigation is not managed by a |
| 31 // NavigationController because is has no facility for navigating (other than | 31 // NavigationController because is has no facility for navigating (other than |
| 32 // programatically view window.location.href) or RenderViewHostManager because | 32 // programatically view window.location.href) or RenderViewHostManager because |
| 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, const std::vector<GURL>& alias_urls); |
| 41 virtual ~PrerenderContents(); | 41 virtual ~PrerenderContents(); |
| 42 virtual void StartPrerendering(); | 42 virtual void StartPrerendering(); |
| 43 | 43 |
| 44 RenderViewHost* render_view_host() { return render_view_host_; } | 44 RenderViewHost* render_view_host() { return render_view_host_; } |
| 45 // Allows replacing of the RenderViewHost owned by this class, including | 45 // Allows replacing of the RenderViewHost owned by this class, including |
| 46 // replacing with a NULL value. When a caller uses this, the caller will | 46 // replacing with a NULL value. When a caller uses this, the caller will |
| 47 // own (and is responsible for freeing) the old RVH. | 47 // own (and is responsible for freeing) the old RVH. |
| 48 void set_render_view_host(RenderViewHost* rvh) { render_view_host_ = rvh; } | 48 void set_render_view_host(RenderViewHost* rvh) { render_view_host_ = rvh; } |
| 49 ViewHostMsg_FrameNavigate_Params* navigate_params() { | 49 ViewHostMsg_FrameNavigate_Params* navigate_params() { |
| 50 return navigate_params_.get(); | 50 return navigate_params_.get(); |
| 51 } | 51 } |
| 52 string16 title() const { return title_; } | 52 string16 title() const { return title_; } |
| 53 int32 page_id() const { return page_id_; } | 53 int32 page_id() const { return page_id_; } |
| 54 | 54 |
| 55 // Indicates whether this prerendered page can be used for the provided |
| 56 // URL, i.e. whether there is a match. |
| 57 bool MatchesURL(const GURL& url) const; |
| 58 |
| 55 // RenderViewHostDelegate implementation. | 59 // RenderViewHostDelegate implementation. |
| 56 virtual RenderViewHostDelegate::View* GetViewDelegate(); | 60 virtual RenderViewHostDelegate::View* GetViewDelegate(); |
| 57 virtual const GURL& GetURL() const; | 61 virtual const GURL& GetURL() const; |
| 58 virtual ViewType::Type GetRenderViewType() const; | 62 virtual ViewType::Type GetRenderViewType() const; |
| 59 virtual int GetBrowserWindowID() const; | 63 virtual int GetBrowserWindowID() const; |
| 60 virtual void DidNavigate(RenderViewHost* render_view_host, | 64 virtual void DidNavigate(RenderViewHost* render_view_host, |
| 61 const ViewHostMsg_FrameNavigate_Params& params); | 65 const ViewHostMsg_FrameNavigate_Params& params); |
| 62 virtual void UpdateTitle(RenderViewHost* render_view_host, | 66 virtual void UpdateTitle(RenderViewHost* render_view_host, |
| 63 int32 page_id, | 67 int32 page_id, |
| 64 const std::wstring& title); | 68 const std::wstring& title); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 const std::wstring& prompt); | 130 const std::wstring& prompt); |
| 127 virtual void SetSuppressMessageBoxes(bool suppress_message_boxes) {} | 131 virtual void SetSuppressMessageBoxes(bool suppress_message_boxes) {} |
| 128 virtual gfx::NativeWindow GetMessageBoxRootWindow(); | 132 virtual gfx::NativeWindow GetMessageBoxRootWindow(); |
| 129 virtual TabContents* AsTabContents(); | 133 virtual TabContents* AsTabContents(); |
| 130 virtual ExtensionHost* AsExtensionHost(); | 134 virtual ExtensionHost* AsExtensionHost(); |
| 131 | 135 |
| 132 virtual void UpdateInspectorSetting(const std::string& key, | 136 virtual void UpdateInspectorSetting(const std::string& key, |
| 133 const std::string& value); | 137 const std::string& value); |
| 134 virtual void ClearInspectorSettings(); | 138 virtual void ClearInspectorSettings(); |
| 135 | 139 |
| 140 protected: |
| 141 // from RenderViewHostDelegate. |
| 142 virtual bool OnMessageReceived(const IPC::Message& message); |
| 143 |
| 136 private: | 144 private: |
| 145 // Message handlers. |
| 146 void OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 147 bool main_frame, |
| 148 const GURL& url); |
| 149 void OnDidRedirectProvisionalLoad(int32 page_id, |
| 150 const GURL& source_url, |
| 151 const GURL& target_url); |
| 152 |
| 153 void AddAliasURL(const GURL& url); |
| 154 |
| 137 // The prerender manager owning this object. | 155 // The prerender manager owning this object. |
| 138 PrerenderManager* prerender_manager_; | 156 PrerenderManager* prerender_manager_; |
| 139 | 157 |
| 140 // The host for our HTML content. | 158 // The host for our HTML content. |
| 141 RenderViewHost* render_view_host_; | 159 RenderViewHost* render_view_host_; |
| 142 | 160 |
| 143 // Common implementations of some RenderViewHostDelegate::View methods. | 161 // Common implementations of some RenderViewHostDelegate::View methods. |
| 144 RenderViewHostDelegateViewHelper delegate_view_helper_; | 162 RenderViewHostDelegateViewHelper delegate_view_helper_; |
| 145 | 163 |
| 146 // The URL being prerendered. | 164 // The URL being prerendered. |
| 147 GURL prerender_url_; | 165 GURL prerender_url_; |
| 148 | 166 |
| 149 // The NavigationParameters of the finished navigation. | 167 // The NavigationParameters of the finished navigation. |
| 150 scoped_ptr<ViewHostMsg_FrameNavigate_Params> navigate_params_; | 168 scoped_ptr<ViewHostMsg_FrameNavigate_Params> navigate_params_; |
| 151 | 169 |
| 152 // The profile being used | 170 // The profile being used |
| 153 Profile* profile_; | 171 Profile* profile_; |
| 154 | 172 |
| 155 // Information about the title and URL of the page that this class as a | 173 // Information about the title and URL of the page that this class as a |
| 156 // RenderViewHostDelegate has received from the RenderView. | 174 // RenderViewHostDelegate has received from the RenderView. |
| 157 // Used to apply to the new RenderViewHost delegate that might eventually | 175 // Used to apply to the new RenderViewHost delegate that might eventually |
| 158 // own the contained RenderViewHost when the prerendered page is shown | 176 // own the contained RenderViewHost when the prerendered page is shown |
| 159 // in a TabContents. | 177 // in a TabContents. |
| 160 string16 title_; | 178 string16 title_; |
| 161 int32 page_id_; | 179 int32 page_id_; |
| 162 GURL url_; | 180 GURL url_; |
| 163 NotificationRegistrar registrar_; | 181 NotificationRegistrar registrar_; |
| 164 | 182 |
| 183 // A vector of URLs that this prerendered page matches against. |
| 184 // This array can contain more than element as a result of redirects, |
| 185 // such as HTTP redirects or javascript redirects. |
| 186 std::vector<GURL> alias_urls_; |
| 187 |
| 165 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 188 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
| 166 }; | 189 }; |
| 167 | 190 |
| 168 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 191 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| OLD | NEW |