Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 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" | 32 #include "content/browser/frame_host/navigator.h" |
| 33 #include "content/browser/frame_host/render_frame_host_impl.h" | |
| 33 #include "content/browser/host_zoom_map_impl.h" | 34 #include "content/browser/host_zoom_map_impl.h" |
| 34 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 35 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 35 #include "content/browser/message_port_message_filter.h" | 36 #include "content/browser/message_port_message_filter.h" |
| 36 #include "content/browser/message_port_service.h" | 37 #include "content/browser/message_port_service.h" |
| 37 #include "content/browser/power_save_blocker_impl.h" | 38 #include "content/browser/power_save_blocker_impl.h" |
| 38 #include "content/browser/renderer_host/render_process_host_impl.h" | 39 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 39 #include "content/browser/renderer_host/render_view_host_impl.h" | 40 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 40 #include "content/browser/renderer_host/render_widget_host_impl.h" | 41 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 41 #include "content/browser/site_instance_impl.h" | 42 #include "content/browser/site_instance_impl.h" |
| 42 #include "content/browser/web_contents/web_contents_view_guest.h" | 43 #include "content/browser/web_contents/web_contents_view_guest.h" |
| (...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1959 if (entry && entry->GetURL() == GURL(kAboutBlankURL)) | 1960 if (entry && entry->GetURL() == GURL(kAboutBlankURL)) |
| 1960 return true; | 1961 return true; |
| 1961 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); | 1962 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); |
| 1962 } | 1963 } |
| 1963 | 1964 |
| 1964 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { | 1965 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { |
| 1965 if (delegate_) | 1966 if (delegate_) |
| 1966 delegate_->SetFocusToLocationBar(select_all); | 1967 delegate_->SetFocusToLocationBar(select_all); |
| 1967 } | 1968 } |
| 1968 | 1969 |
| 1969 void WebContentsImpl::DidStartProvisionalLoadForFrame( | 1970 void WebContentsImpl::DidStartProvisionalLoad( |
| 1970 RenderViewHost* render_view_host, | 1971 RenderFrameHostImpl* render_frame_host, |
| 1971 int64 frame_id, | 1972 int64 frame_id, |
| 1972 int64 parent_frame_id, | 1973 int64 parent_frame_id, |
| 1973 bool is_main_frame, | 1974 bool is_main_frame, |
| 1974 const GURL& url) { | 1975 const GURL& validated_url, |
| 1975 bool is_error_page = (url.spec() == kUnreachableWebDataURL); | 1976 bool is_error_page, |
| 1976 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); | 1977 bool is_iframe_srcdoc) { |
| 1977 GURL validated_url(url); | 1978 if (is_main_frame) |
| 1978 RenderProcessHost* render_process_host = | |
| 1979 render_view_host->GetProcess(); | |
| 1980 RenderViewHost::FilterURL(render_process_host, false, &validated_url); | |
| 1981 | |
| 1982 if (is_main_frame) { | |
| 1983 DidChangeLoadProgress(0); | 1979 DidChangeLoadProgress(0); |
| 1984 | 1980 |
| 1985 // If there is no browser-initiated pending entry for this navigation and it | |
| 1986 // is not for the error URL, create a pending entry using the current | |
| 1987 // SiteInstance, and ensure the address bar updates accordingly. We don't | |
| 1988 // know the referrer or extra headers at this point, but the referrer will | |
| 1989 // be set properly upon commit. | |
| 1990 NavigationEntryImpl* pending_entry = | |
| 1991 NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()); | |
| 1992 bool has_browser_initiated_pending_entry = pending_entry && | |
| 1993 !pending_entry->is_renderer_initiated(); | |
| 1994 if (!has_browser_initiated_pending_entry && !is_error_page) { | |
| 1995 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | |
| 1996 controller_.CreateNavigationEntry(validated_url, | |
| 1997 content::Referrer(), | |
| 1998 content::PAGE_TRANSITION_LINK, | |
| 1999 true /* is_renderer_initiated */, | |
| 2000 std::string(), | |
| 2001 GetBrowserContext())); | |
| 2002 entry->set_site_instance( | |
| 2003 static_cast<SiteInstanceImpl*>(GetSiteInstance())); | |
| 2004 // TODO(creis): If there's a pending entry already, find a safe way to | |
| 2005 // update it instead of replacing it and copying over things like this. | |
| 2006 if (pending_entry) { | |
| 2007 entry->set_transferred_global_request_id( | |
| 2008 pending_entry->transferred_global_request_id()); | |
| 2009 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | |
| 2010 entry->set_redirect_chain(pending_entry->redirect_chain()); | |
| 2011 } | |
| 2012 controller_.SetPendingEntry(entry); | |
| 2013 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); | |
| 2014 } | |
| 2015 } | |
| 2016 | |
| 2017 // Notify observers about the start of the provisional load. | 1981 // Notify observers about the start of the provisional load. |
| 2018 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1982 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2019 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id, | 1983 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id, |
| 2020 is_main_frame, validated_url, is_error_page, | 1984 is_main_frame, validated_url, is_error_page, |
| 2021 is_iframe_srcdoc, render_view_host)); | 1985 is_iframe_srcdoc, render_frame_host->render_view_host())); |
| 1986 } | |
| 2022 | 1987 |
| 2023 if (is_main_frame) { | 1988 void WebContentsImpl::NotifyProvisionalChangeToMainFrameUrl( |
|
Charlie Reis
2013/11/21 21:59:32
Why did we need to split this part out into its ow
nasko
2013/11/22 01:02:34
Done.
| |
| 2024 // Notify observers about the provisional change in the main frame URL. | 1989 RenderFrameHostImpl* render_frame_host, |
| 2025 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1990 const GURL& url) { |
| 2026 ProvisionalChangeToMainFrameUrl(validated_url, | 1991 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2027 render_view_host)); | 1992 ProvisionalChangeToMainFrameUrl( |
| 2028 } | 1993 url, render_frame_host->render_view_host())); |
| 2029 } | 1994 } |
| 2030 | 1995 |
| 2031 void WebContentsImpl::DidRedirectProvisionalLoad( | 1996 void WebContentsImpl::DidRedirectProvisionalLoad( |
| 2032 RenderViewHost* render_view_host, | 1997 RenderViewHost* render_view_host, |
| 2033 int32 page_id, | 1998 int32 page_id, |
| 2034 const GURL& source_url, | 1999 const GURL& source_url, |
| 2035 const GURL& target_url) { | 2000 const GURL& target_url) { |
| 2036 // TODO(creis): Remove this method and have the pre-rendering code listen to | 2001 // TODO(creis): Remove this method and have the pre-rendering code listen to |
| 2037 // WebContentsObserver::DidGetRedirectForResourceRequest instead. | 2002 // WebContentsObserver::DidGetRedirectForResourceRequest instead. |
| 2038 // See http://crbug.com/78512. | 2003 // See http://crbug.com/78512. |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3682 } | 3647 } |
| 3683 | 3648 |
| 3684 void WebContentsImpl::OnFrameRemoved( | 3649 void WebContentsImpl::OnFrameRemoved( |
| 3685 RenderViewHostImpl* render_view_host, | 3650 RenderViewHostImpl* render_view_host, |
| 3686 int64 frame_id) { | 3651 int64 frame_id) { |
| 3687 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3652 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3688 FrameDetached(render_view_host, frame_id)); | 3653 FrameDetached(render_view_host, frame_id)); |
| 3689 } | 3654 } |
| 3690 | 3655 |
| 3691 } // namespace content | 3656 } // namespace content |
| OLD | NEW |