| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #include "content/common/page_state_serialization.h" | 87 #include "content/common/page_state_serialization.h" |
| 88 #include "content/common/render_message_filter.mojom.h" | 88 #include "content/common/render_message_filter.mojom.h" |
| 89 #include "content/common/site_isolation_policy.h" | 89 #include "content/common/site_isolation_policy.h" |
| 90 #include "content/common/view_messages.h" | 90 #include "content/common/view_messages.h" |
| 91 #include "content/public/browser/ax_event_notification_details.h" | 91 #include "content/public/browser/ax_event_notification_details.h" |
| 92 #include "content/public/browser/browser_context.h" | 92 #include "content/public/browser/browser_context.h" |
| 93 #include "content/public/browser/browser_plugin_guest_manager.h" | 93 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 94 #include "content/public/browser/content_browser_client.h" | 94 #include "content/public/browser/content_browser_client.h" |
| 95 #include "content/public/browser/download_manager.h" | 95 #include "content/public/browser/download_manager.h" |
| 96 #include "content/public/browser/download_url_parameters.h" | 96 #include "content/public/browser/download_url_parameters.h" |
| 97 #include "content/public/browser/focused_node_details.h" |
| 97 #include "content/public/browser/guest_mode.h" | 98 #include "content/public/browser/guest_mode.h" |
| 98 #include "content/public/browser/invalidate_type.h" | 99 #include "content/public/browser/invalidate_type.h" |
| 99 #include "content/public/browser/javascript_dialog_manager.h" | 100 #include "content/public/browser/javascript_dialog_manager.h" |
| 100 #include "content/public/browser/load_notification_details.h" | 101 #include "content/public/browser/load_notification_details.h" |
| 101 #include "content/public/browser/navigation_details.h" | 102 #include "content/public/browser/navigation_details.h" |
| 102 #include "content/public/browser/notification_details.h" | 103 #include "content/public/browser/notification_details.h" |
| 103 #include "content/public/browser/notification_service.h" | 104 #include "content/public/browser/notification_service.h" |
| 104 #include "content/public/browser/notification_types.h" | 105 #include "content/public/browser/notification_types.h" |
| 105 #include "content/public/browser/render_widget_host_iterator.h" | 106 #include "content/public/browser/render_widget_host_iterator.h" |
| 106 #include "content/public/browser/resource_request_details.h" | 107 #include "content/public/browser/resource_request_details.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 132 #include "ppapi/features/features.h" | 133 #include "ppapi/features/features.h" |
| 133 #include "services/service_manager/public/cpp/interface_provider.h" | 134 #include "services/service_manager/public/cpp/interface_provider.h" |
| 134 #include "third_party/WebKit/public/platform/WebSecurityStyle.h" | 135 #include "third_party/WebKit/public/platform/WebSecurityStyle.h" |
| 135 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 136 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 136 #include "third_party/skia/include/core/SkBitmap.h" | 137 #include "third_party/skia/include/core/SkBitmap.h" |
| 137 #include "ui/accessibility/ax_tree_combiner.h" | 138 #include "ui/accessibility/ax_tree_combiner.h" |
| 138 #include "ui/base/layout.h" | 139 #include "ui/base/layout.h" |
| 139 #include "ui/events/blink/web_input_event_traits.h" | 140 #include "ui/events/blink/web_input_event_traits.h" |
| 140 #include "ui/gl/gl_switches.h" | 141 #include "ui/gl/gl_switches.h" |
| 141 | 142 |
| 143 #if defined(OS_WIN) |
| 144 #include "content/browser/renderer_host/dip_util.h" |
| 145 #include "ui/gfx/geometry/dip_util.h" |
| 146 #endif |
| 147 |
| 142 #if defined(OS_ANDROID) | 148 #if defined(OS_ANDROID) |
| 143 #include "content/browser/android/content_video_view.h" | 149 #include "content/browser/android/content_video_view.h" |
| 144 #include "content/browser/android/date_time_chooser_android.h" | 150 #include "content/browser/android/date_time_chooser_android.h" |
| 145 #include "content/browser/android/java_interfaces_impl.h" | 151 #include "content/browser/android/java_interfaces_impl.h" |
| 146 #include "content/browser/media/android/media_web_contents_observer_android.h" | 152 #include "content/browser/media/android/media_web_contents_observer_android.h" |
| 147 #include "content/browser/web_contents/web_contents_android.h" | 153 #include "content/browser/web_contents/web_contents_android.h" |
| 148 #endif // OS_ANDROID | 154 #endif // OS_ANDROID |
| 149 | 155 |
| 150 #if defined(OS_MACOSX) | 156 #if defined(OS_MACOSX) |
| 151 #include "base/mac/foundation_util.h" | 157 #include "base/mac/foundation_util.h" |
| (...skipping 4044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4196 | 4202 |
| 4197 GURL url = pending_entry->GetURL(); | 4203 GURL url = pending_entry->GetURL(); |
| 4198 return HostZoomMap::GetForWebContents(this)->GetZoomLevelForHostAndScheme( | 4204 return HostZoomMap::GetForWebContents(this)->GetZoomLevelForHostAndScheme( |
| 4199 url.scheme(), net::GetHostOrSpecFromURL(url)); | 4205 url.scheme(), net::GetHostOrSpecFromURL(url)); |
| 4200 } | 4206 } |
| 4201 | 4207 |
| 4202 bool WebContentsImpl::HideDownloadUI() const { | 4208 bool WebContentsImpl::HideDownloadUI() const { |
| 4203 return is_overlay_content_; | 4209 return is_overlay_content_; |
| 4204 } | 4210 } |
| 4205 | 4211 |
| 4212 bool WebContentsImpl::IsFocusedElementEditable() { |
| 4213 RenderFrameHostImpl* frame = GetFocusedFrame(); |
| 4214 return frame && frame->has_focused_editable_element(); |
| 4215 } |
| 4216 |
| 4217 void WebContentsImpl::ClearFocusedElement() { |
| 4218 if (auto* frame = GetFocusedFrame()) |
| 4219 frame->ClearFocusedElement(); |
| 4220 } |
| 4221 |
| 4206 bool WebContentsImpl::IsNeverVisible() { | 4222 bool WebContentsImpl::IsNeverVisible() { |
| 4207 if (!delegate_) | 4223 if (!delegate_) |
| 4208 return false; | 4224 return false; |
| 4209 return delegate_->IsNeverVisible(this); | 4225 return delegate_->IsNeverVisible(this); |
| 4210 } | 4226 } |
| 4211 | 4227 |
| 4212 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { | 4228 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { |
| 4213 return render_view_host_delegate_view_; | 4229 return render_view_host_delegate_view_; |
| 4214 } | 4230 } |
| 4215 | 4231 |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4701 if (!GuestMode::IsCrossProcessFrameGuest(this) && browser_plugin_guest_) { | 4717 if (!GuestMode::IsCrossProcessFrameGuest(this) && browser_plugin_guest_) { |
| 4702 frame_tree_.SetFocusedFrame(node, source); | 4718 frame_tree_.SetFocusedFrame(node, source); |
| 4703 return; | 4719 return; |
| 4704 } | 4720 } |
| 4705 | 4721 |
| 4706 SetAsFocusedWebContentsIfNecessary(); | 4722 SetAsFocusedWebContentsIfNecessary(); |
| 4707 | 4723 |
| 4708 frame_tree_.SetFocusedFrame(node, source); | 4724 frame_tree_.SetFocusedFrame(node, source); |
| 4709 } | 4725 } |
| 4710 | 4726 |
| 4727 void WebContentsImpl::OnFocusedElementChangedInFrame( |
| 4728 RenderFrameHostImpl* frame, |
| 4729 const gfx::Rect& bounds_in_root_view) { |
| 4730 RenderWidgetHostViewBase* root_view = |
| 4731 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); |
| 4732 if (!root_view || !frame->GetView()) |
| 4733 return; |
| 4734 |
| 4735 // Converting to screen coordinates. |
| 4736 gfx::Point origin = bounds_in_root_view.origin(); |
| 4737 origin += root_view->GetViewBounds().OffsetFromOrigin(); |
| 4738 gfx::Rect bounds_in_screen(origin, bounds_in_root_view.size()); |
| 4739 |
| 4740 root_view->FocusedNodeChanged(frame->has_focused_editable_element(), |
| 4741 bounds_in_screen); |
| 4742 |
| 4743 FocusedNodeDetails details = {frame->has_focused_editable_element(), |
| 4744 bounds_in_screen}; |
| 4745 |
| 4746 // TODO(ekaramad): We should replace this with an observer notification |
| 4747 // (https://crbug.com/675975). |
| 4748 NotificationService::current()->Notify( |
| 4749 NOTIFICATION_FOCUS_CHANGED_IN_PAGE, |
| 4750 Source<RenderViewHost>(GetRenderViewHost()), |
| 4751 Details<FocusedNodeDetails>(&details)); |
| 4752 } |
| 4753 |
| 4711 bool WebContentsImpl::DidAddMessageToConsole(int32_t level, | 4754 bool WebContentsImpl::DidAddMessageToConsole(int32_t level, |
| 4712 const base::string16& message, | 4755 const base::string16& message, |
| 4713 int32_t line_no, | 4756 int32_t line_no, |
| 4714 const base::string16& source_id) { | 4757 const base::string16& source_id) { |
| 4715 if (!delegate_) | 4758 if (!delegate_) |
| 4716 return false; | 4759 return false; |
| 4717 return delegate_->DidAddMessageToConsole(this, level, message, line_no, | 4760 return delegate_->DidAddMessageToConsole(this, level, message, line_no, |
| 4718 source_id); | 4761 source_id); |
| 4719 } | 4762 } |
| 4720 | 4763 |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5306 binding_sets_.erase(it); | 5349 binding_sets_.erase(it); |
| 5307 } | 5350 } |
| 5308 | 5351 |
| 5309 bool WebContentsImpl::AddDomainInfoToRapporSample(rappor::Sample* sample) { | 5352 bool WebContentsImpl::AddDomainInfoToRapporSample(rappor::Sample* sample) { |
| 5310 sample->SetStringField("Domain", ::rappor::GetDomainAndRegistrySampleFromGURL( | 5353 sample->SetStringField("Domain", ::rappor::GetDomainAndRegistrySampleFromGURL( |
| 5311 GetLastCommittedURL())); | 5354 GetLastCommittedURL())); |
| 5312 | 5355 |
| 5313 return true; | 5356 return true; |
| 5314 } | 5357 } |
| 5315 | 5358 |
| 5359 void WebContentsImpl::FocusedNodeTouched(bool editable) { |
| 5360 #if defined(OS_WIN) |
| 5361 // We use the cursor position to determine where the touch occurred. |
| 5362 RenderWidgetHostView* view = GetRenderWidgetHostView(); |
| 5363 if (!view) |
| 5364 return; |
| 5365 POINT cursor_pos = {}; |
| 5366 ::GetCursorPos(&cursor_pos); |
| 5367 float scale = GetScaleFactorForView(view); |
| 5368 gfx::Point location_dips_screen = |
| 5369 gfx::ConvertPointToDIP(scale, gfx::Point(cursor_pos)); |
| 5370 view->FocusedNodeTouched(location_dips_screen, editable); |
| 5371 #endif |
| 5372 } |
| 5373 |
| 5316 void WebContentsImpl::ShowInsecureLocalhostWarningIfNeeded() { | 5374 void WebContentsImpl::ShowInsecureLocalhostWarningIfNeeded() { |
| 5317 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch( | 5375 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 5318 switches::kAllowInsecureLocalhost); | 5376 switches::kAllowInsecureLocalhost); |
| 5319 if (!allow_localhost) | 5377 if (!allow_localhost) |
| 5320 return; | 5378 return; |
| 5321 | 5379 |
| 5322 content::NavigationEntry* entry = GetController().GetLastCommittedEntry(); | 5380 content::NavigationEntry* entry = GetController().GetLastCommittedEntry(); |
| 5323 if (!entry || !net::IsLocalhost(entry->GetURL().host())) | 5381 if (!entry || !net::IsLocalhost(entry->GetURL().host())) |
| 5324 return; | 5382 return; |
| 5325 | 5383 |
| 5326 content::SSLStatus ssl_status = entry->GetSSL(); | 5384 content::SSLStatus ssl_status = entry->GetSSL(); |
| 5327 bool is_cert_error = net::IsCertStatusError(ssl_status.cert_status) && | 5385 bool is_cert_error = net::IsCertStatusError(ssl_status.cert_status) && |
| 5328 !net::IsCertStatusMinorError(ssl_status.cert_status); | 5386 !net::IsCertStatusMinorError(ssl_status.cert_status); |
| 5329 if (!is_cert_error) | 5387 if (!is_cert_error) |
| 5330 return; | 5388 return; |
| 5331 | 5389 |
| 5332 GetMainFrame()->AddMessageToConsole( | 5390 GetMainFrame()->AddMessageToConsole( |
| 5333 content::CONSOLE_MESSAGE_LEVEL_WARNING, | 5391 content::CONSOLE_MESSAGE_LEVEL_WARNING, |
| 5334 base::StringPrintf("This site does not have a valid SSL " | 5392 base::StringPrintf("This site does not have a valid SSL " |
| 5335 "certificate! Without SSL, your site's and " | 5393 "certificate! Without SSL, your site's and " |
| 5336 "visitors' data is vulnerable to theft and " | 5394 "visitors' data is vulnerable to theft and " |
| 5337 "tampering. Get a valid SSL certificate before" | 5395 "tampering. Get a valid SSL certificate before" |
| 5338 " releasing your website to the public.")); | 5396 " releasing your website to the public.")); |
| 5339 } | 5397 } |
| 5340 | 5398 |
| 5341 } // namespace content | 5399 } // namespace content |
| OLD | NEW |