Chromium Code Reviews| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 #include "content/browser/find_request_manager.h" | 50 #include "content/browser/find_request_manager.h" |
| 51 #include "content/browser/frame_host/cross_process_frame_connector.h" | 51 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 52 #include "content/browser/frame_host/frame_tree_node.h" | 52 #include "content/browser/frame_host/frame_tree_node.h" |
| 53 #include "content/browser/frame_host/interstitial_page_impl.h" | 53 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 54 #include "content/browser/frame_host/navigation_entry_impl.h" | 54 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 55 #include "content/browser/frame_host/navigation_handle_impl.h" | 55 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 56 #include "content/browser/frame_host/navigator_impl.h" | 56 #include "content/browser/frame_host/navigator_impl.h" |
| 57 #include "content/browser/frame_host/render_frame_host_impl.h" | 57 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 58 #include "content/browser/frame_host/render_frame_proxy_host.h" | 58 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 59 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 59 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 60 #include "content/browser/host_zoom_map_impl.h" | |
| 61 #include "content/browser/host_zoom_map_observer.h" | |
| 62 #include "content/browser/loader/loader_io_thread_notifier.h" | 60 #include "content/browser/loader/loader_io_thread_notifier.h" |
| 63 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 61 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 64 #include "content/browser/manifest/manifest_manager_host.h" | 62 #include "content/browser/manifest/manifest_manager_host.h" |
| 65 #include "content/browser/media/audio_stream_monitor.h" | 63 #include "content/browser/media/audio_stream_monitor.h" |
| 66 #include "content/browser/media/capture/web_contents_audio_muter.h" | 64 #include "content/browser/media/capture/web_contents_audio_muter.h" |
| 67 #include "content/browser/media/media_web_contents_observer.h" | 65 #include "content/browser/media/media_web_contents_observer.h" |
| 68 #include "content/browser/media/session/media_session_impl.h" | 66 #include "content/browser/media/session/media_session_impl.h" |
| 69 #include "content/browser/plugin_content_origin_whitelist.h" | 67 #include "content/browser/plugin_content_origin_whitelist.h" |
| 70 #include "content/browser/renderer_host/render_process_host_impl.h" | 68 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 71 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 69 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 #include "content/browser/renderer_host/dip_util.h" | 143 #include "content/browser/renderer_host/dip_util.h" |
| 146 #include "ui/gfx/geometry/dip_util.h" | 144 #include "ui/gfx/geometry/dip_util.h" |
| 147 #endif | 145 #endif |
| 148 | 146 |
| 149 #if defined(OS_ANDROID) | 147 #if defined(OS_ANDROID) |
| 150 #include "content/browser/android/content_video_view.h" | 148 #include "content/browser/android/content_video_view.h" |
| 151 #include "content/browser/android/date_time_chooser_android.h" | 149 #include "content/browser/android/date_time_chooser_android.h" |
| 152 #include "content/browser/android/java_interfaces_impl.h" | 150 #include "content/browser/android/java_interfaces_impl.h" |
| 153 #include "content/browser/media/android/media_web_contents_observer_android.h" | 151 #include "content/browser/media/android/media_web_contents_observer_android.h" |
| 154 #include "content/browser/web_contents/web_contents_android.h" | 152 #include "content/browser/web_contents/web_contents_android.h" |
| 153 #else // OS_ANDROID | |
|
wjmaclean
2017/05/12 19:27:50
? ... Isn't this !OS_ANDROID ?
Kevin McNee
2017/05/12 20:28:47
Yeah, I wasn't sure which to use for these--the or
Kevin McNee
2017/05/15 20:02:10
Done.
| |
| 154 #include "content/browser/host_zoom_map_impl.h" | |
| 155 #include "content/browser/host_zoom_map_observer.h" | |
| 155 #endif // OS_ANDROID | 156 #endif // OS_ANDROID |
| 156 | 157 |
| 157 #if defined(OS_MACOSX) | 158 #if defined(OS_MACOSX) |
| 158 #include "base/mac/foundation_util.h" | 159 #include "base/mac/foundation_util.h" |
| 159 #endif | 160 #endif |
| 160 | 161 |
| 161 #if defined(USE_AURA) | 162 #if defined(USE_AURA) |
| 162 #include "content/public/common/service_manager_connection.h" | 163 #include "content/public/common/service_manager_connection.h" |
| 163 #endif | 164 #endif |
| 164 | 165 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 fullscreen_widget_had_focus_at_shutdown_(false), | 502 fullscreen_widget_had_focus_at_shutdown_(false), |
| 502 is_subframe_(false), | 503 is_subframe_(false), |
| 503 force_disable_overscroll_content_(false), | 504 force_disable_overscroll_content_(false), |
| 504 last_dialog_suppressed_(false), | 505 last_dialog_suppressed_(false), |
| 505 geolocation_service_context_(new device::GeolocationServiceContext()), | 506 geolocation_service_context_(new device::GeolocationServiceContext()), |
| 506 accessibility_mode_( | 507 accessibility_mode_( |
| 507 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), | 508 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), |
| 508 audio_stream_monitor_(this), | 509 audio_stream_monitor_(this), |
| 509 bluetooth_connected_device_count_(0), | 510 bluetooth_connected_device_count_(0), |
| 510 virtual_keyboard_requested_(false), | 511 virtual_keyboard_requested_(false), |
| 512 #if !defined(OS_ANDROID) | |
| 511 page_scale_factor_is_one_(true), | 513 page_scale_factor_is_one_(true), |
| 514 #endif // !defined(OS_ANDROID) | |
| 512 mouse_lock_widget_(nullptr), | 515 mouse_lock_widget_(nullptr), |
| 513 is_overlay_content_(false), | 516 is_overlay_content_(false), |
| 514 loading_weak_factory_(this), | 517 loading_weak_factory_(this), |
| 515 weak_factory_(this) { | 518 weak_factory_(this) { |
| 516 frame_tree_.SetFrameRemoveListener( | 519 frame_tree_.SetFrameRemoveListener( |
| 517 base::Bind(&WebContentsImpl::OnFrameRemoved, | 520 base::Bind(&WebContentsImpl::OnFrameRemoved, |
| 518 base::Unretained(this))); | 521 base::Unretained(this))); |
| 519 #if defined(OS_ANDROID) | 522 #if defined(OS_ANDROID) |
| 520 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); | 523 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); |
| 521 #else | 524 #else |
| 522 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); | 525 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); |
| 523 #endif | 526 #endif |
| 524 #if BUILDFLAG(ENABLE_PLUGINS) | 527 #if BUILDFLAG(ENABLE_PLUGINS) |
| 525 pepper_playback_observer_.reset(new PepperPlaybackObserver(this)); | 528 pepper_playback_observer_.reset(new PepperPlaybackObserver(this)); |
| 526 #endif | 529 #endif |
| 527 | 530 |
| 528 loader_io_thread_notifier_.reset(new LoaderIOThreadNotifier(this)); | 531 loader_io_thread_notifier_.reset(new LoaderIOThreadNotifier(this)); |
| 532 #if !defined(OS_ANDROID) | |
| 529 host_zoom_map_observer_.reset(new HostZoomMapObserver(this)); | 533 host_zoom_map_observer_.reset(new HostZoomMapObserver(this)); |
| 534 #endif // !defined(OS_ANDROID) | |
| 530 } | 535 } |
| 531 | 536 |
| 532 WebContentsImpl::~WebContentsImpl() { | 537 WebContentsImpl::~WebContentsImpl() { |
| 533 is_being_destroyed_ = true; | 538 is_being_destroyed_ = true; |
| 534 | 539 |
| 535 // A WebContents should never be deleted while it is notifying observers, | 540 // A WebContents should never be deleted while it is notifying observers, |
| 536 // since this will lead to a use-after-free as it continues to notfiy later | 541 // since this will lead to a use-after-free as it continues to notfiy later |
| 537 // observers. | 542 // observers. |
| 538 CHECK(!is_notifying_observers_); | 543 CHECK(!is_notifying_observers_); |
| 539 | 544 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1049 // them into a single tree and call |callback| with that result, then | 1054 // them into a single tree and call |callback| with that result, then |
| 1050 // delete |combiner|. | 1055 // delete |combiner|. |
| 1051 AXTreeSnapshotCombiner* combiner = new AXTreeSnapshotCombiner(callback); | 1056 AXTreeSnapshotCombiner* combiner = new AXTreeSnapshotCombiner(callback); |
| 1052 for (FrameTreeNode* frame_tree_node : frame_tree_.Nodes()) { | 1057 for (FrameTreeNode* frame_tree_node : frame_tree_.Nodes()) { |
| 1053 bool is_root = frame_tree_node->parent() == nullptr; | 1058 bool is_root = frame_tree_node->parent() == nullptr; |
| 1054 frame_tree_node->current_frame_host()->RequestAXTreeSnapshot( | 1059 frame_tree_node->current_frame_host()->RequestAXTreeSnapshot( |
| 1055 combiner->AddFrame(is_root)); | 1060 combiner->AddFrame(is_root)); |
| 1056 } | 1061 } |
| 1057 } | 1062 } |
| 1058 | 1063 |
| 1064 #if !defined(OS_ANDROID) | |
| 1059 void WebContentsImpl::SetTemporaryZoomLevel(double level, | 1065 void WebContentsImpl::SetTemporaryZoomLevel(double level, |
| 1060 bool temporary_zoom_enabled) { | 1066 bool temporary_zoom_enabled) { |
| 1061 SendPageMessage(new PageMsg_SetZoomLevel( | 1067 SendPageMessage(new PageMsg_SetZoomLevel( |
| 1062 MSG_ROUTING_NONE, | 1068 MSG_ROUTING_NONE, |
| 1063 temporary_zoom_enabled ? PageMsg_SetZoomLevel_Command::SET_TEMPORARY | 1069 temporary_zoom_enabled ? PageMsg_SetZoomLevel_Command::SET_TEMPORARY |
| 1064 : PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY, | 1070 : PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY, |
| 1065 level)); | 1071 level)); |
| 1066 } | 1072 } |
| 1067 | 1073 |
| 1068 void WebContentsImpl::UpdateZoom(double level) { | 1074 void WebContentsImpl::UpdateZoom(double level) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1081 return; | 1087 return; |
| 1082 | 1088 |
| 1083 GURL url = HostZoomMap::GetURLFromEntry(entry); | 1089 GURL url = HostZoomMap::GetURLFromEntry(entry); |
| 1084 if (host != net::GetHostOrSpecFromURL(url) || | 1090 if (host != net::GetHostOrSpecFromURL(url) || |
| 1085 (!scheme.empty() && !url.SchemeIs(scheme))) { | 1091 (!scheme.empty() && !url.SchemeIs(scheme))) { |
| 1086 return; | 1092 return; |
| 1087 } | 1093 } |
| 1088 | 1094 |
| 1089 UpdateZoom(level); | 1095 UpdateZoom(level); |
| 1090 } | 1096 } |
| 1097 #endif // !defined(OS_ANDROID) | |
| 1091 | 1098 |
| 1092 base::Closure WebContentsImpl::AddBindingSet( | 1099 base::Closure WebContentsImpl::AddBindingSet( |
| 1093 const std::string& interface_name, | 1100 const std::string& interface_name, |
| 1094 WebContentsBindingSet* binding_set) { | 1101 WebContentsBindingSet* binding_set) { |
| 1095 auto result = | 1102 auto result = |
| 1096 binding_sets_.insert(std::make_pair(interface_name, binding_set)); | 1103 binding_sets_.insert(std::make_pair(interface_name, binding_set)); |
| 1097 DCHECK(result.second); | 1104 DCHECK(result.second); |
| 1098 return base::Bind(&WebContentsImpl::RemoveBindingSet, | 1105 return base::Bind(&WebContentsImpl::RemoveBindingSet, |
| 1099 weak_factory_.GetWeakPtr(), interface_name); | 1106 weak_factory_.GetWeakPtr(), interface_name); |
| 1100 } | 1107 } |
| (...skipping 2704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3805 | 3812 |
| 3806 void WebContentsImpl::OnUpdateZoomLimits(RenderViewHostImpl* source, | 3813 void WebContentsImpl::OnUpdateZoomLimits(RenderViewHostImpl* source, |
| 3807 int minimum_percent, | 3814 int minimum_percent, |
| 3808 int maximum_percent) { | 3815 int maximum_percent) { |
| 3809 minimum_zoom_percent_ = minimum_percent; | 3816 minimum_zoom_percent_ = minimum_percent; |
| 3810 maximum_zoom_percent_ = maximum_percent; | 3817 maximum_zoom_percent_ = maximum_percent; |
| 3811 } | 3818 } |
| 3812 | 3819 |
| 3813 void WebContentsImpl::OnPageScaleFactorChanged(RenderViewHostImpl* source, | 3820 void WebContentsImpl::OnPageScaleFactorChanged(RenderViewHostImpl* source, |
| 3814 float page_scale_factor) { | 3821 float page_scale_factor) { |
| 3822 #if !defined(OS_ANDROID) | |
| 3823 // While page scale factor is used on mobile, this PageScaleFactorIsOne logic | |
| 3824 // is only needed on desktop. | |
| 3815 bool is_one = page_scale_factor == 1.f; | 3825 bool is_one = page_scale_factor == 1.f; |
| 3816 if (is_one != page_scale_factor_is_one_) { | 3826 if (is_one != page_scale_factor_is_one_) { |
| 3817 page_scale_factor_is_one_ = is_one; | 3827 page_scale_factor_is_one_ = is_one; |
| 3818 | 3828 |
| 3819 HostZoomMapImpl* host_zoom_map = | 3829 HostZoomMapImpl* host_zoom_map = |
| 3820 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); | 3830 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); |
| 3821 | 3831 |
| 3822 if (host_zoom_map) { | 3832 if (host_zoom_map) { |
| 3823 host_zoom_map->SetPageScaleFactorIsOneForView( | 3833 host_zoom_map->SetPageScaleFactorIsOneForView( |
| 3824 source->GetProcess()->GetID(), source->GetRoutingID(), | 3834 source->GetProcess()->GetID(), source->GetRoutingID(), |
| 3825 page_scale_factor_is_one_); | 3835 page_scale_factor_is_one_); |
| 3826 } | 3836 } |
| 3827 } | 3837 } |
| 3838 #endif // !defined(OS_ANDROID) | |
| 3828 | 3839 |
| 3829 for (auto& observer : observers_) | 3840 for (auto& observer : observers_) |
| 3830 observer.OnPageScaleFactorChanged(page_scale_factor); | 3841 observer.OnPageScaleFactorChanged(page_scale_factor); |
| 3831 } | 3842 } |
| 3832 | 3843 |
| 3833 void WebContentsImpl::OnEnumerateDirectory(RenderViewHostImpl* source, | 3844 void WebContentsImpl::OnEnumerateDirectory(RenderViewHostImpl* source, |
| 3834 int request_id, | 3845 int request_id, |
| 3835 const base::FilePath& path) { | 3846 const base::FilePath& path) { |
| 3836 if (!delegate_) | 3847 if (!delegate_) |
| 3837 return; | 3848 return; |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4414 void WebContentsImpl::RunFileChooser(RenderFrameHost* render_frame_host, | 4425 void WebContentsImpl::RunFileChooser(RenderFrameHost* render_frame_host, |
| 4415 const FileChooserParams& params) { | 4426 const FileChooserParams& params) { |
| 4416 if (delegate_) | 4427 if (delegate_) |
| 4417 delegate_->RunFileChooser(render_frame_host, params); | 4428 delegate_->RunFileChooser(render_frame_host, params); |
| 4418 } | 4429 } |
| 4419 | 4430 |
| 4420 WebContents* WebContentsImpl::GetAsWebContents() { | 4431 WebContents* WebContentsImpl::GetAsWebContents() { |
| 4421 return this; | 4432 return this; |
| 4422 } | 4433 } |
| 4423 | 4434 |
| 4435 #if !defined(OS_ANDROID) | |
| 4424 double WebContentsImpl::GetPendingPageZoomLevel() { | 4436 double WebContentsImpl::GetPendingPageZoomLevel() { |
| 4425 NavigationEntry* pending_entry = GetController().GetPendingEntry(); | 4437 NavigationEntry* pending_entry = GetController().GetPendingEntry(); |
| 4426 if (!pending_entry) | 4438 if (!pending_entry) |
| 4427 return HostZoomMap::GetZoomLevel(this); | 4439 return HostZoomMap::GetZoomLevel(this); |
| 4428 | 4440 |
| 4429 GURL url = pending_entry->GetURL(); | 4441 GURL url = pending_entry->GetURL(); |
| 4430 return HostZoomMap::GetForWebContents(this)->GetZoomLevelForHostAndScheme( | 4442 return HostZoomMap::GetForWebContents(this)->GetZoomLevelForHostAndScheme( |
| 4431 url.scheme(), net::GetHostOrSpecFromURL(url)); | 4443 url.scheme(), net::GetHostOrSpecFromURL(url)); |
| 4432 } | 4444 } |
| 4445 #endif // !defined(OS_ANDROID) | |
| 4433 | 4446 |
| 4434 bool WebContentsImpl::HideDownloadUI() const { | 4447 bool WebContentsImpl::HideDownloadUI() const { |
| 4435 return is_overlay_content_; | 4448 return is_overlay_content_; |
| 4436 } | 4449 } |
| 4437 | 4450 |
| 4438 bool WebContentsImpl::HasPersistentVideo() const { | 4451 bool WebContentsImpl::HasPersistentVideo() const { |
| 4439 return has_persistent_video_; | 4452 return has_persistent_video_; |
| 4440 } | 4453 } |
| 4441 | 4454 |
| 4442 bool WebContentsImpl::HasActiveEffectivelyFullscreenVideo() const { | 4455 bool WebContentsImpl::HasActiveEffectivelyFullscreenVideo() const { |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5602 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5615 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
| 5603 if (!render_view_host) | 5616 if (!render_view_host) |
| 5604 continue; | 5617 continue; |
| 5605 render_view_host_set.insert(render_view_host); | 5618 render_view_host_set.insert(render_view_host); |
| 5606 } | 5619 } |
| 5607 for (RenderViewHost* render_view_host : render_view_host_set) | 5620 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5608 render_view_host->OnWebkitPreferencesChanged(); | 5621 render_view_host->OnWebkitPreferencesChanged(); |
| 5609 } | 5622 } |
| 5610 | 5623 |
| 5611 } // namespace content | 5624 } // namespace content |
| OLD | NEW |