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

Side by Side Diff: third_party/WebKit/Source/web/ChromeClientImpl.cpp

Issue 2905283003: Remove a bunch of dead code around WindowFeatures (Closed)
Patch Set: Add missing #include Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 20 matching lines...) Expand all
31 31
32 #include "web/ChromeClientImpl.h" 32 #include "web/ChromeClientImpl.h"
33 33
34 #include <memory> 34 #include <memory>
35 #include "bindings/core/v8/ScriptController.h" 35 #include "bindings/core/v8/ScriptController.h"
36 #include "core/HTMLNames.h" 36 #include "core/HTMLNames.h"
37 #include "core/dom/AXObjectCache.h" 37 #include "core/dom/AXObjectCache.h"
38 #include "core/dom/Document.h" 38 #include "core/dom/Document.h"
39 #include "core/dom/Fullscreen.h" 39 #include "core/dom/Fullscreen.h"
40 #include "core/dom/Node.h" 40 #include "core/dom/Node.h"
41 #include "core/events/UIEventWithKeyState.h"
42 #include "core/events/WebInputEventConversion.h" 41 #include "core/events/WebInputEventConversion.h"
43 #include "core/exported/WebFileChooserCompletionImpl.h" 42 #include "core/exported/WebFileChooserCompletionImpl.h"
44 #include "core/exported/WebPluginContainerBase.h" 43 #include "core/exported/WebPluginContainerBase.h"
45 #include "core/exported/WebViewBase.h" 44 #include "core/exported/WebViewBase.h"
46 #include "core/frame/LocalFrameView.h" 45 #include "core/frame/LocalFrameView.h"
47 #include "core/frame/Settings.h" 46 #include "core/frame/Settings.h"
48 #include "core/frame/UseCounter.h" 47 #include "core/frame/UseCounter.h"
49 #include "core/frame/VisualViewport.h" 48 #include "core/frame/VisualViewport.h"
50 #include "core/html/HTMLInputElement.h" 49 #include "core/html/HTMLInputElement.h"
51 #include "core/html/forms/ColorChooser.h" 50 #include "core/html/forms/ColorChooser.h"
(...skipping 14 matching lines...) Expand all
66 #include "modules/installedapp/InstalledAppController.h" 65 #include "modules/installedapp/InstalledAppController.h"
67 #include "modules/mediastream/UserMediaController.h" 66 #include "modules/mediastream/UserMediaController.h"
68 #include "modules/navigatorcontentutils/NavigatorContentUtils.h" 67 #include "modules/navigatorcontentutils/NavigatorContentUtils.h"
69 #include "modules/presentation/PresentationController.h" 68 #include "modules/presentation/PresentationController.h"
70 #include "modules/push_messaging/PushController.h" 69 #include "modules/push_messaging/PushController.h"
71 #include "modules/screen_orientation/ScreenOrientationControllerImpl.h" 70 #include "modules/screen_orientation/ScreenOrientationControllerImpl.h"
72 #include "modules/vr/VRController.h" 71 #include "modules/vr/VRController.h"
73 #include "platform/Cursor.h" 72 #include "platform/Cursor.h"
74 #include "platform/FileChooser.h" 73 #include "platform/FileChooser.h"
75 #include "platform/Histogram.h" 74 #include "platform/Histogram.h"
76 #include "platform/KeyboardCodes.h"
77 #include "platform/RuntimeEnabledFeatures.h" 75 #include "platform/RuntimeEnabledFeatures.h"
78 #include "platform/WebFrameScheduler.h" 76 #include "platform/WebFrameScheduler.h"
79 #include "platform/animation/CompositorAnimationHost.h" 77 #include "platform/animation/CompositorAnimationHost.h"
80 #include "platform/exported/WrappedResourceRequest.h" 78 #include "platform/exported/WrappedResourceRequest.h"
81 #include "platform/geometry/IntRect.h" 79 #include "platform/geometry/IntRect.h"
82 #include "platform/graphics/GraphicsLayer.h" 80 #include "platform/graphics/GraphicsLayer.h"
83 #include "platform/graphics/TouchAction.h" 81 #include "platform/graphics/TouchAction.h"
84 #include "platform/scheduler/renderer/web_view_scheduler.h" 82 #include "platform/scheduler/renderer/web_view_scheduler.h"
85 #include "platform/weborigin/SecurityOrigin.h" 83 #include "platform/weborigin/SecurityOrigin.h"
86 #include "platform/wtf/Optional.h" 84 #include "platform/wtf/Optional.h"
87 #include "platform/wtf/PtrUtil.h" 85 #include "platform/wtf/PtrUtil.h"
88 #include "platform/wtf/text/CString.h" 86 #include "platform/wtf/text/CString.h"
89 #include "platform/wtf/text/CharacterNames.h" 87 #include "platform/wtf/text/CharacterNames.h"
90 #include "platform/wtf/text/StringBuilder.h" 88 #include "platform/wtf/text/StringBuilder.h"
91 #include "platform/wtf/text/StringConcatenate.h" 89 #include "platform/wtf/text/StringConcatenate.h"
92 #include "public/platform/WebCursorInfo.h" 90 #include "public/platform/WebCursorInfo.h"
93 #include "public/platform/WebFloatRect.h" 91 #include "public/platform/WebFloatRect.h"
94 #include "public/platform/WebInputEvent.h"
95 #include "public/platform/WebRect.h" 92 #include "public/platform/WebRect.h"
96 #include "public/platform/WebURLRequest.h" 93 #include "public/platform/WebURLRequest.h"
97 #include "public/web/WebAXObject.h" 94 #include "public/web/WebAXObject.h"
98 #include "public/web/WebAutofillClient.h" 95 #include "public/web/WebAutofillClient.h"
99 #include "public/web/WebColorChooser.h" 96 #include "public/web/WebColorChooser.h"
100 #include "public/web/WebColorSuggestion.h" 97 #include "public/web/WebColorSuggestion.h"
101 #include "public/web/WebConsoleMessage.h" 98 #include "public/web/WebConsoleMessage.h"
102 #include "public/web/WebFrameClient.h" 99 #include "public/web/WebFrameClient.h"
103 #include "public/web/WebInputElement.h" 100 #include "public/web/WebInputElement.h"
104 #include "public/web/WebKit.h" 101 #include "public/web/WebKit.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame); 266 WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame);
270 WebReferrerPolicy policy = web_frame->GetDocument().GetReferrerPolicy(); 267 WebReferrerPolicy policy = web_frame->GetDocument().GetReferrerPolicy();
271 web_frame->LocalRoot()->FrameWidget()->StartDragging( 268 web_frame->LocalRoot()->FrameWidget()->StartDragging(
272 policy, drag_data, mask, drag_image, drag_image_offset); 269 policy, drag_data, mask, drag_image, drag_image_offset);
273 } 270 }
274 271
275 bool ChromeClientImpl::AcceptsLoadDrops() const { 272 bool ChromeClientImpl::AcceptsLoadDrops() const {
276 return !web_view_->Client() || web_view_->Client()->AcceptsLoadDrops(); 273 return !web_view_->Client() || web_view_->Client()->AcceptsLoadDrops();
277 } 274 }
278 275
279 namespace {
Nate Chapin 2017/05/31 16:55:13 This whole namespace {} block moved to CreateWindo
280
281 void UpdatePolicyForEvent(const WebInputEvent* input_event,
282 NavigationPolicy* policy) {
283 if (!input_event)
284 return;
285
286 unsigned short button_number = 0;
287 if (input_event->GetType() == WebInputEvent::kMouseUp) {
288 const WebMouseEvent* mouse_event =
289 static_cast<const WebMouseEvent*>(input_event);
290
291 switch (mouse_event->button) {
292 case WebMouseEvent::Button::kLeft:
293 button_number = 0;
294 break;
295 case WebMouseEvent::Button::kMiddle:
296 button_number = 1;
297 break;
298 case WebMouseEvent::Button::kRight:
299 button_number = 2;
300 break;
301 default:
302 return;
303 }
304 } else if ((WebInputEvent::IsKeyboardEventType(input_event->GetType()) &&
305 static_cast<const WebKeyboardEvent*>(input_event)
306 ->windows_key_code == VKEY_RETURN) ||
307 WebInputEvent::IsGestureEventType(input_event->GetType())) {
308 // Keyboard and gesture events can simulate mouse events.
309 button_number = 0;
310 } else {
311 return;
312 }
313
314 bool ctrl = input_event->GetModifiers() & WebInputEvent::kControlKey;
315 bool shift = input_event->GetModifiers() & WebInputEvent::kShiftKey;
316 bool alt = input_event->GetModifiers() & WebInputEvent::kAltKey;
317 bool meta = input_event->GetModifiers() & WebInputEvent::kMetaKey;
318
319 NavigationPolicy user_policy = *policy;
320 NavigationPolicyFromMouseEvent(button_number, ctrl, shift, alt, meta,
321 &user_policy);
322
323 // When the input event suggests a download, but the navigation was initiated
324 // by script, we should not override it.
325 if (user_policy == kNavigationPolicyDownload &&
326 *policy != kNavigationPolicyIgnore)
327 return;
328
329 // User and app agree that we want a new window; let the app override the
330 // decorations.
331 if (user_policy == kNavigationPolicyNewWindow &&
332 *policy == kNavigationPolicyNewPopup)
333 return;
334 *policy = user_policy;
335 }
336
337 WebNavigationPolicy GetNavigationPolicy(const WindowFeatures& features) {
338 // If the window features didn't enable the toolbar, or this window wasn't
339 // created by a user gesture, show as a popup instead of a new tab.
340 //
341 // Note: this previously also checked that menubar, resizable, scrollbar, and
342 // statusbar are enabled too. When no feature string is specified, these
343 // features default to enabled (and the window opens as a new tab). However,
344 // when a feature string is specified, any *unspecified* features default to
345 // disabled, often causing the window to open as a popup instead.
346 //
347 // As specifying menubar, resizable, scrollbar, and statusbar have no effect
348 // on the UI, just ignore them and only consider whether or not the toolbar is
349 // enabled, which matches Firefox's behavior.
350 bool as_popup = !features.tool_bar_visible;
351
352 NavigationPolicy policy = kNavigationPolicyNewForegroundTab;
353 if (as_popup)
354 policy = kNavigationPolicyNewPopup;
355 UpdatePolicyForEvent(WebViewBase::CurrentInputEvent(), &policy);
356
357 return static_cast<WebNavigationPolicy>(policy);
358 }
359
360 WebNavigationPolicy EffectiveNavigationPolicy(
361 NavigationPolicy navigation_policy,
362 const WindowFeatures& features) {
363 WebNavigationPolicy policy =
364 static_cast<WebNavigationPolicy>(navigation_policy);
365 if (policy == kWebNavigationPolicyIgnore)
366 return GetNavigationPolicy(features);
367 if (policy == kWebNavigationPolicyNewBackgroundTab &&
368 GetNavigationPolicy(features) != kWebNavigationPolicyNewBackgroundTab &&
369 !UIEventWithKeyState::NewTabModifierSetFromIsolatedWorld())
370 return kWebNavigationPolicyNewForegroundTab;
371
372 return policy;
373 }
374
375 } // namespace
376
377 Page* ChromeClientImpl::CreateWindow(LocalFrame* frame, 276 Page* ChromeClientImpl::CreateWindow(LocalFrame* frame,
378 const FrameLoadRequest& r, 277 const FrameLoadRequest& r,
379 const WindowFeatures& features, 278 const WindowFeatures& features,
380 NavigationPolicy navigation_policy) { 279 NavigationPolicy navigation_policy) {
381 if (!web_view_->Client()) 280 if (!web_view_->Client())
382 return nullptr; 281 return nullptr;
383 282
384 if (!frame->GetPage() || frame->GetPage()->Suspended()) 283 if (!frame->GetPage() || frame->GetPage()->Suspended())
385 return nullptr; 284 return nullptr;
386
387 WebNavigationPolicy policy =
388 EffectiveNavigationPolicy(navigation_policy, features);
389 DCHECK(frame->GetDocument()); 285 DCHECK(frame->GetDocument());
390 Fullscreen::FullyExitFullscreen(*frame->GetDocument()); 286 Fullscreen::FullyExitFullscreen(*frame->GetDocument());
391 287
392 WebViewBase* new_view = 288 WebViewBase* new_view =
393 static_cast<WebViewBase*>(web_view_->Client()->CreateView( 289 static_cast<WebViewBase*>(web_view_->Client()->CreateView(
394 WebLocalFrameImpl::FromFrame(frame), 290 WebLocalFrameImpl::FromFrame(frame),
395 WrappedResourceRequest(r.GetResourceRequest()), features, 291 WrappedResourceRequest(r.GetResourceRequest()), features,
396 r.FrameName(), policy, 292 r.FrameName(), static_cast<WebNavigationPolicy>(navigation_policy),
397 r.GetShouldSetOpener() == kNeverSetOpener || features.noopener)); 293 r.GetShouldSetOpener() == kNeverSetOpener));
398 if (!new_view) 294 if (!new_view)
399 return nullptr; 295 return nullptr;
400 return new_view->GetPage(); 296 return new_view->GetPage();
401 } 297 }
402 298
403 void ChromeClientImpl::DidOverscroll(const FloatSize& overscroll_delta, 299 void ChromeClientImpl::DidOverscroll(const FloatSize& overscroll_delta,
404 const FloatSize& accumulated_overscroll, 300 const FloatSize& accumulated_overscroll,
405 const FloatPoint& position_in_viewport, 301 const FloatPoint& position_in_viewport,
406 const FloatSize& velocity_in_viewport) { 302 const FloatSize& velocity_in_viewport) {
407 if (!web_view_->Client()) 303 if (!web_view_->Client())
408 return; 304 return;
409 305
410 web_view_->Client()->DidOverscroll(overscroll_delta, accumulated_overscroll, 306 web_view_->Client()->DidOverscroll(overscroll_delta, accumulated_overscroll,
411 position_in_viewport, 307 position_in_viewport,
412 velocity_in_viewport); 308 velocity_in_viewport);
413 } 309 }
414 310
415 void ChromeClientImpl::Show(NavigationPolicy navigation_policy) { 311 void ChromeClientImpl::Show(NavigationPolicy navigation_policy) {
416 if (web_view_->Client()) 312 if (web_view_->Client()) {
417 web_view_->Client()->Show( 313 web_view_->Client()->Show(
418 EffectiveNavigationPolicy(navigation_policy, window_features_)); 314 static_cast<WebNavigationPolicy>(navigation_policy));
419 } 315 }
420
421 void ChromeClientImpl::SetToolbarsVisible(bool value) {
422 window_features_.tool_bar_visible = value;
423 }
424
425 bool ChromeClientImpl::ToolbarsVisible() {
426 return window_features_.tool_bar_visible;
427 }
428
429 void ChromeClientImpl::SetStatusbarVisible(bool value) {
430 window_features_.status_bar_visible = value;
431 }
432
433 bool ChromeClientImpl::StatusbarVisible() {
434 return window_features_.status_bar_visible;
435 }
436
437 void ChromeClientImpl::SetScrollbarsVisible(bool value) {
438 window_features_.scrollbars_visible = value;
439 if (WebLocalFrameImpl* web_frame =
440 ToWebLocalFrameImpl(web_view_->MainFrame()))
441 web_frame->SetCanHaveScrollbars(value);
442 }
443
444 bool ChromeClientImpl::ScrollbarsVisible() {
445 return window_features_.scrollbars_visible;
446 }
447
448 void ChromeClientImpl::SetMenubarVisible(bool value) {
449 window_features_.menu_bar_visible = value;
450 }
451
452 bool ChromeClientImpl::MenubarVisible() {
453 return window_features_.menu_bar_visible;
454 }
455
456 void ChromeClientImpl::SetResizable(bool value) {
457 window_features_.resizable = value;
458 } 316 }
459 317
460 bool ChromeClientImpl::ShouldReportDetailedMessageForSource( 318 bool ChromeClientImpl::ShouldReportDetailedMessageForSource(
461 LocalFrame& local_frame, 319 LocalFrame& local_frame,
462 const String& url) { 320 const String& url) {
463 WebLocalFrameImpl* webframe = 321 WebLocalFrameImpl* webframe =
464 WebLocalFrameImpl::FromFrame(&local_frame.LocalFrameRoot()); 322 WebLocalFrameImpl::FromFrame(&local_frame.LocalFrameRoot());
465 return webframe && webframe->Client() && 323 return webframe && webframe->Client() &&
466 webframe->Client()->ShouldReportDetailedMessageForSource(url); 324 webframe->Client()->ShouldReportDetailedMessageForSource(url);
467 } 325 }
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 DCHECK(frame); 933 DCHECK(frame);
1076 WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame); 934 WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame);
1077 WebFrameWidgetBase* widget = web_frame->LocalRoot()->FrameWidget(); 935 WebFrameWidgetBase* widget = web_frame->LocalRoot()->FrameWidget();
1078 if (!widget) 936 if (!widget)
1079 return; 937 return;
1080 938
1081 if (WebWidgetClient* client = widget->Client()) 939 if (WebWidgetClient* client = widget->Client())
1082 client->SetTouchAction(static_cast<TouchAction>(touch_action)); 940 client->SetTouchAction(static_cast<TouchAction>(touch_action));
1083 } 941 }
1084 942
943 const WebInputEvent* ChromeClientImpl::GetCurrentInputEvent() const {
Nate Chapin 2017/05/31 16:55:13 Unfortunate to have to add this, but it seems like
944 return WebViewBase::CurrentInputEvent();
kinuko 2017/06/01 06:39:28 WebViewBase.h is now in core/exported, would just
Nate Chapin 2017/06/01 20:57:11 Linker error :(
945 }
946
1085 bool ChromeClientImpl::RequestPointerLock(LocalFrame* frame) { 947 bool ChromeClientImpl::RequestPointerLock(LocalFrame* frame) {
1086 LocalFrame& local_root = frame->LocalFrameRoot(); 948 LocalFrame& local_root = frame->LocalFrameRoot();
1087 return WebLocalFrameImpl::FromFrame(&local_root) 949 return WebLocalFrameImpl::FromFrame(&local_root)
1088 ->FrameWidget() 950 ->FrameWidget()
1089 ->Client() 951 ->Client()
1090 ->RequestPointerLock(); 952 ->RequestPointerLock();
1091 } 953 }
1092 954
1093 void ChromeClientImpl::RequestPointerUnlock(LocalFrame* frame) { 955 void ChromeClientImpl::RequestPointerUnlock(LocalFrame* frame) {
1094 LocalFrame& local_root = frame->LocalFrameRoot(); 956 LocalFrame& local_root = frame->LocalFrameRoot();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 if (RuntimeEnabledFeatures::presentationEnabled()) 1132 if (RuntimeEnabledFeatures::presentationEnabled())
1271 PresentationController::ProvideTo(frame, client->PresentationClient()); 1133 PresentationController::ProvideTo(frame, client->PresentationClient());
1272 if (RuntimeEnabledFeatures::audioOutputDevicesEnabled()) { 1134 if (RuntimeEnabledFeatures::audioOutputDevicesEnabled()) {
1273 ProvideAudioOutputDeviceClientTo(frame, 1135 ProvideAudioOutputDeviceClientTo(frame,
1274 new AudioOutputDeviceClientImpl(frame)); 1136 new AudioOutputDeviceClientImpl(frame));
1275 } 1137 }
1276 InstalledAppController::ProvideTo(frame, client->GetRelatedAppsFetcher()); 1138 InstalledAppController::ProvideTo(frame, client->GetRelatedAppsFetcher());
1277 } 1139 }
1278 1140
1279 } // namespace blink 1141 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698