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 if (observer.OnMessageReceived(message)) | |
Charlie Reis
2016/12/13 19:03:56
Presumably this should be changed or removed somed
ncarter (slow)
2016/12/14 18:36:47
Added a TODO
| |
685 return true; | |
686 } | |
687 | |
688 bool handled = true; | |
689 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContentsImpl, message, render_view_host) | |
690 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, | |
691 OnFirstVisuallyNonEmptyPaint) | |
692 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | |
693 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | |
694 IPC_MESSAGE_HANDLER(ViewHostMsg_PageScaleFactorChanged, | |
695 OnPageScaleFactorChanged) | |
696 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | |
697 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | |
698 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | |
699 #if BUILDFLAG(ENABLE_PLUGINS) | |
700 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | |
701 OnRequestPpapiBrokerPermission) | |
702 #endif | |
703 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | |
704 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, | |
705 OnShowValidationMessage) | |
706 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, | |
707 OnHideValidationMessage) | |
708 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, | |
709 OnMoveValidationMessage) | |
710 #if defined(OS_ANDROID) | |
711 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, OnOpenDateTimeDialog) | |
712 #endif | |
713 IPC_MESSAGE_UNHANDLED(handled = false) | |
714 IPC_END_MESSAGE_MAP() | |
715 | |
716 return handled; | |
671 } | 717 } |
672 | 718 |
673 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, | 719 bool WebContentsImpl::OnMessageReceived(RenderFrameHostImpl* render_frame_host, |
674 RenderFrameHost* render_frame_host, | |
675 const IPC::Message& message) { | 720 const IPC::Message& message) { |
676 DCHECK(render_view_host || render_frame_host); | 721 for (auto& observer : observers_) { |
677 | 722 if (observer.OnMessageReceived(message, render_frame_host)) |
678 if (render_view_host) { | 723 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 } | 724 } |
687 | 725 |
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; | 726 bool handled = true; |
709 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message) | 727 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContentsImpl, message, render_frame_host) |
710 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, | 728 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, |
711 OnDomOperationResponse) | 729 OnDomOperationResponse) |
712 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, | 730 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, |
713 OnThemeColorChanged) | 731 OnThemeColorChanged) |
714 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, | 732 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, |
715 OnDocumentLoadedInFrame) | 733 OnDocumentLoadedInFrame) |
716 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) | 734 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) |
717 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) | 735 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) |
718 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) | 736 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) |
719 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, | 737 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, |
720 OnSetSelectedColorInColorChooser) | 738 OnSetSelectedColorInColorChooser) |
721 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, | |
722 OnFirstVisuallyNonEmptyPaint) | |
723 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache, | 739 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache, |
724 OnDidLoadResourceFromMemoryCache) | 740 OnDidLoadResourceFromMemoryCache) |
725 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent, | 741 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent, |
726 OnDidDisplayInsecureContent) | 742 OnDidDisplayInsecureContent) |
727 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent, | 743 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent, |
728 OnDidRunInsecureContent) | 744 OnDidRunInsecureContent) |
729 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors, | 745 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors, |
730 OnDidDisplayContentWithCertificateErrors) | 746 OnDidDisplayContentWithCertificateErrors) |
731 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunContentWithCertificateErrors, | 747 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunContentWithCertificateErrors, |
732 OnDidRunContentWithCertificateErrors) | 748 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, | 749 IPC_MESSAGE_HANDLER(FrameHostMsg_RegisterProtocolHandler, |
739 OnRegisterProtocolHandler) | 750 OnRegisterProtocolHandler) |
740 IPC_MESSAGE_HANDLER(FrameHostMsg_UnregisterProtocolHandler, | 751 IPC_MESSAGE_HANDLER(FrameHostMsg_UnregisterProtocolHandler, |
741 OnUnregisterProtocolHandler) | 752 OnUnregisterProtocolHandler) |
742 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdatePageImportanceSignals, | 753 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdatePageImportanceSignals, |
743 OnUpdatePageImportanceSignals) | 754 OnUpdatePageImportanceSignals) |
744 IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply) | 755 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) | 756 #if BUILDFLAG(ENABLE_PLUGINS) |
748 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated, | 757 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated, |
749 OnPepperInstanceCreated) | 758 OnPepperInstanceCreated) |
750 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, | 759 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, |
751 OnPepperInstanceDeleted) | 760 OnPepperInstanceDeleted) |
752 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) | 761 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) |
753 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStartsPlayback, | 762 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStartsPlayback, |
754 OnPepperStartsPlayback) | 763 OnPepperStartsPlayback) |
755 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStopsPlayback, | 764 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStopsPlayback, |
756 OnPepperStopsPlayback) | 765 OnPepperStopsPlayback) |
757 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) | 766 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) |
758 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | |
759 OnRequestPpapiBrokerPermission) | |
760 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 767 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
761 OnBrowserPluginMessage(render_frame_host, | 768 OnBrowserPluginMessage(render_frame_host, |
762 message)) | 769 message)) |
763 #endif | 770 #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) | 771 #if defined(OS_ANDROID) |
772 IPC_MESSAGE_HANDLER(FrameHostMsg_FindMatchRects_Reply, | 772 IPC_MESSAGE_HANDLER(FrameHostMsg_FindMatchRects_Reply, |
773 OnFindMatchRectsReply) | 773 OnFindMatchRectsReply) |
774 IPC_MESSAGE_HANDLER(FrameHostMsg_GetNearestFindResult_Reply, | 774 IPC_MESSAGE_HANDLER(FrameHostMsg_GetNearestFindResult_Reply, |
775 OnGetNearestFindResultReply) | 775 OnGetNearestFindResultReply) |
776 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, | |
777 OnOpenDateTimeDialog) | |
778 #endif | 776 #endif |
779 IPC_MESSAGE_UNHANDLED(handled = false) | 777 IPC_MESSAGE_UNHANDLED(handled = false) |
780 IPC_END_MESSAGE_MAP() | 778 IPC_END_MESSAGE_MAP() |
781 render_view_message_source_ = NULL; | |
782 render_frame_message_source_ = NULL; | |
783 | 779 |
784 return handled; | 780 return handled; |
785 } | 781 } |
786 | 782 |
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() { | 783 NavigationControllerImpl& WebContentsImpl::GetController() { |
799 return controller_; | 784 return controller_; |
800 } | 785 } |
801 | 786 |
802 const NavigationControllerImpl& WebContentsImpl::GetController() const { | 787 const NavigationControllerImpl& WebContentsImpl::GetController() const { |
803 return controller_; | 788 return controller_; |
804 } | 789 } |
805 | 790 |
806 BrowserContext* WebContentsImpl::GetBrowserContext() const { | 791 BrowserContext* WebContentsImpl::GetBrowserContext() const { |
807 return controller_.GetBrowserContext(); | 792 return controller_.GetBrowserContext(); |
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2440 | 2425 |
2441 device::WakeLockServiceContext* WebContentsImpl::GetWakeLockServiceContext() { | 2426 device::WakeLockServiceContext* WebContentsImpl::GetWakeLockServiceContext() { |
2442 return wake_lock_service_context_.get(); | 2427 return wake_lock_service_context_.get(); |
2443 } | 2428 } |
2444 | 2429 |
2445 ScreenOrientationProvider* WebContentsImpl::GetScreenOrientationProvider() { | 2430 ScreenOrientationProvider* WebContentsImpl::GetScreenOrientationProvider() { |
2446 return screen_orientation_.get()->GetScreenOrientationProvider(); | 2431 return screen_orientation_.get()->GetScreenOrientationProvider(); |
2447 } | 2432 } |
2448 | 2433 |
2449 void WebContentsImpl::OnShowValidationMessage( | 2434 void WebContentsImpl::OnShowValidationMessage( |
2435 RenderViewHostImpl* source, | |
2450 const gfx::Rect& anchor_in_root_view, | 2436 const gfx::Rect& anchor_in_root_view, |
2451 const base::string16& main_text, | 2437 const base::string16& main_text, |
2452 const base::string16& sub_text) { | 2438 const base::string16& sub_text) { |
2439 // TODO(nick): |source|? | |
Charlie Reis
2016/12/13 19:03:56
I'm with you, but maybe this TODO should be a litt
ncarter (slow)
2016/12/14 18:36:47
Done.
| |
2453 if (delegate_) | 2440 if (delegate_) |
2454 delegate_->ShowValidationMessage( | 2441 delegate_->ShowValidationMessage( |
2455 this, anchor_in_root_view, main_text, sub_text); | 2442 this, anchor_in_root_view, main_text, sub_text); |
2456 } | 2443 } |
2457 | 2444 |
2458 void WebContentsImpl::OnHideValidationMessage() { | 2445 void WebContentsImpl::OnHideValidationMessage(RenderViewHostImpl* source) { |
2459 if (delegate_) | 2446 if (delegate_) |
2460 delegate_->HideValidationMessage(this); | 2447 delegate_->HideValidationMessage(this); |
2461 } | 2448 } |
2462 | 2449 |
2463 void WebContentsImpl::OnMoveValidationMessage( | 2450 void WebContentsImpl::OnMoveValidationMessage( |
2451 RenderViewHostImpl* source, | |
2464 const gfx::Rect& anchor_in_root_view) { | 2452 const gfx::Rect& anchor_in_root_view) { |
2453 // TODO(nick): |source|? | |
2465 if (delegate_) | 2454 if (delegate_) |
2466 delegate_->MoveValidationMessage(this, anchor_in_root_view); | 2455 delegate_->MoveValidationMessage(this, anchor_in_root_view); |
2467 } | 2456 } |
2468 | 2457 |
2469 void WebContentsImpl::SendScreenRects() { | 2458 void WebContentsImpl::SendScreenRects() { |
2470 for (FrameTreeNode* node : frame_tree_.Nodes()) { | 2459 for (FrameTreeNode* node : frame_tree_.Nodes()) { |
2471 if (node->current_frame_host()->is_local_root()) | 2460 if (node->current_frame_host()->is_local_root()) |
2472 node->current_frame_host()->GetRenderWidgetHost()->SendScreenRects(); | 2461 node->current_frame_host()->GetRenderWidgetHost()->SendScreenRects(); |
2473 } | 2462 } |
2474 | 2463 |
(...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. | 3469 // Disable overscroll when touch emulation is on. See crbug.com/369938. |
3481 if (force_disable_overscroll_content_) | 3470 if (force_disable_overscroll_content_) |
3482 return false; | 3471 return false; |
3483 | 3472 |
3484 if (delegate_) | 3473 if (delegate_) |
3485 return delegate_->CanOverscrollContent(); | 3474 return delegate_->CanOverscrollContent(); |
3486 | 3475 |
3487 return false; | 3476 return false; |
3488 } | 3477 } |
3489 | 3478 |
3490 void WebContentsImpl::OnThemeColorChanged(SkColor theme_color) { | 3479 void WebContentsImpl::OnThemeColorChanged(RenderFrameHostImpl* source, |
Charlie Reis
2016/12/13 19:03:56
A bunch of these methods don't check |source| eith
ncarter (slow)
2016/12/14 18:36:47
I was adding TODOs as I saw obvious problems, but
| |
3480 SkColor theme_color) { | |
3491 // Update the theme color. This is to be published to observers after the | 3481 // Update the theme color. This is to be published to observers after the |
3492 // first visually non-empty paint. | 3482 // first visually non-empty paint. |
3493 theme_color_ = theme_color; | 3483 theme_color_ = theme_color; |
3494 | 3484 |
3495 if (did_first_visually_non_empty_paint_ && | 3485 if (did_first_visually_non_empty_paint_ && |
3496 last_sent_theme_color_ != theme_color_) { | 3486 last_sent_theme_color_ != theme_color_) { |
3497 for (auto& observer : observers_) | 3487 for (auto& observer : observers_) |
3498 observer.DidChangeThemeColor(theme_color_); | 3488 observer.DidChangeThemeColor(theme_color_); |
3499 last_sent_theme_color_ = theme_color_; | 3489 last_sent_theme_color_ = theme_color_; |
3500 } | 3490 } |
3501 } | 3491 } |
3502 | 3492 |
3503 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( | 3493 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( |
3494 RenderFrameHostImpl* source, | |
3504 const GURL& url, | 3495 const GURL& url, |
3505 const std::string& http_method, | 3496 const std::string& http_method, |
3506 const std::string& mime_type, | 3497 const std::string& mime_type, |
3507 ResourceType resource_type) { | 3498 ResourceType resource_type) { |
3508 for (auto& observer : observers_) | 3499 for (auto& observer : observers_) |
3509 observer.DidLoadResourceFromMemoryCache(url, mime_type, resource_type); | 3500 observer.DidLoadResourceFromMemoryCache(url, mime_type, resource_type); |
3510 | 3501 |
3511 if (url.is_valid() && url.SchemeIsHTTPOrHTTPS()) { | 3502 if (url.is_valid() && url.SchemeIsHTTPOrHTTPS()) { |
3512 scoped_refptr<net::URLRequestContextGetter> request_context( | 3503 scoped_refptr<net::URLRequestContextGetter> request_context( |
3513 resource_type == RESOURCE_TYPE_MEDIA ? | 3504 resource_type == RESOURCE_TYPE_MEDIA ? |
3514 GetRenderProcessHost()->GetStoragePartition()-> | 3505 GetRenderProcessHost()->GetStoragePartition()-> |
3515 GetMediaURLRequestContext() : | 3506 GetMediaURLRequestContext() : |
3516 GetRenderProcessHost()->GetStoragePartition()-> | 3507 GetRenderProcessHost()->GetStoragePartition()-> |
3517 GetURLRequestContext()); | 3508 GetURLRequestContext()); |
3518 BrowserThread::PostTask( | 3509 BrowserThread::PostTask( |
3519 BrowserThread::IO, | 3510 BrowserThread::IO, |
3520 FROM_HERE, | 3511 FROM_HERE, |
3521 base::Bind(&NotifyCacheOnIO, request_context, url, http_method)); | 3512 base::Bind(&NotifyCacheOnIO, request_context, url, http_method)); |
3522 } | 3513 } |
3523 } | 3514 } |
3524 | 3515 |
3525 void WebContentsImpl::OnDidDisplayInsecureContent() { | 3516 void WebContentsImpl::OnDidDisplayInsecureContent(RenderFrameHostImpl* source) { |
3526 RecordAction(base::UserMetricsAction("SSL.DisplayedInsecureContent")); | 3517 RecordAction(base::UserMetricsAction("SSL.DisplayedInsecureContent")); |
3527 controller_.ssl_manager()->DidDisplayMixedContent(); | 3518 controller_.ssl_manager()->DidDisplayMixedContent(); |
3528 } | 3519 } |
3529 | 3520 |
3530 void WebContentsImpl::OnDidRunInsecureContent(const GURL& security_origin, | 3521 void WebContentsImpl::OnDidRunInsecureContent(RenderFrameHostImpl* source, |
3522 const GURL& security_origin, | |
3531 const GURL& target_url) { | 3523 const GURL& target_url) { |
3532 LOG(WARNING) << security_origin << " ran insecure content from " | 3524 LOG(WARNING) << security_origin << " ran insecure content from " |
3533 << target_url.possibly_invalid_spec(); | 3525 << target_url.possibly_invalid_spec(); |
3534 RecordAction(base::UserMetricsAction("SSL.RanInsecureContent")); | 3526 RecordAction(base::UserMetricsAction("SSL.RanInsecureContent")); |
3535 if (base::EndsWith(security_origin.spec(), kDotGoogleDotCom, | 3527 if (base::EndsWith(security_origin.spec(), kDotGoogleDotCom, |
3536 base::CompareCase::INSENSITIVE_ASCII)) | 3528 base::CompareCase::INSENSITIVE_ASCII)) |
3537 RecordAction(base::UserMetricsAction("SSL.RanInsecureContentGoogle")); | 3529 RecordAction(base::UserMetricsAction("SSL.RanInsecureContentGoogle")); |
3538 controller_.ssl_manager()->DidRunMixedContent(security_origin); | 3530 controller_.ssl_manager()->DidRunMixedContent(security_origin); |
3539 } | 3531 } |
3540 | 3532 |
3541 void WebContentsImpl::OnDidDisplayContentWithCertificateErrors( | 3533 void WebContentsImpl::OnDidDisplayContentWithCertificateErrors( |
3534 RenderFrameHostImpl* source, | |
3542 const GURL& url) { | 3535 const GURL& url) { |
3543 controller_.ssl_manager()->DidDisplayContentWithCertErrors(); | 3536 controller_.ssl_manager()->DidDisplayContentWithCertErrors(); |
3544 } | 3537 } |
3545 | 3538 |
3546 void WebContentsImpl::OnDidRunContentWithCertificateErrors( | 3539 void WebContentsImpl::OnDidRunContentWithCertificateErrors( |
3540 RenderFrameHostImpl* source, | |
3547 const GURL& url) { | 3541 const GURL& url) { |
3548 NavigationEntry* entry = controller_.GetVisibleEntry(); | 3542 NavigationEntry* entry = controller_.GetVisibleEntry(); |
3549 if (!entry) | 3543 if (!entry) |
3550 return; | 3544 return; |
3551 | 3545 |
3552 // TODO(estark): check that this does something reasonable for | 3546 // TODO(estark): check that this does something reasonable for |
3553 // about:blank and sandboxed origins. https://crbug.com/609527 | 3547 // about:blank and sandboxed origins. https://crbug.com/609527 |
3554 controller_.ssl_manager()->DidRunContentWithCertErrors( | 3548 controller_.ssl_manager()->DidRunContentWithCertErrors( |
3555 entry->GetURL().GetOrigin()); | 3549 entry->GetURL().GetOrigin()); |
3556 } | 3550 } |
3557 | 3551 |
3558 void WebContentsImpl::OnDocumentLoadedInFrame() { | 3552 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_) | 3553 for (auto& observer : observers_) |
3565 observer.DocumentLoadedInFrame(rfh); | 3554 observer.DocumentLoadedInFrame(source); |
3566 } | 3555 } |
3567 | 3556 |
3568 void WebContentsImpl::OnDidFinishLoad(const GURL& url) { | 3557 void WebContentsImpl::OnDidFinishLoad(RenderFrameHostImpl* source, |
3569 if (!HasValidFrameSource()) | 3558 const GURL& url) { |
3570 return; | 3559 GURL validated_url(url); |
3560 source->GetProcess()->FilterURL(false, &validated_url); | |
3571 | 3561 |
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_) | 3562 for (auto& observer : observers_) |
3580 observer.DidFinishLoad(rfh, validated_url); | 3563 observer.DidFinishLoad(source, validated_url); |
3581 } | 3564 } |
3582 | 3565 |
3583 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { | 3566 void WebContentsImpl::OnGoToEntryAtOffset(RenderViewHostImpl* source, |
3567 int offset) { | |
3568 // All frames are allowed to navigate the global history. | |
3584 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) | 3569 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) |
3585 controller_.GoToOffset(offset); | 3570 controller_.GoToOffset(offset); |
3586 } | 3571 } |
3587 | 3572 |
3588 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, | 3573 void WebContentsImpl::OnUpdateZoomLimits(RenderViewHostImpl* source, |
3574 int minimum_percent, | |
3589 int maximum_percent) { | 3575 int maximum_percent) { |
3590 minimum_zoom_percent_ = minimum_percent; | 3576 minimum_zoom_percent_ = minimum_percent; |
3591 maximum_zoom_percent_ = maximum_percent; | 3577 maximum_zoom_percent_ = maximum_percent; |
3592 } | 3578 } |
3593 | 3579 |
3594 void WebContentsImpl::OnPageScaleFactorChanged(float page_scale_factor) { | 3580 void WebContentsImpl::OnPageScaleFactorChanged(RenderViewHostImpl* source, |
3581 float page_scale_factor) { | |
3595 bool is_one = page_scale_factor == 1.f; | 3582 bool is_one = page_scale_factor == 1.f; |
3596 if (is_one != page_scale_factor_is_one_) { | 3583 if (is_one != page_scale_factor_is_one_) { |
3597 page_scale_factor_is_one_ = is_one; | 3584 page_scale_factor_is_one_ = is_one; |
3598 | 3585 |
3599 HostZoomMapImpl* host_zoom_map = | 3586 HostZoomMapImpl* host_zoom_map = |
3600 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); | 3587 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); |
3601 | 3588 |
3589 // TODO(nick): Explain why we use GetRenderViewHost() here instead of | |
3590 // |source|. | |
Charlie Reis
2016/12/13 19:03:56
This seems like something we should resolve before
ncarter (slow)
2016/12/14 18:36:47
I fixed up this one, but will add wjmaclean to the
| |
3602 if (host_zoom_map && GetRenderProcessHost()) { | 3591 if (host_zoom_map && GetRenderProcessHost()) { |
3603 host_zoom_map->SetPageScaleFactorIsOneForView( | 3592 host_zoom_map->SetPageScaleFactorIsOneForView( |
3604 GetRenderProcessHost()->GetID(), GetRenderViewHost()->GetRoutingID(), | 3593 GetRenderProcessHost()->GetID(), GetRenderViewHost()->GetRoutingID(), |
3605 page_scale_factor_is_one_); | 3594 page_scale_factor_is_one_); |
3606 } | 3595 } |
3607 } | 3596 } |
3608 | 3597 |
3609 for (auto& observer : observers_) | 3598 for (auto& observer : observers_) |
3610 observer.OnPageScaleFactorChanged(page_scale_factor); | 3599 observer.OnPageScaleFactorChanged(page_scale_factor); |
3611 } | 3600 } |
3612 | 3601 |
3613 void WebContentsImpl::OnEnumerateDirectory(int request_id, | 3602 void WebContentsImpl::OnEnumerateDirectory(RenderViewHostImpl* source, |
3603 int request_id, | |
3614 const base::FilePath& path) { | 3604 const base::FilePath& path) { |
3615 if (!delegate_) | 3605 if (!delegate_) |
3616 return; | 3606 return; |
3617 | 3607 |
3618 ChildProcessSecurityPolicyImpl* policy = | 3608 ChildProcessSecurityPolicyImpl* policy = |
3619 ChildProcessSecurityPolicyImpl::GetInstance(); | 3609 ChildProcessSecurityPolicyImpl::GetInstance(); |
3620 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path)) | 3610 if (policy->CanReadFile(source->GetProcess()->GetID(), path)) { |
3611 // TODO(nick): |this| param in the call below ought to be a RenderFrameHost. | |
3621 delegate_->EnumerateDirectory(this, request_id, path); | 3612 delegate_->EnumerateDirectory(this, request_id, path); |
3613 } | |
3622 } | 3614 } |
3623 | 3615 |
3624 void WebContentsImpl::OnRegisterProtocolHandler(const std::string& protocol, | 3616 void WebContentsImpl::OnRegisterProtocolHandler(RenderFrameHostImpl* source, |
3617 const std::string& protocol, | |
3625 const GURL& url, | 3618 const GURL& url, |
3626 const base::string16& title, | 3619 const base::string16& title, |
3627 bool user_gesture) { | 3620 bool user_gesture) { |
3628 if (!delegate_) | 3621 if (!delegate_) |
3629 return; | 3622 return; |
3630 | 3623 |
3631 ChildProcessSecurityPolicyImpl* policy = | 3624 ChildProcessSecurityPolicyImpl* policy = |
3632 ChildProcessSecurityPolicyImpl::GetInstance(); | 3625 ChildProcessSecurityPolicyImpl::GetInstance(); |
3633 if (policy->IsPseudoScheme(protocol)) | 3626 if (policy->IsPseudoScheme(protocol)) |
3634 return; | 3627 return; |
3635 | 3628 |
3629 // TODO(nick): |source|? FilterURL? | |
3636 delegate_->RegisterProtocolHandler(this, protocol, url, user_gesture); | 3630 delegate_->RegisterProtocolHandler(this, protocol, url, user_gesture); |
3637 } | 3631 } |
3638 | 3632 |
3639 void WebContentsImpl::OnUnregisterProtocolHandler(const std::string& protocol, | 3633 void WebContentsImpl::OnUnregisterProtocolHandler(RenderFrameHostImpl* source, |
3634 const std::string& protocol, | |
3640 const GURL& url, | 3635 const GURL& url, |
3641 bool user_gesture) { | 3636 bool user_gesture) { |
3642 if (!delegate_) | 3637 if (!delegate_) |
3643 return; | 3638 return; |
3644 | 3639 |
3645 ChildProcessSecurityPolicyImpl* policy = | 3640 ChildProcessSecurityPolicyImpl* policy = |
3646 ChildProcessSecurityPolicyImpl::GetInstance(); | 3641 ChildProcessSecurityPolicyImpl::GetInstance(); |
3647 if (policy->IsPseudoScheme(protocol)) | 3642 if (policy->IsPseudoScheme(protocol)) |
3648 return; | 3643 return; |
3649 | 3644 |
3645 // TODO(nick): |source|? FilterURL? | |
3650 delegate_->UnregisterProtocolHandler(this, protocol, url, user_gesture); | 3646 delegate_->UnregisterProtocolHandler(this, protocol, url, user_gesture); |
3651 } | 3647 } |
3652 | 3648 |
3653 void WebContentsImpl::OnUpdatePageImportanceSignals( | 3649 void WebContentsImpl::OnUpdatePageImportanceSignals( |
3650 RenderFrameHostImpl* source, | |
3654 const PageImportanceSignals& signals) { | 3651 const PageImportanceSignals& signals) { |
3655 page_importance_signals_ = signals; | 3652 page_importance_signals_ = signals; |
3656 } | 3653 } |
3657 | 3654 |
3658 void WebContentsImpl::OnFindReply(int request_id, | 3655 void WebContentsImpl::OnFindReply(RenderFrameHostImpl* source, |
3656 int request_id, | |
3659 int number_of_matches, | 3657 int number_of_matches, |
3660 const gfx::Rect& selection_rect, | 3658 const gfx::Rect& selection_rect, |
3661 int active_match_ordinal, | 3659 int active_match_ordinal, |
3662 bool final_update) { | 3660 bool final_update) { |
3663 // Forward the find reply to the FindRequestManager, along with the | 3661 // Forward the find reply to the FindRequestManager, along with the |
3664 // RenderFrameHost associated with the frame that the reply came from. | 3662 // RenderFrameHost associated with the frame that the reply came from. |
3665 GetOrCreateFindRequestManager()->OnFindReply(render_frame_message_source_, | 3663 GetOrCreateFindRequestManager()->OnFindReply( |
3666 request_id, | 3664 source, request_id, number_of_matches, selection_rect, |
3667 number_of_matches, | 3665 active_match_ordinal, final_update); |
3668 selection_rect, | |
3669 active_match_ordinal, | |
3670 final_update); | |
3671 } | 3666 } |
3672 | 3667 |
3673 #if defined(OS_ANDROID) | 3668 #if defined(OS_ANDROID) |
3674 void WebContentsImpl::OnFindMatchRectsReply( | 3669 void WebContentsImpl::OnFindMatchRectsReply( |
3670 RenderFrameHostImpl* source, | |
3675 int version, | 3671 int version, |
3676 const std::vector<gfx::RectF>& rects, | 3672 const std::vector<gfx::RectF>& rects, |
3677 const gfx::RectF& active_rect) { | 3673 const gfx::RectF& active_rect) { |
3678 GetOrCreateFindRequestManager()->OnFindMatchRectsReply( | 3674 GetOrCreateFindRequestManager()->OnFindMatchRectsReply(source, version, rects, |
3679 render_frame_message_source_, version, rects, active_rect); | 3675 active_rect); |
3680 } | 3676 } |
3681 | 3677 |
3682 void WebContentsImpl::OnGetNearestFindResultReply(int request_id, | 3678 void WebContentsImpl::OnGetNearestFindResultReply(RenderFrameHostImpl* source, |
3679 int request_id, | |
3683 float distance) { | 3680 float distance) { |
3684 GetOrCreateFindRequestManager()->OnGetNearestFindResultReply( | 3681 GetOrCreateFindRequestManager()->OnGetNearestFindResultReply( |
3685 render_frame_message_source_, request_id, distance); | 3682 source, request_id, distance); |
3686 } | 3683 } |
3687 | 3684 |
3688 void WebContentsImpl::OnOpenDateTimeDialog( | 3685 void WebContentsImpl::OnOpenDateTimeDialog( |
3686 RenderViewHostImpl* source, | |
3689 const ViewHostMsg_DateTimeDialogValue_Params& value) { | 3687 const ViewHostMsg_DateTimeDialogValue_Params& value) { |
3690 date_time_chooser_->ShowDialog(GetTopLevelNativeWindow(), | 3688 date_time_chooser_->ShowDialog( |
3691 GetRenderViewHost(), | 3689 GetTopLevelNativeWindow(), source, value.dialog_type, value.dialog_value, |
3692 value.dialog_type, | 3690 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 } | 3691 } |
3699 #endif | 3692 #endif |
3700 | 3693 |
3701 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string) { | 3694 void WebContentsImpl::OnDomOperationResponse(RenderFrameHostImpl* source, |
3695 const std::string& json_string) { | |
3702 std::string json = json_string; | 3696 std::string json = json_string; |
3703 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, | 3697 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, |
3704 Source<WebContents>(this), | 3698 Source<WebContents>(this), |
3705 Details<std::string>(&json)); | 3699 Details<std::string>(&json)); |
3706 } | 3700 } |
3707 | 3701 |
3708 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, | 3702 void WebContentsImpl::OnAppCacheAccessed(RenderViewHostImpl* source, |
3703 const GURL& manifest_url, | |
3709 bool blocked_by_policy) { | 3704 bool blocked_by_policy) { |
3705 // TODO(nick): |source|? FilterURL? | |
3710 // Notify observers about navigation. | 3706 // Notify observers about navigation. |
3711 for (auto& observer : observers_) | 3707 for (auto& observer : observers_) |
3712 observer.AppCacheAccessed(manifest_url, blocked_by_policy); | 3708 observer.AppCacheAccessed(manifest_url, blocked_by_policy); |
3713 } | 3709 } |
3714 | 3710 |
3715 void WebContentsImpl::OnOpenColorChooser( | 3711 void WebContentsImpl::OnOpenColorChooser( |
3712 RenderFrameHostImpl* source, | |
3716 int color_chooser_id, | 3713 int color_chooser_id, |
3717 SkColor color, | 3714 SkColor color, |
3718 const std::vector<ColorSuggestion>& suggestions) { | 3715 const std::vector<ColorSuggestion>& suggestions) { |
3719 if (!HasValidFrameSource()) | |
3720 return; | |
3721 | |
3722 ColorChooser* new_color_chooser = delegate_ ? | 3716 ColorChooser* new_color_chooser = delegate_ ? |
3723 delegate_->OpenColorChooser(this, color, suggestions) : | 3717 delegate_->OpenColorChooser(this, color, suggestions) : |
3724 NULL; | 3718 NULL; |
3725 if (!new_color_chooser) | 3719 if (!new_color_chooser) |
3726 return; | 3720 return; |
3727 if (color_chooser_info_.get()) | 3721 if (color_chooser_info_.get()) |
3728 color_chooser_info_->chooser->End(); | 3722 color_chooser_info_->chooser->End(); |
3729 | 3723 |
3730 color_chooser_info_.reset(new ColorChooserInfo( | 3724 color_chooser_info_.reset(new ColorChooserInfo( |
3731 render_frame_message_source_->GetProcess()->GetID(), | 3725 source->GetProcess()->GetID(), source->GetRoutingID(), new_color_chooser, |
3732 render_frame_message_source_->GetRoutingID(), | |
3733 new_color_chooser, | |
3734 color_chooser_id)); | 3726 color_chooser_id)); |
3735 } | 3727 } |
3736 | 3728 |
3737 void WebContentsImpl::OnEndColorChooser(int color_chooser_id) { | 3729 void WebContentsImpl::OnEndColorChooser(RenderFrameHostImpl* source, |
3730 int color_chooser_id) { | |
3738 if (color_chooser_info_ && | 3731 if (color_chooser_info_ && |
3739 color_chooser_id == color_chooser_info_->identifier) | 3732 color_chooser_info_->Matches(source, color_chooser_id)) |
3740 color_chooser_info_->chooser->End(); | 3733 color_chooser_info_->chooser->End(); |
3741 } | 3734 } |
3742 | 3735 |
3743 void WebContentsImpl::OnSetSelectedColorInColorChooser(int color_chooser_id, | 3736 void WebContentsImpl::OnSetSelectedColorInColorChooser( |
3744 SkColor color) { | 3737 RenderFrameHostImpl* source, |
3738 int color_chooser_id, | |
3739 SkColor color) { | |
3745 if (color_chooser_info_ && | 3740 if (color_chooser_info_ && |
3746 color_chooser_id == color_chooser_info_->identifier) | 3741 color_chooser_info_->Matches(source, color_chooser_id)) |
3747 color_chooser_info_->chooser->SetSelectedColor(color); | 3742 color_chooser_info_->chooser->SetSelectedColor(color); |
3748 } | 3743 } |
3749 | 3744 |
3750 // This exists for render views that don't have a WebUI, but do have WebUI | 3745 // This exists for render views that don't have a WebUI, but do have WebUI |
3751 // bindings enabled. | 3746 // bindings enabled. |
3752 void WebContentsImpl::OnWebUISend(const GURL& source_url, | 3747 void WebContentsImpl::OnWebUISend(RenderViewHostImpl* source, |
3748 const GURL& source_url, | |
3753 const std::string& name, | 3749 const std::string& name, |
3754 const base::ListValue& args) { | 3750 const base::ListValue& args) { |
3751 // TODO(nick): |source|? FilterURL? | |
3755 if (delegate_) | 3752 if (delegate_) |
3756 delegate_->WebUISend(this, source_url, name, args); | 3753 delegate_->WebUISend(this, source_url, name, args); |
3757 } | 3754 } |
3758 | 3755 |
3759 #if BUILDFLAG(ENABLE_PLUGINS) | 3756 #if BUILDFLAG(ENABLE_PLUGINS) |
3760 void WebContentsImpl::OnPepperInstanceCreated(int32_t pp_instance) { | 3757 void WebContentsImpl::OnPepperInstanceCreated(RenderFrameHostImpl* source, |
3758 int32_t pp_instance) { | |
3761 for (auto& observer : observers_) | 3759 for (auto& observer : observers_) |
3762 observer.PepperInstanceCreated(); | 3760 observer.PepperInstanceCreated(); |
3763 pepper_playback_observer_->PepperInstanceCreated( | 3761 pepper_playback_observer_->PepperInstanceCreated(source, pp_instance); |
3764 render_frame_message_source_, pp_instance); | |
3765 } | 3762 } |
3766 | 3763 |
3767 void WebContentsImpl::OnPepperInstanceDeleted(int32_t pp_instance) { | 3764 void WebContentsImpl::OnPepperInstanceDeleted(RenderFrameHostImpl* source, |
3765 int32_t pp_instance) { | |
3768 for (auto& observer : observers_) | 3766 for (auto& observer : observers_) |
3769 observer.PepperInstanceDeleted(); | 3767 observer.PepperInstanceDeleted(); |
3770 pepper_playback_observer_->PepperInstanceDeleted( | 3768 pepper_playback_observer_->PepperInstanceDeleted(source, pp_instance); |
3771 render_frame_message_source_, pp_instance); | |
3772 } | 3769 } |
3773 | 3770 |
3774 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, | 3771 void WebContentsImpl::OnPepperPluginHung(RenderFrameHostImpl* source, |
3772 int plugin_child_id, | |
3775 const base::FilePath& path, | 3773 const base::FilePath& path, |
3776 bool is_hung) { | 3774 bool is_hung) { |
3777 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); | 3775 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); |
3778 | 3776 |
3779 for (auto& observer : observers_) | 3777 for (auto& observer : observers_) |
3780 observer.PluginHungStatusChanged(plugin_child_id, path, is_hung); | 3778 observer.PluginHungStatusChanged(plugin_child_id, path, is_hung); |
3781 } | 3779 } |
3782 | 3780 |
3783 void WebContentsImpl::OnPepperStartsPlayback(int32_t pp_instance) { | 3781 void WebContentsImpl::OnPepperStartsPlayback(RenderFrameHostImpl* source, |
3784 pepper_playback_observer_->PepperStartsPlayback( | 3782 int32_t pp_instance) { |
3785 render_frame_message_source_, pp_instance); | 3783 pepper_playback_observer_->PepperStartsPlayback(source, pp_instance); |
3786 } | 3784 } |
3787 | 3785 |
3788 void WebContentsImpl::OnPepperStopsPlayback(int32_t pp_instance) { | 3786 void WebContentsImpl::OnPepperStopsPlayback(RenderFrameHostImpl* source, |
3789 pepper_playback_observer_->PepperStopsPlayback( | 3787 int32_t pp_instance) { |
3790 render_frame_message_source_, pp_instance); | 3788 pepper_playback_observer_->PepperStopsPlayback(source, pp_instance); |
3791 } | 3789 } |
3792 | 3790 |
3793 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, | 3791 void WebContentsImpl::OnPluginCrashed(RenderFrameHostImpl* source, |
3792 const base::FilePath& plugin_path, | |
3794 base::ProcessId plugin_pid) { | 3793 base::ProcessId plugin_pid) { |
3795 for (auto& observer : observers_) | 3794 for (auto& observer : observers_) |
3796 observer.PluginCrashed(plugin_path, plugin_pid); | 3795 observer.PluginCrashed(plugin_path, plugin_pid); |
3797 } | 3796 } |
3798 | 3797 |
3799 void WebContentsImpl::OnRequestPpapiBrokerPermission( | 3798 void WebContentsImpl::OnRequestPpapiBrokerPermission( |
3800 int routing_id, | 3799 RenderViewHostImpl* source, |
3800 int ppb_broker_route_id, | |
3801 const GURL& url, | 3801 const GURL& url, |
3802 const base::FilePath& plugin_path) { | 3802 const base::FilePath& plugin_path) { |
3803 base::Callback<void(bool)> permission_result_callback = base::Bind( | |
3804 &WebContentsImpl::SendPpapiBrokerPermissionResult, base::Unretained(this), | |
3805 source->GetProcess()->GetID(), ppb_broker_route_id); | |
3803 if (!delegate_) { | 3806 if (!delegate_) { |
3804 OnPpapiBrokerPermissionResult(routing_id, false); | 3807 permission_result_callback.Run(false); |
3805 return; | 3808 return; |
3806 } | 3809 } |
3807 | 3810 |
3808 if (!delegate_->RequestPpapiBrokerPermission( | 3811 if (!delegate_->RequestPpapiBrokerPermission(this, url, plugin_path, |
3809 this, url, plugin_path, | 3812 permission_result_callback)) { |
3810 base::Bind(&WebContentsImpl::OnPpapiBrokerPermissionResult, | |
3811 base::Unretained(this), routing_id))) { | |
3812 NOTIMPLEMENTED(); | 3813 NOTIMPLEMENTED(); |
3813 OnPpapiBrokerPermissionResult(routing_id, false); | 3814 permission_result_callback.Run(false); |
3814 } | 3815 } |
3815 } | 3816 } |
3816 | 3817 |
3817 void WebContentsImpl::OnPpapiBrokerPermissionResult(int routing_id, | 3818 void WebContentsImpl::SendPpapiBrokerPermissionResult(int process_id, |
3818 bool result) { | 3819 int ppb_broker_route_id, |
3819 Send(new ViewMsg_PpapiBrokerPermissionResult(routing_id, result)); | 3820 bool result) { |
3821 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); | |
3822 if (rph) { | |
3823 // Note that this is ViewMsg_, but it's actually sent to a PPB_Broker_Impl. | |
3824 rph->Send( | |
3825 new ViewMsg_PpapiBrokerPermissionResult(ppb_broker_route_id, result)); | |
Charlie Reis
2016/12/13 19:03:56
Nice. Let's include a TODO for your idea to move
ncarter (slow)
2016/12/14 18:36:47
The CL to fix this is already complete; I'll send
| |
3826 } | |
3820 } | 3827 } |
3821 | 3828 |
3822 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, | 3829 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, |
3823 const IPC::Message& message) { | 3830 const IPC::Message& message) { |
3824 CHECK(!browser_plugin_embedder_.get()); | 3831 CHECK(!browser_plugin_embedder_.get()); |
3825 CreateBrowserPluginEmbedderIfNecessary(); | 3832 CreateBrowserPluginEmbedderIfNecessary(); |
3826 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); | 3833 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); |
3827 } | 3834 } |
3828 #endif // BUILDFLAG(ENABLE_PLUGINS) | 3835 #endif // BUILDFLAG(ENABLE_PLUGINS) |
3829 | 3836 |
3830 void WebContentsImpl::OnUpdateFaviconURL( | 3837 void WebContentsImpl::OnUpdateFaviconURL( |
3838 RenderViewHostImpl* source, | |
3831 const std::vector<FaviconURL>& candidates) { | 3839 const std::vector<FaviconURL>& candidates) { |
3832 // We get updated favicon URLs after the page stops loading. If a cross-site | 3840 // 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 | 3841 // navigation occurs while a page is still loading, the initial page |
3834 // may stop loading and send us updated favicon URLs after the navigation | 3842 // may stop loading and send us updated favicon URLs after the navigation |
3835 // for the new page has committed. | 3843 // for the new page has committed. |
3836 RenderViewHostImpl* rvhi = | 3844 if (!source->is_active()) |
3837 static_cast<RenderViewHostImpl*>(render_view_message_source_); | |
3838 if (!rvhi->is_active()) | |
3839 return; | 3845 return; |
3840 | 3846 |
3841 for (auto& observer : observers_) | 3847 for (auto& observer : observers_) |
3842 observer.DidUpdateFaviconURL(candidates); | 3848 observer.DidUpdateFaviconURL(candidates); |
3843 } | 3849 } |
3844 | 3850 |
3845 void WebContentsImpl::OnPasswordInputShownOnHttp() { | 3851 void WebContentsImpl::OnPasswordInputShownOnHttp() { |
3846 controller_.ssl_manager()->DidShowPasswordInputOnHttp(); | 3852 controller_.ssl_manager()->DidShowPasswordInputOnHttp(); |
3847 } | 3853 } |
3848 | 3854 |
3849 void WebContentsImpl::OnAllPasswordInputsHiddenOnHttp() { | 3855 void WebContentsImpl::OnAllPasswordInputsHiddenOnHttp() { |
3850 controller_.ssl_manager()->DidHideAllPasswordInputsOnHttp(); | 3856 controller_.ssl_manager()->DidHideAllPasswordInputsOnHttp(); |
3851 } | 3857 } |
3852 | 3858 |
3853 void WebContentsImpl::OnCreditCardInputShownOnHttp() { | 3859 void WebContentsImpl::OnCreditCardInputShownOnHttp() { |
3854 controller_.ssl_manager()->DidShowCreditCardInputOnHttp(); | 3860 controller_.ssl_manager()->DidShowCreditCardInputOnHttp(); |
3855 } | 3861 } |
3856 | 3862 |
3857 void WebContentsImpl::SetIsOverlayContent(bool is_overlay_content) { | 3863 void WebContentsImpl::SetIsOverlayContent(bool is_overlay_content) { |
3858 is_overlay_content_ = is_overlay_content; | 3864 is_overlay_content_ = is_overlay_content; |
3859 } | 3865 } |
3860 | 3866 |
3861 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { | 3867 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint(RenderViewHostImpl* source) { |
3862 for (auto& observer : observers_) | 3868 for (auto& observer : observers_) |
3863 observer.DidFirstVisuallyNonEmptyPaint(); | 3869 observer.DidFirstVisuallyNonEmptyPaint(); |
3864 | 3870 |
3865 did_first_visually_non_empty_paint_ = true; | 3871 did_first_visually_non_empty_paint_ = true; |
3866 | 3872 |
3867 if (theme_color_ != last_sent_theme_color_) { | 3873 if (theme_color_ != last_sent_theme_color_) { |
3868 // Theme color should have updated by now if there was one. | 3874 // Theme color should have updated by now if there was one. |
3869 for (auto& observer : observers_) | 3875 for (auto& observer : observers_) |
3870 observer.DidChangeThemeColor(theme_color_); | 3876 observer.DidChangeThemeColor(theme_color_); |
3871 last_sent_theme_color_ = theme_color_; | 3877 last_sent_theme_color_ = theme_color_; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4040 Source<WebContents>(this), | 4046 Source<WebContents>(this), |
4041 NotificationService::NoDetails()); | 4047 NotificationService::NoDetails()); |
4042 } | 4048 } |
4043 | 4049 |
4044 void WebContentsImpl::NotifyNavigationEntryCommitted( | 4050 void WebContentsImpl::NotifyNavigationEntryCommitted( |
4045 const LoadCommittedDetails& load_details) { | 4051 const LoadCommittedDetails& load_details) { |
4046 for (auto& observer : observers_) | 4052 for (auto& observer : observers_) |
4047 observer.NavigationEntryCommitted(load_details); | 4053 observer.NavigationEntryCommitted(load_details); |
4048 } | 4054 } |
4049 | 4055 |
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( | 4056 void WebContentsImpl::OnAssociatedInterfaceRequest( |
4056 RenderFrameHost* render_frame_host, | 4057 RenderFrameHost* render_frame_host, |
4057 const std::string& interface_name, | 4058 const std::string& interface_name, |
4058 mojo::ScopedInterfaceEndpointHandle handle) { | 4059 mojo::ScopedInterfaceEndpointHandle handle) { |
4059 auto it = binding_sets_.find(interface_name); | 4060 auto it = binding_sets_.find(interface_name); |
4060 if (it != binding_sets_.end()) | 4061 if (it != binding_sets_.end()) |
4061 it->second->OnRequestForFrame(render_frame_host, std::move(handle)); | 4062 it->second->OnRequestForFrame(render_frame_host, std::move(handle)); |
4062 } | 4063 } |
4063 | 4064 |
4064 const GURL& WebContentsImpl::GetMainFrameLastCommittedURL() const { | 4065 const GURL& WebContentsImpl::GetMainFrameLastCommittedURL() const { |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5321 GetMainFrame()->AddMessageToConsole( | 5322 GetMainFrame()->AddMessageToConsole( |
5322 content::CONSOLE_MESSAGE_LEVEL_WARNING, | 5323 content::CONSOLE_MESSAGE_LEVEL_WARNING, |
5323 base::StringPrintf("This site does not have a valid SSL " | 5324 base::StringPrintf("This site does not have a valid SSL " |
5324 "certificate! Without SSL, your site's and " | 5325 "certificate! Without SSL, your site's and " |
5325 "visitors' data is vulnerable to theft and " | 5326 "visitors' data is vulnerable to theft and " |
5326 "tampering. Get a valid SSL certificate before" | 5327 "tampering. Get a valid SSL certificate before" |
5327 " releasing your website to the public.")); | 5328 " releasing your website to the public.")); |
5328 } | 5329 } |
5329 | 5330 |
5330 } // namespace content | 5331 } // namespace content |
OLD | NEW |