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 #include "chrome/browser/prerender/prerender_contents.h" | 5 #include "chrome/browser/prerender/prerender_contents.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/common/icon_messages.h" | 26 #include "chrome/common/icon_messages.h" |
27 #include "chrome/common/render_messages.h" | 27 #include "chrome/common/render_messages.h" |
28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
29 #include "content/browser/browsing_instance.h" | 29 #include "content/browser/browsing_instance.h" |
30 #include "content/browser/renderer_host/render_view_host.h" | 30 #include "content/browser/renderer_host/render_view_host.h" |
31 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 31 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
32 #include "content/browser/renderer_host/resource_request_details.h" | 32 #include "content/browser/renderer_host/resource_request_details.h" |
33 #include "content/browser/site_instance.h" | 33 #include "content/browser/site_instance.h" |
34 #include "content/browser/tab_contents/tab_contents_delegate.h" | 34 #include "content/browser/tab_contents/tab_contents_delegate.h" |
35 #include "content/browser/tab_contents/tab_contents_view.h" | 35 #include "content/browser/tab_contents/tab_contents_view.h" |
| 36 #include "content/common/content_constants.h" |
36 #include "content/common/notification_service.h" | 37 #include "content/common/notification_service.h" |
37 #include "content/common/view_messages.h" | 38 #include "content/common/view_messages.h" |
38 #include "ui/gfx/rect.h" | 39 #include "ui/gfx/rect.h" |
39 | 40 |
40 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
41 #include "chrome/browser/mach_broker_mac.h" | 42 #include "chrome/browser/mach_broker_mac.h" |
42 #endif | 43 #endif |
43 | 44 |
44 namespace prerender { | 45 namespace prerender { |
45 | 46 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 251 |
251 prerendering_has_started_ = true; | 252 prerendering_has_started_ = true; |
252 TabContents* new_contents = new TabContents(profile_, NULL, MSG_ROUTING_NONE, | 253 TabContents* new_contents = new TabContents(profile_, NULL, MSG_ROUTING_NONE, |
253 NULL, NULL); | 254 NULL, NULL); |
254 prerender_contents_.reset(new TabContentsWrapper(new_contents)); | 255 prerender_contents_.reset(new TabContentsWrapper(new_contents)); |
255 tab_contents_observer_registrar_.Observe(new_contents); | 256 tab_contents_observer_registrar_.Observe(new_contents); |
256 | 257 |
257 TabContents* source_tc = | 258 TabContents* source_tc = |
258 source_render_view_host->delegate()->GetAsTabContents(); | 259 source_render_view_host->delegate()->GetAsTabContents(); |
259 if (source_tc) { | 260 if (source_tc) { |
260 // So that history merging will work, get the max page ID | 261 // So that history merging will work, set the max page ID to one greater |
261 // of the old page, and add a safety margin of 10 to it (for things | 262 // than the largest we can ever have. This allows for redirects, but also |
262 // such as redirects). | 263 // for any tabs the user may open between us rendering this page and |
263 int32 max_page_id = source_tc->GetMaxPageID(); | 264 // swapping it in. |
264 if (max_page_id != -1) { | 265 prerender_contents_->controller().set_max_restored_page_id( |
265 prerender_contents_->controller().set_max_restored_page_id( | 266 content::kMaxSessionHistoryEntries + 1); |
266 max_page_id + 10); | |
267 } | |
268 | 267 |
269 tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); | 268 tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); |
270 new_contents->set_delegate(tab_contents_delegate_.get()); | 269 new_contents->set_delegate(tab_contents_delegate_.get()); |
271 | 270 |
272 // Set the size of the new TC to that of the old TC. | 271 // Set the size of the new TC to that of the old TC. |
273 gfx::Rect tab_bounds; | 272 gfx::Rect tab_bounds; |
274 source_tc->view()->GetContainerBounds(&tab_bounds); | 273 source_tc->view()->GetContainerBounds(&tab_bounds); |
275 prerender_contents_->view()->SizeContents(tab_bounds.size()); | 274 prerender_contents_->view()->SizeContents(tab_bounds.size()); |
276 } | 275 } |
277 | 276 |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 } | 802 } |
804 return render_view_host_; | 803 return render_view_host_; |
805 } | 804 } |
806 | 805 |
807 void PrerenderContents::CommitHistory(TabContents* tc) { | 806 void PrerenderContents::CommitHistory(TabContents* tc) { |
808 if (tab_contents_delegate_.get()) | 807 if (tab_contents_delegate_.get()) |
809 tab_contents_delegate_->CommitHistory(tc); | 808 tab_contents_delegate_->CommitHistory(tc); |
810 } | 809 } |
811 | 810 |
812 } // namespace prerender | 811 } // namespace prerender |
OLD | NEW |