| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 int identifier) | 345 int identifier) |
| 346 : render_process_id(render_process_id), | 346 : render_process_id(render_process_id), |
| 347 render_frame_id(render_frame_id), | 347 render_frame_id(render_frame_id), |
| 348 chooser(chooser), | 348 chooser(chooser), |
| 349 identifier(identifier) { | 349 identifier(identifier) { |
| 350 } | 350 } |
| 351 | 351 |
| 352 WebContentsImpl::ColorChooserInfo::~ColorChooserInfo() { | 352 WebContentsImpl::ColorChooserInfo::~ColorChooserInfo() { |
| 353 } | 353 } |
| 354 | 354 |
| 355 bool WebContentsImpl::ColorChooserInfo::Matches( |
| 356 RenderFrameHostImpl* render_frame_host, |
| 357 int color_chooser_id) { |
| 358 return this->render_process_id == render_frame_host->GetProcess()->GetID() && |
| 359 this->render_frame_id == render_frame_host->GetRoutingID() && |
| 360 this->identifier == color_chooser_id; |
| 361 } |
| 362 |
| 355 // WebContentsImpl::WebContentsTreeNode ---------------------------------------- | 363 // WebContentsImpl::WebContentsTreeNode ---------------------------------------- |
| 356 WebContentsImpl::WebContentsTreeNode::WebContentsTreeNode() | 364 WebContentsImpl::WebContentsTreeNode::WebContentsTreeNode() |
| 357 : outer_web_contents_(nullptr), | 365 : outer_web_contents_(nullptr), |
| 358 outer_contents_frame_tree_node_id_( | 366 outer_contents_frame_tree_node_id_( |
| 359 FrameTreeNode::kFrameTreeNodeInvalidId), | 367 FrameTreeNode::kFrameTreeNodeInvalidId), |
| 360 focused_web_contents_(nullptr) {} | 368 focused_web_contents_(nullptr) {} |
| 361 | 369 |
| 362 WebContentsImpl::WebContentsTreeNode::~WebContentsTreeNode() { | 370 WebContentsImpl::WebContentsTreeNode::~WebContentsTreeNode() { |
| 363 // Remove child pointer from our parent. | 371 // Remove child pointer from our parent. |
| 364 if (outer_web_contents_) { | 372 if (outer_web_contents_) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 did_first_set_visible_(false), | 439 did_first_set_visible_(false), |
| 432 is_being_destroyed_(false), | 440 is_being_destroyed_(false), |
| 433 notify_disconnection_(false), | 441 notify_disconnection_(false), |
| 434 dialog_manager_(NULL), | 442 dialog_manager_(NULL), |
| 435 is_showing_before_unload_dialog_(false), | 443 is_showing_before_unload_dialog_(false), |
| 436 last_active_time_(base::TimeTicks::Now()), | 444 last_active_time_(base::TimeTicks::Now()), |
| 437 closed_by_user_gesture_(false), | 445 closed_by_user_gesture_(false), |
| 438 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 446 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
| 439 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 447 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
| 440 zoom_scroll_remainder_(0), | 448 zoom_scroll_remainder_(0), |
| 441 render_view_message_source_(NULL), | |
| 442 render_frame_message_source_(NULL), | |
| 443 fullscreen_widget_process_id_(ChildProcessHost::kInvalidUniqueID), | 449 fullscreen_widget_process_id_(ChildProcessHost::kInvalidUniqueID), |
| 444 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), | 450 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), |
| 445 fullscreen_widget_had_focus_at_shutdown_(false), | 451 fullscreen_widget_had_focus_at_shutdown_(false), |
| 446 is_subframe_(false), | 452 is_subframe_(false), |
| 447 force_disable_overscroll_content_(false), | 453 force_disable_overscroll_content_(false), |
| 448 last_dialog_suppressed_(false), | 454 last_dialog_suppressed_(false), |
| 449 geolocation_service_context_(new device::GeolocationServiceContext()), | 455 geolocation_service_context_(new device::GeolocationServiceContext()), |
| 450 accessibility_mode_( | 456 accessibility_mode_( |
| 451 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), | 457 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), |
| 452 audio_stream_monitor_(this), | 458 audio_stream_monitor_(this), |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 if (!render_frame_host) | 664 if (!render_frame_host) |
| 659 return nullptr; | 665 return nullptr; |
| 660 | 666 |
| 661 return WebContents::FromRenderFrameHost(render_frame_host); | 667 return WebContents::FromRenderFrameHost(render_frame_host); |
| 662 } | 668 } |
| 663 | 669 |
| 664 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 670 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
| 665 return GetRenderManager(); | 671 return GetRenderManager(); |
| 666 } | 672 } |
| 667 | 673 |
| 668 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, | 674 bool WebContentsImpl::OnMessageReceived(RenderViewHostImpl* render_view_host, |
| 669 const IPC::Message& message) { | 675 const IPC::Message& message) { |
| 670 return OnMessageReceived(render_view_host, NULL, message); | 676 RenderFrameHost* main_frame = render_view_host->GetMainFrame(); |
| 677 if (main_frame) { |
| 678 WebUIImpl* web_ui = static_cast<RenderFrameHostImpl*>(main_frame)->web_ui(); |
| 679 if (web_ui && web_ui->OnMessageReceived(message)) |
| 680 return true; |
| 681 } |
| 682 |
| 683 for (auto& observer : observers_) { |
| 684 // TODO(nick, creis): Replace all uses of this variant of OnMessageReceived |
| 685 // with the version that takes a RenderFrameHost, and delete it. |
| 686 if (observer.OnMessageReceived(message)) |
| 687 return true; |
| 688 } |
| 689 |
| 690 bool handled = true; |
| 691 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContentsImpl, message, render_view_host) |
| 692 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, |
| 693 OnFirstVisuallyNonEmptyPaint) |
| 694 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
| 695 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
| 696 IPC_MESSAGE_HANDLER(ViewHostMsg_PageScaleFactorChanged, |
| 697 OnPageScaleFactorChanged) |
| 698 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
| 699 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
| 700 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
| 701 #if BUILDFLAG(ENABLE_PLUGINS) |
| 702 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
| 703 OnRequestPpapiBrokerPermission) |
| 704 #endif |
| 705 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 706 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, |
| 707 OnShowValidationMessage) |
| 708 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, |
| 709 OnHideValidationMessage) |
| 710 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, |
| 711 OnMoveValidationMessage) |
| 712 #if defined(OS_ANDROID) |
| 713 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, OnOpenDateTimeDialog) |
| 714 #endif |
| 715 IPC_MESSAGE_UNHANDLED(handled = false) |
| 716 IPC_END_MESSAGE_MAP() |
| 717 |
| 718 return handled; |
| 671 } | 719 } |
| 672 | 720 |
| 673 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, | 721 bool WebContentsImpl::OnMessageReceived(RenderFrameHostImpl* render_frame_host, |
| 674 RenderFrameHost* render_frame_host, | |
| 675 const IPC::Message& message) { | 722 const IPC::Message& message) { |
| 676 DCHECK(render_view_host || render_frame_host); | 723 for (auto& observer : observers_) { |
| 677 | 724 if (observer.OnMessageReceived(message, render_frame_host)) |
| 678 if (render_view_host) { | 725 return true; |
| 679 RenderFrameHost* main_frame = render_view_host->GetMainFrame(); | |
| 680 if (main_frame) { | |
| 681 WebUIImpl* web_ui = | |
| 682 static_cast<RenderFrameHostImpl*>(main_frame)->web_ui(); | |
| 683 if (web_ui && web_ui->OnMessageReceived(message)) | |
| 684 return true; | |
| 685 } | |
| 686 } | 726 } |
| 687 | 727 |
| 688 if (render_frame_host) { | |
| 689 for (auto& observer : observers_) { | |
| 690 if (observer.OnMessageReceived(message, render_frame_host)) | |
| 691 return true; | |
| 692 } | |
| 693 } else { | |
| 694 for (auto& observer : observers_) { | |
| 695 if (observer.OnMessageReceived(message)) | |
| 696 return true; | |
| 697 } | |
| 698 } | |
| 699 | |
| 700 // Message handlers should be aware of which | |
| 701 // RenderViewHost/RenderFrameHost sent the message, which is temporarily | |
| 702 // stored in render_(view|frame)_message_source_. | |
| 703 if (render_frame_host) | |
| 704 render_frame_message_source_ = render_frame_host; | |
| 705 else | |
| 706 render_view_message_source_ = render_view_host; | |
| 707 | |
| 708 bool handled = true; | 728 bool handled = true; |
| 709 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message) | 729 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContentsImpl, message, render_frame_host) |
| 710 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, | 730 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, |
| 711 OnDomOperationResponse) | 731 OnDomOperationResponse) |
| 712 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, | 732 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, |
| 713 OnThemeColorChanged) | 733 OnThemeColorChanged) |
| 714 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, | 734 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, |
| 715 OnDocumentLoadedInFrame) | 735 OnDocumentLoadedInFrame) |
| 716 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) | 736 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 717 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) | 737 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) |
| 718 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) | 738 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) |
| 719 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, | 739 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, |
| 720 OnSetSelectedColorInColorChooser) | 740 OnSetSelectedColorInColorChooser) |
| 721 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, | |
| 722 OnFirstVisuallyNonEmptyPaint) | |
| 723 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache, | 741 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache, |
| 724 OnDidLoadResourceFromMemoryCache) | 742 OnDidLoadResourceFromMemoryCache) |
| 725 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent, | 743 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent, |
| 726 OnDidDisplayInsecureContent) | 744 OnDidDisplayInsecureContent) |
| 727 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent, | 745 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent, |
| 728 OnDidRunInsecureContent) | 746 OnDidRunInsecureContent) |
| 729 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors, | 747 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors, |
| 730 OnDidDisplayContentWithCertificateErrors) | 748 OnDidDisplayContentWithCertificateErrors) |
| 731 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunContentWithCertificateErrors, | 749 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunContentWithCertificateErrors, |
| 732 OnDidRunContentWithCertificateErrors) | 750 OnDidRunContentWithCertificateErrors) |
| 733 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | |
| 734 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | |
| 735 IPC_MESSAGE_HANDLER(ViewHostMsg_PageScaleFactorChanged, | |
| 736 OnPageScaleFactorChanged) | |
| 737 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | |
| 738 IPC_MESSAGE_HANDLER(FrameHostMsg_RegisterProtocolHandler, | 751 IPC_MESSAGE_HANDLER(FrameHostMsg_RegisterProtocolHandler, |
| 739 OnRegisterProtocolHandler) | 752 OnRegisterProtocolHandler) |
| 740 IPC_MESSAGE_HANDLER(FrameHostMsg_UnregisterProtocolHandler, | 753 IPC_MESSAGE_HANDLER(FrameHostMsg_UnregisterProtocolHandler, |
| 741 OnUnregisterProtocolHandler) | 754 OnUnregisterProtocolHandler) |
| 742 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdatePageImportanceSignals, | 755 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdatePageImportanceSignals, |
| 743 OnUpdatePageImportanceSignals) | 756 OnUpdatePageImportanceSignals) |
| 744 IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply) | 757 IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply) |
| 745 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | |
| 746 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | |
| 747 #if BUILDFLAG(ENABLE_PLUGINS) | 758 #if BUILDFLAG(ENABLE_PLUGINS) |
| 748 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated, | 759 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated, |
| 749 OnPepperInstanceCreated) | 760 OnPepperInstanceCreated) |
| 750 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, | 761 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, |
| 751 OnPepperInstanceDeleted) | 762 OnPepperInstanceDeleted) |
| 752 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) | 763 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) |
| 753 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStartsPlayback, | 764 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStartsPlayback, |
| 754 OnPepperStartsPlayback) | 765 OnPepperStartsPlayback) |
| 755 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStopsPlayback, | 766 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStopsPlayback, |
| 756 OnPepperStopsPlayback) | 767 OnPepperStopsPlayback) |
| 757 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) | 768 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) |
| 758 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | |
| 759 OnRequestPpapiBrokerPermission) | |
| 760 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 769 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
| 761 OnBrowserPluginMessage(render_frame_host, | 770 OnBrowserPluginMessage(render_frame_host, |
| 762 message)) | 771 message)) |
| 763 #endif | 772 #endif |
| 764 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | |
| 765 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, | |
| 766 OnShowValidationMessage) | |
| 767 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, | |
| 768 OnHideValidationMessage) | |
| 769 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, | |
| 770 OnMoveValidationMessage) | |
| 771 #if defined(OS_ANDROID) | 773 #if defined(OS_ANDROID) |
| 772 IPC_MESSAGE_HANDLER(FrameHostMsg_FindMatchRects_Reply, | 774 IPC_MESSAGE_HANDLER(FrameHostMsg_FindMatchRects_Reply, |
| 773 OnFindMatchRectsReply) | 775 OnFindMatchRectsReply) |
| 774 IPC_MESSAGE_HANDLER(FrameHostMsg_GetNearestFindResult_Reply, | 776 IPC_MESSAGE_HANDLER(FrameHostMsg_GetNearestFindResult_Reply, |
| 775 OnGetNearestFindResultReply) | 777 OnGetNearestFindResultReply) |
| 776 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, | |
| 777 OnOpenDateTimeDialog) | |
| 778 #endif | 778 #endif |
| 779 IPC_MESSAGE_UNHANDLED(handled = false) | 779 IPC_MESSAGE_UNHANDLED(handled = false) |
| 780 IPC_END_MESSAGE_MAP() | 780 IPC_END_MESSAGE_MAP() |
| 781 render_view_message_source_ = NULL; | |
| 782 render_frame_message_source_ = NULL; | |
| 783 | 781 |
| 784 return handled; | 782 return handled; |
| 785 } | 783 } |
| 786 | 784 |
| 787 bool WebContentsImpl::HasValidFrameSource() { | |
| 788 if (!render_frame_message_source_) { | |
| 789 DCHECK(render_view_message_source_); | |
| 790 bad_message::ReceivedBadMessage(GetRenderProcessHost(), | |
| 791 bad_message::WC_INVALID_FRAME_SOURCE); | |
| 792 return false; | |
| 793 } | |
| 794 | |
| 795 return true; | |
| 796 } | |
| 797 | |
| 798 NavigationControllerImpl& WebContentsImpl::GetController() { | 785 NavigationControllerImpl& WebContentsImpl::GetController() { |
| 799 return controller_; | 786 return controller_; |
| 800 } | 787 } |
| 801 | 788 |
| 802 const NavigationControllerImpl& WebContentsImpl::GetController() const { | 789 const NavigationControllerImpl& WebContentsImpl::GetController() const { |
| 803 return controller_; | 790 return controller_; |
| 804 } | 791 } |
| 805 | 792 |
| 806 BrowserContext* WebContentsImpl::GetBrowserContext() const { | 793 BrowserContext* WebContentsImpl::GetBrowserContext() const { |
| 807 return controller_.GetBrowserContext(); | 794 return controller_.GetBrowserContext(); |
| (...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2440 | 2427 |
| 2441 device::WakeLockServiceContext* WebContentsImpl::GetWakeLockServiceContext() { | 2428 device::WakeLockServiceContext* WebContentsImpl::GetWakeLockServiceContext() { |
| 2442 return wake_lock_service_context_.get(); | 2429 return wake_lock_service_context_.get(); |
| 2443 } | 2430 } |
| 2444 | 2431 |
| 2445 ScreenOrientationProvider* WebContentsImpl::GetScreenOrientationProvider() { | 2432 ScreenOrientationProvider* WebContentsImpl::GetScreenOrientationProvider() { |
| 2446 return screen_orientation_.get()->GetScreenOrientationProvider(); | 2433 return screen_orientation_.get()->GetScreenOrientationProvider(); |
| 2447 } | 2434 } |
| 2448 | 2435 |
| 2449 void WebContentsImpl::OnShowValidationMessage( | 2436 void WebContentsImpl::OnShowValidationMessage( |
| 2437 RenderViewHostImpl* source, |
| 2450 const gfx::Rect& anchor_in_root_view, | 2438 const gfx::Rect& anchor_in_root_view, |
| 2451 const base::string16& main_text, | 2439 const base::string16& main_text, |
| 2452 const base::string16& sub_text) { | 2440 const base::string16& sub_text) { |
| 2441 // TODO(nick): Should we consider |source| here or pass it to the delegate? |
| 2453 if (delegate_) | 2442 if (delegate_) |
| 2454 delegate_->ShowValidationMessage( | 2443 delegate_->ShowValidationMessage( |
| 2455 this, anchor_in_root_view, main_text, sub_text); | 2444 this, anchor_in_root_view, main_text, sub_text); |
| 2456 } | 2445 } |
| 2457 | 2446 |
| 2458 void WebContentsImpl::OnHideValidationMessage() { | 2447 void WebContentsImpl::OnHideValidationMessage(RenderViewHostImpl* source) { |
| 2448 // TODO(nick): Should we consider |source| here or pass it to the delegate? |
| 2459 if (delegate_) | 2449 if (delegate_) |
| 2460 delegate_->HideValidationMessage(this); | 2450 delegate_->HideValidationMessage(this); |
| 2461 } | 2451 } |
| 2462 | 2452 |
| 2463 void WebContentsImpl::OnMoveValidationMessage( | 2453 void WebContentsImpl::OnMoveValidationMessage( |
| 2454 RenderViewHostImpl* source, |
| 2464 const gfx::Rect& anchor_in_root_view) { | 2455 const gfx::Rect& anchor_in_root_view) { |
| 2456 // TODO(nick): Should we consider |source| here or pass it to the delegate? |
| 2465 if (delegate_) | 2457 if (delegate_) |
| 2466 delegate_->MoveValidationMessage(this, anchor_in_root_view); | 2458 delegate_->MoveValidationMessage(this, anchor_in_root_view); |
| 2467 } | 2459 } |
| 2468 | 2460 |
| 2469 void WebContentsImpl::SendScreenRects() { | 2461 void WebContentsImpl::SendScreenRects() { |
| 2470 for (FrameTreeNode* node : frame_tree_.Nodes()) { | 2462 for (FrameTreeNode* node : frame_tree_.Nodes()) { |
| 2471 if (node->current_frame_host()->is_local_root()) | 2463 if (node->current_frame_host()->is_local_root()) |
| 2472 node->current_frame_host()->GetRenderWidgetHost()->SendScreenRects(); | 2464 node->current_frame_host()->GetRenderWidgetHost()->SendScreenRects(); |
| 2473 } | 2465 } |
| 2474 | 2466 |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3480 // Disable overscroll when touch emulation is on. See crbug.com/369938. | 3472 // Disable overscroll when touch emulation is on. See crbug.com/369938. |
| 3481 if (force_disable_overscroll_content_) | 3473 if (force_disable_overscroll_content_) |
| 3482 return false; | 3474 return false; |
| 3483 | 3475 |
| 3484 if (delegate_) | 3476 if (delegate_) |
| 3485 return delegate_->CanOverscrollContent(); | 3477 return delegate_->CanOverscrollContent(); |
| 3486 | 3478 |
| 3487 return false; | 3479 return false; |
| 3488 } | 3480 } |
| 3489 | 3481 |
| 3490 void WebContentsImpl::OnThemeColorChanged(SkColor theme_color) { | 3482 void WebContentsImpl::OnThemeColorChanged(RenderFrameHostImpl* source, |
| 3483 SkColor theme_color) { |
| 3484 if (source != GetMainFrame()) { |
| 3485 // Only the main frame may control the theme. |
| 3486 return; |
| 3487 } |
| 3488 |
| 3491 // Update the theme color. This is to be published to observers after the | 3489 // Update the theme color. This is to be published to observers after the |
| 3492 // first visually non-empty paint. | 3490 // first visually non-empty paint. |
| 3493 theme_color_ = theme_color; | 3491 theme_color_ = theme_color; |
| 3494 | 3492 |
| 3495 if (did_first_visually_non_empty_paint_ && | 3493 if (did_first_visually_non_empty_paint_ && |
| 3496 last_sent_theme_color_ != theme_color_) { | 3494 last_sent_theme_color_ != theme_color_) { |
| 3497 for (auto& observer : observers_) | 3495 for (auto& observer : observers_) |
| 3498 observer.DidChangeThemeColor(theme_color_); | 3496 observer.DidChangeThemeColor(theme_color_); |
| 3499 last_sent_theme_color_ = theme_color_; | 3497 last_sent_theme_color_ = theme_color_; |
| 3500 } | 3498 } |
| 3501 } | 3499 } |
| 3502 | 3500 |
| 3503 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( | 3501 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( |
| 3502 RenderFrameHostImpl* source, |
| 3504 const GURL& url, | 3503 const GURL& url, |
| 3505 const std::string& http_method, | 3504 const std::string& http_method, |
| 3506 const std::string& mime_type, | 3505 const std::string& mime_type, |
| 3507 ResourceType resource_type) { | 3506 ResourceType resource_type) { |
| 3508 for (auto& observer : observers_) | 3507 for (auto& observer : observers_) |
| 3509 observer.DidLoadResourceFromMemoryCache(url, mime_type, resource_type); | 3508 observer.DidLoadResourceFromMemoryCache(url, mime_type, resource_type); |
| 3510 | 3509 |
| 3511 if (url.is_valid() && url.SchemeIsHTTPOrHTTPS()) { | 3510 if (url.is_valid() && url.SchemeIsHTTPOrHTTPS()) { |
| 3511 StoragePartition* partition = source->GetProcess()->GetStoragePartition(); |
| 3512 scoped_refptr<net::URLRequestContextGetter> request_context( | 3512 scoped_refptr<net::URLRequestContextGetter> request_context( |
| 3513 resource_type == RESOURCE_TYPE_MEDIA ? | 3513 resource_type == RESOURCE_TYPE_MEDIA |
| 3514 GetRenderProcessHost()->GetStoragePartition()-> | 3514 ? partition->GetMediaURLRequestContext() |
| 3515 GetMediaURLRequestContext() : | 3515 : partition->GetURLRequestContext()); |
| 3516 GetRenderProcessHost()->GetStoragePartition()-> | |
| 3517 GetURLRequestContext()); | |
| 3518 BrowserThread::PostTask( | 3516 BrowserThread::PostTask( |
| 3519 BrowserThread::IO, | 3517 BrowserThread::IO, FROM_HERE, |
| 3520 FROM_HERE, | |
| 3521 base::Bind(&NotifyCacheOnIO, request_context, url, http_method)); | 3518 base::Bind(&NotifyCacheOnIO, request_context, url, http_method)); |
| 3522 } | 3519 } |
| 3523 } | 3520 } |
| 3524 | 3521 |
| 3525 void WebContentsImpl::OnDidDisplayInsecureContent() { | 3522 void WebContentsImpl::OnDidDisplayInsecureContent(RenderFrameHostImpl* source) { |
| 3523 // Any frame can trigger display of insecure content, so we don't check |
| 3524 // |source| here. |
| 3526 RecordAction(base::UserMetricsAction("SSL.DisplayedInsecureContent")); | 3525 RecordAction(base::UserMetricsAction("SSL.DisplayedInsecureContent")); |
| 3527 controller_.ssl_manager()->DidDisplayMixedContent(); | 3526 controller_.ssl_manager()->DidDisplayMixedContent(); |
| 3528 } | 3527 } |
| 3529 | 3528 |
| 3530 void WebContentsImpl::OnDidRunInsecureContent(const GURL& security_origin, | 3529 void WebContentsImpl::OnDidRunInsecureContent(RenderFrameHostImpl* source, |
| 3530 const GURL& security_origin, |
| 3531 const GURL& target_url) { | 3531 const GURL& target_url) { |
| 3532 // TODO(nick, estark): Should we call FilterURL using |source|'s process on |
| 3533 // these parameters? |target_url| seems unused, except for a log message. And |
| 3534 // |security_origin| might be replaceable with the origin of the main frame. |
| 3532 LOG(WARNING) << security_origin << " ran insecure content from " | 3535 LOG(WARNING) << security_origin << " ran insecure content from " |
| 3533 << target_url.possibly_invalid_spec(); | 3536 << target_url.possibly_invalid_spec(); |
| 3534 RecordAction(base::UserMetricsAction("SSL.RanInsecureContent")); | 3537 RecordAction(base::UserMetricsAction("SSL.RanInsecureContent")); |
| 3535 if (base::EndsWith(security_origin.spec(), kDotGoogleDotCom, | 3538 if (base::EndsWith(security_origin.spec(), kDotGoogleDotCom, |
| 3536 base::CompareCase::INSENSITIVE_ASCII)) | 3539 base::CompareCase::INSENSITIVE_ASCII)) |
| 3537 RecordAction(base::UserMetricsAction("SSL.RanInsecureContentGoogle")); | 3540 RecordAction(base::UserMetricsAction("SSL.RanInsecureContentGoogle")); |
| 3538 controller_.ssl_manager()->DidRunMixedContent(security_origin); | 3541 controller_.ssl_manager()->DidRunMixedContent(security_origin); |
| 3539 } | 3542 } |
| 3540 | 3543 |
| 3541 void WebContentsImpl::OnDidDisplayContentWithCertificateErrors( | 3544 void WebContentsImpl::OnDidDisplayContentWithCertificateErrors( |
| 3545 RenderFrameHostImpl* source, |
| 3542 const GURL& url) { | 3546 const GURL& url) { |
| 3547 // TODO(nick): |url| is unused; get rid of it. |
| 3543 controller_.ssl_manager()->DidDisplayContentWithCertErrors(); | 3548 controller_.ssl_manager()->DidDisplayContentWithCertErrors(); |
| 3544 } | 3549 } |
| 3545 | 3550 |
| 3546 void WebContentsImpl::OnDidRunContentWithCertificateErrors( | 3551 void WebContentsImpl::OnDidRunContentWithCertificateErrors( |
| 3552 RenderFrameHostImpl* source, |
| 3547 const GURL& url) { | 3553 const GURL& url) { |
| 3554 // TODO(nick, estark): Do we need to consider |source| here somehow? |
| 3548 NavigationEntry* entry = controller_.GetVisibleEntry(); | 3555 NavigationEntry* entry = controller_.GetVisibleEntry(); |
| 3549 if (!entry) | 3556 if (!entry) |
| 3550 return; | 3557 return; |
| 3551 | 3558 |
| 3552 // TODO(estark): check that this does something reasonable for | 3559 // TODO(estark): check that this does something reasonable for |
| 3553 // about:blank and sandboxed origins. https://crbug.com/609527 | 3560 // about:blank and sandboxed origins. https://crbug.com/609527 |
| 3554 controller_.ssl_manager()->DidRunContentWithCertErrors( | 3561 controller_.ssl_manager()->DidRunContentWithCertErrors( |
| 3555 entry->GetURL().GetOrigin()); | 3562 entry->GetURL().GetOrigin()); |
| 3556 } | 3563 } |
| 3557 | 3564 |
| 3558 void WebContentsImpl::OnDocumentLoadedInFrame() { | 3565 void WebContentsImpl::OnDocumentLoadedInFrame(RenderFrameHostImpl* source) { |
| 3559 if (!HasValidFrameSource()) | |
| 3560 return; | |
| 3561 | |
| 3562 RenderFrameHostImpl* rfh = | |
| 3563 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | |
| 3564 for (auto& observer : observers_) | 3566 for (auto& observer : observers_) |
| 3565 observer.DocumentLoadedInFrame(rfh); | 3567 observer.DocumentLoadedInFrame(source); |
| 3566 } | 3568 } |
| 3567 | 3569 |
| 3568 void WebContentsImpl::OnDidFinishLoad(const GURL& url) { | 3570 void WebContentsImpl::OnDidFinishLoad(RenderFrameHostImpl* source, |
| 3569 if (!HasValidFrameSource()) | 3571 const GURL& url) { |
| 3570 return; | 3572 GURL validated_url(url); |
| 3573 source->GetProcess()->FilterURL(false, &validated_url); |
| 3571 | 3574 |
| 3572 GURL validated_url(url); | |
| 3573 RenderProcessHost* render_process_host = | |
| 3574 render_frame_message_source_->GetProcess(); | |
| 3575 render_process_host->FilterURL(false, &validated_url); | |
| 3576 | |
| 3577 RenderFrameHostImpl* rfh = | |
| 3578 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | |
| 3579 for (auto& observer : observers_) | 3575 for (auto& observer : observers_) |
| 3580 observer.DidFinishLoad(rfh, validated_url); | 3576 observer.DidFinishLoad(source, validated_url); |
| 3581 } | 3577 } |
| 3582 | 3578 |
| 3583 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { | 3579 void WebContentsImpl::OnGoToEntryAtOffset(RenderViewHostImpl* source, |
| 3580 int offset) { |
| 3581 // All frames are allowed to navigate the global history. |
| 3584 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) | 3582 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) |
| 3585 controller_.GoToOffset(offset); | 3583 controller_.GoToOffset(offset); |
| 3586 } | 3584 } |
| 3587 | 3585 |
| 3588 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, | 3586 void WebContentsImpl::OnUpdateZoomLimits(RenderViewHostImpl* source, |
| 3587 int minimum_percent, |
| 3589 int maximum_percent) { | 3588 int maximum_percent) { |
| 3590 minimum_zoom_percent_ = minimum_percent; | 3589 minimum_zoom_percent_ = minimum_percent; |
| 3591 maximum_zoom_percent_ = maximum_percent; | 3590 maximum_zoom_percent_ = maximum_percent; |
| 3592 } | 3591 } |
| 3593 | 3592 |
| 3594 void WebContentsImpl::OnPageScaleFactorChanged(float page_scale_factor) { | 3593 void WebContentsImpl::OnPageScaleFactorChanged(RenderViewHostImpl* source, |
| 3594 float page_scale_factor) { |
| 3595 bool is_one = page_scale_factor == 1.f; | 3595 bool is_one = page_scale_factor == 1.f; |
| 3596 if (is_one != page_scale_factor_is_one_) { | 3596 if (is_one != page_scale_factor_is_one_) { |
| 3597 page_scale_factor_is_one_ = is_one; | 3597 page_scale_factor_is_one_ = is_one; |
| 3598 | 3598 |
| 3599 HostZoomMapImpl* host_zoom_map = | 3599 HostZoomMapImpl* host_zoom_map = |
| 3600 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); | 3600 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); |
| 3601 | 3601 |
| 3602 if (host_zoom_map && GetRenderProcessHost()) { | 3602 if (host_zoom_map) { |
| 3603 host_zoom_map->SetPageScaleFactorIsOneForView( | 3603 host_zoom_map->SetPageScaleFactorIsOneForView( |
| 3604 GetRenderProcessHost()->GetID(), GetRenderViewHost()->GetRoutingID(), | 3604 source->GetProcess()->GetID(), source->GetRoutingID(), |
| 3605 page_scale_factor_is_one_); | 3605 page_scale_factor_is_one_); |
| 3606 } | 3606 } |
| 3607 } | 3607 } |
| 3608 | 3608 |
| 3609 for (auto& observer : observers_) | 3609 for (auto& observer : observers_) |
| 3610 observer.OnPageScaleFactorChanged(page_scale_factor); | 3610 observer.OnPageScaleFactorChanged(page_scale_factor); |
| 3611 } | 3611 } |
| 3612 | 3612 |
| 3613 void WebContentsImpl::OnEnumerateDirectory(int request_id, | 3613 void WebContentsImpl::OnEnumerateDirectory(RenderViewHostImpl* source, |
| 3614 int request_id, |
| 3614 const base::FilePath& path) { | 3615 const base::FilePath& path) { |
| 3615 if (!delegate_) | 3616 if (!delegate_) |
| 3616 return; | 3617 return; |
| 3617 | 3618 |
| 3618 ChildProcessSecurityPolicyImpl* policy = | 3619 ChildProcessSecurityPolicyImpl* policy = |
| 3619 ChildProcessSecurityPolicyImpl::GetInstance(); | 3620 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 3620 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path)) | 3621 if (policy->CanReadFile(source->GetProcess()->GetID(), path)) { |
| 3622 // TODO(nick): |this| param in the call below ought to be a RenderFrameHost. |
| 3621 delegate_->EnumerateDirectory(this, request_id, path); | 3623 delegate_->EnumerateDirectory(this, request_id, path); |
| 3624 } |
| 3622 } | 3625 } |
| 3623 | 3626 |
| 3624 void WebContentsImpl::OnRegisterProtocolHandler(const std::string& protocol, | 3627 void WebContentsImpl::OnRegisterProtocolHandler(RenderFrameHostImpl* source, |
| 3628 const std::string& protocol, |
| 3625 const GURL& url, | 3629 const GURL& url, |
| 3626 const base::string16& title, | 3630 const base::string16& title, |
| 3627 bool user_gesture) { | 3631 bool user_gesture) { |
| 3632 // TODO(nick): Should we consider |source| here or pass it to the delegate? |
| 3633 // TODO(nick): Do we need to apply FilterURL to |url|? |
| 3628 if (!delegate_) | 3634 if (!delegate_) |
| 3629 return; | 3635 return; |
| 3630 | 3636 |
| 3631 ChildProcessSecurityPolicyImpl* policy = | 3637 ChildProcessSecurityPolicyImpl* policy = |
| 3632 ChildProcessSecurityPolicyImpl::GetInstance(); | 3638 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 3633 if (policy->IsPseudoScheme(protocol)) | 3639 if (policy->IsPseudoScheme(protocol)) |
| 3634 return; | 3640 return; |
| 3635 | 3641 |
| 3636 delegate_->RegisterProtocolHandler(this, protocol, url, user_gesture); | 3642 delegate_->RegisterProtocolHandler(this, protocol, url, user_gesture); |
| 3637 } | 3643 } |
| 3638 | 3644 |
| 3639 void WebContentsImpl::OnUnregisterProtocolHandler(const std::string& protocol, | 3645 void WebContentsImpl::OnUnregisterProtocolHandler(RenderFrameHostImpl* source, |
| 3646 const std::string& protocol, |
| 3640 const GURL& url, | 3647 const GURL& url, |
| 3641 bool user_gesture) { | 3648 bool user_gesture) { |
| 3649 // TODO(nick): Should we consider |source| here or pass it to the delegate? |
| 3650 // TODO(nick): Do we need to apply FilterURL to |url|? |
| 3642 if (!delegate_) | 3651 if (!delegate_) |
| 3643 return; | 3652 return; |
| 3644 | 3653 |
| 3645 ChildProcessSecurityPolicyImpl* policy = | 3654 ChildProcessSecurityPolicyImpl* policy = |
| 3646 ChildProcessSecurityPolicyImpl::GetInstance(); | 3655 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 3647 if (policy->IsPseudoScheme(protocol)) | 3656 if (policy->IsPseudoScheme(protocol)) |
| 3648 return; | 3657 return; |
| 3649 | 3658 |
| 3650 delegate_->UnregisterProtocolHandler(this, protocol, url, user_gesture); | 3659 delegate_->UnregisterProtocolHandler(this, protocol, url, user_gesture); |
| 3651 } | 3660 } |
| 3652 | 3661 |
| 3653 void WebContentsImpl::OnUpdatePageImportanceSignals( | 3662 void WebContentsImpl::OnUpdatePageImportanceSignals( |
| 3663 RenderFrameHostImpl* source, |
| 3654 const PageImportanceSignals& signals) { | 3664 const PageImportanceSignals& signals) { |
| 3665 // TODO(nick, kouhei): Fix this for oopifs; currently all frames' state gets |
| 3666 // written to this one field. |
| 3655 page_importance_signals_ = signals; | 3667 page_importance_signals_ = signals; |
| 3656 } | 3668 } |
| 3657 | 3669 |
| 3658 void WebContentsImpl::OnFindReply(int request_id, | 3670 void WebContentsImpl::OnFindReply(RenderFrameHostImpl* source, |
| 3671 int request_id, |
| 3659 int number_of_matches, | 3672 int number_of_matches, |
| 3660 const gfx::Rect& selection_rect, | 3673 const gfx::Rect& selection_rect, |
| 3661 int active_match_ordinal, | 3674 int active_match_ordinal, |
| 3662 bool final_update) { | 3675 bool final_update) { |
| 3663 // Forward the find reply to the FindRequestManager, along with the | 3676 // Forward the find reply to the FindRequestManager, along with the |
| 3664 // RenderFrameHost associated with the frame that the reply came from. | 3677 // RenderFrameHost associated with the frame that the reply came from. |
| 3665 GetOrCreateFindRequestManager()->OnFindReply(render_frame_message_source_, | 3678 GetOrCreateFindRequestManager()->OnFindReply( |
| 3666 request_id, | 3679 source, request_id, number_of_matches, selection_rect, |
| 3667 number_of_matches, | 3680 active_match_ordinal, final_update); |
| 3668 selection_rect, | |
| 3669 active_match_ordinal, | |
| 3670 final_update); | |
| 3671 } | 3681 } |
| 3672 | 3682 |
| 3673 #if defined(OS_ANDROID) | 3683 #if defined(OS_ANDROID) |
| 3674 void WebContentsImpl::OnFindMatchRectsReply( | 3684 void WebContentsImpl::OnFindMatchRectsReply( |
| 3685 RenderFrameHostImpl* source, |
| 3675 int version, | 3686 int version, |
| 3676 const std::vector<gfx::RectF>& rects, | 3687 const std::vector<gfx::RectF>& rects, |
| 3677 const gfx::RectF& active_rect) { | 3688 const gfx::RectF& active_rect) { |
| 3678 GetOrCreateFindRequestManager()->OnFindMatchRectsReply( | 3689 GetOrCreateFindRequestManager()->OnFindMatchRectsReply(source, version, rects, |
| 3679 render_frame_message_source_, version, rects, active_rect); | 3690 active_rect); |
| 3680 } | 3691 } |
| 3681 | 3692 |
| 3682 void WebContentsImpl::OnGetNearestFindResultReply(int request_id, | 3693 void WebContentsImpl::OnGetNearestFindResultReply(RenderFrameHostImpl* source, |
| 3694 int request_id, |
| 3683 float distance) { | 3695 float distance) { |
| 3684 GetOrCreateFindRequestManager()->OnGetNearestFindResultReply( | 3696 GetOrCreateFindRequestManager()->OnGetNearestFindResultReply( |
| 3685 render_frame_message_source_, request_id, distance); | 3697 source, request_id, distance); |
| 3686 } | 3698 } |
| 3687 | 3699 |
| 3688 void WebContentsImpl::OnOpenDateTimeDialog( | 3700 void WebContentsImpl::OnOpenDateTimeDialog( |
| 3701 RenderViewHostImpl* source, |
| 3689 const ViewHostMsg_DateTimeDialogValue_Params& value) { | 3702 const ViewHostMsg_DateTimeDialogValue_Params& value) { |
| 3690 date_time_chooser_->ShowDialog(GetTopLevelNativeWindow(), | 3703 date_time_chooser_->ShowDialog( |
| 3691 GetRenderViewHost(), | 3704 GetTopLevelNativeWindow(), source, value.dialog_type, value.dialog_value, |
| 3692 value.dialog_type, | 3705 value.minimum, value.maximum, value.step, value.suggestions); |
| 3693 value.dialog_value, | |
| 3694 value.minimum, | |
| 3695 value.maximum, | |
| 3696 value.step, | |
| 3697 value.suggestions); | |
| 3698 } | 3706 } |
| 3699 #endif | 3707 #endif |
| 3700 | 3708 |
| 3701 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string) { | 3709 void WebContentsImpl::OnDomOperationResponse(RenderFrameHostImpl* source, |
| 3710 const std::string& json_string) { |
| 3711 // TODO(nick, lukasza): The notification below should probably be updated to |
| 3712 // include |source|. |
| 3702 std::string json = json_string; | 3713 std::string json = json_string; |
| 3703 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, | 3714 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 3704 Source<WebContents>(this), | 3715 Source<WebContents>(this), |
| 3705 Details<std::string>(&json)); | 3716 Details<std::string>(&json)); |
| 3706 } | 3717 } |
| 3707 | 3718 |
| 3708 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, | 3719 void WebContentsImpl::OnAppCacheAccessed(RenderViewHostImpl* source, |
| 3720 const GURL& manifest_url, |
| 3709 bool blocked_by_policy) { | 3721 bool blocked_by_policy) { |
| 3722 // TODO(nick): Should we consider |source| here? Should we call FilterURL on |
| 3723 // |manifest_url|? |
| 3724 |
| 3710 // Notify observers about navigation. | 3725 // Notify observers about navigation. |
| 3711 for (auto& observer : observers_) | 3726 for (auto& observer : observers_) |
| 3712 observer.AppCacheAccessed(manifest_url, blocked_by_policy); | 3727 observer.AppCacheAccessed(manifest_url, blocked_by_policy); |
| 3713 } | 3728 } |
| 3714 | 3729 |
| 3715 void WebContentsImpl::OnOpenColorChooser( | 3730 void WebContentsImpl::OnOpenColorChooser( |
| 3731 RenderFrameHostImpl* source, |
| 3716 int color_chooser_id, | 3732 int color_chooser_id, |
| 3717 SkColor color, | 3733 SkColor color, |
| 3718 const std::vector<ColorSuggestion>& suggestions) { | 3734 const std::vector<ColorSuggestion>& suggestions) { |
| 3719 if (!HasValidFrameSource()) | |
| 3720 return; | |
| 3721 | |
| 3722 ColorChooser* new_color_chooser = delegate_ ? | 3735 ColorChooser* new_color_chooser = delegate_ ? |
| 3723 delegate_->OpenColorChooser(this, color, suggestions) : | 3736 delegate_->OpenColorChooser(this, color, suggestions) : |
| 3724 NULL; | 3737 NULL; |
| 3725 if (!new_color_chooser) | 3738 if (!new_color_chooser) |
| 3726 return; | 3739 return; |
| 3727 if (color_chooser_info_.get()) | 3740 if (color_chooser_info_.get()) |
| 3728 color_chooser_info_->chooser->End(); | 3741 color_chooser_info_->chooser->End(); |
| 3729 | 3742 |
| 3730 color_chooser_info_.reset(new ColorChooserInfo( | 3743 color_chooser_info_.reset(new ColorChooserInfo( |
| 3731 render_frame_message_source_->GetProcess()->GetID(), | 3744 source->GetProcess()->GetID(), source->GetRoutingID(), new_color_chooser, |
| 3732 render_frame_message_source_->GetRoutingID(), | |
| 3733 new_color_chooser, | |
| 3734 color_chooser_id)); | 3745 color_chooser_id)); |
| 3735 } | 3746 } |
| 3736 | 3747 |
| 3737 void WebContentsImpl::OnEndColorChooser(int color_chooser_id) { | 3748 void WebContentsImpl::OnEndColorChooser(RenderFrameHostImpl* source, |
| 3749 int color_chooser_id) { |
| 3738 if (color_chooser_info_ && | 3750 if (color_chooser_info_ && |
| 3739 color_chooser_id == color_chooser_info_->identifier) | 3751 color_chooser_info_->Matches(source, color_chooser_id)) |
| 3740 color_chooser_info_->chooser->End(); | 3752 color_chooser_info_->chooser->End(); |
| 3741 } | 3753 } |
| 3742 | 3754 |
| 3743 void WebContentsImpl::OnSetSelectedColorInColorChooser(int color_chooser_id, | 3755 void WebContentsImpl::OnSetSelectedColorInColorChooser( |
| 3744 SkColor color) { | 3756 RenderFrameHostImpl* source, |
| 3757 int color_chooser_id, |
| 3758 SkColor color) { |
| 3745 if (color_chooser_info_ && | 3759 if (color_chooser_info_ && |
| 3746 color_chooser_id == color_chooser_info_->identifier) | 3760 color_chooser_info_->Matches(source, color_chooser_id)) |
| 3747 color_chooser_info_->chooser->SetSelectedColor(color); | 3761 color_chooser_info_->chooser->SetSelectedColor(color); |
| 3748 } | 3762 } |
| 3749 | 3763 |
| 3750 // This exists for render views that don't have a WebUI, but do have WebUI | 3764 // This exists for render views that don't have a WebUI, but do have WebUI |
| 3751 // bindings enabled. | 3765 // bindings enabled. |
| 3752 void WebContentsImpl::OnWebUISend(const GURL& source_url, | 3766 void WebContentsImpl::OnWebUISend(RenderViewHostImpl* source, |
| 3767 const GURL& source_url, |
| 3753 const std::string& name, | 3768 const std::string& name, |
| 3754 const base::ListValue& args) { | 3769 const base::ListValue& args) { |
| 3770 // TODO(nick): Should we consider |source| here or pass it to the delegate? |
| 3771 // TODO(nick): Should FilterURL be applied to |source_url|? |
| 3772 // TODO(nick): This IPC should be ported to FrameHostMsg_, and |source_url| |
| 3773 // should be eliminated (use last_committed_url() on the RFH instead). |
| 3755 if (delegate_) | 3774 if (delegate_) |
| 3756 delegate_->WebUISend(this, source_url, name, args); | 3775 delegate_->WebUISend(this, source_url, name, args); |
| 3757 } | 3776 } |
| 3758 | 3777 |
| 3759 #if BUILDFLAG(ENABLE_PLUGINS) | 3778 #if BUILDFLAG(ENABLE_PLUGINS) |
| 3760 void WebContentsImpl::OnPepperInstanceCreated(int32_t pp_instance) { | 3779 void WebContentsImpl::OnPepperInstanceCreated(RenderFrameHostImpl* source, |
| 3780 int32_t pp_instance) { |
| 3761 for (auto& observer : observers_) | 3781 for (auto& observer : observers_) |
| 3762 observer.PepperInstanceCreated(); | 3782 observer.PepperInstanceCreated(); |
| 3763 pepper_playback_observer_->PepperInstanceCreated( | 3783 pepper_playback_observer_->PepperInstanceCreated(source, pp_instance); |
| 3764 render_frame_message_source_, pp_instance); | |
| 3765 } | 3784 } |
| 3766 | 3785 |
| 3767 void WebContentsImpl::OnPepperInstanceDeleted(int32_t pp_instance) { | 3786 void WebContentsImpl::OnPepperInstanceDeleted(RenderFrameHostImpl* source, |
| 3787 int32_t pp_instance) { |
| 3768 for (auto& observer : observers_) | 3788 for (auto& observer : observers_) |
| 3769 observer.PepperInstanceDeleted(); | 3789 observer.PepperInstanceDeleted(); |
| 3770 pepper_playback_observer_->PepperInstanceDeleted( | 3790 pepper_playback_observer_->PepperInstanceDeleted(source, pp_instance); |
| 3771 render_frame_message_source_, pp_instance); | |
| 3772 } | 3791 } |
| 3773 | 3792 |
| 3774 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, | 3793 void WebContentsImpl::OnPepperPluginHung(RenderFrameHostImpl* source, |
| 3794 int plugin_child_id, |
| 3775 const base::FilePath& path, | 3795 const base::FilePath& path, |
| 3776 bool is_hung) { | 3796 bool is_hung) { |
| 3777 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); | 3797 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); |
| 3778 | 3798 |
| 3779 for (auto& observer : observers_) | 3799 for (auto& observer : observers_) |
| 3780 observer.PluginHungStatusChanged(plugin_child_id, path, is_hung); | 3800 observer.PluginHungStatusChanged(plugin_child_id, path, is_hung); |
| 3781 } | 3801 } |
| 3782 | 3802 |
| 3783 void WebContentsImpl::OnPepperStartsPlayback(int32_t pp_instance) { | 3803 void WebContentsImpl::OnPepperStartsPlayback(RenderFrameHostImpl* source, |
| 3784 pepper_playback_observer_->PepperStartsPlayback( | 3804 int32_t pp_instance) { |
| 3785 render_frame_message_source_, pp_instance); | 3805 pepper_playback_observer_->PepperStartsPlayback(source, pp_instance); |
| 3786 } | 3806 } |
| 3787 | 3807 |
| 3788 void WebContentsImpl::OnPepperStopsPlayback(int32_t pp_instance) { | 3808 void WebContentsImpl::OnPepperStopsPlayback(RenderFrameHostImpl* source, |
| 3789 pepper_playback_observer_->PepperStopsPlayback( | 3809 int32_t pp_instance) { |
| 3790 render_frame_message_source_, pp_instance); | 3810 pepper_playback_observer_->PepperStopsPlayback(source, pp_instance); |
| 3791 } | 3811 } |
| 3792 | 3812 |
| 3793 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, | 3813 void WebContentsImpl::OnPluginCrashed(RenderFrameHostImpl* source, |
| 3814 const base::FilePath& plugin_path, |
| 3794 base::ProcessId plugin_pid) { | 3815 base::ProcessId plugin_pid) { |
| 3816 // TODO(nick): Eliminate the |plugin_pid| parameter, which can't be trusted, |
| 3817 // and is only used by BlinkTestController. |
| 3795 for (auto& observer : observers_) | 3818 for (auto& observer : observers_) |
| 3796 observer.PluginCrashed(plugin_path, plugin_pid); | 3819 observer.PluginCrashed(plugin_path, plugin_pid); |
| 3797 } | 3820 } |
| 3798 | 3821 |
| 3799 void WebContentsImpl::OnRequestPpapiBrokerPermission( | 3822 void WebContentsImpl::OnRequestPpapiBrokerPermission( |
| 3800 int routing_id, | 3823 RenderViewHostImpl* source, |
| 3824 int ppb_broker_route_id, |
| 3801 const GURL& url, | 3825 const GURL& url, |
| 3802 const base::FilePath& plugin_path) { | 3826 const base::FilePath& plugin_path) { |
| 3827 base::Callback<void(bool)> permission_result_callback = base::Bind( |
| 3828 &WebContentsImpl::SendPpapiBrokerPermissionResult, base::Unretained(this), |
| 3829 source->GetProcess()->GetID(), ppb_broker_route_id); |
| 3803 if (!delegate_) { | 3830 if (!delegate_) { |
| 3804 OnPpapiBrokerPermissionResult(routing_id, false); | 3831 permission_result_callback.Run(false); |
| 3805 return; | 3832 return; |
| 3806 } | 3833 } |
| 3807 | 3834 |
| 3808 if (!delegate_->RequestPpapiBrokerPermission( | 3835 if (!delegate_->RequestPpapiBrokerPermission(this, url, plugin_path, |
| 3809 this, url, plugin_path, | 3836 permission_result_callback)) { |
| 3810 base::Bind(&WebContentsImpl::OnPpapiBrokerPermissionResult, | |
| 3811 base::Unretained(this), routing_id))) { | |
| 3812 NOTIMPLEMENTED(); | 3837 NOTIMPLEMENTED(); |
| 3813 OnPpapiBrokerPermissionResult(routing_id, false); | 3838 permission_result_callback.Run(false); |
| 3814 } | 3839 } |
| 3815 } | 3840 } |
| 3816 | 3841 |
| 3817 void WebContentsImpl::OnPpapiBrokerPermissionResult(int routing_id, | 3842 void WebContentsImpl::SendPpapiBrokerPermissionResult(int process_id, |
| 3818 bool result) { | 3843 int ppb_broker_route_id, |
| 3819 Send(new ViewMsg_PpapiBrokerPermissionResult(routing_id, result)); | 3844 bool result) { |
| 3845 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); |
| 3846 if (rph) { |
| 3847 // TODO(nick): Convert this from ViewMsg_ to a Ppapi msg, since it |
| 3848 // is not routed to a RenderView. |
| 3849 rph->Send( |
| 3850 new ViewMsg_PpapiBrokerPermissionResult(ppb_broker_route_id, result)); |
| 3851 } |
| 3820 } | 3852 } |
| 3821 | 3853 |
| 3822 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, | 3854 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, |
| 3823 const IPC::Message& message) { | 3855 const IPC::Message& message) { |
| 3824 CHECK(!browser_plugin_embedder_.get()); | 3856 CHECK(!browser_plugin_embedder_.get()); |
| 3825 CreateBrowserPluginEmbedderIfNecessary(); | 3857 CreateBrowserPluginEmbedderIfNecessary(); |
| 3826 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); | 3858 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); |
| 3827 } | 3859 } |
| 3828 #endif // BUILDFLAG(ENABLE_PLUGINS) | 3860 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 3829 | 3861 |
| 3830 void WebContentsImpl::OnUpdateFaviconURL( | 3862 void WebContentsImpl::OnUpdateFaviconURL( |
| 3863 RenderViewHostImpl* source, |
| 3831 const std::vector<FaviconURL>& candidates) { | 3864 const std::vector<FaviconURL>& candidates) { |
| 3832 // We get updated favicon URLs after the page stops loading. If a cross-site | 3865 // We get updated favicon URLs after the page stops loading. If a cross-site |
| 3833 // navigation occurs while a page is still loading, the initial page | 3866 // navigation occurs while a page is still loading, the initial page |
| 3834 // may stop loading and send us updated favicon URLs after the navigation | 3867 // may stop loading and send us updated favicon URLs after the navigation |
| 3835 // for the new page has committed. | 3868 // for the new page has committed. |
| 3836 RenderViewHostImpl* rvhi = | 3869 if (!source->is_active()) |
| 3837 static_cast<RenderViewHostImpl*>(render_view_message_source_); | |
| 3838 if (!rvhi->is_active()) | |
| 3839 return; | 3870 return; |
| 3840 | 3871 |
| 3841 for (auto& observer : observers_) | 3872 for (auto& observer : observers_) |
| 3842 observer.DidUpdateFaviconURL(candidates); | 3873 observer.DidUpdateFaviconURL(candidates); |
| 3843 } | 3874 } |
| 3844 | 3875 |
| 3845 void WebContentsImpl::OnPasswordInputShownOnHttp() { | 3876 void WebContentsImpl::OnPasswordInputShownOnHttp() { |
| 3846 controller_.ssl_manager()->DidShowPasswordInputOnHttp(); | 3877 controller_.ssl_manager()->DidShowPasswordInputOnHttp(); |
| 3847 } | 3878 } |
| 3848 | 3879 |
| 3849 void WebContentsImpl::OnAllPasswordInputsHiddenOnHttp() { | 3880 void WebContentsImpl::OnAllPasswordInputsHiddenOnHttp() { |
| 3850 controller_.ssl_manager()->DidHideAllPasswordInputsOnHttp(); | 3881 controller_.ssl_manager()->DidHideAllPasswordInputsOnHttp(); |
| 3851 } | 3882 } |
| 3852 | 3883 |
| 3853 void WebContentsImpl::OnCreditCardInputShownOnHttp() { | 3884 void WebContentsImpl::OnCreditCardInputShownOnHttp() { |
| 3854 controller_.ssl_manager()->DidShowCreditCardInputOnHttp(); | 3885 controller_.ssl_manager()->DidShowCreditCardInputOnHttp(); |
| 3855 } | 3886 } |
| 3856 | 3887 |
| 3857 void WebContentsImpl::SetIsOverlayContent(bool is_overlay_content) { | 3888 void WebContentsImpl::SetIsOverlayContent(bool is_overlay_content) { |
| 3858 is_overlay_content_ = is_overlay_content; | 3889 is_overlay_content_ = is_overlay_content; |
| 3859 } | 3890 } |
| 3860 | 3891 |
| 3861 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { | 3892 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint(RenderViewHostImpl* source) { |
| 3893 // TODO(nick): When this is ported to FrameHostMsg_, we should only listen if |
| 3894 // |source| is the main frame. |
| 3862 for (auto& observer : observers_) | 3895 for (auto& observer : observers_) |
| 3863 observer.DidFirstVisuallyNonEmptyPaint(); | 3896 observer.DidFirstVisuallyNonEmptyPaint(); |
| 3864 | 3897 |
| 3865 did_first_visually_non_empty_paint_ = true; | 3898 did_first_visually_non_empty_paint_ = true; |
| 3866 | 3899 |
| 3867 if (theme_color_ != last_sent_theme_color_) { | 3900 if (theme_color_ != last_sent_theme_color_) { |
| 3868 // Theme color should have updated by now if there was one. | 3901 // Theme color should have updated by now if there was one. |
| 3869 for (auto& observer : observers_) | 3902 for (auto& observer : observers_) |
| 3870 observer.DidChangeThemeColor(theme_color_); | 3903 observer.DidChangeThemeColor(theme_color_); |
| 3871 last_sent_theme_color_ = theme_color_; | 3904 last_sent_theme_color_ = theme_color_; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4040 Source<WebContents>(this), | 4073 Source<WebContents>(this), |
| 4041 NotificationService::NoDetails()); | 4074 NotificationService::NoDetails()); |
| 4042 } | 4075 } |
| 4043 | 4076 |
| 4044 void WebContentsImpl::NotifyNavigationEntryCommitted( | 4077 void WebContentsImpl::NotifyNavigationEntryCommitted( |
| 4045 const LoadCommittedDetails& load_details) { | 4078 const LoadCommittedDetails& load_details) { |
| 4046 for (auto& observer : observers_) | 4079 for (auto& observer : observers_) |
| 4047 observer.NavigationEntryCommitted(load_details); | 4080 observer.NavigationEntryCommitted(load_details); |
| 4048 } | 4081 } |
| 4049 | 4082 |
| 4050 bool WebContentsImpl::OnMessageReceived(RenderFrameHost* render_frame_host, | |
| 4051 const IPC::Message& message) { | |
| 4052 return OnMessageReceived(NULL, render_frame_host, message); | |
| 4053 } | |
| 4054 | |
| 4055 void WebContentsImpl::OnAssociatedInterfaceRequest( | 4083 void WebContentsImpl::OnAssociatedInterfaceRequest( |
| 4056 RenderFrameHost* render_frame_host, | 4084 RenderFrameHost* render_frame_host, |
| 4057 const std::string& interface_name, | 4085 const std::string& interface_name, |
| 4058 mojo::ScopedInterfaceEndpointHandle handle) { | 4086 mojo::ScopedInterfaceEndpointHandle handle) { |
| 4059 auto it = binding_sets_.find(interface_name); | 4087 auto it = binding_sets_.find(interface_name); |
| 4060 if (it != binding_sets_.end()) | 4088 if (it != binding_sets_.end()) |
| 4061 it->second->OnRequestForFrame(render_frame_host, std::move(handle)); | 4089 it->second->OnRequestForFrame(render_frame_host, std::move(handle)); |
| 4062 } | 4090 } |
| 4063 | 4091 |
| 4064 const GURL& WebContentsImpl::GetMainFrameLastCommittedURL() const { | 4092 const GURL& WebContentsImpl::GetMainFrameLastCommittedURL() const { |
| (...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5321 GetMainFrame()->AddMessageToConsole( | 5349 GetMainFrame()->AddMessageToConsole( |
| 5322 content::CONSOLE_MESSAGE_LEVEL_WARNING, | 5350 content::CONSOLE_MESSAGE_LEVEL_WARNING, |
| 5323 base::StringPrintf("This site does not have a valid SSL " | 5351 base::StringPrintf("This site does not have a valid SSL " |
| 5324 "certificate! Without SSL, your site's and " | 5352 "certificate! Without SSL, your site's and " |
| 5325 "visitors' data is vulnerable to theft and " | 5353 "visitors' data is vulnerable to theft and " |
| 5326 "tampering. Get a valid SSL certificate before" | 5354 "tampering. Get a valid SSL certificate before" |
| 5327 " releasing your website to the public.")); | 5355 " releasing your website to the public.")); |
| 5328 } | 5356 } |
| 5329 | 5357 |
| 5330 } // namespace content | 5358 } // namespace content |
| OLD | NEW |