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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 365 |
366 #if defined(OS_ANDROID) | 366 #if defined(OS_ANDROID) |
367 // Delay between tapping in content and launching the associated android intent. | 367 // Delay between tapping in content and launching the associated android intent. |
368 // Used to allow users see what has been recognized as content. | 368 // Used to allow users see what has been recognized as content. |
369 const size_t kContentIntentDelayMilliseconds = 700; | 369 const size_t kContentIntentDelayMilliseconds = 700; |
370 #endif | 370 #endif |
371 | 371 |
372 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = | 372 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = |
373 NULL; | 373 NULL; |
374 | 374 |
375 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | |
376 // Replace any occurrences of swappedout:// with about:blank. | |
377 const WebURL& blank_url = GURL(kAboutBlankURL); | |
378 WebVector<WebURL> urls; | |
379 ds->redirectChain(urls); | |
380 result->reserve(urls.size()); | |
381 for (size_t i = 0; i < urls.size(); ++i) { | |
382 if (urls[i] != GURL(kSwappedOutURL)) | |
383 result->push_back(urls[i]); | |
384 else | |
385 result->push_back(blank_url); | |
386 } | |
387 } | |
388 | |
389 // If |data_source| is non-null and has an InternalDocumentStateData associated | 375 // If |data_source| is non-null and has an InternalDocumentStateData associated |
390 // with it, the AltErrorPageResourceFetcher is reset. | 376 // with it, the AltErrorPageResourceFetcher is reset. |
391 static void StopAltErrorPageFetcher(WebDataSource* data_source) { | 377 static void StopAltErrorPageFetcher(WebDataSource* data_source) { |
392 if (data_source) { | 378 if (data_source) { |
393 InternalDocumentStateData* internal_data = | 379 InternalDocumentStateData* internal_data = |
394 InternalDocumentStateData::FromDataSource(data_source); | 380 InternalDocumentStateData::FromDataSource(data_source); |
395 if (internal_data) | 381 if (internal_data) |
396 internal_data->set_alt_error_page_fetcher(NULL); | 382 internal_data->set_alt_error_page_fetcher(NULL); |
397 } | 383 } |
398 } | 384 } |
399 | 385 |
400 static bool IsReload(const ViewMsg_Navigate_Params& params) { | 386 static bool IsReload(const ViewMsg_Navigate_Params& params) { |
401 return | 387 return |
402 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || | 388 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
403 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE || | 389 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE || |
404 params.navigation_type == | 390 params.navigation_type == |
405 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; | 391 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
406 } | 392 } |
407 | 393 |
408 // static | 394 // static |
| 395 void RenderViewImpl::GetRedirectChain(WebDataSource* ds, |
| 396 std::vector<GURL>* result) { |
| 397 // Replace any occurrences of swappedout:// with about:blank. |
| 398 const WebURL& blank_url = GURL(kAboutBlankURL); |
| 399 WebVector<WebURL> urls; |
| 400 ds->redirectChain(urls); |
| 401 result->reserve(urls.size()); |
| 402 for (size_t i = 0; i < urls.size(); ++i) { |
| 403 if (urls[i] != GURL(kSwappedOutURL)) |
| 404 result->push_back(urls[i]); |
| 405 else |
| 406 result->push_back(blank_url); |
| 407 } |
| 408 } |
| 409 |
| 410 // static |
409 WebReferrerPolicy RenderViewImpl::GetReferrerPolicyFromRequest( | 411 WebReferrerPolicy RenderViewImpl::GetReferrerPolicyFromRequest( |
410 WebFrame* frame, | 412 WebFrame* frame, |
411 const WebURLRequest& request) { | 413 const WebURLRequest& request) { |
412 return request.extraData() ? | 414 return request.extraData() ? |
413 static_cast<RequestExtraData*>(request.extraData())->referrer_policy() : | 415 static_cast<RequestExtraData*>(request.extraData())->referrer_policy() : |
414 frame->document().referrerPolicy(); | 416 frame->document().referrerPolicy(); |
415 } | 417 } |
416 | 418 |
417 // static | 419 // static |
418 Referrer RenderViewImpl::GetReferrerFromRequest( | 420 Referrer RenderViewImpl::GetReferrerFromRequest( |
(...skipping 3110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3529 | 3531 |
3530 float maxPageScaleFactor = | 3532 float maxPageScaleFactor = |
3531 command_line.HasSwitch(switches::kEnablePinch) ? 4.f : 1.f ; | 3533 command_line.HasSwitch(switches::kEnablePinch) ? 4.f : 1.f ; |
3532 webview()->setPageScaleFactorLimits(1, maxPageScaleFactor); | 3534 webview()->setPageScaleFactorLimits(1, maxPageScaleFactor); |
3533 } | 3535 } |
3534 | 3536 |
3535 // TODO(nasko): Remove this method once WebTestProxy in Blink is fixed. | 3537 // TODO(nasko): Remove this method once WebTestProxy in Blink is fixed. |
3536 void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) { | 3538 void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) { |
3537 } | 3539 } |
3538 | 3540 |
3539 void RenderViewImpl::didReceiveServerRedirectForProvisionalLoad( | |
3540 WebFrame* frame) { | |
3541 if (frame->parent()) | |
3542 return; | |
3543 // Received a redirect on the main frame. | |
3544 WebDataSource* data_source = frame->provisionalDataSource(); | |
3545 if (!data_source) { | |
3546 // Should only be invoked when we have a data source. | |
3547 NOTREACHED(); | |
3548 return; | |
3549 } | |
3550 std::vector<GURL> redirects; | |
3551 GetRedirectChain(data_source, &redirects); | |
3552 if (redirects.size() >= 2) { | |
3553 Send(new ViewHostMsg_DidRedirectProvisionalLoad(routing_id_, page_id_, | |
3554 redirects[redirects.size() - 2], redirects.back())); | |
3555 } | |
3556 } | |
3557 | |
3558 void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, | 3541 void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, |
3559 const WebURLError& error) { | 3542 const WebURLError& error) { |
3560 // Notify the browser that we failed a provisional load with an error. | 3543 // Notify the browser that we failed a provisional load with an error. |
3561 // | 3544 // |
3562 // Note: It is important this notification occur before DidStopLoading so the | 3545 // Note: It is important this notification occur before DidStopLoading so the |
3563 // SSL manager can react to the provisional load failure before being | 3546 // SSL manager can react to the provisional load failure before being |
3564 // notified the load stopped. | 3547 // notified the load stopped. |
3565 // | 3548 // |
3566 FOR_EACH_OBSERVER( | 3549 FOR_EACH_OBSERVER( |
3567 RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); | 3550 RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); |
(...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6380 for (size_t i = 0; i < icon_urls.size(); i++) { | 6363 for (size_t i = 0; i < icon_urls.size(); i++) { |
6381 WebURL url = icon_urls[i].iconURL(); | 6364 WebURL url = icon_urls[i].iconURL(); |
6382 if (!url.isEmpty()) | 6365 if (!url.isEmpty()) |
6383 urls.push_back(FaviconURL(url, | 6366 urls.push_back(FaviconURL(url, |
6384 ToFaviconType(icon_urls[i].iconType()))); | 6367 ToFaviconType(icon_urls[i].iconType()))); |
6385 } | 6368 } |
6386 SendUpdateFaviconURL(urls); | 6369 SendUpdateFaviconURL(urls); |
6387 } | 6370 } |
6388 | 6371 |
6389 } // namespace content | 6372 } // namespace content |
OLD | NEW |