| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/prerender/prerender_final_status.h" | 16 #include "chrome/browser/prerender/prerender_final_status.h" |
| 17 #include "content/browser/tab_contents/tab_contents_observer.h" | 17 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/common/referrer.h" |
| 19 | 20 |
| 20 class Profile; | 21 class Profile; |
| 21 class RenderViewHost; | 22 class RenderViewHost; |
| 22 class RenderViewHostDelegate; | 23 class RenderViewHostDelegate; |
| 23 class SessionStorageNamespace; | 24 class SessionStorageNamespace; |
| 24 class TabContents; | 25 class TabContents; |
| 25 class TabContentsWrapper; | 26 class TabContentsWrapper; |
| 26 struct FaviconURL; | 27 struct FaviconURL; |
| 27 | 28 |
| 28 namespace base { | 29 namespace base { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 50 Factory() {} | 51 Factory() {} |
| 51 virtual ~Factory() {} | 52 virtual ~Factory() {} |
| 52 | 53 |
| 53 // Ownership is not transfered through this interface as prerender_manager, | 54 // Ownership is not transfered through this interface as prerender_manager, |
| 54 // prerender_tracker, and profile are stored as weak pointers. | 55 // prerender_tracker, and profile are stored as weak pointers. |
| 55 virtual PrerenderContents* CreatePrerenderContents( | 56 virtual PrerenderContents* CreatePrerenderContents( |
| 56 PrerenderManager* prerender_manager, | 57 PrerenderManager* prerender_manager, |
| 57 PrerenderTracker* prerender_tracker, | 58 PrerenderTracker* prerender_tracker, |
| 58 Profile* profile, | 59 Profile* profile, |
| 59 const GURL& url, | 60 const GURL& url, |
| 60 const GURL& referrer, | 61 const content::Referrer& referrer, |
| 61 Origin origin, | 62 Origin origin, |
| 62 uint8 experiment_id) = 0; | 63 uint8 experiment_id) = 0; |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(Factory); | 66 DISALLOW_COPY_AND_ASSIGN(Factory); |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 // Information on pages that the prerendered page has tried to prerender. | 69 // Information on pages that the prerendered page has tried to prerender. |
| 69 struct PendingPrerenderData { | 70 struct PendingPrerenderData { |
| 70 PendingPrerenderData(Origin origin, const GURL& url, const GURL& referrer); | 71 PendingPrerenderData(Origin origin, |
| 72 const GURL& url, |
| 73 const content::Referrer& referrer); |
| 71 | 74 |
| 72 Origin origin; | 75 Origin origin; |
| 73 GURL url; | 76 GURL url; |
| 74 GURL referrer; | 77 content::Referrer referrer; |
| 75 }; | 78 }; |
| 76 typedef std::list<PendingPrerenderData> PendingPrerenderList; | 79 typedef std::list<PendingPrerenderData> PendingPrerenderList; |
| 77 | 80 |
| 78 virtual ~PrerenderContents(); | 81 virtual ~PrerenderContents(); |
| 79 | 82 |
| 80 bool Init(); | 83 bool Init(); |
| 81 | 84 |
| 82 static Factory* CreateFactory(); | 85 static Factory* CreateFactory(); |
| 83 | 86 |
| 84 // |source_render_view_host| is the RenderViewHost that initiated | 87 // |source_render_view_host| is the RenderViewHost that initiated |
| 85 // prerendering. | 88 // prerendering. |
| 86 virtual void StartPrerendering( | 89 virtual void StartPrerendering( |
| 87 const RenderViewHost* source_render_view_host, | 90 const RenderViewHost* source_render_view_host, |
| 88 SessionStorageNamespace* session_storage_namespace); | 91 SessionStorageNamespace* session_storage_namespace); |
| 89 | 92 |
| 90 // Verifies that the prerendering is not using too many resources, and kills | 93 // Verifies that the prerendering is not using too many resources, and kills |
| 91 // it if not. | 94 // it if not. |
| 92 void DestroyWhenUsingTooManyResources(); | 95 void DestroyWhenUsingTooManyResources(); |
| 93 | 96 |
| 94 RenderViewHost* render_view_host_mutable(); | 97 RenderViewHost* render_view_host_mutable(); |
| 95 const RenderViewHost* render_view_host() const; | 98 const RenderViewHost* render_view_host() const; |
| 96 string16 title() const { return title_; } | 99 string16 title() const { return title_; } |
| 97 int32 page_id() const { return page_id_; } | 100 int32 page_id() const { return page_id_; } |
| 98 GURL icon_url() const { return icon_url_; } | 101 GURL icon_url() const { return icon_url_; } |
| 99 const GURL& prerender_url() const { return prerender_url_; } | 102 const GURL& prerender_url() const { return prerender_url_; } |
| 100 const GURL& referrer() const { return referrer_; } | 103 const content::Referrer& referrer() const { return referrer_; } |
| 101 bool has_stopped_loading() const { return has_stopped_loading_; } | 104 bool has_stopped_loading() const { return has_stopped_loading_; } |
| 102 bool prerendering_has_started() const { return prerendering_has_started_; } | 105 bool prerendering_has_started() const { return prerendering_has_started_; } |
| 103 | 106 |
| 104 // Sets the parameter to the value of the associated RenderViewHost's child id | 107 // Sets the parameter to the value of the associated RenderViewHost's child id |
| 105 // and returns a boolean indicating the validity of that id. | 108 // and returns a boolean indicating the validity of that id. |
| 106 virtual bool GetChildId(int* child_id) const; | 109 virtual bool GetChildId(int* child_id) const; |
| 107 | 110 |
| 108 // Sets the parameter to the value of the associated RenderViewHost's route id | 111 // Sets the parameter to the value of the associated RenderViewHost's route id |
| 109 // and returns a boolean indicating the validity of that id. | 112 // and returns a boolean indicating the validity of that id. |
| 110 virtual bool GetRouteId(int* route_id) const; | 113 virtual bool GetRouteId(int* route_id) const; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 base::Value* GetAsValue() const; | 175 base::Value* GetAsValue() const; |
| 173 | 176 |
| 174 // Returns whether a pending cross-site navigation is happening. | 177 // Returns whether a pending cross-site navigation is happening. |
| 175 // This could happen with renderer-issued navigations, such as a | 178 // This could happen with renderer-issued navigations, such as a |
| 176 // MouseEvent being dispatched by a link to a website installed as an app. | 179 // MouseEvent being dispatched by a link to a website installed as an app. |
| 177 bool IsCrossSiteNavigationPending() const; | 180 bool IsCrossSiteNavigationPending() const; |
| 178 | 181 |
| 179 // Adds a pending prerender to the list. | 182 // Adds a pending prerender to the list. |
| 180 virtual void AddPendingPrerender(Origin origin, | 183 virtual void AddPendingPrerender(Origin origin, |
| 181 const GURL& url, | 184 const GURL& url, |
| 182 const GURL& referrer); | 185 const content::Referrer& referrer); |
| 183 | 186 |
| 184 // Returns true if |url| corresponds to a pending prerender. | 187 // Returns true if |url| corresponds to a pending prerender. |
| 185 bool IsPendingEntry(const GURL& url) const; | 188 bool IsPendingEntry(const GURL& url) const; |
| 186 | 189 |
| 187 // Reissues any pending prerender requests from the prerendered page. Also | 190 // Reissues any pending prerender requests from the prerendered page. Also |
| 188 // clears the list of pending requests. | 191 // clears the list of pending requests. |
| 189 void StartPendingPrerenders(); | 192 void StartPendingPrerenders(); |
| 190 | 193 |
| 191 protected: | 194 protected: |
| 192 PrerenderContents(PrerenderManager* prerender_manager, | 195 PrerenderContents(PrerenderManager* prerender_manager, |
| 193 PrerenderTracker* prerender_tracker, | 196 PrerenderTracker* prerender_tracker, |
| 194 Profile* profile, | 197 Profile* profile, |
| 195 const GURL& url, | 198 const GURL& url, |
| 196 const GURL& referrer, | 199 const content::Referrer& referrer, |
| 197 Origin origin, | 200 Origin origin, |
| 198 uint8 experiment_id); | 201 uint8 experiment_id); |
| 199 | 202 |
| 200 // Called whenever a RenderViewHost is created for prerendering. Only called | 203 // Called whenever a RenderViewHost is created for prerendering. Only called |
| 201 // once the RenderViewHost has a RenderView and RenderWidgetHostView. | 204 // once the RenderViewHost has a RenderView and RenderWidgetHostView. |
| 202 virtual void OnRenderViewHostCreated(RenderViewHost* new_render_view_host); | 205 virtual void OnRenderViewHostCreated(RenderViewHost* new_render_view_host); |
| 203 | 206 |
| 204 content::NotificationRegistrar& notification_registrar() { | 207 content::NotificationRegistrar& notification_registrar() { |
| 205 return notification_registrar_; | 208 return notification_registrar_; |
| 206 } | 209 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 229 // The prerender manager owning this object. | 232 // The prerender manager owning this object. |
| 230 PrerenderManager* prerender_manager_; | 233 PrerenderManager* prerender_manager_; |
| 231 | 234 |
| 232 // The prerender tracker tracking prerenders. | 235 // The prerender tracker tracking prerenders. |
| 233 PrerenderTracker* prerender_tracker_; | 236 PrerenderTracker* prerender_tracker_; |
| 234 | 237 |
| 235 // The URL being prerendered. | 238 // The URL being prerendered. |
| 236 GURL prerender_url_; | 239 GURL prerender_url_; |
| 237 | 240 |
| 238 // The referrer. | 241 // The referrer. |
| 239 GURL referrer_; | 242 content::Referrer referrer_; |
| 240 | 243 |
| 241 // The profile being used | 244 // The profile being used |
| 242 Profile* profile_; | 245 Profile* profile_; |
| 243 | 246 |
| 244 // Information about the title and URL of the page that this class as a | 247 // Information about the title and URL of the page that this class as a |
| 245 // RenderViewHostDelegate has received from the RenderView. | 248 // RenderViewHostDelegate has received from the RenderView. |
| 246 // Used to apply to the new RenderViewHost delegate that might eventually | 249 // Used to apply to the new RenderViewHost delegate that might eventually |
| 247 // own the contained RenderViewHost when the prerendered page is shown | 250 // own the contained RenderViewHost when the prerendered page is shown |
| 248 // in a TabContents. | 251 // in a TabContents. |
| 249 string16 title_; | 252 string16 title_; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 306 |
| 304 // Offset by which to offset prerendered pages | 307 // Offset by which to offset prerendered pages |
| 305 static const int32 kPrerenderPageIdOffset = 10; | 308 static const int32 kPrerenderPageIdOffset = 10; |
| 306 | 309 |
| 307 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 310 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
| 308 }; | 311 }; |
| 309 | 312 |
| 310 } // namespace prerender | 313 } // namespace prerender |
| 311 | 314 |
| 312 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 315 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| OLD | NEW |