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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h" | 22 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h" |
23 #include "content/browser/child_process_security_policy_impl.h" | 23 #include "content/browser/child_process_security_policy_impl.h" |
24 #include "content/browser/devtools/devtools_manager_impl.h" | 24 #include "content/browser/devtools/devtools_manager_impl.h" |
25 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 25 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
26 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 26 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
27 #include "content/browser/download/download_stats.h" | 27 #include "content/browser/download/download_stats.h" |
28 #include "content/browser/download/mhtml_generation_manager.h" | 28 #include "content/browser/download/mhtml_generation_manager.h" |
29 #include "content/browser/download/save_package.h" | 29 #include "content/browser/download/save_package.h" |
30 #include "content/browser/frame_host/interstitial_page_impl.h" | 30 #include "content/browser/frame_host/interstitial_page_impl.h" |
31 #include "content/browser/frame_host/navigation_entry_impl.h" | 31 #include "content/browser/frame_host/navigation_entry_impl.h" |
32 #include "content/browser/frame_host/navigator.h" | |
33 #include "content/browser/frame_host/render_frame_host_impl.h" | |
32 #include "content/browser/host_zoom_map_impl.h" | 34 #include "content/browser/host_zoom_map_impl.h" |
33 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 35 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
34 #include "content/browser/message_port_message_filter.h" | 36 #include "content/browser/message_port_message_filter.h" |
35 #include "content/browser/message_port_service.h" | 37 #include "content/browser/message_port_service.h" |
36 #include "content/browser/power_save_blocker_impl.h" | 38 #include "content/browser/power_save_blocker_impl.h" |
37 #include "content/browser/renderer_host/render_process_host_impl.h" | 39 #include "content/browser/renderer_host/render_process_host_impl.h" |
38 #include "content/browser/renderer_host/render_view_host_impl.h" | 40 #include "content/browser/renderer_host/render_view_host_impl.h" |
39 #include "content/browser/renderer_host/render_widget_host_impl.h" | 41 #include "content/browser/renderer_host/render_widget_host_impl.h" |
40 #include "content/browser/site_instance_impl.h" | 42 #include "content/browser/site_instance_impl.h" |
41 #include "content/browser/web_contents/web_contents_view_guest.h" | 43 #include "content/browser/web_contents/web_contents_view_guest.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 is_showing_before_unload_dialog_(false), | 360 is_showing_before_unload_dialog_(false), |
359 closed_by_user_gesture_(false), | 361 closed_by_user_gesture_(false), |
360 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 362 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
361 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 363 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
362 temporary_zoom_settings_(false), | 364 temporary_zoom_settings_(false), |
363 color_chooser_identifier_(0), | 365 color_chooser_identifier_(0), |
364 message_source_(NULL), | 366 message_source_(NULL), |
365 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) { | 367 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) { |
366 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 368 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
367 g_created_callbacks.Get().at(i).Run(this); | 369 g_created_callbacks.Get().at(i).Run(this); |
370 frame_tree_.Init(&controller_, this); | |
368 frame_tree_.SetFrameRemoveListener( | 371 frame_tree_.SetFrameRemoveListener( |
369 base::Bind(&WebContentsImpl::OnFrameRemoved, | 372 base::Bind(&WebContentsImpl::OnFrameRemoved, |
370 base::Unretained(this))); | 373 base::Unretained(this))); |
371 } | 374 } |
372 | 375 |
373 WebContentsImpl::~WebContentsImpl() { | 376 WebContentsImpl::~WebContentsImpl() { |
374 is_being_destroyed_ = true; | 377 is_being_destroyed_ = true; |
375 | 378 |
376 ClearAllPowerSaveBlockers(); | 379 ClearAllPowerSaveBlockers(); |
377 | 380 |
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1950 if (entry && entry->GetURL() == GURL(kAboutBlankURL)) | 1953 if (entry && entry->GetURL() == GURL(kAboutBlankURL)) |
1951 return true; | 1954 return true; |
1952 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); | 1955 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); |
1953 } | 1956 } |
1954 | 1957 |
1955 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { | 1958 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { |
1956 if (delegate_) | 1959 if (delegate_) |
1957 delegate_->SetFocusToLocationBar(select_all); | 1960 delegate_->SetFocusToLocationBar(select_all); |
1958 } | 1961 } |
1959 | 1962 |
1960 void WebContentsImpl::DidStartProvisionalLoadForFrame( | 1963 void WebContentsImpl::DidStartProvisionalLoad( |
1961 RenderViewHost* render_view_host, | |
1962 int64 frame_id, | 1964 int64 frame_id, |
1963 int64 parent_frame_id, | 1965 int64 parent_frame_id, |
1964 bool is_main_frame, | 1966 bool is_main_frame, |
1965 const GURL& url) { | 1967 const GURL& validated_url, |
1966 bool is_error_page = (url.spec() == kUnreachableWebDataURL); | 1968 bool is_error_page, |
1967 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); | 1969 bool is_iframe_srcdoc, |
1968 GURL validated_url(url); | 1970 RenderFrameHost* render_frame_host) { |
1969 RenderProcessHost* render_process_host = | 1971 DidChangeLoadProgress(0); |
Charlie Reis
2013/11/07 01:22:43
This used to be behind a is_main_frame check. Is
| |
1970 render_view_host->GetProcess(); | |
1971 RenderViewHost::FilterURL(render_process_host, false, &validated_url); | |
1972 | 1972 |
1973 if (is_main_frame) { | 1973 RenderFrameHostImpl* rfh = |
1974 DidChangeLoadProgress(0); | 1974 static_cast<RenderFrameHostImpl*>(render_frame_host); |
1975 | 1975 |
1976 // If there is no browser-initiated pending entry for this navigation and it | |
1977 // is not for the error URL, create a pending entry using the current | |
1978 // SiteInstance, and ensure the address bar updates accordingly. We don't | |
1979 // know the referrer or extra headers at this point, but the referrer will | |
1980 // be set properly upon commit. | |
1981 NavigationEntryImpl* pending_entry = | |
1982 NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()); | |
1983 bool has_browser_initiated_pending_entry = pending_entry && | |
1984 !pending_entry->is_renderer_initiated(); | |
1985 if (!has_browser_initiated_pending_entry && !is_error_page) { | |
1986 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | |
1987 controller_.CreateNavigationEntry(validated_url, | |
1988 content::Referrer(), | |
1989 content::PAGE_TRANSITION_LINK, | |
1990 true /* is_renderer_initiated */, | |
1991 std::string(), | |
1992 GetBrowserContext())); | |
1993 entry->set_site_instance( | |
1994 static_cast<SiteInstanceImpl*>(GetSiteInstance())); | |
1995 // TODO(creis): If there's a pending entry already, find a safe way to | |
1996 // update it instead of replacing it and copying over things like this. | |
1997 if (pending_entry) { | |
1998 entry->set_transferred_global_request_id( | |
1999 pending_entry->transferred_global_request_id()); | |
2000 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | |
2001 entry->set_redirect_chain(pending_entry->redirect_chain()); | |
2002 } | |
2003 controller_.SetPendingEntry(entry); | |
2004 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); | |
2005 } | |
2006 } | |
2007 | |
2008 // Notify observers about the start of the provisional load. | |
2009 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1976 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2010 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id, | 1977 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id, |
2011 is_main_frame, validated_url, is_error_page, | 1978 is_main_frame, validated_url, is_error_page, |
2012 is_iframe_srcdoc, render_view_host)); | 1979 is_iframe_srcdoc, rfh->render_view_host())); |
1980 } | |
2013 | 1981 |
2014 if (is_main_frame) { | 1982 void WebContentsImpl::ProvisionalChangeToMainFrameUrl( |
2015 // Notify observers about the provisional change in the main frame URL. | 1983 const GURL& url, |
2016 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1984 RenderFrameHost* render_frame_host) { |
2017 ProvisionalChangeToMainFrameUrl(validated_url, | 1985 RenderFrameHostImpl* rfh = |
2018 render_view_host)); | 1986 static_cast<RenderFrameHostImpl*>(render_frame_host); |
2019 } | 1987 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1988 ProvisionalChangeToMainFrameUrl( | |
1989 url, rfh->render_view_host())); | |
2020 } | 1990 } |
2021 | 1991 |
2022 void WebContentsImpl::DidRedirectProvisionalLoad( | 1992 void WebContentsImpl::DidRedirectProvisionalLoad( |
2023 RenderViewHost* render_view_host, | 1993 RenderViewHost* render_view_host, |
2024 int32 page_id, | 1994 int32 page_id, |
2025 const GURL& source_url, | 1995 const GURL& source_url, |
2026 const GURL& target_url) { | 1996 const GURL& target_url) { |
2027 // TODO(creis): Remove this method and have the pre-rendering code listen to | 1997 // TODO(creis): Remove this method and have the pre-rendering code listen to |
2028 // WebContentsObserver::DidGetRedirectForResourceRequest instead. | 1998 // WebContentsObserver::DidGetRedirectForResourceRequest instead. |
2029 // See http://crbug.com/78512. | 1999 // See http://crbug.com/78512. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2089 } | 2059 } |
2090 | 2060 |
2091 render_manager_.RendererAbortedProvisionalLoad(render_view_host); | 2061 render_manager_.RendererAbortedProvisionalLoad(render_view_host); |
2092 } | 2062 } |
2093 | 2063 |
2094 // Do not usually clear the pending entry if one exists, so that the user's | 2064 // Do not usually clear the pending entry if one exists, so that the user's |
2095 // typed URL is not lost when a navigation fails or is aborted. However, in | 2065 // typed URL is not lost when a navigation fails or is aborted. However, in |
2096 // cases that we don't show the pending entry (e.g., renderer-initiated | 2066 // cases that we don't show the pending entry (e.g., renderer-initiated |
2097 // navigations in an existing tab), we don't keep it around. That prevents | 2067 // navigations in an existing tab), we don't keep it around. That prevents |
2098 // spoofs on in-page navigations that don't go through | 2068 // spoofs on in-page navigations that don't go through |
2099 // DidStartProvisionalLoadForFrame. | 2069 // DidStartProvisionalLoad. |
2100 // In general, we allow the view to clear the pending entry and typed URL if | 2070 // In general, we allow the view to clear the pending entry and typed URL if |
2101 // the user requests (e.g., hitting Escape with focus in the address bar). | 2071 // the user requests (e.g., hitting Escape with focus in the address bar). |
2102 // Note: don't touch the transient entry, since an interstitial may exist. | 2072 // Note: don't touch the transient entry, since an interstitial may exist. |
2103 if (controller_.GetPendingEntry() != controller_.GetVisibleEntry()) | 2073 if (controller_.GetPendingEntry() != controller_.GetVisibleEntry()) |
2104 controller_.DiscardPendingEntry(); | 2074 controller_.DiscardPendingEntry(); |
2105 | 2075 |
2106 FOR_EACH_OBSERVER(WebContentsObserver, | 2076 FOR_EACH_OBSERVER(WebContentsObserver, |
2107 observers_, | 2077 observers_, |
2108 DidFailProvisionalLoad(params.frame_id, | 2078 DidFailProvisionalLoad(params.frame_id, |
2109 params.frame_unique_name, | 2079 params.frame_unique_name, |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3650 } | 3620 } |
3651 | 3621 |
3652 void WebContentsImpl::OnFrameRemoved( | 3622 void WebContentsImpl::OnFrameRemoved( |
3653 RenderViewHostImpl* render_view_host, | 3623 RenderViewHostImpl* render_view_host, |
3654 int64 frame_id) { | 3624 int64 frame_id) { |
3655 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3625 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3656 FrameDetached(render_view_host, frame_id)); | 3626 FrameDetached(render_view_host, frame_id)); |
3657 } | 3627 } |
3658 | 3628 |
3659 } // namespace content | 3629 } // namespace content |
OLD | NEW |