Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2874833002: Don't compile code for desktop zoom or GuestViews on mobile platforms. (Closed)
Patch Set: Rebase. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
145 #include "ui/gfx/geometry/dip_util.h" 143 #include "ui/gfx/geometry/dip_util.h"
146 #endif 144 #endif
147 145
148 #if defined(OS_ANDROID) 146 #if defined(OS_ANDROID)
149 #include "content/browser/android/content_video_view.h" 147 #include "content/browser/android/content_video_view.h"
150 #include "content/browser/android/date_time_chooser_android.h" 148 #include "content/browser/android/date_time_chooser_android.h"
151 #include "content/browser/android/java_interfaces_impl.h" 149 #include "content/browser/android/java_interfaces_impl.h"
152 #include "content/browser/media/android/media_web_contents_observer_android.h" 150 #include "content/browser/media/android/media_web_contents_observer_android.h"
153 #include "content/browser/web_contents/web_contents_android.h" 151 #include "content/browser/web_contents/web_contents_android.h"
154 #include "services/device/public/interfaces/nfc.mojom.h" 152 #include "services/device/public/interfaces/nfc.mojom.h"
153 #else // !OS_ANDROID
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
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 // Imperfect sanity check against double free, given some crashes unexpectedly 538 // Imperfect sanity check against double free, given some crashes unexpectedly
534 // observed in the wild. 539 // observed in the wild.
535 CHECK(!is_being_destroyed_); 540 CHECK(!is_being_destroyed_);
536 541
537 // We generally keep track of is_being_destroyed_ to let other features know 542 // We generally keep track of is_being_destroyed_ to let other features know
538 // to avoid certain actions during destruction. 543 // to avoid certain actions during destruction.
539 is_being_destroyed_ = true; 544 is_being_destroyed_ = true;
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 // them into a single tree and call |callback| with that result, then 1060 // them into a single tree and call |callback| with that result, then
1056 // delete |combiner|. 1061 // delete |combiner|.
1057 AXTreeSnapshotCombiner* combiner = new AXTreeSnapshotCombiner(callback); 1062 AXTreeSnapshotCombiner* combiner = new AXTreeSnapshotCombiner(callback);
1058 for (FrameTreeNode* frame_tree_node : frame_tree_.Nodes()) { 1063 for (FrameTreeNode* frame_tree_node : frame_tree_.Nodes()) {
1059 bool is_root = frame_tree_node->parent() == nullptr; 1064 bool is_root = frame_tree_node->parent() == nullptr;
1060 frame_tree_node->current_frame_host()->RequestAXTreeSnapshot( 1065 frame_tree_node->current_frame_host()->RequestAXTreeSnapshot(
1061 combiner->AddFrame(is_root)); 1066 combiner->AddFrame(is_root));
1062 } 1067 }
1063 } 1068 }
1064 1069
1070 #if !defined(OS_ANDROID)
1065 void WebContentsImpl::SetTemporaryZoomLevel(double level, 1071 void WebContentsImpl::SetTemporaryZoomLevel(double level,
1066 bool temporary_zoom_enabled) { 1072 bool temporary_zoom_enabled) {
1067 SendPageMessage(new PageMsg_SetZoomLevel( 1073 SendPageMessage(new PageMsg_SetZoomLevel(
1068 MSG_ROUTING_NONE, 1074 MSG_ROUTING_NONE,
1069 temporary_zoom_enabled ? PageMsg_SetZoomLevel_Command::SET_TEMPORARY 1075 temporary_zoom_enabled ? PageMsg_SetZoomLevel_Command::SET_TEMPORARY
1070 : PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY, 1076 : PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY,
1071 level)); 1077 level));
1072 } 1078 }
1073 1079
1074 void WebContentsImpl::UpdateZoom(double level) { 1080 void WebContentsImpl::UpdateZoom(double level) {
(...skipping 12 matching lines...) Expand all
1087 return; 1093 return;
1088 1094
1089 GURL url = HostZoomMap::GetURLFromEntry(entry); 1095 GURL url = HostZoomMap::GetURLFromEntry(entry);
1090 if (host != net::GetHostOrSpecFromURL(url) || 1096 if (host != net::GetHostOrSpecFromURL(url) ||
1091 (!scheme.empty() && !url.SchemeIs(scheme))) { 1097 (!scheme.empty() && !url.SchemeIs(scheme))) {
1092 return; 1098 return;
1093 } 1099 }
1094 1100
1095 UpdateZoom(level); 1101 UpdateZoom(level);
1096 } 1102 }
1103 #endif // !defined(OS_ANDROID)
1097 1104
1098 base::Closure WebContentsImpl::AddBindingSet( 1105 base::Closure WebContentsImpl::AddBindingSet(
1099 const std::string& interface_name, 1106 const std::string& interface_name,
1100 WebContentsBindingSet* binding_set) { 1107 WebContentsBindingSet* binding_set) {
1101 auto result = 1108 auto result =
1102 binding_sets_.insert(std::make_pair(interface_name, binding_set)); 1109 binding_sets_.insert(std::make_pair(interface_name, binding_set));
1103 DCHECK(result.second); 1110 DCHECK(result.second);
1104 return base::Bind(&WebContentsImpl::RemoveBindingSet, 1111 return base::Bind(&WebContentsImpl::RemoveBindingSet,
1105 weak_factory_.GetWeakPtr(), interface_name); 1112 weak_factory_.GetWeakPtr(), interface_name);
1106 } 1113 }
(...skipping 2736 matching lines...) Expand 10 before | Expand all | Expand 10 after
3843 3850
3844 void WebContentsImpl::OnUpdateZoomLimits(RenderViewHostImpl* source, 3851 void WebContentsImpl::OnUpdateZoomLimits(RenderViewHostImpl* source,
3845 int minimum_percent, 3852 int minimum_percent,
3846 int maximum_percent) { 3853 int maximum_percent) {
3847 minimum_zoom_percent_ = minimum_percent; 3854 minimum_zoom_percent_ = minimum_percent;
3848 maximum_zoom_percent_ = maximum_percent; 3855 maximum_zoom_percent_ = maximum_percent;
3849 } 3856 }
3850 3857
3851 void WebContentsImpl::OnPageScaleFactorChanged(RenderViewHostImpl* source, 3858 void WebContentsImpl::OnPageScaleFactorChanged(RenderViewHostImpl* source,
3852 float page_scale_factor) { 3859 float page_scale_factor) {
3860 #if !defined(OS_ANDROID)
3861 // While page scale factor is used on mobile, this PageScaleFactorIsOne logic
3862 // is only needed on desktop.
3853 bool is_one = page_scale_factor == 1.f; 3863 bool is_one = page_scale_factor == 1.f;
3854 if (is_one != page_scale_factor_is_one_) { 3864 if (is_one != page_scale_factor_is_one_) {
3855 page_scale_factor_is_one_ = is_one; 3865 page_scale_factor_is_one_ = is_one;
3856 3866
3857 HostZoomMapImpl* host_zoom_map = 3867 HostZoomMapImpl* host_zoom_map =
3858 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); 3868 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this));
3859 3869
3860 if (host_zoom_map) { 3870 if (host_zoom_map) {
3861 host_zoom_map->SetPageScaleFactorIsOneForView( 3871 host_zoom_map->SetPageScaleFactorIsOneForView(
3862 source->GetProcess()->GetID(), source->GetRoutingID(), 3872 source->GetProcess()->GetID(), source->GetRoutingID(),
3863 page_scale_factor_is_one_); 3873 page_scale_factor_is_one_);
3864 } 3874 }
3865 } 3875 }
3876 #endif // !defined(OS_ANDROID)
3866 3877
3867 for (auto& observer : observers_) 3878 for (auto& observer : observers_)
3868 observer.OnPageScaleFactorChanged(page_scale_factor); 3879 observer.OnPageScaleFactorChanged(page_scale_factor);
3869 } 3880 }
3870 3881
3871 void WebContentsImpl::OnEnumerateDirectory(RenderViewHostImpl* source, 3882 void WebContentsImpl::OnEnumerateDirectory(RenderViewHostImpl* source,
3872 int request_id, 3883 int request_id,
3873 const base::FilePath& path) { 3884 const base::FilePath& path) {
3874 if (!delegate_) 3885 if (!delegate_)
3875 return; 3886 return;
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 void WebContentsImpl::RunFileChooser(RenderFrameHost* render_frame_host, 4461 void WebContentsImpl::RunFileChooser(RenderFrameHost* render_frame_host,
4451 const FileChooserParams& params) { 4462 const FileChooserParams& params) {
4452 if (delegate_) 4463 if (delegate_)
4453 delegate_->RunFileChooser(render_frame_host, params); 4464 delegate_->RunFileChooser(render_frame_host, params);
4454 } 4465 }
4455 4466
4456 WebContents* WebContentsImpl::GetAsWebContents() { 4467 WebContents* WebContentsImpl::GetAsWebContents() {
4457 return this; 4468 return this;
4458 } 4469 }
4459 4470
4471 #if !defined(OS_ANDROID)
4460 double WebContentsImpl::GetPendingPageZoomLevel() { 4472 double WebContentsImpl::GetPendingPageZoomLevel() {
4461 NavigationEntry* pending_entry = GetController().GetPendingEntry(); 4473 NavigationEntry* pending_entry = GetController().GetPendingEntry();
4462 if (!pending_entry) 4474 if (!pending_entry)
4463 return HostZoomMap::GetZoomLevel(this); 4475 return HostZoomMap::GetZoomLevel(this);
4464 4476
4465 GURL url = pending_entry->GetURL(); 4477 GURL url = pending_entry->GetURL();
4466 return HostZoomMap::GetForWebContents(this)->GetZoomLevelForHostAndScheme( 4478 return HostZoomMap::GetForWebContents(this)->GetZoomLevelForHostAndScheme(
4467 url.scheme(), net::GetHostOrSpecFromURL(url)); 4479 url.scheme(), net::GetHostOrSpecFromURL(url));
4468 } 4480 }
4481 #endif // !defined(OS_ANDROID)
4469 4482
4470 bool WebContentsImpl::HideDownloadUI() const { 4483 bool WebContentsImpl::HideDownloadUI() const {
4471 return is_overlay_content_; 4484 return is_overlay_content_;
4472 } 4485 }
4473 4486
4474 bool WebContentsImpl::HasPersistentVideo() const { 4487 bool WebContentsImpl::HasPersistentVideo() const {
4475 return has_persistent_video_; 4488 return has_persistent_video_;
4476 } 4489 }
4477 4490
4478 bool WebContentsImpl::HasActiveEffectivelyFullscreenVideo() const { 4491 bool WebContentsImpl::HasActiveEffectivelyFullscreenVideo() const {
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
5638 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); 5651 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host);
5639 if (!render_view_host) 5652 if (!render_view_host)
5640 continue; 5653 continue;
5641 render_view_host_set.insert(render_view_host); 5654 render_view_host_set.insert(render_view_host);
5642 } 5655 }
5643 for (RenderViewHost* render_view_host : render_view_host_set) 5656 for (RenderViewHost* render_view_host : render_view_host_set)
5644 render_view_host->OnWebkitPreferencesChanged(); 5657 render_view_host->OnWebkitPreferencesChanged();
5645 } 5658 }
5646 5659
5647 } // namespace content 5660 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698