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

Side by Side Diff: chrome/renderer/media/media_iph_impl.cc

Issue 2943983003: chrome/blink: Add functionality for in-product help for media elements. (Closed)
Patch Set: 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/media/media_iph_impl.h"
6
7 #include "content/public/renderer/render_frame.h"
8 #include "mojo/public/cpp/bindings/strong_binding.h"
9 #include "services/service_manager/public/cpp/binder_registry.h"
10 #include "services/service_manager/public/cpp/interface_provider.h"
11 #include "third_party/WebKit/public/platform/WebRect.h"
12
13 class MediaIPHImpl::MediaIPHDelegateService
14 : public chrome::mojom::MediaIPHDelegateService {
15 public:
16 explicit MediaIPHDelegateService(MediaIPHImpl* media_iph_impl)
17 : media_iph_impl_(media_iph_impl) {
18 DCHECK(media_iph_impl_);
19 }
20 ~MediaIPHDelegateService() override = default;
21
22 // chrome::MediaIPHDelegateService implementation.
23 void WidgetDismissed() override { media_iph_impl_->IPHWidgetDismissed(); }
24
25 private:
26 MediaIPHImpl* media_iph_impl_;
27 };
28
29 MediaIPHImpl::MediaIPHImpl(content::RenderFrame* render_frame)
30 : render_frame_(render_frame), weak_factory_(this) {
31 render_frame_->GetInterfaceRegistry()->AddInterface(base::Bind(
32 &MediaIPHImpl::CreateDelegateService, weak_factory_.GetWeakPtr()));
33 }
34
35 MediaIPHImpl::~MediaIPHImpl() {
36 if (client_)
37 client_->DidHideMediaIPHWidget();
38 }
39
40 void MediaIPHImpl::BindToClient(blink::WebMediaIPHClient* client) {
41 DCHECK(!client_);
42 client_ = client;
43 }
44
45 void MediaIPHImpl::ShowMediaDownloadIPH(const blink::WebRect& rect) {
46 bool new_request = !iph_active_;
47 iph_active_ = true;
48
49 chrome::mojom::MediaIPHServicePtr iph_service;
50 render_frame_->GetRemoteInterfaces()->GetInterface(&iph_service);
51 iph_service->ShowIPHWidget(rect, new_request);
52 }
53
54 void MediaIPHImpl::HideMediaDownloadIPH() {
55 chrome::mojom::MediaIPHServicePtr iph_service;
56 render_frame_->GetRemoteInterfaces()->GetInterface(&iph_service);
57 iph_service->HideIPHWidget();
58 }
59
60 void MediaIPHImpl::CreateDelegateService(
61 const service_manager::BindSourceInfo& source_info,
62 chrome::mojom::MediaIPHDelegateServiceRequest request) {
63 mojo::MakeStrongBinding(base::MakeUnique<MediaIPHDelegateService>(this),
64 std::move(request));
65 }
66
67 void MediaIPHImpl::IPHWidgetDismissed() {
68 DCHECK(client_);
69 iph_active_ = false;
70 client_->DidHideMediaIPHWidget();
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698