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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 2943983003: chrome/blink: Add functionality for in-product help for media elements. (Closed)
Patch Set: addressed comments Created 3 years, 5 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
9 * rights reserved. 9 * rights reserved.
10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/frame/ContentSettingsClient.h" 47 #include "core/frame/ContentSettingsClient.h"
48 #include "core/frame/EventHandlerRegistry.h" 48 #include "core/frame/EventHandlerRegistry.h"
49 #include "core/frame/FrameConsole.h" 49 #include "core/frame/FrameConsole.h"
50 #include "core/frame/LocalDOMWindow.h" 50 #include "core/frame/LocalDOMWindow.h"
51 #include "core/frame/LocalFrameClient.h" 51 #include "core/frame/LocalFrameClient.h"
52 #include "core/frame/LocalFrameView.h" 52 #include "core/frame/LocalFrameView.h"
53 #include "core/frame/PerformanceMonitor.h" 53 #include "core/frame/PerformanceMonitor.h"
54 #include "core/frame/Settings.h" 54 #include "core/frame/Settings.h"
55 #include "core/frame/VisualViewport.h" 55 #include "core/frame/VisualViewport.h"
56 #include "core/html/HTMLFrameElementBase.h" 56 #include "core/html/HTMLFrameElementBase.h"
57 #include "core/html/HTMLMediaElement.h"
57 #include "core/html/HTMLPlugInElement.h" 58 #include "core/html/HTMLPlugInElement.h"
58 #include "core/html/PluginDocument.h" 59 #include "core/html/PluginDocument.h"
59 #include "core/input/EventHandler.h" 60 #include "core/input/EventHandler.h"
60 #include "core/inspector/ConsoleMessage.h" 61 #include "core/inspector/ConsoleMessage.h"
61 #include "core/layout/HitTestResult.h" 62 #include "core/layout/HitTestResult.h"
62 #include "core/layout/LayoutView.h" 63 #include "core/layout/LayoutView.h"
63 #include "core/layout/api/LayoutEmbeddedContentItem.h" 64 #include "core/layout/api/LayoutEmbeddedContentItem.h"
64 #include "core/layout/api/LayoutViewItem.h" 65 #include "core/layout/api/LayoutViewItem.h"
65 #include "core/layout/compositing/PaintLayerCompositor.h" 66 #include "core/layout/compositing/PaintLayerCompositor.h"
66 #include "core/loader/DocumentLoader.h" 67 #include "core/loader/DocumentLoader.h"
67 #include "core/loader/FrameLoadRequest.h" 68 #include "core/loader/FrameLoadRequest.h"
68 #include "core/loader/NavigationScheduler.h" 69 #include "core/loader/NavigationScheduler.h"
69 #include "core/page/ChromeClient.h" 70 #include "core/page/ChromeClient.h"
70 #include "core/page/FocusController.h" 71 #include "core/page/FocusController.h"
71 #include "core/page/Page.h" 72 #include "core/page/Page.h"
72 #include "core/page/scrolling/ScrollingCoordinator.h" 73 #include "core/page/scrolling/ScrollingCoordinator.h"
73 #include "core/paint/ObjectPainter.h" 74 #include "core/paint/ObjectPainter.h"
74 #include "core/paint/PaintInfo.h" 75 #include "core/paint/PaintInfo.h"
75 #include "core/paint/PaintLayer.h" 76 #include "core/paint/PaintLayer.h"
76 #include "core/paint/PaintLayerPainter.h" 77 #include "core/paint/PaintLayerPainter.h"
77 #include "core/paint/TransformRecorder.h" 78 #include "core/paint/TransformRecorder.h"
78 #include "core/plugins/PluginView.h" 79 #include "core/plugins/PluginView.h"
79 #include "core/probe/CoreProbes.h" 80 #include "core/probe/CoreProbes.h"
80 #include "core/svg/SVGDocumentExtensions.h" 81 #include "core/svg/SVGDocumentExtensions.h"
81 #include "core/timing/Performance.h" 82 #include "core/timing/Performance.h"
83 #include "mojo/public/cpp/bindings/strong_binding.h"
82 #include "platform/DragImage.h" 84 #include "platform/DragImage.h"
83 #include "platform/Histogram.h" 85 #include "platform/Histogram.h"
84 #include "platform/PluginScriptForbiddenScope.h" 86 #include "platform/PluginScriptForbiddenScope.h"
85 #include "platform/RuntimeEnabledFeatures.h" 87 #include "platform/RuntimeEnabledFeatures.h"
86 #include "platform/ScriptForbiddenScope.h" 88 #include "platform/ScriptForbiddenScope.h"
87 #include "platform/WebFrameScheduler.h" 89 #include "platform/WebFrameScheduler.h"
88 #include "platform/graphics/GraphicsContext.h" 90 #include "platform/graphics/GraphicsContext.h"
89 #include "platform/graphics/StaticBitmapImage.h" 91 #include "platform/graphics/StaticBitmapImage.h"
90 #include "platform/graphics/paint/ClipRecorder.h" 92 #include "platform/graphics/paint/ClipRecorder.h"
91 #include "platform/graphics/paint/PaintCanvas.h" 93 #include "platform/graphics/paint/PaintCanvas.h"
92 #include "platform/graphics/paint/PaintController.h" 94 #include "platform/graphics/paint/PaintController.h"
93 #include "platform/graphics/paint/PaintRecordBuilder.h" 95 #include "platform/graphics/paint/PaintRecordBuilder.h"
94 #include "platform/graphics/paint/TransformDisplayItem.h" 96 #include "platform/graphics/paint/TransformDisplayItem.h"
95 #include "platform/instrumentation/resource_coordinator/FrameResourceCoordinator .h" 97 #include "platform/instrumentation/resource_coordinator/FrameResourceCoordinator .h"
96 #include "platform/json/JSONValues.h" 98 #include "platform/json/JSONValues.h"
97 #include "platform/loader/fetch/FetchParameters.h" 99 #include "platform/loader/fetch/FetchParameters.h"
98 #include "platform/loader/fetch/ResourceFetcher.h" 100 #include "platform/loader/fetch/ResourceFetcher.h"
99 #include "platform/loader/fetch/ResourceRequest.h" 101 #include "platform/loader/fetch/ResourceRequest.h"
100 #include "platform/plugins/PluginData.h" 102 #include "platform/plugins/PluginData.h"
101 #include "platform/scheduler/renderer/web_view_scheduler.h" 103 #include "platform/scheduler/renderer/web_view_scheduler.h"
102 #include "platform/text/TextStream.h" 104 #include "platform/text/TextStream.h"
103 #include "platform/wtf/PtrUtil.h" 105 #include "platform/wtf/PtrUtil.h"
104 #include "platform/wtf/StdLibExtras.h" 106 #include "platform/wtf/StdLibExtras.h"
105 #include "public/platform/InterfaceProvider.h" 107 #include "public/platform/InterfaceProvider.h"
106 #include "public/platform/InterfaceRegistry.h" 108 #include "public/platform/InterfaceRegistry.h"
107 #include "public/platform/WebScreenInfo.h" 109 #include "public/platform/WebScreenInfo.h"
108 #include "public/platform/WebURLRequest.h" 110 #include "public/platform/WebURLRequest.h"
111 #include "public/platform/media_in_product_help.mojom-blink.h"
112 #include "services/service_manager/public/cpp/bind_source_info.h"
113 #include "services/service_manager/public/cpp/interface_provider.h"
109 #include "third_party/skia/include/core/SkImage.h" 114 #include "third_party/skia/include/core/SkImage.h"
110 #include "third_party/skia/include/core/SkSurface.h" 115 #include "third_party/skia/include/core/SkSurface.h"
111 116
112 namespace blink { 117 namespace blink {
113 118
114 using namespace HTMLNames; 119 using namespace HTMLNames;
115 120
116 namespace { 121 namespace {
117 122
118 // Converts from bounds in CSS space to device space based on the given 123 // Converts from bounds in CSS space to device space based on the given
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return ToLocalFrame(parent)->TextZoomFactor(); 270 return ToLocalFrame(parent)->TextZoomFactor();
266 } 271 }
267 272
268 using FrameInitCallbackVector = WTF::Vector<LocalFrame::FrameInitCallback>; 273 using FrameInitCallbackVector = WTF::Vector<LocalFrame::FrameInitCallback>;
269 FrameInitCallbackVector& GetInitializationVector() { 274 FrameInitCallbackVector& GetInitializationVector() {
270 DEFINE_THREAD_SAFE_STATIC_LOCAL(FrameInitCallbackVector, 275 DEFINE_THREAD_SAFE_STATIC_LOCAL(FrameInitCallbackVector,
271 initialization_vector, ()); 276 initialization_vector, ());
272 return initialization_vector; 277 return initialization_vector;
273 } 278 }
274 279
280 class MediaInProductHelpDelegateService
281 : public mojom::blink::MediaInProductHelpDelegateService {
282 public:
283 explicit MediaInProductHelpDelegateService(LocalFrame& frame)
284 : frame_(&frame) {}
285 ~MediaInProductHelpDelegateService() override = default;
286
287 // chrome::MediaInProductHelpDelegateService implementation.
288 void WidgetDismissed() override {
289 if (frame_)
290 frame_->NotifyInProductHelpDismissed();
291 }
292
293 private:
294 WeakPersistent<LocalFrame> frame_;
295 };
296
297 void CreateMediaInProductHelpDelegateService(
298 LocalFrame* frame,
299 mojom::blink::MediaInProductHelpDelegateServiceRequest request) {
300 mojo::MakeStrongBinding(
301 WTF::WrapUnique(new MediaInProductHelpDelegateService(*frame)),
302 std::move(request));
303 }
304
275 } // namespace 305 } // namespace
276 306
277 template class CORE_TEMPLATE_EXPORT Supplement<LocalFrame>; 307 template class CORE_TEMPLATE_EXPORT Supplement<LocalFrame>;
278 308
279 LocalFrame* LocalFrame::Create(LocalFrameClient* client, 309 LocalFrame* LocalFrame::Create(LocalFrameClient* client,
280 Page& page, 310 Page& page,
281 FrameOwner* owner, 311 FrameOwner* owner,
282 InterfaceProvider* interface_provider, 312 InterfaceProvider* interface_provider,
283 InterfaceRegistry* interface_registry) { 313 InterfaceRegistry* interface_registry) {
284 LocalFrame* frame = new LocalFrame( 314 LocalFrame* frame = new LocalFrame(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 visitor->Trace(dom_window_); 405 visitor->Trace(dom_window_);
376 visitor->Trace(page_popup_owner_); 406 visitor->Trace(page_popup_owner_);
377 visitor->Trace(script_controller_); 407 visitor->Trace(script_controller_);
378 visitor->Trace(editor_); 408 visitor->Trace(editor_);
379 visitor->Trace(spell_checker_); 409 visitor->Trace(spell_checker_);
380 visitor->Trace(selection_); 410 visitor->Trace(selection_);
381 visitor->Trace(event_handler_); 411 visitor->Trace(event_handler_);
382 visitor->Trace(console_); 412 visitor->Trace(console_);
383 visitor->Trace(input_method_controller_); 413 visitor->Trace(input_method_controller_);
384 visitor->Trace(frame_resource_coordinator_); 414 visitor->Trace(frame_resource_coordinator_);
415 visitor->Trace(element_with_active_in_product_help_);
385 Frame::Trace(visitor); 416 Frame::Trace(visitor);
386 Supplementable<LocalFrame>::Trace(visitor); 417 Supplementable<LocalFrame>::Trace(visitor);
387 } 418 }
388 419
389 void LocalFrame::Navigate(Document& origin_document, 420 void LocalFrame::Navigate(Document& origin_document,
390 const KURL& url, 421 const KURL& url,
391 bool replace_current_item, 422 bool replace_current_item,
392 UserGestureStatus user_gesture_status) { 423 UserGestureStatus user_gesture_status) {
393 navigation_scheduler_->ScheduleLocationChange(&origin_document, url, 424 navigation_scheduler_->ScheduleLocationChange(&origin_document, url,
394 replace_current_item); 425 replace_current_item);
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 1269
1239 void LocalFrame::SetViewportIntersectionFromParent( 1270 void LocalFrame::SetViewportIntersectionFromParent(
1240 const IntRect& viewport_intersection) { 1271 const IntRect& viewport_intersection) {
1241 if (remote_viewport_intersection_ != viewport_intersection) { 1272 if (remote_viewport_intersection_ != viewport_intersection) {
1242 remote_viewport_intersection_ = viewport_intersection; 1273 remote_viewport_intersection_ = viewport_intersection;
1243 if (View()) 1274 if (View())
1244 View()->ScheduleAnimation(); 1275 View()->ScheduleAnimation();
1245 } 1276 }
1246 } 1277 }
1247 1278
1279 void LocalFrame::ShowDownloadMediaInProductHelp(HTMLMediaElement& elem) {
Sam McNally 2017/06/28 09:19:58 Could this be handled within MediaControlDownloadB
Khushal 2017/06/28 22:28:46 The element had to be tracked at some place which
Sam McNally 2017/07/03 09:45:40 MediaControlsImpl should be able to observe layout
Khushal 2017/07/07 04:18:13 The ResizeObserver only hears about size changes i
1280 if (!GetSettings() || !GetSettings()->GetMediaDownloadInProductHelpEnabled())
1281 return;
1282
1283 if (element_with_active_in_product_help_ ||
1284 media_in_product_help_shown_for_frame_)
1285 return;
1286
1287 if (!Client())
1288 return;
1289
1290 // Add the service to know when this widget is dismissed.
1291 GetInterfaceRegistry()->AddInterface(WTF::Bind(
1292 &CreateMediaInProductHelpDelegateService, WrapWeakPersistent(this)));
1293
1294 element_with_active_in_product_help_ = &elem;
1295 media_in_product_help_shown_for_frame_ = true;
1296 }
1297
1298 bool LocalFrame::IsDownloadMediaInProductHelpVisibleForElement(
1299 HTMLMediaElement& elem) {
1300 return element_with_active_in_product_help_ &&
1301 *element_with_active_in_product_help_ == elem;
1302 }
1303
1304 void LocalFrame::NotifyMediaControlsHidden(HTMLMediaElement& elem) {
1305 if (!element_with_active_in_product_help_ ||
1306 *element_with_active_in_product_help_ != elem || !Client())
1307 return;
1308
1309 mojom::blink::MediaInProductHelpServicePtr service;
1310 Client()->GetInterfaceProvider()->GetInterface(mojo::MakeRequest(&service));
1311 service->HideInProductHelpWidget();
1312 }
1313
1314 void LocalFrame::LayoutUpdated() {
1315 if (!element_with_active_in_product_help_ || !Client())
1316 return;
1317
1318 IntRect button_rect;
1319 if (!element_with_active_in_product_help_->GetMediaControls()
1320 ->GetDownloadButtonRect(button_rect)) {
1321 mojom::blink::MediaInProductHelpServicePtr service;
1322 Client()->GetInterfaceProvider()->GetInterface(mojo::MakeRequest(&service));
1323 service->HideInProductHelpWidget();
1324 return;
1325 }
1326
1327 mojom::blink::MediaInProductHelpServicePtr service;
1328 Client()->GetInterfaceProvider()->GetInterface(mojo::MakeRequest(&service));
1329 service->ShowInProductHelpWidget(button_rect.X(), button_rect.Y(),
1330 button_rect.Width(), button_rect.Height());
1331 }
1332
1333 void LocalFrame::NotifyInProductHelpDismissed() {
1334 if (element_with_active_in_product_help_ &&
1335 element_with_active_in_product_help_->GetMediaControls()) {
1336 element_with_active_in_product_help_->GetMediaControls()
1337 ->InProductHelpDisabled();
1338 }
1339 element_with_active_in_product_help_ = nullptr;
1340 }
1341
1248 } // namespace blink 1342 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698