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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #include "content/public/browser/web_contents_observer.h" | 72 #include "content/public/browser/web_contents_observer.h" |
73 #include "content/public/browser/web_contents_view.h" | 73 #include "content/public/browser/web_contents_view.h" |
74 #include "content/public/common/bindings_policy.h" | 74 #include "content/public/common/bindings_policy.h" |
75 #include "content/public/common/content_constants.h" | 75 #include "content/public/common/content_constants.h" |
76 #include "content/public/common/content_switches.h" | 76 #include "content/public/common/content_switches.h" |
77 #include "content/public/common/page_zoom.h" | 77 #include "content/public/common/page_zoom.h" |
78 #include "content/public/common/url_constants.h" | 78 #include "content/public/common/url_constants.h" |
79 #include "net/base/mime_util.h" | 79 #include "net/base/mime_util.h" |
80 #include "net/base/net_util.h" | 80 #include "net/base/net_util.h" |
81 #include "net/base/network_change_notifier.h" | 81 #include "net/base/network_change_notifier.h" |
| 82 #include "net/http/http_cache.h" |
| 83 #include "net/http/http_transaction_factory.h" |
| 84 #include "net/url_request/url_request_context.h" |
82 #include "net/url_request/url_request_context_getter.h" | 85 #include "net/url_request/url_request_context_getter.h" |
83 #include "ui/base/layout.h" | 86 #include "ui/base/layout.h" |
84 #include "ui/base/touch/touch_device.h" | 87 #include "ui/base/touch/touch_device.h" |
85 #include "ui/base/touch/touch_enabled.h" | 88 #include "ui/base/touch/touch_enabled.h" |
86 #include "ui/base/ui_base_switches.h" | 89 #include "ui/base/ui_base_switches.h" |
87 #include "ui/gfx/display.h" | 90 #include "ui/gfx/display.h" |
88 #include "ui/gfx/screen.h" | 91 #include "ui/gfx/screen.h" |
89 #include "ui/gl/gl_switches.h" | 92 #include "ui/gl/gl_switches.h" |
90 #include "webkit/common/webpreferences.h" | 93 #include "webkit/common/webpreferences.h" |
91 | 94 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 params->url = entry.GetURL(); | 261 params->url = entry.GetURL(); |
259 } | 262 } |
260 | 263 |
261 params->can_load_local_resources = entry.GetCanLoadLocalResources(); | 264 params->can_load_local_resources = entry.GetCanLoadLocalResources(); |
262 params->frame_to_navigate = entry.GetFrameToNavigate(); | 265 params->frame_to_navigate = entry.GetFrameToNavigate(); |
263 | 266 |
264 if (delegate) | 267 if (delegate) |
265 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); | 268 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); |
266 } | 269 } |
267 | 270 |
| 271 void NotifyCacheOnIO( |
| 272 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 273 const GURL& url, |
| 274 const std::string& http_method) { |
| 275 request_context->GetURLRequestContext()->http_transaction_factory()-> |
| 276 GetCache()->OnExternalCacheHit(url, http_method); |
| 277 } |
| 278 |
268 } // namespace | 279 } // namespace |
269 | 280 |
270 WebContents* WebContents::Create(const WebContents::CreateParams& params) { | 281 WebContents* WebContents::Create(const WebContents::CreateParams& params) { |
271 return WebContentsImpl::CreateWithOpener( | 282 return WebContentsImpl::CreateWithOpener( |
272 params, static_cast<WebContentsImpl*>(params.opener)); | 283 params, static_cast<WebContentsImpl*>(params.opener)); |
273 } | 284 } |
274 | 285 |
275 WebContents* WebContents::CreateWithSessionStorage( | 286 WebContents* WebContents::CreateWithSessionStorage( |
276 const WebContents::CreateParams& params, | 287 const WebContents::CreateParams& params, |
277 const SessionStorageNamespaceMap& session_storage_namespace_map) { | 288 const SessionStorageNamespaceMap& session_storage_namespace_map) { |
(...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 controller_.ssl_manager()->DidLoadFromMemoryCache(details); | 2293 controller_.ssl_manager()->DidLoadFromMemoryCache(details); |
2283 | 2294 |
2284 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2295 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2285 DidLoadResourceFromMemoryCache(details)); | 2296 DidLoadResourceFromMemoryCache(details)); |
2286 | 2297 |
2287 // TODO(avi): Remove. http://crbug.com/170921 | 2298 // TODO(avi): Remove. http://crbug.com/170921 |
2288 NotificationService::current()->Notify( | 2299 NotificationService::current()->Notify( |
2289 NOTIFICATION_LOAD_FROM_MEMORY_CACHE, | 2300 NOTIFICATION_LOAD_FROM_MEMORY_CACHE, |
2290 Source<NavigationController>(&controller_), | 2301 Source<NavigationController>(&controller_), |
2291 Details<LoadFromMemoryCacheDetails>(&details)); | 2302 Details<LoadFromMemoryCacheDetails>(&details)); |
| 2303 |
| 2304 if (url.is_valid() && url.SchemeIsHTTPOrHTTPS()) { |
| 2305 scoped_refptr<net::URLRequestContextGetter> request_context( |
| 2306 resource_type == ResourceType::MEDIA ? |
| 2307 GetBrowserContext()->GetMediaRequestContextForRenderProcess( |
| 2308 GetRenderProcessHost()->GetID()) : |
| 2309 GetBrowserContext()->GetRequestContextForRenderProcess( |
| 2310 GetRenderProcessHost()->GetID())); |
| 2311 BrowserThread::PostTask( |
| 2312 BrowserThread::IO, |
| 2313 FROM_HERE, |
| 2314 base::Bind(&NotifyCacheOnIO, request_context, url, http_method)); |
| 2315 } |
2292 } | 2316 } |
2293 | 2317 |
2294 void WebContentsImpl::OnDidDisplayInsecureContent() { | 2318 void WebContentsImpl::OnDidDisplayInsecureContent() { |
2295 RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); | 2319 RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); |
2296 displayed_insecure_content_ = true; | 2320 displayed_insecure_content_ = true; |
2297 SSLManager::NotifySSLInternalStateChanged( | 2321 SSLManager::NotifySSLInternalStateChanged( |
2298 GetController().GetBrowserContext()); | 2322 GetController().GetBrowserContext()); |
2299 } | 2323 } |
2300 | 2324 |
2301 void WebContentsImpl::OnDidRunInsecureContent( | 2325 void WebContentsImpl::OnDidRunInsecureContent( |
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3790 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { | 3814 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { |
3791 gfx::Size size; | 3815 gfx::Size size; |
3792 if (delegate_) | 3816 if (delegate_) |
3793 size = delegate_->GetSizeForNewRenderView(this); | 3817 size = delegate_->GetSizeForNewRenderView(this); |
3794 if (size.IsEmpty()) | 3818 if (size.IsEmpty()) |
3795 size = view_->GetContainerSize(); | 3819 size = view_->GetContainerSize(); |
3796 return size; | 3820 return size; |
3797 } | 3821 } |
3798 | 3822 |
3799 } // namespace content | 3823 } // namespace content |
OLD | NEW |