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

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 MediaInProductHelpDelegate
281 : public mojom::blink::MediaInProductHelpDelegate {
282 public:
283 explicit MediaInProductHelpDelegate(LocalFrame& frame) : frame_(&frame) {}
284 ~MediaInProductHelpDelegate() override = default;
285
286 // chrome::MediaInProductHelpDelegate implementation.
287 void WidgetDismissed() override {
288 if (frame_)
289 frame_->NotifyInProductHelpDismissed();
290 }
291
292 private:
293 WeakPersistent<LocalFrame> frame_;
294 };
295
296 void CreateMediaInProductHelpDelegate(
297 LocalFrame* frame,
298 mojom::blink::MediaInProductHelpDelegateRequest request) {
299 mojo::MakeStrongBinding(
300 WTF::WrapUnique(new MediaInProductHelpDelegate(*frame)),
301 std::move(request));
302 }
303
275 } // namespace 304 } // namespace
276 305
277 template class CORE_TEMPLATE_EXPORT Supplement<LocalFrame>; 306 template class CORE_TEMPLATE_EXPORT Supplement<LocalFrame>;
278 307
279 LocalFrame* LocalFrame::Create(LocalFrameClient* client, 308 LocalFrame* LocalFrame::Create(LocalFrameClient* client,
280 Page& page, 309 Page& page,
281 FrameOwner* owner, 310 FrameOwner* owner,
282 InterfaceProvider* interface_provider, 311 InterfaceProvider* interface_provider,
283 InterfaceRegistry* interface_registry) { 312 InterfaceRegistry* interface_registry) {
284 LocalFrame* frame = new LocalFrame( 313 LocalFrame* frame = new LocalFrame(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 visitor->Trace(dom_window_); 404 visitor->Trace(dom_window_);
376 visitor->Trace(page_popup_owner_); 405 visitor->Trace(page_popup_owner_);
377 visitor->Trace(script_controller_); 406 visitor->Trace(script_controller_);
378 visitor->Trace(editor_); 407 visitor->Trace(editor_);
379 visitor->Trace(spell_checker_); 408 visitor->Trace(spell_checker_);
380 visitor->Trace(selection_); 409 visitor->Trace(selection_);
381 visitor->Trace(event_handler_); 410 visitor->Trace(event_handler_);
382 visitor->Trace(console_); 411 visitor->Trace(console_);
383 visitor->Trace(input_method_controller_); 412 visitor->Trace(input_method_controller_);
384 visitor->Trace(frame_resource_coordinator_); 413 visitor->Trace(frame_resource_coordinator_);
414 visitor->Trace(element_with_active_in_product_help_);
385 Frame::Trace(visitor); 415 Frame::Trace(visitor);
386 Supplementable<LocalFrame>::Trace(visitor); 416 Supplementable<LocalFrame>::Trace(visitor);
387 } 417 }
388 418
389 void LocalFrame::Navigate(Document& origin_document, 419 void LocalFrame::Navigate(Document& origin_document,
390 const KURL& url, 420 const KURL& url,
391 bool replace_current_item, 421 bool replace_current_item,
392 UserGestureStatus user_gesture_status) { 422 UserGestureStatus user_gesture_status) {
393 navigation_scheduler_->ScheduleLocationChange(&origin_document, url, 423 navigation_scheduler_->ScheduleLocationChange(&origin_document, url,
394 replace_current_item); 424 replace_current_item);
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 1268
1239 void LocalFrame::SetViewportIntersectionFromParent( 1269 void LocalFrame::SetViewportIntersectionFromParent(
1240 const IntRect& viewport_intersection) { 1270 const IntRect& viewport_intersection) {
1241 if (remote_viewport_intersection_ != viewport_intersection) { 1271 if (remote_viewport_intersection_ != viewport_intersection) {
1242 remote_viewport_intersection_ = viewport_intersection; 1272 remote_viewport_intersection_ = viewport_intersection;
1243 if (View()) 1273 if (View())
1244 View()->ScheduleAnimation(); 1274 View()->ScheduleAnimation();
1245 } 1275 }
1246 } 1276 }
1247 1277
1278 void LocalFrame::ShowDownloadMediaInProductHelp(HTMLMediaElement& elem) {
1279 if (!GetSettings() || !GetSettings()->GetMediaDownloadInProductHelpEnabled())
1280 return;
1281
1282 if (element_with_active_in_product_help_ ||
1283 media_in_product_help_shown_for_frame_)
1284 return;
1285
1286 if (!Client())
1287 return;
1288
1289 // Add the service to know when this widget is dismissed.
1290 GetInterfaceRegistry()->AddInterface(
1291 WTF::Bind(&CreateMediaInProductHelpDelegate, WrapWeakPersistent(this)));
1292
1293 element_with_active_in_product_help_ = &elem;
1294 media_in_product_help_shown_for_frame_ = true;
1295 }
1296
1297 bool LocalFrame::IsDownloadMediaInProductHelpVisibleForElement(
1298 HTMLMediaElement& elem) {
1299 return element_with_active_in_product_help_ &&
1300 *element_with_active_in_product_help_ == elem;
1301 }
1302
1303 void LocalFrame::LayoutUpdated() {
1304 if (!element_with_active_in_product_help_ || !Client())
1305 return;
1306
1307 IntRect button_rect;
1308 if (!element_with_active_in_product_help_->GetMediaControls()
1309 ->GetDownloadButtonRect(button_rect)) {
1310 mojom::blink::MediaInProductHelpPtr service;
1311 Client()->GetInterfaceProvider()->GetInterface(mojo::MakeRequest(&service));
1312 service->HideInProductHelpWidget();
1313 return;
1314 }
1315
1316 mojom::blink::MediaInProductHelpPtr service;
1317 Client()->GetInterfaceProvider()->GetInterface(mojo::MakeRequest(&service));
1318 service->ShowInProductHelpWidget(button_rect);
1319 }
1320
1321 void LocalFrame::NotifyInProductHelpDismissed() {
1322 if (element_with_active_in_product_help_ &&
1323 element_with_active_in_product_help_->GetMediaControls()) {
1324 element_with_active_in_product_help_->GetMediaControls()
1325 ->InProductHelpDisabled();
1326 }
1327 element_with_active_in_product_help_ = nullptr;
1328 }
1329
1248 } // namespace blink 1330 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698