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 13 matching lines...) Expand all Loading... |
24 #include "content/browser/child_process_security_policy_impl.h" | 24 #include "content/browser/child_process_security_policy_impl.h" |
25 #include "content/browser/devtools/devtools_manager_impl.h" | 25 #include "content/browser/devtools/devtools_manager_impl.h" |
26 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 26 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
27 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 27 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
28 #include "content/browser/download/download_stats.h" | 28 #include "content/browser/download/download_stats.h" |
29 #include "content/browser/download/mhtml_generation_manager.h" | 29 #include "content/browser/download/mhtml_generation_manager.h" |
30 #include "content/browser/download/save_package.h" | 30 #include "content/browser/download/save_package.h" |
31 #include "content/browser/frame_host/interstitial_page_impl.h" | 31 #include "content/browser/frame_host/interstitial_page_impl.h" |
32 #include "content/browser/frame_host/navigation_entry_impl.h" | 32 #include "content/browser/frame_host/navigation_entry_impl.h" |
33 #include "content/browser/frame_host/navigator_impl.h" | 33 #include "content/browser/frame_host/navigator_impl.h" |
| 34 #include "content/browser/frame_host/render_frame_host_impl.h" |
34 #include "content/browser/host_zoom_map_impl.h" | 35 #include "content/browser/host_zoom_map_impl.h" |
35 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 36 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
36 #include "content/browser/message_port_message_filter.h" | 37 #include "content/browser/message_port_message_filter.h" |
37 #include "content/browser/message_port_service.h" | 38 #include "content/browser/message_port_service.h" |
38 #include "content/browser/power_save_blocker_impl.h" | 39 #include "content/browser/power_save_blocker_impl.h" |
39 #include "content/browser/renderer_host/render_process_host_impl.h" | 40 #include "content/browser/renderer_host/render_process_host_impl.h" |
40 #include "content/browser/renderer_host/render_view_host_impl.h" | 41 #include "content/browser/renderer_host/render_view_host_impl.h" |
41 #include "content/browser/renderer_host/render_widget_host_impl.h" | 42 #include "content/browser/renderer_host/render_widget_host_impl.h" |
42 #include "content/browser/site_instance_impl.h" | 43 #include "content/browser/site_instance_impl.h" |
43 #include "content/browser/web_contents/web_contents_view_guest.h" | 44 #include "content/browser/web_contents/web_contents_view_guest.h" |
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 if (entry && entry->GetURL() == GURL(kAboutBlankURL)) | 2029 if (entry && entry->GetURL() == GURL(kAboutBlankURL)) |
2029 return true; | 2030 return true; |
2030 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); | 2031 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); |
2031 } | 2032 } |
2032 | 2033 |
2033 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { | 2034 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { |
2034 if (delegate_) | 2035 if (delegate_) |
2035 delegate_->SetFocusToLocationBar(select_all); | 2036 delegate_->SetFocusToLocationBar(select_all); |
2036 } | 2037 } |
2037 | 2038 |
2038 void WebContentsImpl::DidStartProvisionalLoadForFrame( | 2039 void WebContentsImpl::DidStartProvisionalLoad( |
2039 RenderViewHost* render_view_host, | 2040 RenderFrameHostImpl* render_frame_host, |
2040 int64 frame_id, | 2041 int64 frame_id, |
2041 int64 parent_frame_id, | 2042 int64 parent_frame_id, |
2042 bool is_main_frame, | 2043 bool is_main_frame, |
2043 const GURL& url) { | 2044 const GURL& validated_url, |
2044 bool is_error_page = (url.spec() == kUnreachableWebDataURL); | 2045 bool is_error_page, |
2045 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); | 2046 bool is_iframe_srcdoc) { |
2046 GURL validated_url(url); | 2047 if (is_main_frame) |
2047 RenderProcessHost* render_process_host = | |
2048 render_view_host->GetProcess(); | |
2049 RenderViewHost::FilterURL(render_process_host, false, &validated_url); | |
2050 | |
2051 if (is_main_frame) { | |
2052 DidChangeLoadProgress(0); | 2048 DidChangeLoadProgress(0); |
2053 | 2049 |
2054 // If there is no browser-initiated pending entry for this navigation and it | |
2055 // is not for the error URL, create a pending entry using the current | |
2056 // SiteInstance, and ensure the address bar updates accordingly. We don't | |
2057 // know the referrer or extra headers at this point, but the referrer will | |
2058 // be set properly upon commit. | |
2059 NavigationEntryImpl* pending_entry = | |
2060 NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()); | |
2061 bool has_browser_initiated_pending_entry = pending_entry && | |
2062 !pending_entry->is_renderer_initiated(); | |
2063 if (!has_browser_initiated_pending_entry && !is_error_page) { | |
2064 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | |
2065 controller_.CreateNavigationEntry(validated_url, | |
2066 content::Referrer(), | |
2067 content::PAGE_TRANSITION_LINK, | |
2068 true /* is_renderer_initiated */, | |
2069 std::string(), | |
2070 GetBrowserContext())); | |
2071 entry->set_site_instance( | |
2072 static_cast<SiteInstanceImpl*>(GetSiteInstance())); | |
2073 // TODO(creis): If there's a pending entry already, find a safe way to | |
2074 // update it instead of replacing it and copying over things like this. | |
2075 if (pending_entry) { | |
2076 entry->set_transferred_global_request_id( | |
2077 pending_entry->transferred_global_request_id()); | |
2078 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | |
2079 entry->set_redirect_chain(pending_entry->redirect_chain()); | |
2080 } | |
2081 controller_.SetPendingEntry(entry); | |
2082 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); | |
2083 } | |
2084 } | |
2085 | |
2086 // Notify observers about the start of the provisional load. | 2050 // Notify observers about the start of the provisional load. |
2087 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2051 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2088 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id, | 2052 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id, |
2089 is_main_frame, validated_url, is_error_page, | 2053 is_main_frame, validated_url, is_error_page, |
2090 is_iframe_srcdoc, render_view_host)); | 2054 is_iframe_srcdoc, render_frame_host->render_view_host())); |
2091 | 2055 |
2092 if (is_main_frame) { | 2056 if (is_main_frame) { |
2093 // Notify observers about the provisional change in the main frame URL. | 2057 FOR_EACH_OBSERVER( |
2094 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2058 WebContentsObserver, |
2095 ProvisionalChangeToMainFrameUrl(validated_url, | 2059 observers_, |
2096 render_view_host)); | 2060 ProvisionalChangeToMainFrameUrl(validated_url, |
| 2061 render_frame_host->render_view_host())); |
2097 } | 2062 } |
2098 } | 2063 } |
2099 | 2064 |
| 2065 void WebContentsImpl::NotifyChangedNavigationState( |
| 2066 InvalidateTypes changed_flags) { |
| 2067 NotifyNavigationStateChanged(changed_flags); |
| 2068 } |
| 2069 |
2100 void WebContentsImpl::DidRedirectProvisionalLoad( | 2070 void WebContentsImpl::DidRedirectProvisionalLoad( |
2101 RenderViewHost* render_view_host, | 2071 RenderViewHost* render_view_host, |
2102 int32 page_id, | 2072 int32 page_id, |
2103 const GURL& source_url, | 2073 const GURL& source_url, |
2104 const GURL& target_url) { | 2074 const GURL& target_url) { |
2105 // TODO(creis): Remove this method and have the pre-rendering code listen to | 2075 // TODO(creis): Remove this method and have the pre-rendering code listen to |
2106 // WebContentsObserver::DidGetRedirectForResourceRequest instead. | 2076 // WebContentsObserver::DidGetRedirectForResourceRequest instead. |
2107 // See http://crbug.com/78512. | 2077 // See http://crbug.com/78512. |
2108 GURL validated_source_url(source_url); | 2078 GURL validated_source_url(source_url); |
2109 GURL validated_target_url(target_url); | 2079 GURL validated_target_url(target_url); |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3775 } | 3745 } |
3776 | 3746 |
3777 void WebContentsImpl::OnFrameRemoved( | 3747 void WebContentsImpl::OnFrameRemoved( |
3778 RenderViewHostImpl* render_view_host, | 3748 RenderViewHostImpl* render_view_host, |
3779 int64 frame_id) { | 3749 int64 frame_id) { |
3780 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3750 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3781 FrameDetached(render_view_host, frame_id)); | 3751 FrameDetached(render_view_host, frame_id)); |
3782 } | 3752 } |
3783 | 3753 |
3784 } // namespace content | 3754 } // namespace content |
OLD | NEW |