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

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

Issue 2571583008: Support tracking focused element for OOPIFs. (Closed)
Patch Set: Fixed some compile errors Created 4 years 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
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 4031 matching lines...) Expand 10 before | Expand all | Expand 10 after
4183 4189
4184 GURL url = pending_entry->GetURL(); 4190 GURL url = pending_entry->GetURL();
4185 return HostZoomMap::GetForWebContents(this)->GetZoomLevelForHostAndScheme( 4191 return HostZoomMap::GetForWebContents(this)->GetZoomLevelForHostAndScheme(
4186 url.scheme(), net::GetHostOrSpecFromURL(url)); 4192 url.scheme(), net::GetHostOrSpecFromURL(url));
4187 } 4193 }
4188 4194
4189 bool WebContentsImpl::HideDownloadUI() const { 4195 bool WebContentsImpl::HideDownloadUI() const {
4190 return is_overlay_content_; 4196 return is_overlay_content_;
4191 } 4197 }
4192 4198
4199 bool WebContentsImpl::IsFocusedElementEditable() {
4200 RenderFrameHostImpl* frame = GetFocusedFrame();
4201 return frame && frame->has_focused_editable_element();
4202 }
4203
4204 void WebContentsImpl::ClearFocusedElement() {
4205 if (auto* frame = GetFocusedFrame())
4206 frame->ClearFocusedElement();
4207 }
4208
4193 bool WebContentsImpl::IsNeverVisible() { 4209 bool WebContentsImpl::IsNeverVisible() {
4194 if (!delegate_) 4210 if (!delegate_)
4195 return false; 4211 return false;
4196 return delegate_->IsNeverVisible(this); 4212 return delegate_->IsNeverVisible(this);
4197 } 4213 }
4198 4214
4199 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { 4215 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() {
4200 return render_view_host_delegate_view_; 4216 return render_view_host_delegate_view_;
4201 } 4217 }
4202 4218
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
4688 if (!GuestMode::IsCrossProcessFrameGuest(this) && browser_plugin_guest_) { 4704 if (!GuestMode::IsCrossProcessFrameGuest(this) && browser_plugin_guest_) {
4689 frame_tree_.SetFocusedFrame(node, source); 4705 frame_tree_.SetFocusedFrame(node, source);
4690 return; 4706 return;
4691 } 4707 }
4692 4708
4693 SetAsFocusedWebContentsIfNecessary(); 4709 SetAsFocusedWebContentsIfNecessary();
4694 4710
4695 frame_tree_.SetFocusedFrame(node, source); 4711 frame_tree_.SetFocusedFrame(node, source);
4696 } 4712 }
4697 4713
4714 void WebContentsImpl::OnFocusedElementChangedInFrame(
4715 RenderFrameHostImpl* frame,
4716 const gfx::Rect& bounds_in_root_view) {
4717 RenderWidgetHostViewBase* root_view =
4718 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView());
4719 if (!root_view || !frame->GetView())
4720 return;
4721
4722 // Converting to screen coordinates.
4723 gfx::Point origin = bounds_in_root_view.origin();
4724 origin += root_view->GetViewBounds().OffsetFromOrigin();
4725 gfx::Rect bounds_in_screen(origin, bounds_in_root_view.size());
4726
4727 // TODO(ekaramad): Do we want to early return here when |frame| is not focused
4728 // and the focused frame has active editable element?
4729 root_view->FocusedNodeChanged(frame->has_focused_editable_element(),
4730 bounds_in_screen);
4731
4732 FocusedNodeDetails details = {frame->has_focused_editable_element(),
4733 bounds_in_screen};
4734
4735 // TODO(ekaramad): Should we do this step with |this| as source now? Requires
4736 // changes to public API.
ncarter (slow) 2016/12/16 19:17:21 WebContents can be made to be the source (and, I t
EhsanK 2016/12/20 16:39:11 Yes I am not quite fond of notifications as they c
ncarter (slow) 2016/12/20 22:37:44 SGTM!
4737 NotificationService::current()->Notify(
4738 NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
4739 Source<RenderViewHost>(GetRenderViewHost()),
4740 Details<FocusedNodeDetails>(&details));
4741 }
4742
4698 bool WebContentsImpl::DidAddMessageToConsole(int32_t level, 4743 bool WebContentsImpl::DidAddMessageToConsole(int32_t level,
4699 const base::string16& message, 4744 const base::string16& message,
4700 int32_t line_no, 4745 int32_t line_no,
4701 const base::string16& source_id) { 4746 const base::string16& source_id) {
4702 if (!delegate_) 4747 if (!delegate_)
4703 return false; 4748 return false;
4704 return delegate_->DidAddMessageToConsole(this, level, message, line_no, 4749 return delegate_->DidAddMessageToConsole(this, level, message, line_no,
4705 source_id); 4750 source_id);
4706 } 4751 }
4707 4752
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
5293 binding_sets_.erase(it); 5338 binding_sets_.erase(it);
5294 } 5339 }
5295 5340
5296 bool WebContentsImpl::AddDomainInfoToRapporSample(rappor::Sample* sample) { 5341 bool WebContentsImpl::AddDomainInfoToRapporSample(rappor::Sample* sample) {
5297 sample->SetStringField("Domain", ::rappor::GetDomainAndRegistrySampleFromGURL( 5342 sample->SetStringField("Domain", ::rappor::GetDomainAndRegistrySampleFromGURL(
5298 GetLastCommittedURL())); 5343 GetLastCommittedURL()));
5299 5344
5300 return true; 5345 return true;
5301 } 5346 }
5302 5347
5348 void WebContentsImpl::FocusedNodeTouched(bool editable) {
5349 #if defined(OS_WIN)
5350 // We use the cursor position to determine where the touch occurred.
5351 RenderWidgetHostView* view = GetRenderWidgetHostView();
5352 if (!view)
5353 return;
5354 POINT cursor_pos = {};
5355 ::GetCursorPos(&cursor_pos);
5356 float scale = GetScaleFactorForView(view);
5357 gfx::Point location_dips_screen =
5358 gfx::ConvertPointToDIP(scale, gfx::Point(cursor_pos));
5359 view->FocusedNodeTouched(location_dips_screen, editable);
5360 #endif
5361 }
5362
5303 void WebContentsImpl::ShowInsecureLocalhostWarningIfNeeded() { 5363 void WebContentsImpl::ShowInsecureLocalhostWarningIfNeeded() {
5304 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch( 5364 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch(
5305 switches::kAllowInsecureLocalhost); 5365 switches::kAllowInsecureLocalhost);
5306 if (!allow_localhost) 5366 if (!allow_localhost)
5307 return; 5367 return;
5308 5368
5309 content::NavigationEntry* entry = GetController().GetLastCommittedEntry(); 5369 content::NavigationEntry* entry = GetController().GetLastCommittedEntry();
5310 if (!entry || !net::IsLocalhost(entry->GetURL().host())) 5370 if (!entry || !net::IsLocalhost(entry->GetURL().host()))
5311 return; 5371 return;
5312 5372
5313 content::SSLStatus ssl_status = entry->GetSSL(); 5373 content::SSLStatus ssl_status = entry->GetSSL();
5314 bool is_cert_error = net::IsCertStatusError(ssl_status.cert_status) && 5374 bool is_cert_error = net::IsCertStatusError(ssl_status.cert_status) &&
5315 !net::IsCertStatusMinorError(ssl_status.cert_status); 5375 !net::IsCertStatusMinorError(ssl_status.cert_status);
5316 if (!is_cert_error) 5376 if (!is_cert_error)
5317 return; 5377 return;
5318 5378
5319 GetMainFrame()->AddMessageToConsole( 5379 GetMainFrame()->AddMessageToConsole(
5320 content::CONSOLE_MESSAGE_LEVEL_WARNING, 5380 content::CONSOLE_MESSAGE_LEVEL_WARNING,
5321 base::StringPrintf("This site does not have a valid SSL " 5381 base::StringPrintf("This site does not have a valid SSL "
5322 "certificate! Without SSL, your site's and " 5382 "certificate! Without SSL, your site's and "
5323 "visitors' data is vulnerable to theft and " 5383 "visitors' data is vulnerable to theft and "
5324 "tampering. Get a valid SSL certificate before" 5384 "tampering. Get a valid SSL certificate before"
5325 " releasing your website to the public.")); 5385 " releasing your website to the public."));
5326 } 5386 }
5327 5387
5328 } // namespace content 5388 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698