| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 this, | 409 this, |
| 410 this), | 410 this), |
| 411 is_load_to_different_document_(false), | 411 is_load_to_different_document_(false), |
| 412 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 412 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 413 crashed_error_code_(0), | 413 crashed_error_code_(0), |
| 414 waiting_for_response_(false), | 414 waiting_for_response_(false), |
| 415 load_state_(net::LOAD_STATE_IDLE, base::string16()), | 415 load_state_(net::LOAD_STATE_IDLE, base::string16()), |
| 416 upload_size_(0), | 416 upload_size_(0), |
| 417 upload_position_(0), | 417 upload_position_(0), |
| 418 is_resume_pending_(false), | 418 is_resume_pending_(false), |
| 419 displayed_insecure_content_(false), | |
| 420 displayed_content_with_cert_errors_(false), | |
| 421 displayed_password_field_on_http_(false), | |
| 422 displayed_credit_card_field_on_http_(false), | |
| 423 has_accessed_initial_document_(false), | 419 has_accessed_initial_document_(false), |
| 424 theme_color_(SK_ColorTRANSPARENT), | 420 theme_color_(SK_ColorTRANSPARENT), |
| 425 last_sent_theme_color_(SK_ColorTRANSPARENT), | 421 last_sent_theme_color_(SK_ColorTRANSPARENT), |
| 426 did_first_visually_non_empty_paint_(false), | 422 did_first_visually_non_empty_paint_(false), |
| 427 capturer_count_(0), | 423 capturer_count_(0), |
| 428 should_normally_be_visible_(true), | 424 should_normally_be_visible_(true), |
| 429 did_first_set_visible_(false), | 425 did_first_set_visible_(false), |
| 430 is_being_destroyed_(false), | 426 is_being_destroyed_(false), |
| 431 notify_disconnection_(false), | 427 notify_disconnection_(false), |
| 432 dialog_manager_(NULL), | 428 dialog_manager_(NULL), |
| (...skipping 2095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2528 void WebContentsImpl::ResizeDueToAutoResize( | 2524 void WebContentsImpl::ResizeDueToAutoResize( |
| 2529 RenderWidgetHostImpl* render_widget_host, | 2525 RenderWidgetHostImpl* render_widget_host, |
| 2530 const gfx::Size& new_size) { | 2526 const gfx::Size& new_size) { |
| 2531 if (render_widget_host != GetRenderViewHost()->GetWidget()) | 2527 if (render_widget_host != GetRenderViewHost()->GetWidget()) |
| 2532 return; | 2528 return; |
| 2533 | 2529 |
| 2534 if (delegate_) | 2530 if (delegate_) |
| 2535 delegate_->ResizeDueToAutoResize(this, new_size); | 2531 delegate_->ResizeDueToAutoResize(this, new_size); |
| 2536 } | 2532 } |
| 2537 | 2533 |
| 2538 bool WebContentsImpl::DisplayedInsecureContent() const { | |
| 2539 return displayed_insecure_content_; | |
| 2540 } | |
| 2541 | |
| 2542 bool WebContentsImpl::DisplayedContentWithCertErrors() const { | |
| 2543 return displayed_content_with_cert_errors_; | |
| 2544 } | |
| 2545 | |
| 2546 bool WebContentsImpl::DisplayedPasswordFieldOnHttp() const { | |
| 2547 return displayed_password_field_on_http_; | |
| 2548 } | |
| 2549 | |
| 2550 bool WebContentsImpl::DisplayedCreditCardFieldOnHttp() const { | |
| 2551 return displayed_credit_card_field_on_http_; | |
| 2552 } | |
| 2553 | |
| 2554 WebContents* WebContentsImpl::OpenURL(const OpenURLParams& params) { | 2534 WebContents* WebContentsImpl::OpenURL(const OpenURLParams& params) { |
| 2555 if (!delegate_) | 2535 if (!delegate_) |
| 2556 return NULL; | 2536 return NULL; |
| 2557 | 2537 |
| 2558 WebContents* new_contents = delegate_->OpenURLFromTab(this, params); | 2538 WebContents* new_contents = delegate_->OpenURLFromTab(this, params); |
| 2559 return new_contents; | 2539 return new_contents; |
| 2560 } | 2540 } |
| 2561 | 2541 |
| 2562 bool WebContentsImpl::Send(IPC::Message* message) { | 2542 bool WebContentsImpl::Send(IPC::Message* message) { |
| 2563 if (!GetRenderViewHost()) { | 2543 if (!GetRenderViewHost()) { |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3420 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); | 3400 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); |
| 3421 if (rwhvb) | 3401 if (rwhvb) |
| 3422 rwhvb->OnDidNavigateMainFrameToNewPage(); | 3402 rwhvb->OnDidNavigateMainFrameToNewPage(); |
| 3423 | 3403 |
| 3424 did_first_visually_non_empty_paint_ = false; | 3404 did_first_visually_non_empty_paint_ = false; |
| 3425 | 3405 |
| 3426 // Reset theme color on navigation to new page. | 3406 // Reset theme color on navigation to new page. |
| 3427 theme_color_ = SK_ColorTRANSPARENT; | 3407 theme_color_ = SK_ColorTRANSPARENT; |
| 3428 } | 3408 } |
| 3429 | 3409 |
| 3430 if (!details.is_in_page) { | |
| 3431 // Once the main frame is navigated, we're no longer considered to have | |
| 3432 // displayed insecure content. | |
| 3433 displayed_insecure_content_ = false; | |
| 3434 displayed_content_with_cert_errors_ = false; | |
| 3435 displayed_password_field_on_http_ = false; | |
| 3436 displayed_credit_card_field_on_http_ = false; | |
| 3437 SSLManager::NotifySSLInternalStateChanged( | |
| 3438 GetController().GetBrowserContext()); | |
| 3439 } | |
| 3440 | |
| 3441 // Notify observers about navigation. | 3410 // Notify observers about navigation. |
| 3442 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3411 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3443 DidNavigateMainFrame(details, params)); | 3412 DidNavigateMainFrame(details, params)); |
| 3444 | 3413 |
| 3445 if (delegate_) | 3414 if (delegate_) |
| 3446 delegate_->DidNavigateMainFramePostCommit(this); | 3415 delegate_->DidNavigateMainFramePostCommit(this); |
| 3447 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 3416 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 3448 } | 3417 } |
| 3449 | 3418 |
| 3450 void WebContentsImpl::DidNavigateAnyFramePostCommit( | 3419 void WebContentsImpl::DidNavigateAnyFramePostCommit( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3515 GetURLRequestContext()); | 3484 GetURLRequestContext()); |
| 3516 BrowserThread::PostTask( | 3485 BrowserThread::PostTask( |
| 3517 BrowserThread::IO, | 3486 BrowserThread::IO, |
| 3518 FROM_HERE, | 3487 FROM_HERE, |
| 3519 base::Bind(&NotifyCacheOnIO, request_context, url, http_method)); | 3488 base::Bind(&NotifyCacheOnIO, request_context, url, http_method)); |
| 3520 } | 3489 } |
| 3521 } | 3490 } |
| 3522 | 3491 |
| 3523 void WebContentsImpl::OnDidDisplayInsecureContent() { | 3492 void WebContentsImpl::OnDidDisplayInsecureContent() { |
| 3524 RecordAction(base::UserMetricsAction("SSL.DisplayedInsecureContent")); | 3493 RecordAction(base::UserMetricsAction("SSL.DisplayedInsecureContent")); |
| 3525 displayed_insecure_content_ = true; | 3494 controller_.ssl_manager()->DidDisplayMixedContent(); |
| 3526 SSLManager::NotifySSLInternalStateChanged( | |
| 3527 GetController().GetBrowserContext()); | |
| 3528 } | 3495 } |
| 3529 | 3496 |
| 3530 void WebContentsImpl::OnDidRunInsecureContent(const GURL& security_origin, | 3497 void WebContentsImpl::OnDidRunInsecureContent(const GURL& security_origin, |
| 3531 const GURL& target_url) { | 3498 const GURL& target_url) { |
| 3532 LOG(WARNING) << security_origin << " ran insecure content from " | 3499 LOG(WARNING) << security_origin << " ran insecure content from " |
| 3533 << target_url.possibly_invalid_spec(); | 3500 << target_url.possibly_invalid_spec(); |
| 3534 RecordAction(base::UserMetricsAction("SSL.RanInsecureContent")); | 3501 RecordAction(base::UserMetricsAction("SSL.RanInsecureContent")); |
| 3535 if (base::EndsWith(security_origin.spec(), kDotGoogleDotCom, | 3502 if (base::EndsWith(security_origin.spec(), kDotGoogleDotCom, |
| 3536 base::CompareCase::INSENSITIVE_ASCII)) | 3503 base::CompareCase::INSENSITIVE_ASCII)) |
| 3537 RecordAction(base::UserMetricsAction("SSL.RanInsecureContentGoogle")); | 3504 RecordAction(base::UserMetricsAction("SSL.RanInsecureContentGoogle")); |
| 3538 controller_.ssl_manager()->DidRunInsecureContent(security_origin); | 3505 controller_.ssl_manager()->DidRunMixedContent(security_origin); |
| 3539 SSLManager::NotifySSLInternalStateChanged( | |
| 3540 GetController().GetBrowserContext()); | |
| 3541 } | 3506 } |
| 3542 | 3507 |
| 3543 void WebContentsImpl::OnDidDisplayContentWithCertificateErrors( | 3508 void WebContentsImpl::OnDidDisplayContentWithCertificateErrors( |
| 3544 const GURL& url) { | 3509 const GURL& url) { |
| 3545 displayed_content_with_cert_errors_ = true; | 3510 controller_.ssl_manager()->DidDisplayContentWithCertErrors(); |
| 3546 SSLManager::NotifySSLInternalStateChanged( | |
| 3547 GetController().GetBrowserContext()); | |
| 3548 } | 3511 } |
| 3549 | 3512 |
| 3550 void WebContentsImpl::OnDidRunContentWithCertificateErrors( | 3513 void WebContentsImpl::OnDidRunContentWithCertificateErrors( |
| 3551 const GURL& url) { | 3514 const GURL& url) { |
| 3552 NavigationEntry* entry = controller_.GetVisibleEntry(); | 3515 NavigationEntry* entry = controller_.GetVisibleEntry(); |
| 3553 if (!entry) | 3516 if (!entry) |
| 3554 return; | 3517 return; |
| 3555 | 3518 |
| 3556 // TODO(estark): check that this does something reasonable for | 3519 // TODO(estark): check that this does something reasonable for |
| 3557 // about:blank and sandboxed origins. https://crbug.com/609527 | 3520 // about:blank and sandboxed origins. https://crbug.com/609527 |
| 3558 controller_.ssl_manager()->DidRunContentWithCertErrors( | 3521 controller_.ssl_manager()->DidRunContentWithCertErrors( |
| 3559 entry->GetURL().GetOrigin()); | 3522 entry->GetURL().GetOrigin()); |
| 3560 SSLManager::NotifySSLInternalStateChanged( | |
| 3561 GetController().GetBrowserContext()); | |
| 3562 } | 3523 } |
| 3563 | 3524 |
| 3564 void WebContentsImpl::OnDocumentLoadedInFrame() { | 3525 void WebContentsImpl::OnDocumentLoadedInFrame() { |
| 3565 if (!HasValidFrameSource()) | 3526 if (!HasValidFrameSource()) |
| 3566 return; | 3527 return; |
| 3567 | 3528 |
| 3568 RenderFrameHostImpl* rfh = | 3529 RenderFrameHostImpl* rfh = |
| 3569 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | 3530 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); |
| 3570 FOR_EACH_OBSERVER( | 3531 FOR_EACH_OBSERVER( |
| 3571 WebContentsObserver, observers_, DocumentLoadedInFrame(rfh)); | 3532 WebContentsObserver, observers_, DocumentLoadedInFrame(rfh)); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3859 | 3820 |
| 3860 void WebContentsImpl::SuspendMediaSession() { | 3821 void WebContentsImpl::SuspendMediaSession() { |
| 3861 MediaSession::Get(this)->Suspend(MediaSession::SuspendType::UI); | 3822 MediaSession::Get(this)->Suspend(MediaSession::SuspendType::UI); |
| 3862 } | 3823 } |
| 3863 | 3824 |
| 3864 void WebContentsImpl::StopMediaSession() { | 3825 void WebContentsImpl::StopMediaSession() { |
| 3865 MediaSession::Get(this)->Stop(MediaSession::SuspendType::UI); | 3826 MediaSession::Get(this)->Stop(MediaSession::SuspendType::UI); |
| 3866 } | 3827 } |
| 3867 | 3828 |
| 3868 void WebContentsImpl::OnPasswordInputShownOnHttp() { | 3829 void WebContentsImpl::OnPasswordInputShownOnHttp() { |
| 3869 displayed_password_field_on_http_ = true; | 3830 controller_.ssl_manager()->DidShowPasswordInputOnHttp(); |
| 3870 SSLManager::NotifySSLInternalStateChanged( | |
| 3871 GetController().GetBrowserContext()); | |
| 3872 } | 3831 } |
| 3873 | 3832 |
| 3874 void WebContentsImpl::OnCreditCardInputShownOnHttp() { | 3833 void WebContentsImpl::OnCreditCardInputShownOnHttp() { |
| 3875 displayed_credit_card_field_on_http_ = true; | 3834 controller_.ssl_manager()->DidShowCreditCardInputOnHttp(); |
| 3876 SSLManager::NotifySSLInternalStateChanged( | |
| 3877 GetController().GetBrowserContext()); | |
| 3878 } | 3835 } |
| 3879 | 3836 |
| 3880 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { | 3837 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { |
| 3881 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3838 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3882 DidFirstVisuallyNonEmptyPaint()); | 3839 DidFirstVisuallyNonEmptyPaint()); |
| 3883 | 3840 |
| 3884 did_first_visually_non_empty_paint_ = true; | 3841 did_first_visually_non_empty_paint_ = true; |
| 3885 | 3842 |
| 3886 if (theme_color_ != last_sent_theme_color_) { | 3843 if (theme_color_ != last_sent_theme_color_) { |
| 3887 // Theme color should have updated by now if there was one. | 3844 // Theme color should have updated by now if there was one. |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5278 dialog_manager_ = dialog_manager; | 5235 dialog_manager_ = dialog_manager; |
| 5279 } | 5236 } |
| 5280 | 5237 |
| 5281 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { | 5238 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { |
| 5282 auto it = binding_sets_.find(interface_name); | 5239 auto it = binding_sets_.find(interface_name); |
| 5283 if (it != binding_sets_.end()) | 5240 if (it != binding_sets_.end()) |
| 5284 binding_sets_.erase(it); | 5241 binding_sets_.erase(it); |
| 5285 } | 5242 } |
| 5286 | 5243 |
| 5287 } // namespace content | 5244 } // namespace content |
| OLD | NEW |