OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #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" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/history/history_tab_helper.h" | 12 #include "chrome/browser/history/history_tab_helper.h" |
13 #include "chrome/browser/history/history_types.h" | 13 #include "chrome/browser/history/history_types.h" |
14 #include "chrome/browser/prerender/prerender_final_status.h" | 14 #include "chrome/browser/prerender/prerender_final_status.h" |
15 #include "chrome/browser/prerender/prerender_manager.h" | 15 #include "chrome/browser/prerender/prerender_manager.h" |
16 #include "chrome/browser/prerender/prerender_render_view_host_observer.h" | 16 #include "chrome/browser/prerender/prerender_render_view_host_observer.h" |
17 #include "chrome/browser/prerender/prerender_tracker.h" | 17 #include "chrome/browser/prerender/prerender_tracker.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/icon_messages.h" | 23 #include "chrome/common/icon_messages.h" |
24 #include "chrome/common/prerender_messages.h" | 24 #include "chrome/common/prerender_messages.h" |
25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
26 #include "content/public/browser/resource_request_details.h" | 26 #include "content/public/browser/resource_request_details.h" |
27 #include "content/public/browser/browser_child_process_host.h" | 27 #include "content/public/browser/browser_child_process_host.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
30 #include "content/public/browser/render_view_host.h" | 30 #include "content/public/browser/render_view_host.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 size_ = prerender_manager_->config().default_tab_bounds.size(); | 289 size_ = prerender_manager_->config().default_tab_bounds.size(); |
290 #if !defined(OS_ANDROID) | 290 #if !defined(OS_ANDROID) |
291 // Try to get the active tab of the active browser and use that for tab | 291 // Try to get the active tab of the active browser and use that for tab |
292 // bounds. If the browser has never been active, we will fail to get a size | 292 // bounds. If the browser has never been active, we will fail to get a size |
293 // but we shouldn't be prerendering in that case anyway. | 293 // but we shouldn't be prerendering in that case anyway. |
294 // | 294 // |
295 // This code is unneeded on Android as we do not have a Browser object so we | 295 // This code is unneeded on Android as we do not have a Browser object so we |
296 // can't get the size, and |default_tab_bounds| will be set to the right | 296 // can't get the size, and |default_tab_bounds| will be set to the right |
297 // value. | 297 // value. |
298 if (Browser* active_browser = | 298 if (Browser* active_browser = |
299 BrowserList::GetLastActiveWithProfile(profile_)) { | 299 browser::FindLastActiveWithProfile(profile_)) { |
300 if (WebContents* active_web_contents = active_browser->GetWebContentsAt( | 300 if (WebContents* active_web_contents = active_browser->GetWebContentsAt( |
301 active_browser->active_index())) { | 301 active_browser->active_index())) { |
302 gfx::Rect container_bounds; | 302 gfx::Rect container_bounds; |
303 active_web_contents->GetView()->GetContainerBounds(&container_bounds); | 303 active_web_contents->GetView()->GetContainerBounds(&container_bounds); |
304 size_ = container_bounds.size(); | 304 size_ = container_bounds.size(); |
305 } | 305 } |
306 } | 306 } |
307 #endif // !defined(OS_ANDROID) | 307 #endif // !defined(OS_ANDROID) |
308 } | 308 } |
309 | 309 |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 bool PrerenderContents::IsCrossSiteNavigationPending() const { | 708 bool PrerenderContents::IsCrossSiteNavigationPending() const { |
709 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) | 709 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) |
710 return false; | 710 return false; |
711 const WebContents* web_contents = prerender_contents_->web_contents(); | 711 const WebContents* web_contents = prerender_contents_->web_contents(); |
712 return (web_contents->GetSiteInstance() != | 712 return (web_contents->GetSiteInstance() != |
713 web_contents->GetPendingSiteInstance()); | 713 web_contents->GetPendingSiteInstance()); |
714 } | 714 } |
715 | 715 |
716 | 716 |
717 } // namespace prerender | 717 } // namespace prerender |
OLD | NEW |